release.sh changes & fixes
[minix3.git] / tools / gcc / mknative-gcc
bloba392c641e13a2466770d3c31f08c28b351469c90
1 #!/bin/sh
2 # $NetBSD: mknative-gcc,v 1.74 2013/11/28 12:08:57 mrg 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 _SRC=$4
13 _PLATFORM=$5
14 _DESTDIR=$6
15 _ABI=$7
16 _VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
17 _GNU_DIST=`cd ${_VPATH}; pwd`
19 if [ -z "$_DESTDIR" ]; then
20 echo "\$_DESTDIR is empty" 2>&1
21 exit 1
24 . $_TOP/tools/gcc/mknative.common
26 # default to GCC 4.1 for now
27 _OUTDIR="$_TOP/gnu"
28 _OUTDIRBASE="gnu"
30 sanitise_includes () {
31 sed \
32 -e "s,-I$_DESTDIR/usr/include,,g" \
33 -e "s,-I$_SRC/external/lgpl3/mpfr/dist,,g" \
34 -e "s,-I$_SRC/external/lgpl3/mpc/dist/src,,g" \
35 -e "s,-I$_SRC/external/lgpl3/gmp/lib/libgmp/arch/$MACHINE_ARCH,,g" \
36 -e "s,-I/usr/include/[^ ]*,,"
39 ##### gnu/lib/crtstuff #####
41 get_crtstuff () {
42 _subdir="$1"
43 mkdir -p $_OUTDIR/lib/$_subdir/arch
45 getvars gcc/Makefile \
46 INCLUDES CRTSTUFF_CFLAGS CRTSTUFF_T_CFLAGS CRTSTUFF_T_CFLAGS_S \
47 tm_defines xm_file xm_defines \
48 | sanitise_includes \
49 | write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH.mk
52 ##### gnu/lib/libg2c #####
54 get_libg2c () {
55 mkdir -p $_OUTDIR/lib/libg2c3/arch/$MACHINE_ARCH
57 write_c $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/config.h <$_TMPDIR/$_PLATFORM/libf2c/libU77/config.h
58 write_c $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/g2c.h <$_TMPDIR/$_PLATFORM/libf2c/g2c.h
61 getvars $_PLATFORM/libf2c/Makefile \
62 F2CEXT
63 getvars $_PLATFORM/libf2c/libF77/Makefile \
64 ALL_CFLAGS OBJS
65 getvars $_PLATFORM/libf2c/libI77/Makefile \
66 ALL_CFLAGS OBJS | sed 's,=,+=,'
67 getvars $_PLATFORM/libf2c/libU77/Makefile \
68 ALL_CFLAGS OBJS | sed 's,=,+=,'
69 } | write_mk $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/defs.mk
72 ##### gnu/lib/libgcc #####
74 get_libgcc_list_funcs_asm () {
76 getvars gcc/Makefile LIB1ASMFUNCS | {
77 # print newline separated list
78 sed -e '
79 s,^.*=,,
80 s, *$,,
81 s, *, ,g
82 s, ,\
83 ,g'
85 getvars gcc/Makefile LIB2FUNCS_EXTRA | {
86 # print newline separated list
87 sed -e '
88 s,^.*=,,
89 s, *$,,
90 s, *, ,g
91 s, ,\
92 ,g' | \
93 sed -ne '
94 /\.S$/ { s,^.*/,,; s,\.S$,,; p; }
95 /\.asm$/ { s,^.*/,,; s,\.asm$,,; p; }
98 } | {
99 # print foo and foo_s
100 sed -ne '
101 /./ {
103 s,$,_s,
107 } | sort
110 get_libgcc_list_funcs_lib () {
111 local _lib=$1
112 local _lib_prefix=${_lib%.*}
113 local _lib_suffix=${_lib#*.}
114 local _abi=${2:-'\.'}
116 cat build/gcc/libgcc.mk | \
117 grep '/'${_abi}'/' | \
118 sed -ne '
119 /^'${_abi}'\/'${_lib_prefix}'\.'${_lib_suffix}': .*\.o$/ {
120 s,^.*/,,
121 s,\.o$,,
124 ' | sort
127 get_libgcc_list_objs_libs () {
128 local _abi=${1:-'\.'}
130 cat build/gcc/libgcc.mk | \
131 grep '/'${_abi}'/' | \
132 egrep '^'${_abi}'\/(libgcc_s\.so|libgcc\.a|libgcc_eh\.a|libgcov\.a): (libgcc_s|libgcc|libgcc_eh|libgcov)\/.*\.o$' | \
133 sed -e '
134 s,^'${_abi}'\/,,
135 s,: .*/, ,
136 s,^\(.*\) \(.*\)$,\2 \1,
137 ' | sort
140 get_libgcc_list_objs_srcs () {
141 local _abi=${1:-'\.'} # XXX not used
143 if [ -e $_TOP/${libgcc_db_funcs}.S ]; then
144 cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
145 comm -23 /dev/stdin $_TOP/${libgcc_db_funcs}.S | \
146 sed -e 's,\(.*\),\1.o \1.c,'
148 cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
149 comm -12 /dev/stdin $_TOP/${libgcc_db_funcs}.S | \
150 sed -e 's,\(.*\),\1.o \1.S,'
151 else
152 cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
153 sed -e 's,\(.*\),\1.o \1.c,'
154 fi | sort
157 get_libgcc_list_objs_tmplsrcs () {
158 local _abi=${1:-'\.'}
160 grep 'GCC_FOR_TARGET.*\.o$' build/gcc/libgcc.mk | \
161 grep '/'${_abi}'/' | \
162 sed -ne '
163 s,^.* -c \([^ ]*\).* -o .*/\([^ ]*\.o\)$,\2 \1,
164 # basename
165 /\$/ { s,\$.*/,,; }
166 /\// { s,\/.*/,,; }
168 ' | sort -u
171 get_libgcc_list_objs_xflags () {
172 local _flags=$1
173 local _abi=${2:-'\.'}
175 grep 'GCC_FOR_TARGET.*\.o$' build/gcc/libgcc.mk | \
176 grep '/'${_abi}'/' | \
177 sed -n '
179 :loop
181 s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\5 \2/p
183 s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\1 \3 \4\/\5/
185 t loop
186 ' | sort
189 get_libgcc_list_objs_cppflags () {
190 get_libgcc_list_objs_xflags D $1
193 get_libgcc_list_objs_copts () {
194 get_libgcc_list_objs_xflags fmx $1
197 get_libgcc_list_tmplsrcs () {
198 local _lib=$1
199 local _abi=$2 # XXX not used
200 local _tmplallsrcs=$( mktemp /tmp/mknative-gcc._tmplallsrcs.XXXXXX )
202 touch $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
203 touch $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
204 touch $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
206 # all files
207 local _lib_prefix=${_lib%.*}
208 local _lib_suffix=${_lib#*.}
209 join $_TOP/$libgcc_db_objs_libs $_TOP/$libgcc_db_objs_tmplsrcs | \
210 grep ${_lib_prefix}'\.'${_lib_suffix} | cut -d' ' -f 3 | sort -u > \
211 $_tmplallsrcs
213 # TMPLFPSRCS = [fdp]p-bit.c
214 grep '[fdt]p-bit\.c' <$_tmplallsrcs | sort -u | \
215 writefile ${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
217 # TMPLASMSRCS = $(LIB1ASMSRC)
218 grep '\$(LIB1ASMSRC)' <$_tmplallsrcs | sort -u | \
219 writefile ${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
221 # TMPLSRCS is anything else; exclude TMPLFPSRCS and TMPLASMSRCS
222 cat $_tmplallsrcs | \
223 comm -23 /dev/stdin $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*} | \
224 comm -23 /dev/stdin $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*} | \
225 writefile ${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
227 rm -f $_tmplallsrcs
230 get_libgcc_new_analyze () {
231 local _abi=$1
233 mkdir -p $_TOP/${_machine_arch_subdir}
235 touch $_TOP/${libgcc_db_funcs}.S
236 get_libgcc_list_funcs_asm | \
237 writefile ${libgcc_db_funcs}.S
239 for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
240 touch $_TOP/${libgcc_db_funcs}.${_lib%.*}
241 get_libgcc_list_funcs_lib $_lib $_abi | \
242 writefile ${libgcc_db_funcs}.${_lib%.*}
243 done
245 get_libgcc_list_objs_libs $_abi | writefile ${libgcc_db_objs_libs}
246 get_libgcc_list_objs_srcs $_abi | writefile ${libgcc_db_objs_srcs}
247 get_libgcc_list_objs_tmplsrcs $_abi | writefile ${libgcc_db_objs_tmplsrcs}
248 get_libgcc_list_objs_cppflags $_abi | writefile ${libgcc_db_objs_cppflags}
249 get_libgcc_list_objs_copts $_abi | writefile ${libgcc_db_objs_copts}
251 for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
252 get_libgcc_list_tmplsrcs $_lib $_abi
253 done
256 #####
258 get_libgcc_gen_tmplsrcs_tmplsrcs () {
259 local _lib=$1
261 printf '\n'
262 printf 'TMPLSRCS.%s = \\\n' $_lib
263 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
266 get_libgcc_gen_tmplsrcs_tmplfpsrcs () {
267 local _lib=$1
269 printf '\n'
270 printf 'TMPLFPSRCS.%s = \\\n' $_lib
271 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
274 get_libgcc_gen_tmplsrcs_tmplasmsrcs () {
275 local _lib=$1
277 printf '\n'
278 printf 'TMPLASMSRCS.%s = \\\n' $_lib
279 sed -e 's,^, ,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*} | \
280 sed -e 's,LIB1ASMSRC,G_&,'
283 get_libgcc_gen_srcs () {
284 local _lib=$1
286 printf '\n'
287 printf 'SRCS.%s = \\\n' $_lib
288 if [ -e $_TOP/${libgcc_db_funcs}.S ]; then
289 comm -23 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
290 sed -e 's,$,.c,; s,^,tmp_,'
291 comm -12 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
292 sed -e 's,$,.S,; s,^,tmp_,'
293 else
294 cat $_TOP/${libgcc_db_funcs}.${_lib%.*} | \
295 sed -e 's,$,.c,; s,^,tmp_,'
296 fi | sort | \
297 sed -e 's,^, ,; s,$, \\,'
300 _lookup_objs () {
301 local _obj=$1; local _key=$2
303 eval grep \^$_obj\\\ \$_TOP/\${libgcc_db_objs_${_key}} | cut -f2
306 get_libgcc_gen_srcs_tmplsrcs () {
307 cut -f1 $_TOP/${libgcc_db_objs_libs} | \
308 while read _obj; do
309 printf 'SRCS.tmp_%s=%s\n' \
310 "$( _lookup_objs $_obj srcs )" \
311 "$( _lookup_objs $_obj tmplsrcs )"
312 done | \
313 sed -e 's,\$(\(.*\)),${G_\1},'
316 get_libgcc_gen_srcs_cppflags () {
317 cut -f1 $_TOP/${libgcc_db_objs_libs} | \
318 while read _obj; do
319 printf '_CPPFLAGS.tmp_%s=%s\n' \
320 "$( _lookup_objs $_obj srcs )" \
321 "$( _lookup_objs $_obj cppflags | xargs )"
322 done
325 get_libgcc_gen_srcs_copts () {
326 cut -f1 $_TOP/${libgcc_db_objs_libs} | \
327 while read _obj; do
328 printf 'COPTS.tmp_%s=%s\n' \
329 "$( _lookup_objs $_obj srcs )" \
330 "$( _lookup_objs $_obj copts | xargs )"
331 done
334 get_libgcc_new_generate () {
335 local _abi=$1
337 for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
338 for _tmpl in tmplsrcs tmplfpsrcs tmplasmsrcs; do
339 eval get_libgcc_gen_tmplsrcs_${_tmpl} $_lib | \
340 write_mk ${libgcc_libs_mk}.${_lib%.*}.tmplsrcs.${_tmpl}.mk
341 done
343 get_libgcc_gen_srcs $_lib | \
344 write_mk ${libgcc_libs_mk}.${_lib%.*}.srcs.mk
345 done
347 for _arg in tmplsrcs cppflags copts; do
348 eval get_libgcc_gen_srcs_${_arg} | \
349 eval writefile \$libgcc_srcs_mk_${_arg}
350 done
353 #####
355 get_libgcc_new () {
356 _subdir="$1"
357 _abi="$2"
359 # List of generated files.
361 _machine_arch_subdir=$_OUTDIRBASE/lib/lib$_subdir/arch${_archsubdir}/$MACHINE_ARCH/$_abi
363 libgcc_db_funcs=${_machine_arch_subdir}/funcs
364 libgcc_db_tmplsrcs=${_machine_arch_subdir}/tmplsrcs
365 libgcc_db_objs_libs=${_machine_arch_subdir}/objs.libs
366 libgcc_db_objs_srcs=${_machine_arch_subdir}/objs.srcs
367 libgcc_db_objs_tmplsrcs=${_machine_arch_subdir}/objs.tmplsrcs
368 libgcc_db_objs_cppflags=${_machine_arch_subdir}/objs.cppflags
369 libgcc_db_objs_copts=${_machine_arch_subdir}/objs.copts
371 get_libgcc_new_analyze $_abi
373 libgcc_libs_mk=${_machine_arch_subdir}/libs
374 libgcc_srcs_mk=${_machine_arch_subdir}/srcs.mk
375 libgcc_srcs_mk_tmplsrcs=${_machine_arch_subdir}/srcs.tmplsrcs.mk
376 libgcc_srcs_mk_cppflags=${_machine_arch_subdir}/srcs.cppflags.mk
377 libgcc_srcs_mk_copts=${_machine_arch_subdir}/srcs.copts.mk
379 get_libgcc_new_generate $_abi
382 get_libgcc () {
383 _subdir="$1"
384 mkdir -p $_OUTDIR/lib/lib$_subdir/arch
386 case "$_subdir" in
387 gcc4|gcc)
388 _extravars="COLLECT2 UNWIND_H xm_include_list"
389 _archsubdir=""
391 esac
393 # DPBIT, FPBIT only used on mn10[23]00, we don't need them.
394 # XXX we should probably grab everything Just In Case for
395 # the future.
397 getvars gcc/Makefile \
398 INCLUDES LIB2ADD LIB2ADDEH LIB2ADD_ST \
399 LIB1ASMFUNCS LIB1ASMSRC \
400 LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
401 LIB2FUNCS_EXTRA \
402 LIBGCC2_CFLAGS \
403 SHLIB_MKMAP SHLIB_MKMAP_OPTS \
404 SHLIB_MAPFILES SHLIB_NM_FLAGS \
405 EXTRA_HEADERS xm_defines \
406 tm_defines ${_extravars}
407 } | sanitise_includes \
408 | write_mk $_OUTDIRBASE/lib/lib$_subdir/arch${_archsubdir}/$MACHINE_ARCH.mk
410 # Generate new style files.
411 if [ -n "${MKNATIVE_LIBGCC_NEW}" ]; then
412 get_libgcc_new $_subdir $_ABI
416 ##### gnu/lib/libgcov #####
418 get_libgcov () {
419 _subdir="$1"
421 mkdir -p $_OUTDIR/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH
424 getvars gcc/Makefile \
425 LIBGCOV
426 } | write_mk $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/defs.mk
428 write_c $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/gcov-iov.h \
429 <$_TMPDIR/gcc/gcov-iov.h
433 ##### gnu/usr.bin/gcc[34]/libiberty #####
435 get_gcc_libiberty () {
436 _subdir="$1"
437 case "$_subdir" in
438 gcc4)
439 _libibertydir="usr.bin/$_subdir/libiberty"
441 gcc)
442 _libibertydir="lib/libiberty"
444 esac
445 mkdir -p $_OUTDIR/$_libibertydir/arch/$MACHINE_ARCH
447 getvars libiberty/Makefile \
448 ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
449 | write_mk $_OUTDIRBASE/$_libibertydir/defs.mk
451 write_c $_OUTDIRBASE/$_libibertydir/arch/$MACHINE_ARCH/config.h \
452 <$_TMPDIR/libiberty/config.h
455 ##### lib/libdecnumber #####
457 get_libdecnumber () {
458 _subdir="$1"
460 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
461 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/config.h \
462 <$_TMPDIR/libdecnumber/config.h
465 ##### lib/libgomp #####
467 get_libgomp () {
468 _subdir="$1"
470 mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
471 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/config.h \
472 <$_TMPDIR/$_PLATFORM/libgomp/config.h
473 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/libgomp_f.h \
474 <$_TMPDIR/$_PLATFORM/libgomp/libgomp_f.h
475 write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/libgomp.spec \
476 <$_TMPDIR/$_PLATFORM/libgomp/libgomp.spec
477 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/omp.h \
478 <$_TMPDIR/$_PLATFORM/libgomp/omp.h
481 ##### gnu/lib/libobjc #####
483 get_libobjc () {
484 _subdir="$1/arch/$MACHINE_ARCH"
485 _options="ALL_OPT_FILES"
486 _unwind="UNWIND_H"
488 mkdir -p $_OUTDIR/lib/$_subdir
491 if [ -n "$_options" ]; then
492 getvars gcc/Makefile $_options
494 getvars $_PLATFORM/libobjc/Makefile \
495 ALL_CFLAGS INCLUDES OBJS OBJC_H \
496 | sed "s,$_GNU_DIST,\${GNUHOSTDIST},g"
497 if [ -n "$_unwind" ]; then
498 getvars gcc/Makefile $_unwind
500 } | write_mk $_OUTDIRBASE/lib/$_subdir/defs.mk
502 write_c $_OUTDIRBASE/lib/$_subdir/config.h \
503 <$_TMPDIR/$_PLATFORM/libobjc/config.h
506 ##### gnu/lib/libstdc++-v3 #####
508 get_libstdcxx_v3 () {
509 _subdir="$1"
510 mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
512 case ${_subdir} in
514 _src_CC_files="atomicity_file CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_CC CLOCALE_CC BASIC_FILE_CC"
515 _headers1="host_headers debug_headers tr1_headers c_compatibility_headers_extra tr1_impl_headers parallel_headers decimal_headers"
516 _headers2="thread_host_headers host_headers_extra"
517 _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"
518 _unwind="UNWIND_H"
520 esac
522 # build files
523 for h in $_build_headers; do
524 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/$h \
525 <$_TMPDIR/$_PLATFORM/libstdc++-v3/include/$_PLATFORM/bits/$h
526 done
528 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/config.h \
529 <$_TMPDIR/$_PLATFORM/libstdc++-v3/config.h
530 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/gstdint.h \
531 <$_TMPDIR/$_PLATFORM/libstdc++-v3/include/gstdint.h
534 # libsupc++
535 getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
536 sources | sed 's/^G_sources=/G_LIBSUPCXX_SOURCES=/'
537 getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
538 c_sources | sed 's/^G_c_sources=/G_LIBSUPCXX_C_SOURCES=/'
540 # src
541 getvars $_PLATFORM/libstdc++-v3/src/Makefile \
542 sources $_src_CC_files SECTION_FLAGS | sed 's/^G_sources=/G_SRC_SOURCES=/'
544 # include
545 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
546 c_base_headers std_headers | sed -e 's#/[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
547 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
548 bits_headers backward_headers ext_headers c_base_headers_extra \
549 $_headers1 | sed -e 's#/[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
550 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
551 $_headers2 | sed -e 's#\./[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
553 if [ -n "$_unwind" ]; then
554 getvars gcc/Makefile $_unwind
556 } | write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/defs.mk
559 ##### gnu/usr.bin/gcc* #####
561 get_gcc_bootstrap () {
562 _subdir="$1"
563 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
564 for f in auto-host tm config gthr-default; do
565 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
566 done
569 get_gcc () {
570 _subdir="$1"
571 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
572 mkdir -p $_OUTDIR/usr.bin/libcpp/arch/$MACHINE_ARCH
573 case ${_subdir} in
574 gcc4)
575 _buildname="BUILD_"
576 _libcppsubdir=""
577 _extravars="TM_H ALL_OPT_FILES"
578 _hconfig_h=""
579 _extravars2="tm_file_list build_xm_include_list"
580 _extravars3="tm_p_include_list"
583 gcc)
584 _buildname="BUILD_"
585 _libcppsubdir=""
586 _extravars="TM_H ALL_OPT_FILES"
587 _hconfig_h=""
588 _extravars2="tm_file_list build_xm_include_list"
589 _extravars3="tm_p_include_list"
591 esac
594 getvars gcc/Makefile \
595 ${_buildname}EARLY_SUPPORT ${_buildname}ERRORS ${_buildname}PRINT \
596 ${_buildname}RTL ${_buildname}SUPPORT ${_buildname}VARRAY | \
597 sed -e 's#build/errors.o#build-errors.o#g' \
598 -e 's#build/print-rtl.o#build-print-rtl.o#g' \
599 -e 's#build/rtl.o#build-rtl.o#g' \
600 -e 's#build/varray.o#build-varray.o#g' \
601 -e 's#build/ggc-none.o#build-ggc-none.o#g' \
602 -e 's#build/##g'
603 getvars gcc/Makefile \
604 ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
605 GCOV_OBJS PROTO_OBJS ${_extravars1} \
606 INCLUDES md_file OBJC_OBJS OBJS out_file version \
607 BUILD_PREFIX RTL_H TREE_H ${_hconfig_h} BASIC_BLOCK_H GCC_H \
608 GTFILES_SRCDIR GTFILES_FILES_FILES GTFILES_FILES_LANGS \
609 GTFILES GTFILES_LANG_DIR_NAMES \
610 tm_defines host_xm_file host_xm_defines tm_p_file \
611 target_cpu_default ${_extravars} ${_extravars2} \
612 lang_specs_files ${_extravars3} \
613 | sanitise_includes
614 getvars gcc/Makefile \
615 LIB2ADDEHDEP | sed 's/unwind.inc//'
616 getvars gcc/Makefile \
617 CXX_OBJS CXX_C_OBJS | sed 's/cp\///g'
618 getvars gcc/Makefile \
619 F77_OBJS | sed 's/f\///g'
620 case ${_subdir} in
621 gcc4 | gcc)
622 getvars libcpp/Makefile \
623 libcpp_a_OBJS
625 esac
626 getvars gcc/Makefile \
627 ENABLE_SHARED
628 case ${_subdir} in
629 gcc4 | gcc)
630 echo G_SHLIB_LINK="$CC -shared"
631 echo G_SHLIB_MULTILIB=.
633 esac
634 } | write_mk $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/defs.mk
636 case "$_subdir" in
637 gcc4)
638 write_c $_OUTDIRBASE/usr.bin/$_subdir/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
639 hfiles='auto-host gencheck configargs gthr-default tm bconfig config multilib'
641 gcc)
642 write_c $_OUTDIRBASE/usr.bin/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
643 hfiles='auto-host configargs gthr-default tm bconfig config multilib bversion plugin-version'
645 esac
646 for f in $hfiles; do
647 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
648 if [ "${MACHINE_ARCH}" = "powerpc" -a "${f}" = "configargs" ]
649 then
650 ex <<__EOF__ $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
651 /configuration_arguments/ s/$//
654 #ifdef _SOFT_FLOAT
657 s/";$/ -with-float=soft";/
659 #else
660 #endif
662 . m +1
663 /configure_default_options/ s/{ NULL.*$//
665 #ifdef _SOFT_FLOAT
666 { "float", "soft" },
667 #endif
668 { NULL, NULL }
672 __EOF__
674 done
676 # keep identical
677 for f in all-tree.def; do
678 cp $_TMPDIR/gcc/$f $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
679 done
681 # special transforms
682 for f in gtyp-input.list; do
683 sed -e 's/^.*external\/gpl3\/gcc\/dist/SRCDIR/' < $_TMPDIR/gcc/$f > $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
684 done
686 # special platforms
687 if [ "${MACHINE_ARCH}" = "sh3el" -o "${MACHINE_ARCH}" = "sh3eb" ]; then
688 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/sysroot-suffix.h <$_TMPDIR/gcc/sysroot-suffix.h
692 ##### main #####
694 case "$1" in
695 # .mk and .h files for libgcc bootstrap (from host build)
697 libgcc4)
698 get_libgcc gcc4
699 get_crtstuff crtstuff4
700 exit 0
703 libgcc45)
704 _OUTDIR="$_TOP/external/gpl3/gcc"
705 _OUTDIRBASE="external/gpl3/gcc"
706 get_libgcc gcc
707 get_crtstuff crtstuff
708 get_libgcov gcc
709 get_gcc_bootstrap gcc
710 exit 0
713 # gcc files
714 gcc4)
715 get_gcc gcc4
716 get_libgcc gcc4
717 get_libgcov gcc4
718 get_crtstuff crtstuff4
719 get_gcc_libiberty gcc4
720 get_libobjc libobjc4
721 get_libstdcxx_v3 libstdc++-v3_4
722 exit 0
725 gcc45)
726 _OUTDIR="$_TOP/external/gpl3/gcc"
727 _OUTDIRBASE="external/gpl3/gcc"
728 get_gcc gcc
729 get_libgcc gcc
730 get_libgcov gcc
731 get_crtstuff crtstuff
732 get_gcc_libiberty gcc
733 get_libobjc libobjc
734 get_libstdcxx_v3 libstdc++-v3
735 get_libdecnumber libdecnumber
736 get_libgomp libgomp
737 exit 0
741 *) echo invalid arguments; exit 1;;
742 esac