First copy of toolchain2netbsd script, used to generate the platform-specific
GNU toolchain files in one pass (which are then committed). Still missing is support for gdb (in progress).
This commit is contained in:
parent
cbe144f269
commit
82e96808ff
|
@ -0,0 +1,124 @@
|
|||
#!/bin/sh
|
||||
# $NetBSD: toolchain2netbsd,v 1.1 2001/06/18 16:07:07 tv Exp $
|
||||
#
|
||||
# Shell script for generating all the constants needed for a native
|
||||
# platform build of src/gnu/dist/toolchain.
|
||||
#
|
||||
|
||||
TMPDIR=${TMPDIR:-/tmp}
|
||||
MAKE=${MAKE:-make}
|
||||
|
||||
# usage: getvars MAKEFILE VARNAME [VARNAME...]
|
||||
getvars () {
|
||||
_mf="$1"; shift
|
||||
$MAKE -f - _x_ <<EOF || { echo >&2 "ABORT: getvars $_mf $* failed"; exit 1; }
|
||||
_x_:
|
||||
.for var in $*
|
||||
@echo G_\${var}=\${\${var}:Q} | sed 's,$_VPATH,\$\${DIST},g'
|
||||
.endfor
|
||||
.include "$_TMPDIR/$_mf"
|
||||
EOF
|
||||
}
|
||||
|
||||
# usage: write_c FILENAME
|
||||
write_c () {
|
||||
echo '/* This file is automatically generated. DO NOT EDIT! */' >$1.tmp || \
|
||||
{ echo >&2 "ABORT: cannot create $1"; exit 1; }
|
||||
grep '$''NetBSD' toolchain2netbsd | sed 's,[#$],,g;s,.*,/* Generated from: & */,' >>$1.tmp
|
||||
echo '' >>$1.tmp
|
||||
writefile $1
|
||||
}
|
||||
|
||||
# usage: write_mk FILENAME
|
||||
write_mk () {
|
||||
echo '# This file is automatically generated. DO NOT EDIT!' >$1.tmp || \
|
||||
{ echo >&2 "ABORT: cannot create $1"; exit 1; }
|
||||
grep '$''NetBSD' toolchain2netbsd | sed 's,[#$],,g;s,.*,# Generated from: &,' >>$1.tmp
|
||||
echo '#' >>$1.tmp
|
||||
writefile $1
|
||||
}
|
||||
|
||||
writefile () {
|
||||
cat >>$1.tmp
|
||||
# will not overwrite a file that has the same content
|
||||
if cmp $1.tmp $1 >/dev/null 2>&1; then
|
||||
echo >&2 "$1 is unchanged"
|
||||
rm -f $1.tmp
|
||||
else
|
||||
mv -f $1.tmp $1
|
||||
fi
|
||||
}
|
||||
|
||||
##### run GNU configure script #####
|
||||
|
||||
_TMPDIR=${TMPDIR:-/tmp}/gnu.dist.toolchain.tmp
|
||||
MACHINE_ARCH=`sysctl -n hw.machine_arch`
|
||||
|
||||
if [ ! -d $_TMPDIR ]; then
|
||||
mkdir -p $_TMPDIR
|
||||
cwd=`pwd`
|
||||
(cd $_TMPDIR && LDFLAGS=-lintl LANGUAGES="c c++ objc f77" \
|
||||
$cwd/dist/toolchain/configure --disable-shared)
|
||||
fi
|
||||
|
||||
_VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*= ,,'`
|
||||
|
||||
##### gnu/lib/libbfd #####
|
||||
|
||||
mkdir -p lib/libbfd/arch/$MACHINE_ARCH
|
||||
|
||||
{
|
||||
getvars bfd/Makefile \
|
||||
libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS INCLUDES TDEFAULTS
|
||||
getvars opcodes/Makefile \
|
||||
archdefs BFD_MACHINES | sed 's,=,+=,g'
|
||||
} | write_mk lib/libbfd/arch/$MACHINE_ARCH/defs.mk
|
||||
|
||||
(cd $_TMPDIR/bfd && $MAKE bfd.h)
|
||||
|
||||
write_c lib/libbfd/arch/$MACHINE_ARCH/bfd.h <$_TMPDIR/bfd/bfd.h
|
||||
|
||||
{
|
||||
cat $_TMPDIR/bfd/config.h
|
||||
grep -v PACKAGE $_TMPDIR/opcodes/config.h
|
||||
} | write_c lib/libbfd/arch/$MACHINE_ARCH/config.h
|
||||
|
||||
##### gnu/lib/libgcc #####
|
||||
|
||||
# DPBIT, FPBIT only used on mn10[23]00, we don't need them.
|
||||
getvars gcc/Makefile \
|
||||
CXX_EXTRA_HEADERS CXX_LIB2FUNCS CXX_LIB2SRCS \
|
||||
INCLUDES LIB2ADD LIB2FUNCS LIB2FUNCS_EH \
|
||||
LIBGCC2_CFLAGS MAYBE_USE_COLLECT2 \
|
||||
| write_mk lib/libgcc/$MACHINE_ARCH.mk
|
||||
|
||||
##### gnu/lib/libiberty #####
|
||||
|
||||
mkdir -p lib/libiberty/arch/$MACHINE_ARCH
|
||||
|
||||
getvars libiberty/Makefile \
|
||||
ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
|
||||
| write_mk lib/libiberty/arch/$MACHINE_ARCH/defs.mk
|
||||
|
||||
write_c lib/libiberty/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libiberty/config.h
|
||||
|
||||
##### gnu/usr.bin/gcc #####
|
||||
|
||||
mkdir -p usr.bin/gcc/arch/$MACHINE_ARCH
|
||||
|
||||
{
|
||||
getvars gcc/Makefile \
|
||||
ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS DRIVER_DEFINES \
|
||||
HOST_LIBS HOST_PRINT HOST_RTL HOST_RTLANAL INCLUDES \
|
||||
md_file OBJC_OBJS OBJS out_file version
|
||||
getvars gcc/cp/Makefile \
|
||||
CXX_OBJS
|
||||
getvars gcc/f/Makefile \
|
||||
F77_OBJS
|
||||
} | write_mk usr.bin/gcc/arch/$MACHINE_ARCH/defs.mk
|
||||
|
||||
for f in auto-host config gencheck hconfig options specs tconfig tm; do
|
||||
write_c usr.bin/gcc/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
|
||||
done
|
||||
|
||||
# -rm -rf ${_TMPDIR}
|
Loading…
Reference in New Issue