EMILE/scripts/tools.sh
2007-09-07 08:41:20 +00:00

139 lines
2.7 KiB
Bash

#!/bin/sh
# build info
WHO=$(whoami)
WHERE=$(hostname)
ARCH=$(uname -m)
OS=$(uname -o)
cat <<!EOF
# file generated by $0
WHO = ${WHO}
WHERE = ${WHERE}
ARCH = ${ARCH}
OS = ${OS}
SIGNATURE = \$(PACKAGE)-\$(VERSION) \$(WHO)@\$(WHERE)(\$(ARCH) \$(OS)) \$(WHEN)
!EOF
# m68k cross-compiler
if test "${ARCH}" != "m68k"
then
M68K_CROSS_COMPILE=m68k-linux-
if ! type "${M68K_CROSS_COMPILE}gcc" > /dev/null 2>&1
then
M68K_CROSS_COMPILE=m68k-linux-gnu-
if ! type "${M68K_CROSS_COMPILE}gcc" > /dev/null 2>&1
then
echo "Cannot find m68k cross-compiler" 1>&2
exit 1
fi
fi
M68K_GCC_VERSION=$(${M68K_CROSS_COMPILE}gcc -dumpversion 2> /dev/null)
echo "cross-compiler is ${M68K_CROSS_COMPILE}gcc ${M68K_GCC_VERSION}" 1>&2
fi
cat <<!EOF
M68K_CROSS_COMPILE = ${M68K_CROSS_COMPILE}
M68K_AS = \$(M68K_CROSS_COMPILE)as
M68K_CC = \$(M68K_CROSS_COMPILE)gcc
M68K_LD = \$(M68K_CROSS_COMPILE)ld
M68K_OBJCOPY = \$(M68K_CROSS_COMPILE)objcopy
M68K_STRIP = \$(M68K_CROSS_COMPILE)strip
!EOF
if test "${ARCH}" != "ppc"
then
PPC_CROSS_COMPILE=powerpc-linux-
if ! type "${PPC_CROSS_COMPILE}gcc" > /dev/null 2>&1
then
PPC_CROSS_COMPILE=powerpc-linux-gnu-
if ! type "${PPC_CROSS_COMPILE}gcc" > /dev/null 2>&1
then
echo "Cannot find powerpc cross-compiler" 1>&2
exit 0
fi
fi
PPC_GCC_VERSION=$(${PPC_CROSS_COMPILE}gcc -dumpversion 2> /dev/null)
echo "cross-compiler is ${PPC_CROSS_COMPILE}gcc ${PPC_GCC_VERSION}" 1>&2
fi
cat <<!EOF
PPC_CROSS_COMPILE = ${PPC_CROSS_COMPILE}
PPC_AS = \$(PPC_CROSS_COMPILE)as
PPC_CC = \$(PPC_CROSS_COMPILE)gcc
PPC_LD = \$(PPC_CROSS_COMPILE)ld
PPC_OBJCOPY = \$(PPC_CROSS_COMPILE)objcopy
PPC_STRIP = \$(PPC_CROSS_COMPILE)strip
!EOF
# target compiler
cat <<!EOF
ifeq (\$(TARGET),m68k-linux)
override AS = \$(M68K_AS)
override CC = \$(M68K_CC)
override LD = \$(M68K_LD)
override OBJCOPY = \$(M68K_OBJCOPY)
override STRIP = \$(M68K_STRIP)
else ifeq (\$(TARGET),m68k-netbsd)
override AS = \$(M68K_AS)
override CC = \$(M68K_CC)
override LD = \$(M68K_LD)
override OBJCOPY = \$(M68K_OBJCOPY)
override STRIP = \$(M68K_STRIP)
else ifeq (\$(TARGET),ppc-linux)
override AS = \$(PPC_AS)
override CC = \$(PPC_CC)
override LD = \$(PPC_LD)
override OBJCOPY = \$(PPC_OBJCOPY)
override STRIP = \$(PPC_STRIP)
else
AS = \$(CROSS_COMPILE)as
CC = \$(CROSS_COMPILE)gcc
LD = \$(CROSS_COMPILE)ld
OBJCOPY = \$(CROSS_COMPILE)objcopy
STRIP = \$(CROSS_COMPILE)strip
endif
!EOF
# docbook to man
if type docbook-to-man > /dev/null 2>&1
then
cat <<!EOF
%.8: %.sgml
docbook-to-man \$< > \$@
!EOF
else
if type ${docbook-to-man} > /dev/null 2>&1
then
cat <<!EOF
%.8: %.sgml
docbook2man \$<
!EOF
else
%.8: %.sgml
echo "Missing tools to generate \$@ from \$<"
fi
fi