make vfs & filesystems use failable copying
[minix3.git] / tools / binutils / mknative-binutils
blob82b12307edb06aef2fee68476dcd35daf96024c1
1 #!/bin/sh
2 # $NetBSD: mknative-binutils,v 1.9 2013/10/01 15:41:17 skrll Exp $
4 # Shell script for generating all the constants needed for a native
5 # platform build of src/external/gpl3/binutils
8 # initialise
10 _TMPDIR=$2
11 _TOP=$3
12 _PLATFORM=$4
13 _VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
15 . $_TOP/tools/gcc/mknative.common
17 ##### external/gpl3/binutils/lib/libbfd #####
19 get_libbfd () {
20 mkdir -p $_TOP/external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH
23 getvars bfd/Makefile \
24 libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS \
25 INCLUDES TDEFAULTS
26 } | write_mk external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH/defs.mk
28 write_c external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH/bfd.h <$_TMPDIR/bfd/bfd.h
29 write_c external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH/bfdver.h <$_TMPDIR/bfd/bfdver.h
30 write_c external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH/bfd_stdint.h <$_TMPDIR/bfd/bfd_stdint.h
33 cat $_TMPDIR/bfd/config.h
34 } | write_c external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH/config.h
37 ##### external/gpl3/binutils/lib/libopcodes #####
39 get_libopcodes () {
40 mkdir -p $_TOP/external/gpl3/binutils/lib/libopcodes/arch/$MACHINE_ARCH
43 getvars opcodes/Makefile \
44 archdefs BFD_MACHINES libopcodes_la_SOURCES
45 } | write_mk external/gpl3/binutils/lib/libopcodes/arch/$MACHINE_ARCH/defs.mk
48 cat $_TMPDIR/opcodes/config.h
49 } | write_c external/gpl3/binutils/lib/libopcodes/arch/$MACHINE_ARCH/config.h
52 ##### external/gpl3/binutils/lib/libiberty #####
54 get_libiberty () {
55 mkdir -p $_TOP/external/gpl3/binutils/lib/libiberty/arch/$MACHINE_ARCH
57 getvars libiberty/Makefile \
58 ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
59 | write_mk external/gpl3/binutils/lib/libiberty/arch/$MACHINE_ARCH/defs.mk
61 write_c external/gpl3/binutils/lib/libiberty/arch/$MACHINE_ARCH/config.h \
62 <$_TMPDIR/libiberty/config.h
65 ##### external/gpl3/binutils/usr.bin #####
67 get_binutils () {
68 ### common
70 mkdir -p $_TOP/external/gpl3/binutils/usr.bin/common/arch/$MACHINE_ARCH
73 getvars binutils/Makefile \
74 VERSION DEFS INCLUDES PROGRAMS
75 getvars binutils/doc/Makefile \
76 man_MANS TEXINFOS
77 getvars bfd/doc/Makefile \
78 PKGVERSION | sed 's,\\\(.\),\1,'
79 getvars bfd/doc/Makefile \
80 REPORT_BUGS_TEXI
82 for f in `getvars binutils/Makefile PROGRAMS | sed 'y,-,_,;s,^[^=]*=,,'`; do
83 getvars binutils/Makefile ${f}_OBJECTS ${f}_DEPENDENCIES
84 done
85 } | write_mk external/gpl3/binutils/usr.bin/common/arch/$MACHINE_ARCH/defs.mk
87 write_c external/gpl3/binutils/usr.bin/common/arch/$MACHINE_ARCH/config.h \
88 <$_TMPDIR/binutils/config.h
90 ### gas
92 mkdir -p $_TOP/external/gpl3/binutils/usr.bin/gas/arch/$MACHINE_ARCH
94 grep -v DEPDIR "$_TMPDIR/gas/Makefile" > "$_TMPDIR/gas/Makefile.nodeps"
95 getvars gas/Makefile.nodeps \
96 DEFS INCLUDES as_new_OBJECTS as_new_LDADD |
97 sed -e s/G_as_new_OBJECTS/G_OBJS/ \
98 -e s/G_as_new_LDADD=/G_OBJS+=/ \
99 -e 's/\.\..*a//' |
100 write_mk external/gpl3/binutils/usr.bin/gas/arch/$MACHINE_ARCH/defs.mk
102 for f in config itbl-cpu obj-format targ-cpu targ-env; do
103 write_c external/gpl3/binutils/usr.bin/gas/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gas/$f.h
104 done
106 ### gprof
108 mkdir -p $_TOP/external/gpl3/binutils/usr.bin/gprof/arch/$MACHINE_ARCH
110 getvars gprof/Makefile \
111 DEFS gprof_OBJECTS INCLUDES TEXINFOS \
112 | write_mk external/gpl3/binutils/usr.bin/gprof/arch/$MACHINE_ARCH/defs.mk
114 write_c external/gpl3/binutils/usr.bin/gprof/arch/$MACHINE_ARCH/gconfig.h <$_TMPDIR/gprof/gconfig.h
116 ### ld
118 mkdir -p $_TOP/external/gpl3/binutils/usr.bin/ld/arch/$MACHINE_ARCH
121 getvars ld/Makefile \
122 DEFS EMUL EMULATION_OFILES INCLUDES OFILES STRINGIFY TEXINFOS
123 getvars ld/Makefile \
124 target_alias | sed 's,[\._0-9A-Z]*$,,'
125 getvars ld/Makefile \
126 enable_initfini_array
127 } | write_mk external/gpl3/binutils/usr.bin/ld/arch/$MACHINE_ARCH/defs.mk
129 for f in config ldemul-list; do
130 write_c external/gpl3/binutils/usr.bin/ld/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/ld/$f.h
131 done
134 ##### main #####
136 case $1 in
137 all|binutils) # everything (uses "canadian cross" temp environment)
138 get_binutils
139 get_libbfd
140 get_libopcodes
141 get_libiberty
142 exit 0
145 *) echo invalid arguments; exit 1;;
146 esac