tools/binutils: Add support to mknative for binutils.old

This commit is contained in:
rin 2023-11-25 12:11:27 +00:00
parent 8cde2f1c1d
commit 6673897143
2 changed files with 165 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.37 2023/01/18 12:52:55 christos Exp $
# $NetBSD: Makefile,v 1.38 2023/11/25 12:11:27 rin Exp $
.include <bsd.hostinit.mk>
@ -41,6 +41,9 @@ LDADDFLAGS= -L${DESTDIR}/lib -L${DESTDIR}/usr/lib
CONFIGURE_ENV+= ac_cv_path_mkdir="${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install -d"
NEWCONFIGDIR?= ${.CURDIR}/../..
.if ${EXTERNAL_BINUTILS_SUBDIR} == "binutils.old"
MKNATIVE= ${.CURDIR}/mknative-binutils.old
.endif
MKNATIVE?= ${.CURDIR}/mknative-binutils
native-binutils: .native/.configure_done

View File

@ -0,0 +1,161 @@
#!/bin/sh
# $NetBSD: mknative-binutils.old,v 1.1 2023/11/25 12:11:27 rin Exp $
# NetBSD: mknative-binutils,v 1.13 2020/04/04 01:34:53 christos Exp
#
# Shell script for generating all the constants needed for a native
# platform build of src/external/gpl3/binutils.old
#
# initialise
_TMPDIR=$2
_TOP=$3
_PLATFORM=$4
_VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
. $_TOP/tools/gcc/mknative.common
##### external/gpl3/binutils.old/lib/libbfd #####
get_libbfd () {
mkdir -p $_TOP/external/gpl3/binutils.old/lib/libbfd/arch/$MACHINE_ARCH
{
getvars bfd/Makefile \
libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS \
INCLUDES TDEFAULTS HAVEVECS
} | write_mk external/gpl3/binutils.old/lib/libbfd/arch/$MACHINE_ARCH/defs.mk
write_c external/gpl3/binutils.old/lib/libbfd/arch/$MACHINE_ARCH/bfd.h <$_TMPDIR/bfd/bfd.h
write_c external/gpl3/binutils.old/lib/libbfd/arch/$MACHINE_ARCH/bfdver.h <$_TMPDIR/bfd/bfdver.h
write_c external/gpl3/binutils.old/lib/libbfd/arch/$MACHINE_ARCH/bfd_stdint.h <$_TMPDIR/bfd/bfd_stdint.h
{
cat $_TMPDIR/bfd/config.h
} | write_c external/gpl3/binutils.old/lib/libbfd/arch/$MACHINE_ARCH/config.h
}
##### external/gpl3/binutils.old/lib/libopcodes #####
get_libopcodes () {
mkdir -p $_TOP/external/gpl3/binutils.old/lib/libopcodes/arch/$MACHINE_ARCH
{
getvars opcodes/Makefile \
archdefs BFD_MACHINES libopcodes_la_SOURCES
} | write_mk external/gpl3/binutils.old/lib/libopcodes/arch/$MACHINE_ARCH/defs.mk
{
cat $_TMPDIR/opcodes/config.h
} | write_c external/gpl3/binutils.old/lib/libopcodes/arch/$MACHINE_ARCH/config.h
}
get_libgnuctf () {
mkdir -p $_TOP/external/gpl3/binutils.old/lib/libgnuctf/arch/$MACHINE_ARCH
{
getvars libctf/Makefile libctf_la_SOURCES
} | write_mk external/gpl3/binutils.old/lib/libgnuctf/arch/$MACHINE_ARCH/defs.mk
{
cat $_TMPDIR/libctf/config.h
} | write_c external/gpl3/binutils.old/lib/libgnuctf/arch/$MACHINE_ARCH/config.h
}
##### external/gpl3/binutils.old/lib/libiberty #####
get_libiberty () {
mkdir -p $_TOP/external/gpl3/binutils.old/lib/libiberty/arch/$MACHINE_ARCH
getvars libiberty/Makefile \
ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
| write_mk external/gpl3/binutils.old/lib/libiberty/arch/$MACHINE_ARCH/defs.mk
write_c external/gpl3/binutils.old/lib/libiberty/arch/$MACHINE_ARCH/config.h \
<$_TMPDIR/libiberty/config.h
}
##### external/gpl3/binutils.old/usr.bin #####
get_binutils () {
### common
mkdir -p $_TOP/external/gpl3/binutils.old/usr.bin/common/arch/$MACHINE_ARCH
{
getvars binutils/Makefile \
VERSION DEFS INCLUDES PROGRAMS
getvars binutils/doc/Makefile \
man_MANS TEXINFOS
getvars bfd/doc/Makefile \
PKGVERSION | sed 's,\\\(.\),\1,'
getvars bfd/doc/Makefile \
REPORT_BUGS_TEXI
for f in `getvars binutils/Makefile PROGRAMS | sed 'y,-,_,;s,^[^=]*=,,'`; do
getvars binutils/Makefile ${f}_OBJECTS ${f}_DEPENDENCIES
done
} | write_mk external/gpl3/binutils.old/usr.bin/common/arch/$MACHINE_ARCH/defs.mk
write_c external/gpl3/binutils.old/usr.bin/common/arch/$MACHINE_ARCH/config.h \
<$_TMPDIR/binutils/config.h
### gas
mkdir -p $_TOP/external/gpl3/binutils.old/usr.bin/gas/arch/$MACHINE_ARCH
grep -v DEPDIR "$_TMPDIR/gas/Makefile" > "$_TMPDIR/gas/Makefile.nodeps"
getvars gas/Makefile.nodeps \
DEFS INCLUDES as_new_OBJECTS as_new_LDADD |
sed -e s/G_as_new_OBJECTS/G_OBJS/ \
-e s/G_as_new_LDADD=/G_OBJS+=/ \
-e s@config/@@g \
-e 's/\.\..*a//' |
write_mk external/gpl3/binutils.old/usr.bin/gas/arch/$MACHINE_ARCH/defs.mk
for f in config itbl-cpu obj-format targ-cpu targ-env; do
write_c external/gpl3/binutils.old/usr.bin/gas/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gas/$f.h
done
### gprof
mkdir -p $_TOP/external/gpl3/binutils.old/usr.bin/gprof/arch/$MACHINE_ARCH
getvars gprof/Makefile \
DEFS gprof_OBJECTS INCLUDES TEXINFOS \
| write_mk external/gpl3/binutils.old/usr.bin/gprof/arch/$MACHINE_ARCH/defs.mk
write_c external/gpl3/binutils.old/usr.bin/gprof/arch/$MACHINE_ARCH/gconfig.h <$_TMPDIR/gprof/gconfig.h
### ld
mkdir -p $_TOP/external/gpl3/binutils.old/usr.bin/ld/arch/$MACHINE_ARCH
{
getvars ld/Makefile \
DEFS EMUL EMULATION_OFILES INCLUDES OFILES STRINGIFY TEXINFOS
getvars ld/Makefile \
target_alias | sed 's,[\._0-9A-Z]*$,,'
getvars ld/Makefile \
enable_initfini_array
} | write_mk external/gpl3/binutils.old/usr.bin/ld/arch/$MACHINE_ARCH/defs.mk
for f in config ldemul-list; do
write_c external/gpl3/binutils.old/usr.bin/ld/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/ld/$f.h
done
}
##### main #####
case $1 in
all|binutils) # everything (uses "canadian cross" temp environment)
get_binutils
get_libbfd
get_libgnuctf
get_libopcodes
get_libiberty
exit 0
;;
*) echo invalid arguments; exit 1;;
esac