Home | History | Annotate | Line # | Download | only in gcc
mknative-gcc revision 1.65
      1 #!/bin/sh
      2 #	$NetBSD: mknative-gcc,v 1.65 2011/10/13 19:52:33 matt Exp $
      3 #
      4 # Shell script for generating all the constants needed for a native
      5 # platform build of src/gnu/dist/gcc.
      6 #
      7 
      8 # initialise
      9 
     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`
     17 
     18 if [ -z "$_DESTDIR" ]; then
     19 	echo "\$_DESTDIR is empty" 2>&1
     20 	exit 1
     21 fi
     22 
     23 . $_TOP/tools/gcc/mknative.common
     24 
     25 # default to GCC 4.1 for now
     26 _OUTDIR="$_TOP/gnu"
     27 _OUTDIRBASE="gnu"
     28 
     29 ##### gnu/lib/crtstuff #####
     30 
     31 get_crtstuff () {
     32 	_subdir="$1"
     33 	mkdir -p $_OUTDIR/lib/$_subdir/arch
     34 
     35 	getvars gcc/Makefile \
     36 		INCLUDES CRTSTUFF_CFLAGS CRTSTUFF_T_CFLAGS \
     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
     40 }
     41 
     42 ##### gnu/lib/libg2c #####
     43 
     44 get_libg2c () {
     45 	mkdir -p $_OUTDIR/lib/libg2c3/arch/$MACHINE_ARCH
     46 
     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
     49 
     50 	{
     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
     60 }
     61 
     62 ##### gnu/lib/libgcc #####
     63 
     64 get_libgcc_list_funcs_asm () {
     65 	{
     66 		getvars gcc/Makefile LIB1ASMFUNCS | {
     67 			# print newline separated list
     68 			sed -e '
     69 				s,^.*=,,
     70 				s, *$,,
     71 				s,  *, ,g
     72 				s, ,\
     73 ,g'
     74 		}
     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; }
     86 			'
     87 		}
     88 	} | {
     89 		# print foo and foo_s
     90 		sed -ne '
     91 			/./ {
     92 				p
     93 				s,$,_s,
     94 				p
     95 			}
     96 		'
     97 	} | sort
     98 }
     99 
    100 get_libgcc_list_funcs_lib () {
    101 	local _lib=$1
    102 	local _lib_prefix=${_lib%.*}
    103 	local _lib_suffix=${_lib#*.}
    104 	local _abi=${2:-'\.'}
    105 
    106 	cat build/gcc/libgcc.mk | \
    107 	grep '/'${_abi}'/' | \
    108 	sed -ne '
    109 		/^'${_abi}'\/'${_lib_prefix}'\.'${_lib_suffix}': .*\.o$/ {
    110 			s,^.*/,,
    111 			s,\.o$,,
    112 			p
    113 		}
    114 	' | sort
    115 }
    116 
    117 get_libgcc_list_objs_libs () {
    118 	local _abi=${1:-'\.'}
    119 
    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
    128 }
    129 
    130 get_libgcc_list_objs_srcs () {
    131 	local _abi=${1:-'\.'}	# XXX not used
    132 
    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,'
    137 
    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
    145 }
    146 
    147 get_libgcc_list_objs_tmplsrcs () {
    148 	local _abi=${1:-'\.'}
    149 
    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,\/.*/,,; }
    157 		p
    158 	' | sort -u
    159 }
    160 
    161 get_libgcc_list_objs_xflags () {
    162 	local _flags=$1
    163 	local _abi=${2:-'\.'}
    164 
    165 	grep 'GCC_FOR_TARGET.*\.o$' build/gcc/libgcc.mk | \
    166 	grep '/'${_abi}'/' | \
    167 	sed -n '
    168 		x
    169 	:loop
    170 		g
    171 		s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\5	\2/p
    172 		g
    173 		s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\1 \3 \4\/\5/
    174 		h
    175 		t loop
    176 	' | sort
    177 }
    178 
    179 get_libgcc_list_objs_cppflags () {
    180 	get_libgcc_list_objs_xflags D $1
    181 }
    182 
    183 get_libgcc_list_objs_copts () {
    184 	get_libgcc_list_objs_xflags fmx $1
    185 }
    186 
    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 )
    191 
    192 	touch $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
    193 	touch $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
    194 	touch $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
    195 
    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
    202 
    203 	# TMPLFPSRCS = [fdp]p-bit.c
    204 	grep '[fdt]p-bit\.c' <$_tmplallsrcs | sort -u | \
    205 	writefile ${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
    206 
    207 	# TMPLASMSRCS = $(LIB1ASMSRC)
    208 	grep '\$(LIB1ASMSRC)' <$_tmplallsrcs | sort -u | \
    209 	writefile ${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
    210 
    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%.*}
    216 
    217 	rm -f $_tmplallsrcs
    218 }
    219 
    220 get_libgcc_new_analyze () {
    221 	local _abi=$1
    222 
    223 	mkdir -p $_TOP/${_machine_arch_subdir}
    224 
    225 	touch $_TOP/${libgcc_db_funcs}.S
    226 	get_libgcc_list_funcs_asm | \
    227 	writefile ${libgcc_db_funcs}.S
    228 
    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
    234 
    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}
    240 
    241 	for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
    242 		get_libgcc_list_tmplsrcs $_lib $_abi
    243 	done
    244 }
    245 
    246 #####
    247 
    248 get_libgcc_gen_tmplsrcs_tmplsrcs () {
    249 	local _lib=$1
    250 
    251 	printf '\n'
    252 	printf 'TMPLSRCS.%s = \\\n' $_lib
    253 	sed -e 's,^,	,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
    254 }
    255 
    256 get_libgcc_gen_tmplsrcs_tmplfpsrcs () {
    257 	local _lib=$1
    258 
    259 	printf '\n'
    260 	printf 'TMPLFPSRCS.%s = \\\n' $_lib
    261 	sed -e 's,^,	,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
    262 }
    263 
    264 get_libgcc_gen_tmplsrcs_tmplasmsrcs () {
    265 	local _lib=$1
    266 
    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_&,'
    271 }
    272 
    273 get_libgcc_gen_srcs () {
    274 	local _lib=$1
    275 
    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,$, \\,'
    288 }
    289 
    290 _lookup_objs () {
    291 	local _obj=$1; local _key=$2
    292 
    293 	eval grep \^$_obj\\\	 \$_TOP/\${libgcc_db_objs_${_key}} | cut -f2
    294 }
    295 
    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},'
    304 }
    305 
    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
    313 }
    314 
    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
    322 }
    323 
    324 get_libgcc_new_generate () {
    325 	local _abi=$1
    326 
    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
    332 
    333 		get_libgcc_gen_srcs $_lib | \
    334 		write_mk ${libgcc_libs_mk}.${_lib%.*}.srcs.mk
    335 	done
    336 
    337 	for _arg in tmplsrcs cppflags copts; do
    338 		eval get_libgcc_gen_srcs_${_arg} | \
    339 		eval writefile \$libgcc_srcs_mk_${_arg}
    340 	done
    341 }
    342 
    343 #####
    344 
    345 get_libgcc_new () {
    346 	_subdir="$1"
    347 	_abi="$2"
    348 
    349 	# List of generated files.
    350 
    351 	_machine_arch_subdir=$_OUTDIRBASE/lib/lib$_subdir/arch${_archsubdir}/$MACHINE_ARCH/$_abi
    352 
    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
    360 
    361 	get_libgcc_new_analyze $_abi
    362 
    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
    368 
    369 	get_libgcc_new_generate $_abi
    370 }
    371 
    372 get_libgcc () {
    373 	_subdir="$1"
    374 	mkdir -p $_OUTDIR/lib/lib$_subdir/arch
    375 
    376 	case "$_subdir" in
    377 	gcc4|gcc)
    378 		_extravars="COLLECT2 UNWIND_H xm_include_list"
    379 		_archsubdir=""
    380 		;;
    381 	esac
    382 
    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.
    386 	{
    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
    399 
    400 	# Generate new style files.
    401 	if [ -n "${MKNATIVE_LIBGCC_NEW}" ]; then
    402 		get_libgcc_new $_subdir $_ABI
    403 	fi
    404 }
    405 
    406 ##### gnu/lib/libgcov #####
    407 
    408 get_libgcov () {
    409 	_subdir="$1"
    410 
    411 	mkdir -p $_OUTDIR/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH
    412 
    413 	{
    414 		getvars gcc/Makefile \
    415 			LIBGCOV
    416 	} | write_mk $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/defs.mk
    417 
    418 	write_c $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/gcov-iov.h \
    419 	   <$_TMPDIR/gcc/gcov-iov.h
    420 
    421 }
    422 
    423 ##### gnu/usr.bin/gcc[34]/libiberty #####
    424 
    425 get_gcc_libiberty () {
    426 	_subdir="$1"
    427 	case "$_subdir" in
    428 	gcc4)
    429 		_libibertydir="usr.bin/$_subdir/libiberty"
    430 		;;
    431 	gcc)
    432 		_libibertydir="lib/libiberty"
    433 		;;
    434 	esac
    435 	mkdir -p $_OUTDIR/$_libibertydir/arch/$MACHINE_ARCH
    436 
    437 	getvars libiberty/Makefile \
    438 		ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
    439 		| write_mk $_OUTDIRBASE/$_libibertydir/defs.mk
    440 
    441 	write_c $_OUTDIRBASE/$_libibertydir/arch/$MACHINE_ARCH/config.h \
    442 		<$_TMPDIR/libiberty/config.h
    443 }
    444 
    445 ##### lib/libdecnumber #####
    446 
    447 get_libdecnumber () {
    448 	_subdir="$1"
    449 
    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
    453 }
    454 
    455 ##### lib/libgomp #####
    456 
    457 get_libgomp () {
    458 	_subdir="$1"
    459 
    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
    469 }
    470 
    471 ##### gnu/lib/libobjc #####
    472 
    473 get_libobjc () {
    474 	_subdir="$1/arch/$MACHINE_ARCH"
    475 	_options="ALL_OPT_FILES"
    476 	_unwind="UNWIND_H"
    477 
    478 	mkdir -p $_OUTDIR/lib/$_subdir
    479 
    480 	{
    481 		if [ -n "$_options" ]; then
    482 			getvars gcc/Makefile $_options
    483 		fi
    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
    489 		fi
    490 	} | write_mk $_OUTDIRBASE/lib/$_subdir/defs.mk
    491 
    492 	write_c $_OUTDIRBASE/lib/$_subdir/config.h \
    493 		<$_TMPDIR/$_PLATFORM/libobjc/config.h
    494 }
    495 
    496 ##### gnu/lib/libstdc++-v3 #####
    497 
    498 get_libstdcxx_v3 () {
    499 	_subdir="$1"
    500 	mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
    501 
    502 	case ${_subdir} in
    503 	*)
    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"
    509 		;;
    510 	esac
    511 
    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
    517 
    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
    522 
    523 	{
    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=/'
    529 
    530 		# src
    531 		getvars $_PLATFORM/libstdc++-v3/src/Makefile \
    532 			sources $_src_CC_files SECTION_FLAGS | sed 's/^G_sources=/G_SRC_SOURCES=/'
    533 
    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'
    542 
    543 		if [ -n "$_unwind" ]; then
    544 			getvars gcc/Makefile $_unwind
    545 		fi
    546 	} | write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/defs.mk
    547 }
    548 
    549 ##### gnu/usr.bin/gcc3 #####
    550 
    551 get_gcc () {
    552 	_subdir="$1"
    553 	mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
    554 	mkdir -p $_OUTDIR/usr.bin/libcpp/arch/$MACHINE_ARCH
    555 	case ${_subdir} in
    556 	gcc4)
    557 		_buildname="BUILD_"
    558 		_libcppsubdir=""
    559 		_extravars="TM_H ALL_OPT_FILES"
    560 		_hconfig_h=""
    561 		_extravars2="tm_file_list build_xm_include_list"
    562 		_extravars3="tm_p_include_list"
    563 		;;
    564 		
    565 	gcc)
    566 		_buildname="BUILD_"
    567 		_libcppsubdir=""
    568 		_extravars="TM_H ALL_OPT_FILES"
    569 		_hconfig_h=""
    570 		_extravars2="tm_file_list build_xm_include_list"
    571 		_extravars3="tm_p_include_list"
    572 		;;
    573 	esac
    574 
    575 	{
    576 		getvars gcc/Makefile \
    577 			${_buildname}EARLY_SUPPORT ${_buildname}ERRORS ${_buildname}PRINT \
    578 			${_buildname}RTL ${_buildname}SUPPORT ${_buildname}VARRAY | \
    579 		    sed -e 's#build/errors.o#build-errors.o#g' \
    580 			-e 's#build/print-rtl.o#build-print-rtl.o#g' \
    581 			-e 's#build/rtl.o#build-rtl.o#g' \
    582 			-e 's#build/varray.o#build-varray.o#g' \
    583 			-e 's#build/ggc-none.o#build-ggc-none.o#g' \
    584 			-e 's#build/##g'
    585 		getvars gcc/Makefile \
    586 			ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
    587 			GCOV_OBJS PROTO_OBJS ${_extravars1} \
    588 			INCLUDES md_file OBJC_OBJS OBJS out_file version \
    589 			BUILD_PREFIX RTL_H TREE_H ${_hconfig_h} BASIC_BLOCK_H GCC_H \
    590 			GTFILES_SRCDIR GTFILES_FILES_FILES GTFILES_FILES_LANGS \
    591 			GTFILES GTFILES_LANG_DIR_NAMES \
    592 			tm_defines host_xm_file host_xm_defines tm_p_file \
    593 			target_cpu_default ${_extravars} ${_extravars2} \
    594 			lang_specs_files ${_extravars3} \
    595 				| sed "s,-I$_DESTDIR/usr/include,,g"
    596 		getvars gcc/Makefile \
    597 			LIB2ADDEHDEP | sed 's/unwind.inc//'
    598 		getvars gcc/Makefile \
    599 			CXX_OBJS CXX_C_OBJS | sed 's/cp\///g'
    600 		getvars gcc/Makefile \
    601 			F77_OBJS | sed 's/f\///g'
    602 		case ${_subdir} in
    603 		gcc4 | gcc)
    604 			getvars libcpp/Makefile \
    605 				libcpp_a_OBJS
    606 			;;
    607 		gcc3)
    608 			getvars gcc/Makefile \
    609 				LIBCPP_OBJS LIBCPP_H
    610 			;;
    611 		esac
    612 		getvars gcc/Makefile \
    613 			ENABLE_SHARED
    614 		case ${_subdir} in
    615 		gcc4 | gcc)
    616 			echo G_SHLIB_LINK="$CC -shared"
    617 			echo G_SHLIB_MULTILIB=.
    618 			;;
    619 		esac
    620 	} | write_mk $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/defs.mk
    621 
    622 	case "$_subdir" in
    623 	gcc4)
    624 		write_c $_OUTDIRBASE/usr.bin/$_subdir/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
    625 		hfiles='auto-host gencheck configargs gthr-default tm bconfig config multilib'
    626 		;;
    627 	gcc)
    628 		write_c $_OUTDIRBASE/usr.bin/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
    629 		hfiles='auto-host configargs gthr-default tm bconfig config multilib bversion plugin-version'
    630 		;;
    631 	esac
    632 	for f in $hfiles; do
    633 		write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
    634 		if [ "${MACHINE_ARCH}" = "powerpc" -a "${f}" = "configargs" ]
    635 		then
    636 			ex <<__EOF__ $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
    637 /configuration_arguments/ s/$//
    638 ya
    639 i
    640 #ifdef _SOFT_FLOAT
    641 .
    642 pu
    643 s/";$/ -with-float=soft";/
    644 a
    645 #else
    646 #endif
    647 .
    648 . m +1
    649 /configure_default_options/ s/{ NULL.*$//
    650 a
    651 #ifdef _SOFT_FLOAT
    652   { "float", "soft" },
    653 #endif
    654   { NULL, NULL }
    655 };
    656 .
    657 wq
    658 __EOF__
    659 		fi
    660 	done
    661 
    662 	# keep identical
    663 	for f in all-tree.def; do
    664 		cp $_TMPDIR/gcc/$f $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
    665 	done
    666 
    667 	# special transforms
    668 	for f in gtyp-input.list; do
    669 		sed -e 's/^.*external\/gpl3\/gcc\/dist/SRCDIR/' < $_TMPDIR/gcc/$f > $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
    670 	done
    671 
    672 	# special platforms
    673 	if [ "${MACHINE_ARCH}" = "sh3el" -o "${MACHINE_ARCH}" = "sh3eb" ]; then
    674 		write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/sysroot-suffix.h <$_TMPDIR/gcc/sysroot-suffix.h
    675 	fi
    676 }
    677 
    678 ##### main #####
    679 
    680 case "$1" in
    681 # .mk and .h files for libgcc bootstrap (from host build)
    682 libgcc)
    683 	get_libgcc gcc3
    684 	get_crtstuff crtstuff3
    685 	exit 0
    686 	;;
    687 
    688 libgcc4)
    689 	get_libgcc gcc4
    690 	get_crtstuff crtstuff4
    691 	exit 0
    692 	;;
    693 
    694 # gcc files
    695 gcc4)
    696 	get_gcc gcc4
    697 	get_libgcc gcc4
    698 	get_libgcov gcc4
    699 	get_crtstuff crtstuff4
    700 	get_gcc_libiberty gcc4
    701 	get_libobjc libobjc4
    702 	get_libstdcxx_v3 libstdc++-v3_4
    703 	exit 0
    704 	;;
    705 
    706 gcc45)
    707 	_OUTDIR="$_TOP/external/gpl3/gcc"
    708 	_OUTDIRBASE="external/gpl3/gcc"
    709 	get_gcc gcc
    710 	get_libgcc gcc
    711 	get_libgcov gcc
    712 	get_crtstuff crtstuff
    713 	get_gcc_libiberty gcc
    714 	get_libobjc libobjc
    715 	get_libstdcxx_v3 libstdc++-v3
    716 	get_libdecnumber libdecnumber
    717 	get_libgomp libgomp
    718 	exit 0
    719 	;;
    720 
    721 
    722 *)	echo invalid arguments; exit 1;;
    723 esac
    724