getifaddrs: add un-namespaced alias
[minix.git] / tools / gcc / mknative-gcc
blob981f2781ea6b6e3b23898b8c685c1d5acad9faf2
1 #!/bin/sh
2 # $NetBSD: mknative-gcc,v 1.68 2012/09/25 06:55:10 skrll Exp $
4 # Shell script for generating all the constants needed for a native
5 # platform build of gcc.
8 # initialise
10 _TMPDIR=$2
11 _TOP=$3
12 _PLATFORM=$4
13 _DESTDIR=$5
14 _ABI=$6
15 _VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
16 _GNU_DIST=`cd ${_VPATH}; pwd`
18 if [ -z "$_DESTDIR" ]; then
19 echo "\$_DESTDIR is empty" 2>&1
20 exit 1
23 . $_TOP/tools/gcc/mknative.common
25 # default to GCC 4.1 for now
26 _OUTDIR="$_TOP/gnu"
27 _OUTDIRBASE="gnu"
29 ##### gnu/lib/crtstuff #####
31 get_crtstuff () {
32 _subdir="$1"
33 mkdir -p $_OUTDIR/lib/$_subdir/arch
35 getvars gcc/Makefile \
36 INCLUDES CRTSTUFF_CFLAGS CRTSTUFF_T_CFLAGS CRTSTUFF_T_CFLAGS_S \
37 tm_defines xm_file xm_defines \
38 | sed "s,-I$_DESTDIR/usr/include,,g" \
39 | write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH.mk
42 ##### gnu/lib/libg2c #####
44 get_libg2c () {
45 mkdir -p $_OUTDIR/lib/libg2c3/arch/$MACHINE_ARCH
47 write_c $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/config.h <$_TMPDIR/$_PLATFORM/libf2c/libU77/config.h
48 write_c $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/g2c.h <$_TMPDIR/$_PLATFORM/libf2c/g2c.h
51 getvars $_PLATFORM/libf2c/Makefile \
52 F2CEXT
53 getvars $_PLATFORM/libf2c/libF77/Makefile \
54 ALL_CFLAGS OBJS
55 getvars $_PLATFORM/libf2c/libI77/Makefile \
56 ALL_CFLAGS OBJS | sed 's,=,+=,'
57 getvars $_PLATFORM/libf2c/libU77/Makefile \
58 ALL_CFLAGS OBJS | sed 's,=,+=,'
59 } | write_mk $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/defs.mk
62 ##### gnu/lib/libgcc #####
64 get_libgcc_list_funcs_asm () {
66 getvars gcc/Makefile LIB1ASMFUNCS | {
67 # print newline separated list
68 sed -e '
69 s,^.*=,,
70 s, *$,,
71 s, *, ,g
72 s, ,\
73 ,g'
75 getvars gcc/Makefile LIB2FUNCS_EXTRA | {
76 # print newline separated list
77 sed -e '
78 s,^.*=,,
79 s, *$,,
80 s, *, ,g
81 s, ,\
82 ,g' | \
83 sed -ne '
84 /\.S$/ { s,^.*/,,; s,\.S$,,; p; }
85 /\.asm$/ { s,^.*/,,; s,\.asm$,,; p; }
88 } | {
89 # print foo and foo_s
90 sed -ne '
91 /./ {
93 s,$,_s,
97 } | sort
100 get_libgcc_list_funcs_lib () {
101 local _lib=$1
102 local _lib_prefix=${_lib%.*}
103 local _lib_suffix=${_lib#*.}
104 local _abi=${2:-'\.'}
106 cat build/gcc/libgcc.mk | \
107 grep '/'${_abi}'/' | \
108 sed -ne '
109 /^'${_abi}'\/'${_lib_prefix}'\.'${_lib_suffix}': .*\.o$/ {
110 s,^.*/,,
111 s,\.o$,,
114 ' | sort
117 get_libgcc_list_objs_libs () {
118 local _abi=${1:-'\.'}
120 cat build/gcc/libgcc.mk | \
121 grep '/'${_abi}'/' | \
122 egrep '^'${_abi}'\/(libgcc_s\.so|libgcc\.a|libgcc_eh\.a|libgcov\.a): (libgcc_s|libgcc|libgcc_eh|libgcov)\/.*\.o$' | \
123 sed -e '
124 s,^'${_abi}'\/,,
125 s,: .*/, ,
126 s,^\(.*\) \(.*\)$,\2 \1,
127 ' | sort
130 get_libgcc_list_objs_srcs () {
131 local _abi=${1:-'\.'} # XXX not used
133 if [ -e $_TOP/${libgcc_db_funcs}.S ]; then
134 cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
135 comm -23 /dev/stdin $_TOP/${libgcc_db_funcs}.S | \
136 sed -e 's,\(.*\),\1.o \1.c,'
138 cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
139 comm -12 /dev/stdin $_TOP/${libgcc_db_funcs}.S | \
140 sed -e 's,\(.*\),\1.o \1.S,'
141 else
142 cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
143 sed -e 's,\(.*\),\1.o \1.c,'
144 fi | sort
147 get_libgcc_list_objs_tmplsrcs () {
148 local _abi=${1:-'\.'}
150 grep 'GCC_FOR_TARGET.*\.o$' build/gcc/libgcc.mk | \
151 grep '/'${_abi}'/' | \
152 sed -ne '
153 s,^.* -c \([^ ]*\).* -o .*/\([^ ]*\.o\)$,\2 \1,
154 # basename
155 /\$/ { s,\$.*/,,; }
156 /\// { s,\/.*/,,; }
158 ' | sort -u
161 get_libgcc_list_objs_xflags () {
162 local _flags=$1
163 local _abi=${2:-'\.'}
165 grep 'GCC_FOR_TARGET.*\.o$' build/gcc/libgcc.mk | \
166 grep '/'${_abi}'/' | \
167 sed -n '
169 :loop
171 s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\5 \2/p
173 s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\1 \3 \4\/\5/
175 t loop
176 ' | sort
179 get_libgcc_list_objs_cppflags () {
180 get_libgcc_list_objs_xflags D $1
183 get_libgcc_list_objs_copts () {
184 get_libgcc_list_objs_xflags fmx $1
187 get_libgcc_list_tmplsrcs () {
188 local _lib=$1
189 local _abi=$2 # XXX not used
190 local _tmplallsrcs=$( mktemp /tmp/mknative-gcc._tmplallsrcs.XXXXXX )
192 touch $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
193 touch $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
194 touch $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
196 # all files
197 local _lib_prefix=${_lib%.*}
198 local _lib_suffix=${_lib#*.}
199 join $_TOP/$libgcc_db_objs_libs $_TOP/$libgcc_db_objs_tmplsrcs | \
200 grep ${_lib_prefix}'\.'${_lib_suffix} | cut -d' ' -f 3 | sort -u > \
201 $_tmplallsrcs
203 # TMPLFPSRCS = [fdp]p-bit.c
204 grep '[fdt]p-bit\.c' <$_tmplallsrcs | sort -u | \
205 writefile ${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
207 # TMPLASMSRCS = $(LIB1ASMSRC)
208 grep '\$(LIB1ASMSRC)' <$_tmplallsrcs | sort -u | \
209 writefile ${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
211 # TMPLSRCS is anything else; exclude TMPLFPSRCS and TMPLASMSRCS
212 cat $_tmplallsrcs | \
213 comm -23 /dev/stdin $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*} | \
214 comm -23 /dev/stdin $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*} | \
215 writefile ${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
217 rm -f $_tmplallsrcs
220 get_libgcc_new_analyze () {
221 local _abi=$1
223 mkdir -p $_TOP/${_machine_arch_subdir}
225 touch $_TOP/${libgcc_db_funcs}.S
226 get_libgcc_list_funcs_asm | \
227 writefile ${libgcc_db_funcs}.S
229 for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
230 touch $_TOP/${libgcc_db_funcs}.${_lib%.*}
231 get_libgcc_list_funcs_lib $_lib $_abi | \
232 writefile ${libgcc_db_funcs}.${_lib%.*}
233 done
235 get_libgcc_list_objs_libs $_abi | writefile ${libgcc_db_objs_libs}
236 get_libgcc_list_objs_srcs $_abi | writefile ${libgcc_db_objs_srcs}
237 get_libgcc_list_objs_tmplsrcs $_abi | writefile ${libgcc_db_objs_tmplsrcs}
238 get_libgcc_list_objs_cppflags $_abi | writefile ${libgcc_db_objs_cppflags}
239 get_libgcc_list_objs_copts $_abi | writefile ${libgcc_db_objs_copts}
241 for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
242 get_libgcc_list_tmplsrcs $_lib $_abi
243 done
246 #####
248 get_libgcc_gen_tmplsrcs_tmplsrcs () {
249 local _lib=$1
251 printf '\n'
252 printf 'TMPLSRCS.%s = \\\n' $_lib
253 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
256 get_libgcc_gen_tmplsrcs_tmplfpsrcs () {
257 local _lib=$1
259 printf '\n'
260 printf 'TMPLFPSRCS.%s = \\\n' $_lib
261 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
264 get_libgcc_gen_tmplsrcs_tmplasmsrcs () {
265 local _lib=$1
267 printf '\n'
268 printf 'TMPLASMSRCS.%s = \\\n' $_lib
269 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*} | \
270 sed -e 's,LIB1ASMSRC,G_&,'
273 get_libgcc_gen_srcs () {
274 local _lib=$1
276 printf '\n'
277 printf 'SRCS.%s = \\\n' $_lib
278 if [ -e $_TOP/${libgcc_db_funcs}.S ]; then
279 comm -23 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
280 sed -e 's,$,.c,; s,^,tmp_,'
281 comm -12 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
282 sed -e 's,$,.S,; s,^,tmp_,'
283 else
284 cat $_TOP/${libgcc_db_funcs}.${_lib%.*} | \
285 sed -e 's,$,.c,; s,^,tmp_,'
286 fi | sort | \
287 sed -e 's,^, ,; s,$, \\,'
290 _lookup_objs () {
291 local _obj=$1; local _key=$2
293 eval grep \^$_obj\\\ \$_TOP/\${libgcc_db_objs_${_key}} | cut -f2
296 get_libgcc_gen_srcs_tmplsrcs () {
297 cut -f1 $_TOP/${libgcc_db_objs_libs} | \
298 while read _obj; do
299 printf 'SRCS.tmp_%s=%s\n' \
300 "$( _lookup_objs $_obj srcs )" \
301 "$( _lookup_objs $_obj tmplsrcs )"
302 done | \
303 sed -e 's,\$(\(.*\)),${G_\1},'
306 get_libgcc_gen_srcs_cppflags () {
307 cut -f1 $_TOP/${libgcc_db_objs_libs} | \
308 while read _obj; do
309 printf '_CPPFLAGS.tmp_%s=%s\n' \
310 "$( _lookup_objs $_obj srcs )" \
311 "$( _lookup_objs $_obj cppflags | xargs )"
312 done
315 get_libgcc_gen_srcs_copts () {
316 cut -f1 $_TOP/${libgcc_db_objs_libs} | \
317 while read _obj; do
318 printf 'COPTS.tmp_%s=%s\n' \
319 "$( _lookup_objs $_obj srcs )" \
320 "$( _lookup_objs $_obj copts | xargs )"
321 done
324 get_libgcc_new_generate () {
325 local _abi=$1
327 for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
328 for _tmpl in tmplsrcs tmplfpsrcs tmplasmsrcs; do
329 eval get_libgcc_gen_tmplsrcs_${_tmpl} $_lib | \
330 write_mk ${libgcc_libs_mk}.${_lib%.*}.tmplsrcs.${_tmpl}.mk
331 done
333 get_libgcc_gen_srcs $_lib | \
334 write_mk ${libgcc_libs_mk}.${_lib%.*}.srcs.mk
335 done
337 for _arg in tmplsrcs cppflags copts; do
338 eval get_libgcc_gen_srcs_${_arg} | \
339 eval writefile \$libgcc_srcs_mk_${_arg}
340 done
343 #####
345 get_libgcc_new () {
346 _subdir="$1"
347 _abi="$2"
349 # List of generated files.
351 _machine_arch_subdir=$_OUTDIRBASE/lib/lib$_subdir/arch${_archsubdir}/$MACHINE_ARCH/$_abi
353 libgcc_db_funcs=${_machine_arch_subdir}/funcs
354 libgcc_db_tmplsrcs=${_machine_arch_subdir}/tmplsrcs
355 libgcc_db_objs_libs=${_machine_arch_subdir}/objs.libs
356 libgcc_db_objs_srcs=${_machine_arch_subdir}/objs.srcs
357 libgcc_db_objs_tmplsrcs=${_machine_arch_subdir}/objs.tmplsrcs
358 libgcc_db_objs_cppflags=${_machine_arch_subdir}/objs.cppflags
359 libgcc_db_objs_copts=${_machine_arch_subdir}/objs.copts
361 get_libgcc_new_analyze $_abi
363 libgcc_libs_mk=${_machine_arch_subdir}/libs
364 libgcc_srcs_mk=${_machine_arch_subdir}/srcs.mk
365 libgcc_srcs_mk_tmplsrcs=${_machine_arch_subdir}/srcs.tmplsrcs.mk
366 libgcc_srcs_mk_cppflags=${_machine_arch_subdir}/srcs.cppflags.mk
367 libgcc_srcs_mk_copts=${_machine_arch_subdir}/srcs.copts.mk
369 get_libgcc_new_generate $_abi
372 get_libgcc () {
373 _subdir="$1"
374 mkdir -p $_OUTDIR/lib/lib$_subdir/arch
376 case "$_subdir" in
377 gcc4|gcc)
378 _extravars="COLLECT2 UNWIND_H xm_include_list"
379 _archsubdir=""
381 esac
383 # DPBIT, FPBIT only used on mn10[23]00, we don't need them.
384 # XXX we should probably grab everything Just In Case for
385 # the future.
387 getvars gcc/Makefile \
388 INCLUDES LIB2ADD LIB2ADDEH LIB2ADD_ST \
389 LIB1ASMFUNCS LIB1ASMSRC \
390 LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
391 LIB2FUNCS_EXTRA \
392 LIBGCC2_CFLAGS \
393 SHLIB_MKMAP SHLIB_MKMAP_OPTS \
394 SHLIB_MAPFILES SHLIB_NM_FLAGS \
395 EXTRA_HEADERS xm_defines \
396 tm_defines ${_extravars}
397 } | sed "s,-I$_DESTDIR/usr/include,,g" \
398 | write_mk $_OUTDIRBASE/lib/lib$_subdir/arch${_archsubdir}/$MACHINE_ARCH.mk
400 # Generate new style files.
401 if [ -n "${MKNATIVE_LIBGCC_NEW}" ]; then
402 get_libgcc_new $_subdir $_ABI
406 ##### gnu/lib/libgcov #####
408 get_libgcov () {
409 _subdir="$1"
411 mkdir -p $_OUTDIR/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH
414 getvars gcc/Makefile \
415 LIBGCOV
416 } | write_mk $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/defs.mk
418 write_c $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/gcov-iov.h \
419 <$_TMPDIR/gcc/gcov-iov.h
423 ##### gnu/usr.bin/gcc[34]/libiberty #####
425 get_gcc_libiberty () {
426 _subdir="$1"
427 case "$_subdir" in
428 gcc4)
429 _libibertydir="usr.bin/$_subdir/libiberty"
431 gcc)
432 _libibertydir="lib/libiberty"
434 esac
435 mkdir -p $_OUTDIR/$_libibertydir/arch/$MACHINE_ARCH
437 getvars libiberty/Makefile \
438 ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
439 | write_mk $_OUTDIRBASE/$_libibertydir/defs.mk
441 write_c $_OUTDIRBASE/$_libibertydir/arch/$MACHINE_ARCH/config.h \
442 <$_TMPDIR/libiberty/config.h
445 ##### lib/libdecnumber #####
447 get_libdecnumber () {
448 _subdir="$1"
450 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
451 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/config.h \
452 <$_TMPDIR/libdecnumber/config.h
455 ##### lib/libgomp #####
457 get_libgomp () {
458 _subdir="$1"
460 mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
461 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/config.h \
462 <$_TMPDIR/$_PLATFORM/libgomp/config.h
463 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/libgomp_f.h \
464 <$_TMPDIR/$_PLATFORM/libgomp/libgomp_f.h
465 write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/libgomp.spec \
466 <$_TMPDIR/$_PLATFORM/libgomp/libgomp.spec
467 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/omp.h \
468 <$_TMPDIR/$_PLATFORM/libgomp/omp.h
471 ##### gnu/lib/libobjc #####
473 get_libobjc () {
474 _subdir="$1/arch/$MACHINE_ARCH"
475 _options="ALL_OPT_FILES"
476 _unwind="UNWIND_H"
478 mkdir -p $_OUTDIR/lib/$_subdir
481 if [ -n "$_options" ]; then
482 getvars gcc/Makefile $_options
484 getvars $_PLATFORM/libobjc/Makefile \
485 ALL_CFLAGS INCLUDES OBJS OBJC_H \
486 | sed "s,$_GNU_DIST,\${GNUHOSTDIST},g"
487 if [ -n "$_unwind" ]; then
488 getvars gcc/Makefile $_unwind
490 } | write_mk $_OUTDIRBASE/lib/$_subdir/defs.mk
492 write_c $_OUTDIRBASE/lib/$_subdir/config.h \
493 <$_TMPDIR/$_PLATFORM/libobjc/config.h
496 ##### gnu/lib/libstdc++-v3 #####
498 get_libstdcxx_v3 () {
499 _subdir="$1"
500 mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
502 case ${_subdir} in
504 _src_CC_files="atomicity_file CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_CC CLOCALE_CC BASIC_FILE_CC"
505 _headers1="host_headers debug_headers tr1_headers c_compatibility_headers_extra tr1_impl_headers parallel_headers decimal_headers"
506 _headers2="thread_host_headers host_headers_extra"
507 _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"
508 _unwind="UNWIND_H"
510 esac
512 # build files
513 for h in $_build_headers; do
514 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/$h \
515 <$_TMPDIR/$_PLATFORM/libstdc++-v3/include/$_PLATFORM/bits/$h
516 done
518 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/config.h \
519 <$_TMPDIR/$_PLATFORM/libstdc++-v3/config.h
520 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/gstdint.h \
521 <$_TMPDIR/$_PLATFORM/libstdc++-v3/include/gstdint.h
524 # libsupc++
525 getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
526 sources | sed 's/^G_sources=/G_LIBSUPCXX_SOURCES=/'
527 getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
528 c_sources | sed 's/^G_c_sources=/G_LIBSUPCXX_C_SOURCES=/'
530 # src
531 getvars $_PLATFORM/libstdc++-v3/src/Makefile \
532 sources $_src_CC_files SECTION_FLAGS | sed 's/^G_sources=/G_SRC_SOURCES=/'
534 # include
535 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
536 c_base_headers std_headers | sed -e 's#/[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
537 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
538 bits_headers backward_headers ext_headers c_base_headers_extra \
539 $_headers1 | sed -e 's#/[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
540 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
541 $_headers2 | sed -e 's#\./[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
543 if [ -n "$_unwind" ]; then
544 getvars gcc/Makefile $_unwind
546 } | write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/defs.mk
549 ##### gnu/usr.bin/gcc3 #####
551 get_gcc_bootstrap () {
552 _subdir="$1"
553 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
554 for f in auto-host tm config gthr-default; do
555 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
556 done
559 get_gcc () {
560 _subdir="$1"
561 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
562 mkdir -p $_OUTDIR/usr.bin/libcpp/arch/$MACHINE_ARCH
563 case ${_subdir} in
564 gcc4)
565 _buildname="BUILD_"
566 _libcppsubdir=""
567 _extravars="TM_H ALL_OPT_FILES"
568 _hconfig_h=""
569 _extravars2="tm_file_list build_xm_include_list"
570 _extravars3="tm_p_include_list"
573 gcc)
574 _buildname="BUILD_"
575 _libcppsubdir=""
576 _extravars="TM_H ALL_OPT_FILES"
577 _hconfig_h=""
578 _extravars2="tm_file_list build_xm_include_list"
579 _extravars3="tm_p_include_list"
581 esac
584 getvars gcc/Makefile \
585 ${_buildname}EARLY_SUPPORT ${_buildname}ERRORS ${_buildname}PRINT \
586 ${_buildname}RTL ${_buildname}SUPPORT ${_buildname}VARRAY | \
587 sed -e 's#build/errors.o#build-errors.o#g' \
588 -e 's#build/print-rtl.o#build-print-rtl.o#g' \
589 -e 's#build/rtl.o#build-rtl.o#g' \
590 -e 's#build/varray.o#build-varray.o#g' \
591 -e 's#build/ggc-none.o#build-ggc-none.o#g' \
592 -e 's#build/##g'
593 getvars gcc/Makefile \
594 ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
595 GCOV_OBJS PROTO_OBJS ${_extravars1} \
596 INCLUDES md_file OBJC_OBJS OBJS out_file version \
597 BUILD_PREFIX RTL_H TREE_H ${_hconfig_h} BASIC_BLOCK_H GCC_H \
598 GTFILES_SRCDIR GTFILES_FILES_FILES GTFILES_FILES_LANGS \
599 GTFILES GTFILES_LANG_DIR_NAMES \
600 tm_defines host_xm_file host_xm_defines tm_p_file \
601 target_cpu_default ${_extravars} ${_extravars2} \
602 lang_specs_files ${_extravars3} \
603 | sed "s,-I$_DESTDIR/usr/include,,g"
604 getvars gcc/Makefile \
605 LIB2ADDEHDEP | sed 's/unwind.inc//'
606 getvars gcc/Makefile \
607 CXX_OBJS CXX_C_OBJS | sed 's/cp\///g'
608 getvars gcc/Makefile \
609 F77_OBJS | sed 's/f\///g'
610 case ${_subdir} in
611 gcc4 | gcc)
612 getvars libcpp/Makefile \
613 libcpp_a_OBJS
615 gcc3)
616 getvars gcc/Makefile \
617 LIBCPP_OBJS LIBCPP_H
619 esac
620 getvars gcc/Makefile \
621 ENABLE_SHARED
622 case ${_subdir} in
623 gcc4 | gcc)
624 echo G_SHLIB_LINK="$CC -shared"
625 echo G_SHLIB_MULTILIB=.
627 esac
628 } | write_mk $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/defs.mk
630 case "$_subdir" in
631 gcc4)
632 write_c $_OUTDIRBASE/usr.bin/$_subdir/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
633 hfiles='auto-host gencheck configargs gthr-default tm bconfig config multilib'
635 gcc)
636 write_c $_OUTDIRBASE/usr.bin/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
637 hfiles='auto-host configargs gthr-default tm bconfig config multilib bversion plugin-version'
639 esac
640 for f in $hfiles; do
641 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
642 if [ "${MACHINE_ARCH}" = "powerpc" -a "${f}" = "configargs" ]
643 then
644 ex <<__EOF__ $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
645 /configuration_arguments/ s/$//
648 #ifdef _SOFT_FLOAT
651 s/";$/ -with-float=soft";/
653 #else
654 #endif
656 . m +1
657 /configure_default_options/ s/{ NULL.*$//
659 #ifdef _SOFT_FLOAT
660 { "float", "soft" },
661 #endif
662 { NULL, NULL }
666 __EOF__
668 done
670 # keep identical
671 for f in all-tree.def; do
672 cp $_TMPDIR/gcc/$f $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
673 done
675 # special transforms
676 for f in gtyp-input.list; do
677 sed -e 's/^.*external\/gpl3\/gcc\/dist/SRCDIR/' < $_TMPDIR/gcc/$f > $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
678 done
680 # special platforms
681 if [ "${MACHINE_ARCH}" = "sh3el" -o "${MACHINE_ARCH}" = "sh3eb" ]; then
682 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/sysroot-suffix.h <$_TMPDIR/gcc/sysroot-suffix.h
686 ##### main #####
688 case "$1" in
689 # .mk and .h files for libgcc bootstrap (from host build)
690 libgcc)
691 get_libgcc gcc3
692 get_crtstuff crtstuff3
693 exit 0
696 libgcc4)
697 get_libgcc gcc4
698 get_crtstuff crtstuff4
699 exit 0
702 libgcc45)
703 _OUTDIR="$_TOP/external/gpl3/gcc"
704 _OUTDIRBASE="external/gpl3/gcc"
705 get_libgcc gcc
706 get_crtstuff crtstuff
707 get_libgcov gcc
708 get_gcc_bootstrap gcc
709 exit 0
712 # gcc files
713 gcc4)
714 get_gcc gcc4
715 get_libgcc gcc4
716 get_libgcov gcc4
717 get_crtstuff crtstuff4
718 get_gcc_libiberty gcc4
719 get_libobjc libobjc4
720 get_libstdcxx_v3 libstdc++-v3_4
721 exit 0
724 gcc45)
725 _OUTDIR="$_TOP/external/gpl3/gcc"
726 _OUTDIRBASE="external/gpl3/gcc"
727 get_gcc gcc
728 get_libgcc gcc
729 get_libgcov gcc
730 get_crtstuff crtstuff
731 get_gcc_libiberty gcc
732 get_libobjc libobjc
733 get_libstdcxx_v3 libstdc++-v3
734 get_libdecnumber libdecnumber
735 get_libgomp libgomp
736 exit 0
740 *) echo invalid arguments; exit 1;;
741 esac