2003-07-25 20:26:51 +04:00
|
|
|
#!/bin/sh
|
2003-07-28 05:29:01 +04:00
|
|
|
# $NetBSD: mknative-gcc,v 1.2 2003/07/28 01:29:01 mrg Exp $
|
2003-07-25 20:26:51 +04:00
|
|
|
#
|
|
|
|
# Shell script for generating all the constants needed for a native
|
|
|
|
# platform build of src/gnu/dist/toolchain.
|
|
|
|
#
|
|
|
|
|
|
|
|
bomb () {
|
|
|
|
echo >&1 "ABORT: $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# usage: getvars MAKEFILE VARNAME [VARNAME...]
|
|
|
|
getvars () {
|
|
|
|
_mf="$1"; shift
|
|
|
|
$MAKE -f - _x_ <<EOF || bomb "getvars $_mf $* failed"
|
|
|
|
_x_:
|
|
|
|
.for var in $*
|
|
|
|
@echo G_\${var}=\${\${var}:Q} | sed 's,$_VPATH,\$\${GNUHOSTDIST},g'
|
|
|
|
.endfor
|
|
|
|
.include "$_TMPDIR/$_mf"
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
# usage: write_c FILENAME
|
|
|
|
write_c () {
|
|
|
|
echo '/* This file is automatically generated. DO NOT EDIT! */' >$_TOP/$1.tmp || \
|
|
|
|
bomb "cannot create $1"
|
|
|
|
grep '$''NetBSD' $0 | sed 's,[#$],,g;s,.*,/* Generated from: & */,' >>$_TOP/$1.tmp
|
|
|
|
echo '' >>$_TOP/$1.tmp
|
|
|
|
writefile $1
|
|
|
|
}
|
|
|
|
|
|
|
|
# usage: write_mk FILENAME
|
|
|
|
write_mk () {
|
|
|
|
echo '# This file is automatically generated. DO NOT EDIT!' >$_TOP/$1.tmp || \
|
|
|
|
bomb "cannot create $1"
|
|
|
|
grep '$''NetBSD' $0 | sed 's,[#$],,g;s,.*,# Generated from: &,' >>$_TOP/$1.tmp
|
|
|
|
echo '#' >>$_TOP/$1.tmp
|
|
|
|
writefile $1
|
|
|
|
}
|
|
|
|
|
|
|
|
writefile () {
|
|
|
|
sed -e 's,netbsd\(elf\)*1[0-9\.]*\(_\)*[A-Z]*,netbsd\1,' \
|
|
|
|
-e 's,^/\* #undef HAVE_MMAP \*/$,#define HAVE_MMAP 1,' >>$_TOP/$1.tmp
|
|
|
|
|
|
|
|
# Compare new file, sans "generated from" comments and RCS Id, to
|
|
|
|
# old file. If they match, don't change anything.
|
|
|
|
rm -f $_TMPDIR/.1 $_TMPDIR/.2
|
|
|
|
grep -v 'Generated from:' $_TOP/$1 >$_TMPDIR/.1 2>/dev/null
|
|
|
|
grep -v 'Generated from:' $_TOP/$1.tmp >$_TMPDIR/.2
|
|
|
|
|
|
|
|
# will not overwrite a file that has the same content
|
|
|
|
if cmp $_TMPDIR/.1 $_TMPDIR/.2 >/dev/null 2>&1; then
|
|
|
|
rm -f $_TOP/$1.tmp
|
|
|
|
else
|
|
|
|
echo >&2 "$1 changed"
|
|
|
|
mv -f $_TOP/$1.tmp $_TOP/$1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
##### gnu/lib/libg2c #####
|
|
|
|
|
|
|
|
get_libg2c () {
|
|
|
|
mkdir -p $_TOP/gnu/lib/libg2c3/arch/$MACHINE_ARCH
|
|
|
|
|
|
|
|
write_c gnu/lib/libg2c3/arch/$MACHINE_ARCH/config.h <$_TMPDIR/$_PLATFORM/libf2c/libU77/config.h
|
|
|
|
write_c gnu/lib/libg2c3/arch/$MACHINE_ARCH/g2c.h <$_TMPDIR/$_PLATFORM/libf2c/g2c.h
|
|
|
|
|
|
|
|
{
|
|
|
|
getvars $_PLATFORM/libf2c/Makefile \
|
|
|
|
F2CEXT
|
|
|
|
getvars $_PLATFORM/libf2c/libF77/Makefile \
|
|
|
|
ALL_CFLAGS OBJS
|
|
|
|
getvars $_PLATFORM/libf2c/libI77/Makefile \
|
|
|
|
ALL_CFLAGS OBJS | sed 's,=,+=,'
|
|
|
|
getvars $_PLATFORM/libf2c/libU77/Makefile \
|
|
|
|
ALL_CFLAGS OBJS | sed 's,=,+=,'
|
|
|
|
} | write_mk gnu/lib/libg2c3/arch/$MACHINE_ARCH/defs.mk
|
|
|
|
}
|
|
|
|
|
|
|
|
##### gnu/lib/libgcc #####
|
|
|
|
|
|
|
|
get_libgcc () {
|
|
|
|
mkdir -p $_TOP/gnu/usr.bin/gcc3/arch/$MACHINE_ARCH $_TOP/gnu/lib/libgcc3
|
|
|
|
|
|
|
|
# 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 LIB2ADDEH LIB2FUNCS_1 LIB2FUNCS_2 \
|
|
|
|
LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
|
|
|
|
LIBGCC2_CFLAGS MAYBE_USE_COLLECT2 \
|
|
|
|
tm_defines xm_file xm_defines \
|
|
|
|
| write_mk gnu/lib/libgcc3/$MACHINE_ARCH.mk
|
|
|
|
}
|
|
|
|
|
|
|
|
##### gnu/usr.bin/gcc3/libiberty #####
|
|
|
|
|
|
|
|
get_gcc3_libiberty () {
|
|
|
|
mkdir -p $_TOP/gnu/usr.bin/gcc3/libiberty
|
|
|
|
|
|
|
|
getvars libiberty/Makefile \
|
|
|
|
ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
|
|
|
|
| write_mk gnu/usr.bin/gcc3/libiberty/defs.mk
|
|
|
|
|
|
|
|
write_c gnu/usr.bin/gcc3/libiberty/config.h \
|
|
|
|
<$_TMPDIR/libiberty/config.h
|
|
|
|
}
|
|
|
|
|
|
|
|
##### gnu/lib/libobjc #####
|
|
|
|
|
|
|
|
get_libobjc () {
|
|
|
|
mkdir -p $_TOP/gnu/lib/libobjc3
|
|
|
|
|
|
|
|
getvars $_PLATFORM/libobjc/Makefile \
|
|
|
|
ALL_CFLAGS INCLUDES OBJS OBJC_H \
|
2003-07-28 05:29:01 +04:00
|
|
|
| sed "s,$_GNU_DIST,\$\${GNUHOSTDIST},g" \
|
2003-07-25 20:26:51 +04:00
|
|
|
| write_mk gnu/lib/libobjc3/defs.mk
|
|
|
|
}
|
|
|
|
|
|
|
|
##### gnu/lib/libstdc++-v3 #####
|
|
|
|
|
|
|
|
get_libstdcxx_v3 () {
|
|
|
|
mkdir -p $_TOP/gnu/lib/libstdc++-v3/arch/$MACHINE_ARCH
|
|
|
|
|
|
|
|
# build files
|
|
|
|
for h in gthr.h gthr-single.h gthr-posix.h gthr-default.h c++config.h; do
|
|
|
|
write_c gnu/lib/libstdc++-v3/arch/$MACHINE_ARCH/$h \
|
|
|
|
<$_TMPDIR/$_PLATFORM/libstdc++-v3/include/$_PLATFORM/bits/$h
|
|
|
|
done
|
|
|
|
|
|
|
|
{
|
|
|
|
# libmath
|
|
|
|
getvars $_PLATFORM/libstdc++-v3/libmath/Makefile \
|
|
|
|
libmath_la_SOURCES libmath_la_LIBADD
|
|
|
|
|
|
|
|
# libsupc++
|
|
|
|
getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
|
|
|
|
sources | sed 's/^G_sources=/G_LIBSUPCXX_SOURCES=/'
|
|
|
|
getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
|
|
|
|
c_sources | sed 's/^G_c_sources=/G_LIBSUPCXX_C_SOURCES=/'
|
|
|
|
|
|
|
|
# src
|
|
|
|
getvars $_PLATFORM/libstdc++-v3/src/Makefile \
|
|
|
|
sources SECTION_FLAGS | sed 's/^G_sources=/G_SRC_SOURCES=/'
|
|
|
|
|
|
|
|
# include
|
|
|
|
getvars $_PLATFORM/libstdc++-v3/include/Makefile \
|
|
|
|
c_base_headers_rename std_headers_rename
|
|
|
|
getvars $_PLATFORM/libstdc++-v3/include/Makefile \
|
|
|
|
bits_headers backward_headers ext_headers c_base_headers_extra \
|
|
|
|
target_headers | sed 's#/[^ ][^ ]*/##g'
|
|
|
|
getvars $_PLATFORM/libstdc++-v3/include/Makefile \
|
|
|
|
thread_target_headers target_headers_extra | sed 's#\./[^ ][^ ]*/##g'
|
|
|
|
} | write_mk gnu/lib/libstdc++-v3/arch/$MACHINE_ARCH/defs.mk
|
|
|
|
}
|
|
|
|
|
|
|
|
##### gnu/usr.bin/gcc3 #####
|
|
|
|
|
|
|
|
get_gcc () {
|
|
|
|
mkdir -p $_TOP/gnu/usr.bin/gcc3/arch/$MACHINE_ARCH
|
|
|
|
|
|
|
|
{
|
|
|
|
getvars gcc/Makefile \
|
|
|
|
ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
|
|
|
|
GCOV_OBJS PROTO_OBJS HOST_PRINT HOST_RTL HOST_RTLANAL \
|
|
|
|
HOST_SUPPORT HOST_EARLY_SUPPORT HOST_ERRORS HOST_VARRAY \
|
|
|
|
INCLUDES md_file OBJC_OBJS OBJS out_file version \
|
|
|
|
BUILD_PREFIX RTL_H TREE_H HCONFIG_H BASIC_BLOCK_H GCC_H \
|
|
|
|
GTFILES_SRCDIR GTFILES_FILES_FILES GTFILES_FILES_LANGS \
|
|
|
|
GTFILES GTFILES_LANG_DIR_NAMES \
|
|
|
|
tm_defines host_xm_file host_xm_defines tm_p_file \
|
|
|
|
target_cpu_default \
|
|
|
|
LIBCPP_OBJS LIBCPP_H \
|
|
|
|
lang_specs_files
|
|
|
|
getvars gcc/Makefile \
|
|
|
|
LIB2ADDEHDEP | sed 's/unwind.inc//'
|
|
|
|
getvars gcc/Makefile \
|
|
|
|
CXX_OBJS CXX_C_OBJS | sed 's/cp\///g'
|
|
|
|
getvars gcc/Makefile \
|
|
|
|
F77_OBJS | sed 's/f\///g'
|
|
|
|
} | write_mk gnu/usr.bin/gcc3/arch/$MACHINE_ARCH/defs.mk
|
|
|
|
|
|
|
|
for f in auto-build auto-host configargs cs-hconfig gencheck hconfig; do
|
|
|
|
write_c gnu/usr.bin/gcc3/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
##### main #####
|
|
|
|
|
|
|
|
_TMPDIR=$2
|
|
|
|
_TOP=$3
|
|
|
|
_PLATFORM=$4
|
|
|
|
_VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*= ,,'`
|
2003-07-28 05:29:01 +04:00
|
|
|
_GNU_DIST=`cd ${_VPATH}; pwd`
|
2003-07-25 20:26:51 +04:00
|
|
|
|
|
|
|
case $1 in
|
|
|
|
libgcc) # .mk and .h files for libgcc bootstrap (from host build)
|
|
|
|
get_libgcc
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
gcc3)
|
|
|
|
get_gcc
|
|
|
|
get_libg2c
|
|
|
|
get_libgcc
|
|
|
|
get_gcc3_libiberty
|
|
|
|
get_libobjc
|
|
|
|
get_libstdcxx_v3
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
*) echo invalid arguments; exit 1;;
|
|
|
|
esac
|