4 # Shell script for generating all the constants needed for a native
5 # platform build of src/gnu/dist/gcc.
14 _VPATH
=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
15 _GNU_DIST
=`cd ${_VPATH}; pwd`
17 .
$_TOP/tools
/gcc
/mknative.common
19 ##### gnu/lib/crtstuff #####
23 mkdir
-p $_TOP/gnu
/lib
/$_subdir/arch
25 getvars gcc
/Makefile \
26 INCLUDES CRTSTUFF_CFLAGS CRTSTUFF_T_CFLAGS \
27 tm_defines xm_file xm_defines \
28 | write_mk gnu
/lib
/$_subdir/arch
/$MACHINE_ARCH.mk
31 ##### gnu/lib/libg2c #####
34 mkdir
-p $_TOP/gnu
/lib
/libg2c
3/arch
/$MACHINE_ARCH
36 write_c gnu
/lib
/libg2c
3/arch
/$MACHINE_ARCH/config.h
<$_TMPDIR/$_PLATFORM/libf2c
/libU77
/config.h
37 write_c gnu
/lib
/libg2c
3/arch
/$MACHINE_ARCH/g2c.h
<$_TMPDIR/$_PLATFORM/libf2c
/g2c.h
40 getvars
$_PLATFORM/libf2c
/Makefile \
42 getvars
$_PLATFORM/libf2c
/libF77
/Makefile \
44 getvars
$_PLATFORM/libf2c
/libI77
/Makefile \
45 ALL_CFLAGS OBJS |
sed 's,=,+=,'
46 getvars
$_PLATFORM/libf2c
/libU77
/Makefile \
47 ALL_CFLAGS OBJS |
sed 's,=,+=,'
48 } | write_mk gnu
/lib
/libg2c
3/arch
/$MACHINE_ARCH/defs.mk
51 ##### gnu/lib/libgcc #####
53 get_libgcc_list_funcs_asm
() {
55 getvars gcc
/Makefile LIB1ASMFUNCS |
{
56 # print newline separated list
64 getvars gcc
/Makefile LIB2FUNCS_EXTRA |
{
65 # print newline separated list
73 /\.S$/ { s,^.*/,,; s,\.S$,,; p; }
74 /\.asm$/ { s,^.*/,,; s,\.asm$,,; p; }
89 get_libgcc_list_funcs_lib
() {
91 local _lib_prefix
=${_lib%.*}
92 local _lib_suffix
=${_lib#*.}
95 cat build
/gcc
/libgcc.mk | \
96 grep '/'${_abi}'/' | \
98 /^'${_abi}'\/'${_lib_prefix}'\.'${_lib_suffix}': .*\.o$/ {
106 get_libgcc_list_objs_libs
() {
107 local _abi
=${1:-'\.'}
109 cat build
/gcc
/libgcc.mk | \
110 grep '/'${_abi}'/' | \
111 egrep '^'${_abi}'\/(libgcc_s\.so|libgcc\.a|libgcc_eh\.a|libgcov\.a): (libgcc_s|libgcc|libgcc_eh|libgcov)\/.*\.o$' | \
115 s,^\(.*\) \(.*\)$,\2 \1,
119 get_libgcc_list_objs_srcs
() {
120 local _abi
=${1:-'\.'} # XXX not used
122 if [ -e $_TOP/${libgcc_db_funcs}.S
]; then
123 cut
-f1 $_TOP/${libgcc_db_objs_libs} |
sed -e 's,\.o$,,' | \
124 comm -23 /dev
/stdin
$_TOP/${libgcc_db_funcs}.S | \
125 sed -e 's,\(.*\),\1.o \1.c,'
127 cut
-f1 $_TOP/${libgcc_db_objs_libs} |
sed -e 's,\.o$,,' | \
128 comm -12 /dev
/stdin
$_TOP/${libgcc_db_funcs}.S | \
129 sed -e 's,\(.*\),\1.o \1.S,'
131 cut
-f1 $_TOP/${libgcc_db_objs_libs} |
sed -e 's,\.o$,,' | \
132 sed -e 's,\(.*\),\1.o \1.c,'
136 get_libgcc_list_objs_tmplsrcs
() {
137 local _abi
=${1:-'\.'}
139 grep 'GCC_FOR_TARGET.*\.o$' build
/gcc
/libgcc.mk | \
140 grep '/'${_abi}'/' | \
142 s,^.* -c \([^ ]*\).* -o .*/\([^ ]*\.o\)$,\2 \1,
150 get_libgcc_list_objs_xflags
() {
152 local _abi
=${2:-'\.'}
154 grep 'GCC_FOR_TARGET.*\.o$' build
/gcc
/libgcc.mk | \
155 grep '/'${_abi}'/' | \
160 s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\5 \2/p
162 s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\1 \3 \4\/\5/
168 get_libgcc_list_objs_cppflags
() {
169 get_libgcc_list_objs_xflags D
$1
172 get_libgcc_list_objs_copts
() {
173 get_libgcc_list_objs_xflags fmx
$1
176 get_libgcc_list_tmplsrcs
() {
178 local _abi
=$2 # XXX not used
179 local _tmplallsrcs
=$
( mktemp
/tmp
/mknative-gcc._tmplallsrcs.XXXXXX
)
181 touch $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.
${_lib%.*}
182 touch $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.
${_lib%.*}
183 touch $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.
${_lib%.*}
186 local _lib_prefix
=${_lib%.*}
187 local _lib_suffix
=${_lib#*.}
188 join $_TOP/$libgcc_db_objs_libs $_TOP/$libgcc_db_objs_tmplsrcs | \
189 grep ${_lib_prefix}'\.'${_lib_suffix} | cut
-d' ' -f 3 |
sort -u > \
192 # TMPLFPSRCS = [fdp]p-bit.c
193 grep '[fdt]p-bit\.c' <$_tmplallsrcs |
sort -u | \
194 writefile
${libgcc_db_tmplsrcs}.tmplfpsrcs.
${_lib%.*}
196 # TMPLASMSRCS = $(LIB1ASMSRC)
197 grep '\$(LIB1ASMSRC)' <$_tmplallsrcs |
sort -u | \
198 writefile
${libgcc_db_tmplsrcs}.tmplasmsrcs.
${_lib%.*}
200 # TMPLSRCS is anything else; exclude TMPLFPSRCS and TMPLASMSRCS
201 cat $_tmplallsrcs | \
202 comm -23 /dev
/stdin
$_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.
${_lib%.*} | \
203 comm -23 /dev
/stdin
$_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.
${_lib%.*} | \
204 writefile
${libgcc_db_tmplsrcs}.tmplsrcs.
${_lib%.*}
209 get_libgcc_new_analyze
() {
212 mkdir
-p $_TOP/${_machine_arch_subdir}
214 touch $_TOP/${libgcc_db_funcs}.S
215 get_libgcc_list_funcs_asm | \
216 writefile
${libgcc_db_funcs}.S
218 for _lib
in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a
; do
219 touch $_TOP/${libgcc_db_funcs}.
${_lib%.*}
220 get_libgcc_list_funcs_lib
$_lib $_abi | \
221 writefile
${libgcc_db_funcs}.
${_lib%.*}
224 get_libgcc_list_objs_libs
$_abi | writefile
${libgcc_db_objs_libs}
225 get_libgcc_list_objs_srcs
$_abi | writefile
${libgcc_db_objs_srcs}
226 get_libgcc_list_objs_tmplsrcs
$_abi | writefile
${libgcc_db_objs_tmplsrcs}
227 get_libgcc_list_objs_cppflags
$_abi | writefile
${libgcc_db_objs_cppflags}
228 get_libgcc_list_objs_copts
$_abi | writefile
${libgcc_db_objs_copts}
230 for _lib
in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a
; do
231 get_libgcc_list_tmplsrcs
$_lib $_abi
237 get_libgcc_gen_tmplsrcs_tmplsrcs
() {
241 printf 'TMPLSRCS.%s = \\\n' $_lib
242 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.
${_lib%.*}
245 get_libgcc_gen_tmplsrcs_tmplfpsrcs
() {
249 printf 'TMPLFPSRCS.%s = \\\n' $_lib
250 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.
${_lib%.*}
253 get_libgcc_gen_tmplsrcs_tmplasmsrcs
() {
257 printf 'TMPLASMSRCS.%s = \\\n' $_lib
258 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.
${_lib%.*} | \
259 sed -e 's,LIB1ASMSRC,G_&,'
262 get_libgcc_gen_srcs
() {
266 printf 'SRCS.%s = \\\n' $_lib
267 if [ -e $_TOP/${libgcc_db_funcs}.S
]; then
268 comm -23 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
269 sed -e 's,$,.c,; s,^,tmp_,'
270 comm -12 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
271 sed -e 's,$,.S,; s,^,tmp_,'
273 cat $_TOP/${libgcc_db_funcs}.
${_lib%.*} | \
274 sed -e 's,$,.c,; s,^,tmp_,'
276 sed -e 's,^, ,; s,$, \\,'
280 local _obj
=$1; local _key
=$2
282 eval grep \^
$_obj\\\ \
$_TOP/\
${libgcc_db_objs_${_key}} | cut
-f2
285 get_libgcc_gen_srcs_tmplsrcs
() {
286 cut
-f1 $_TOP/${libgcc_db_objs_libs} | \
288 printf 'SRCS.tmp_%s=%s\n' \
289 "$( _lookup_objs $_obj srcs )" \
290 "$( _lookup_objs $_obj tmplsrcs )"
292 sed -e 's,\$(\(.*\)),${G_\1},'
295 get_libgcc_gen_srcs_cppflags
() {
296 cut
-f1 $_TOP/${libgcc_db_objs_libs} | \
298 printf '_CPPFLAGS.tmp_%s=%s\n' \
299 "$( _lookup_objs $_obj srcs )" \
300 "$( _lookup_objs $_obj cppflags | xargs )"
304 get_libgcc_gen_srcs_copts
() {
305 cut
-f1 $_TOP/${libgcc_db_objs_libs} | \
307 printf 'COPTS.tmp_%s=%s\n' \
308 "$( _lookup_objs $_obj srcs )" \
309 "$( _lookup_objs $_obj copts | xargs )"
313 get_libgcc_new_generate
() {
316 for _lib
in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a
; do
317 for _tmpl
in tmplsrcs tmplfpsrcs tmplasmsrcs
; do
318 eval get_libgcc_gen_tmplsrcs_
${_tmpl} $_lib | \
319 write_mk
${libgcc_libs_mk}.${_lib%.*}.tmplsrcs.${_tmpl}.mk
322 get_libgcc_gen_srcs
$_lib | \
323 write_mk
${libgcc_libs_mk}.
${_lib%.*}.srcs.mk
326 for _arg
in tmplsrcs cppflags copts
; do
327 eval get_libgcc_gen_srcs_
${_arg} | \
328 eval writefile \
$libgcc_srcs_mk_${_arg}
338 # List of generated files.
340 _machine_arch_subdir
=gnu
/lib
/lib
$_subdir/arch
${_archsubdir}/$MACHINE_ARCH/$_abi
342 libgcc_db_funcs
=${_machine_arch_subdir}/funcs
343 libgcc_db_tmplsrcs
=${_machine_arch_subdir}/tmplsrcs
344 libgcc_db_objs_libs
=${_machine_arch_subdir}/objs.libs
345 libgcc_db_objs_srcs
=${_machine_arch_subdir}/objs.srcs
346 libgcc_db_objs_tmplsrcs
=${_machine_arch_subdir}/objs.tmplsrcs
347 libgcc_db_objs_cppflags
=${_machine_arch_subdir}/objs.cppflags
348 libgcc_db_objs_copts
=${_machine_arch_subdir}/objs.copts
350 get_libgcc_new_analyze
$_abi
352 libgcc_libs_mk
=${_machine_arch_subdir}/libs
353 libgcc_srcs_mk
=${_machine_arch_subdir}/srcs.mk
354 libgcc_srcs_mk_tmplsrcs
=${_machine_arch_subdir}/srcs.tmplsrcs.mk
355 libgcc_srcs_mk_cppflags
=${_machine_arch_subdir}/srcs.cppflags.mk
356 libgcc_srcs_mk_copts
=${_machine_arch_subdir}/srcs.copts.mk
358 get_libgcc_new_generate
$_abi
363 mkdir
-p $_TOP/gnu
/lib
/lib
$_subdir/arch
367 _extravars
="USE_COLLECT2 LIB2FUNCS_1 LIB2FUNCS_2 xm_file"
371 _extravars
="COLLECT2 UNWIND_H xm_include_list"
376 # DPBIT, FPBIT only used on mn10[23]00, we don't need them.
377 # XXX we should probably grab everything Just In Case for
380 getvars gcc
/Makefile \
381 INCLUDES LIB2ADD LIB2ADDEH \
382 LIB1ASMFUNCS LIB1ASMSRC \
383 LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
386 SHLIB_MKMAP SHLIB_MKMAP_OPTS \
387 SHLIB_MAPFILES SHLIB_NM_FLAGS \
388 EXTRA_HEADERS xm_defines \
389 tm_defines
${_extravars}
390 } | write_mk gnu
/lib
/lib
$_subdir/arch
${_archsubdir}/$MACHINE_ARCH.mk
392 # Generate new style files.
393 if [ -n "${MKNATIVE_LIBGCC_NEW}" ]; then
394 get_libgcc_new
$_subdir $_ABI
398 ##### gnu/lib/libgcov #####
403 mkdir
-p $_TOP/gnu
/lib
/lib
$_subdir/libgcov
/arch
/$MACHINE_ARCH
406 getvars gcc
/Makefile \
408 } | write_mk gnu
/lib
/lib
$_subdir/libgcov
/arch
/$MACHINE_ARCH/defs.mk
410 write_c gnu
/lib
/lib
$_subdir/libgcov
/arch
/$MACHINE_ARCH/gcov-iov.h \
411 <$_TMPDIR/gcc
/gcov-iov.h
415 ##### gnu/usr.bin/gcc[34]/libiberty #####
417 get_gcc_libiberty
() {
419 mkdir
-p $_TOP/gnu
/usr.bin
/$_subdir/libiberty
/arch
/$MACHINE_ARCH
421 getvars libiberty
/Makefile \
422 ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
423 | write_mk gnu
/usr.bin
/$_subdir/libiberty
/defs.mk
425 write_c gnu
/usr.bin
/$_subdir/libiberty
/arch
/$MACHINE_ARCH/config.h \
426 <$_TMPDIR/libiberty
/config.h
429 ##### gnu/lib/libobjc #####
434 _subdir
="$1/arch/$MACHINE_ARCH"
435 _options
="ALL_OPT_FILES"
445 mkdir
-p $_TOP/gnu
/lib
/$_subdir
448 if [ -n "$_options" ]; then
449 getvars gcc
/Makefile
$_options
451 getvars
$_PLATFORM/libobjc
/Makefile \
452 ALL_CFLAGS INCLUDES OBJS OBJC_H \
453 |
sed "s,$_GNU_DIST,\${GNUHOSTDIST},g"
454 if [ -n "$_unwind" ]; then
455 getvars gcc
/Makefile
$_unwind
457 } | write_mk gnu
/lib
/$_subdir/defs.mk
459 write_c gnu
/lib
/$_subdir/config.h \
460 <$_TMPDIR/$_PLATFORM/libobjc
/config.h
463 ##### gnu/lib/libstdc++-v3 #####
465 get_libstdcxx_v3
() {
467 mkdir
-p $_TOP/gnu
/lib
/$_subdir/arch
/$MACHINE_ARCH
471 _src_CC_files
="atomicity_file CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_CC CLOCALE_CC BASIC_FILE_CC"
472 _headers1
="host_headers debug_headers tr1_headers c_compatibility_headers_extra"
473 _headers2
="thread_host_headers host_headers_extra"
474 _build_headers
="c++allocator.h c++config.h cxxabi_tweaks.h gthr-default.h gthr-posix.h gthr-single.h gthr-tpf.h gthr.h"
479 _headers1
="target_headers"
480 _headers2
="thread_target_headers target_headers_extra"
481 _build_headers
="c++config.h gthr-default.h gthr-posix.h gthr-single.h gthr.h"
487 for h
in $_build_headers; do
488 write_c gnu
/lib
/$_subdir/arch
/$MACHINE_ARCH/$h \
489 <$_TMPDIR/$_PLATFORM/libstdc
++-v3/include
/$_PLATFORM/bits
/$h
492 write_c gnu
/lib
/$_subdir/arch
/$MACHINE_ARCH/config.h \
493 <$_TMPDIR/$_PLATFORM/libstdc
++-v3/config.h
497 getvars
$_PLATFORM/libstdc
++-v3/libmath
/Makefile \
498 libmath_la_SOURCES libmath_la_LIBADD
501 getvars
$_PLATFORM/libstdc
++-v3/libsupc
++/Makefile \
502 sources |
sed 's/^G_sources=/G_LIBSUPCXX_SOURCES=/'
503 getvars
$_PLATFORM/libstdc
++-v3/libsupc
++/Makefile \
504 c_sources |
sed 's/^G_c_sources=/G_LIBSUPCXX_C_SOURCES=/'
507 getvars
$_PLATFORM/libstdc
++-v3/src
/Makefile \
508 sources
$_src_CC_files SECTION_FLAGS |
sed 's/^G_sources=/G_SRC_SOURCES=/'
511 getvars
$_PLATFORM/libstdc
++-v3/include
/Makefile \
512 c_base_headers_rename std_headers_rename
513 getvars
$_PLATFORM/libstdc
++-v3/include
/Makefile \
514 bits_headers backward_headers ext_headers c_base_headers_extra \
515 $_headers1 |
sed -e 's#/[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
516 getvars
$_PLATFORM/libstdc
++-v3/include
/Makefile \
517 $_headers2 |
sed -e 's#\./[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
519 if [ -n "$_unwind" ]; then
520 getvars gcc
/Makefile
$_unwind
522 } | write_mk gnu
/lib
/$_subdir/arch
/$MACHINE_ARCH/defs.mk
525 ##### gnu/usr.bin/gcc3 #####
529 mkdir
-p $_TOP/gnu
/usr.bin
/$_subdir/arch
/$MACHINE_ARCH
532 mkdir
-p $_TOP/gnu
/usr.bin
/$_subdir/libcpp
/arch
/$MACHINE_ARCH
535 _extravars
="TM_H ALL_OPT_FILES"
537 _extravars2
="tm_file_list build_xm_include_list"
538 _extravars3
="tm_p_include_list"
545 _hconfig_h
="HCONFIG_H"
552 getvars gcc
/Makefile \
553 ${_buildname}EARLY_SUPPORT ${_buildname}ERRORS ${_buildname}PRINT \
554 ${_buildname}RTL ${_buildname}SUPPORT ${_buildname}VARRAY | \
555 sed -e 's#build/errors.o#build-errors.o#g' \
556 -e 's#build/print-rtl.o#build-print-rtl.o#g' \
557 -e 's#build/rtl.o#build-rtl.o#g' \
558 -e 's#build/varray.o#build-varray.o#g' \
559 -e 's#build/ggc-none.o#build-ggc-none.o#g' \
561 getvars gcc
/Makefile \
562 ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
563 GCOV_OBJS PROTO_OBJS
${_extravars1} \
564 INCLUDES md_file OBJC_OBJS OBJS out_file version \
565 BUILD_PREFIX RTL_H TREE_H
${_hconfig_h} BASIC_BLOCK_H GCC_H \
566 GTFILES_SRCDIR GTFILES_FILES_FILES GTFILES_FILES_LANGS \
567 GTFILES GTFILES_LANG_DIR_NAMES \
568 tm_defines host_xm_file host_xm_defines tm_p_file \
569 target_cpu_default
${_extravars} ${_extravars2} \
570 lang_specs_files
${_extravars3}
571 getvars gcc
/Makefile \
572 LIB2ADDEHDEP |
sed 's/unwind.inc//'
573 getvars gcc
/Makefile \
574 CXX_OBJS CXX_C_OBJS |
sed 's/cp\///g'
575 getvars gcc
/Makefile \
576 F77_OBJS |
sed 's/f\///g'
579 getvars libcpp
/Makefile \
583 getvars gcc
/Makefile \
587 getvars gcc
/Makefile \
591 echo G_SHLIB_LINK
="$CC -shared"
592 echo G_SHLIB_MULTILIB
=.
595 getvars gcc
/Makefile \
596 SHLIB_LINK SHLIB_MULTILIB
599 } | write_mk gnu
/usr.bin
/$_subdir/arch
/$MACHINE_ARCH/defs.mk
603 hfiles
='auto-host configargs cs-hconfig gencheck hconfig gthr-default'
606 write_c gnu
/usr.bin
/$_subdir/libcpp
/arch
/$MACHINE_ARCH/config.h
<$_TMPDIR/libcpp
/config.h
607 hfiles
='auto-host configargs gencheck gthr-default tm bconfig config multilib'
611 write_c gnu
/usr.bin
/$_subdir/arch
/$MACHINE_ARCH/$f.h
<$_TMPDIR/gcc
/$f.h
618 # .mk and .h files for libgcc bootstrap (from host build)
621 get_crtstuff crtstuff3
627 get_crtstuff crtstuff4
636 get_crtstuff crtstuff4
637 get_gcc_libiberty gcc4
639 get_libstdcxx_v3 libstdc
++-v3_4
647 get_crtstuff crtstuff3
648 get_gcc_libiberty gcc3
650 get_libstdcxx_v3 libstdc
++-v3
654 *) echo invalid arguments
; exit 1;;