Home | History | Annotate | Line # | Download | only in gcc
mknative-gcc revision 1.41
      1   1.1       mrg #!/bin/sh
      2  1.26  uebayasi #	$NetBSD: mknative-gcc,v 1.41 2009/11/30 14:34:17 uebayasi Exp $
      3   1.1       mrg #
      4   1.1       mrg # Shell script for generating all the constants needed for a native
      5  1.10       mrg # platform build of src/gnu/dist/gcc.
      6   1.1       mrg #
      7   1.1       mrg 
      8   1.9       mrg # initialise
      9   1.9       mrg 
     10   1.9       mrg _TMPDIR=$2
     11   1.9       mrg _TOP=$3
     12   1.9       mrg _PLATFORM=$4
     13  1.15       mrg _VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ 	]*,,'`
     14   1.9       mrg _GNU_DIST=`cd ${_VPATH}; pwd`
     15   1.9       mrg 
     16   1.9       mrg . $_TOP/tools/gcc/mknative.common
     17   1.1       mrg 
     18  1.14   thorpej ##### gnu/lib/crtstuff #####
     19  1.14   thorpej 
     20  1.14   thorpej get_crtstuff () {
     21  1.16       mrg 	_subdir="$1"
     22  1.16       mrg 	mkdir -p $_TOP/gnu/lib/$_subdir/arch
     23  1.14   thorpej 
     24  1.14   thorpej 	getvars gcc/Makefile \
     25  1.14   thorpej 		INCLUDES CRTSTUFF_CFLAGS CRTSTUFF_T_CFLAGS \
     26  1.14   thorpej 		tm_defines xm_file xm_defines \
     27  1.16       mrg 		| write_mk gnu/lib/$_subdir/arch/$MACHINE_ARCH.mk
     28  1.14   thorpej }
     29  1.14   thorpej 
     30   1.1       mrg ##### gnu/lib/libg2c #####
     31   1.1       mrg 
     32   1.1       mrg get_libg2c () {
     33   1.1       mrg 	mkdir -p $_TOP/gnu/lib/libg2c3/arch/$MACHINE_ARCH
     34   1.1       mrg 
     35   1.1       mrg 	write_c gnu/lib/libg2c3/arch/$MACHINE_ARCH/config.h <$_TMPDIR/$_PLATFORM/libf2c/libU77/config.h
     36   1.1       mrg 	write_c gnu/lib/libg2c3/arch/$MACHINE_ARCH/g2c.h <$_TMPDIR/$_PLATFORM/libf2c/g2c.h
     37   1.1       mrg 
     38   1.1       mrg 	{
     39   1.1       mrg 		getvars $_PLATFORM/libf2c/Makefile \
     40   1.1       mrg 			F2CEXT
     41   1.1       mrg 		getvars $_PLATFORM/libf2c/libF77/Makefile \
     42   1.1       mrg 			ALL_CFLAGS OBJS
     43   1.1       mrg 		getvars $_PLATFORM/libf2c/libI77/Makefile \
     44   1.1       mrg 			ALL_CFLAGS OBJS | sed 's,=,+=,'
     45   1.1       mrg 		getvars $_PLATFORM/libf2c/libU77/Makefile \
     46   1.1       mrg 			ALL_CFLAGS OBJS | sed 's,=,+=,'
     47   1.1       mrg 	} | write_mk gnu/lib/libg2c3/arch/$MACHINE_ARCH/defs.mk
     48   1.1       mrg }
     49   1.1       mrg 
     50   1.1       mrg ##### gnu/lib/libgcc #####
     51   1.1       mrg 
     52  1.28  uebayasi get_libgcc_list_funcs_asm () {
     53  1.28  uebayasi 	getvars gcc/Makefile LIB1ASMFUNCS | {
     54  1.28  uebayasi 		# print newline separated list
     55  1.28  uebayasi 		sed -e '
     56  1.28  uebayasi 			s,^.*=,,
     57  1.28  uebayasi 			s, *$,,
     58  1.28  uebayasi 			s,  *, ,g
     59  1.28  uebayasi 			s, ,\
     60  1.28  uebayasi ,g'
     61  1.28  uebayasi 	} | {
     62  1.28  uebayasi 		# print foo and foo_s
     63  1.28  uebayasi 		sed -ne '
     64  1.28  uebayasi 			/./ {
     65  1.28  uebayasi 				p
     66  1.28  uebayasi 				s,$,_s,
     67  1.28  uebayasi 				p
     68  1.28  uebayasi 			}
     69  1.28  uebayasi 		'
     70  1.28  uebayasi 	} | sort
     71  1.28  uebayasi }
     72  1.28  uebayasi 
     73  1.29  uebayasi get_libgcc_list_funcs_lib () {
     74  1.29  uebayasi 	local _lib=$1
     75  1.29  uebayasi 	local _lib_prefix=${_lib%.*}
     76  1.29  uebayasi 	local _lib_suffix=${_lib#*.}
     77  1.29  uebayasi 
     78  1.29  uebayasi 	sed -ne '
     79  1.29  uebayasi 		/^\.\/'${_lib_prefix}'\.'${_lib_suffix}': .*\.o$/ {
     80  1.29  uebayasi 			s,^.*/,,
     81  1.29  uebayasi 			s,\.o$,,
     82  1.29  uebayasi 			p
     83  1.29  uebayasi 		}
     84  1.29  uebayasi 	' build/gcc/libgcc.mk | sort
     85  1.29  uebayasi }
     86  1.29  uebayasi 
     87  1.30  uebayasi get_libgcc_list_objs_libs () {
     88  1.30  uebayasi 	cat build/gcc/libgcc.mk | \
     89  1.30  uebayasi 	egrep '^\.\/(libgcc_s\.so|libgcc\.a|libgcc_eh\.a|libgcov\.a): (libgcc_s|libgcc|libgcc_eh|libgcov)\/.*\.o$' | \
     90  1.30  uebayasi 	sed -e '
     91  1.30  uebayasi 		s,^\.\/,,
     92  1.30  uebayasi 		s,: .*/,	,
     93  1.30  uebayasi 		s,^\(.*\)	\(.*\)$,\2	\1,
     94  1.30  uebayasi 	' | sort
     95  1.30  uebayasi }
     96  1.30  uebayasi 
     97  1.30  uebayasi get_libgcc_list_objs_srcs () {
     98  1.41  uebayasi 	if [ -e $_TOP/${libgcc_db_funcs}.S ]; then
     99  1.30  uebayasi 		cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
    100  1.30  uebayasi 		comm -23 /dev/stdin $_TOP/${libgcc_db_funcs}.S | \
    101  1.30  uebayasi 		sed -e 's,\(.*\),\1.o	\1.c,'
    102  1.30  uebayasi 
    103  1.30  uebayasi 		cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
    104  1.30  uebayasi 		comm -12 /dev/stdin $_TOP/${libgcc_db_funcs}.S | \
    105  1.30  uebayasi 		sed -e 's,\(.*\),\1.o	\1.S,'
    106  1.41  uebayasi 	else
    107  1.41  uebayasi 		cut -f1 $_TOP/${libgcc_db_objs_libs} | sed -e 's,\.o$,,' | \
    108  1.41  uebayasi 		sed -e 's,\(.*\),\1.o	\1.c,'
    109  1.41  uebayasi 	fi | sort
    110  1.30  uebayasi }
    111  1.30  uebayasi 
    112  1.40  uebayasi get_libgcc_list_objs_tmplsrcs () {
    113  1.32  uebayasi 	grep 'GCC_FOR_TARGET.*\.o$' build/gcc/libgcc.mk | \
    114  1.32  uebayasi 	sed -ne '
    115  1.32  uebayasi 		s,^.* -c \([^ ]*\).* -o .*/\([^ ]*\.o\)$,\2	\1,
    116  1.32  uebayasi 		# basename
    117  1.32  uebayasi 		/\$/ { s,\$.*/,,; }
    118  1.32  uebayasi 		/\// { s,\/.*/,,; }
    119  1.32  uebayasi 		p
    120  1.32  uebayasi 	' | sort
    121  1.32  uebayasi }
    122  1.32  uebayasi 
    123  1.31  uebayasi get_libgcc_list_objs_xflags () {
    124  1.31  uebayasi 	local _flags=$1
    125  1.31  uebayasi 
    126  1.31  uebayasi 	grep 'GCC_FOR_TARGET.*\.o$' build/gcc/libgcc.mk | \
    127  1.31  uebayasi 	sed -n '
    128  1.31  uebayasi 		x
    129  1.31  uebayasi 	:loop
    130  1.31  uebayasi 		g
    131  1.31  uebayasi 		s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\5	\2/p
    132  1.31  uebayasi 		g
    133  1.31  uebayasi 		s/^\(.*\) \(-['${_flags}'][^ ][^ ]*\) \(.*\) \(-o .*\)\/\(.*\.o\)$/\1 \3 \4\/\5/
    134  1.31  uebayasi 		h
    135  1.31  uebayasi 		t loop
    136  1.31  uebayasi 	' | sort
    137  1.31  uebayasi }
    138  1.31  uebayasi 
    139  1.31  uebayasi get_libgcc_list_objs_cppflags () {
    140  1.31  uebayasi 	get_libgcc_list_objs_xflags D
    141  1.31  uebayasi }
    142  1.31  uebayasi 
    143  1.31  uebayasi get_libgcc_list_objs_copts () {
    144  1.31  uebayasi 	get_libgcc_list_objs_xflags fmx
    145  1.31  uebayasi }
    146  1.31  uebayasi 
    147  1.40  uebayasi get_libgcc_list_tmplsrcs () {
    148  1.33  uebayasi 	local _lib=$1
    149  1.40  uebayasi 	local _tmplallsrcs=$( mktemp /tmp/mknative-gcc._tmplallsrcs.XXXXXX )
    150  1.33  uebayasi 
    151  1.40  uebayasi 	touch $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
    152  1.40  uebayasi 	touch $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
    153  1.40  uebayasi 	touch $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
    154  1.33  uebayasi 
    155  1.33  uebayasi 	# all files
    156  1.33  uebayasi 	local _lib_prefix=${_lib%.*}
    157  1.33  uebayasi 	local _lib_suffix=${_lib#*.}
    158  1.40  uebayasi 	join $_TOP/$libgcc_db_objs_libs $_TOP/$libgcc_db_objs_tmplsrcs | \
    159  1.33  uebayasi 	grep ${_lib_prefix}'\.'${_lib_suffix} | cut -d' ' -f 3 | sort -u > \
    160  1.40  uebayasi 	$_tmplallsrcs
    161  1.33  uebayasi 
    162  1.40  uebayasi 	# TMPLFPSRCS = [fdp]p-bit.c
    163  1.40  uebayasi 	grep '[fdt]p-bit\.c' <$_tmplallsrcs | sort -u | \
    164  1.40  uebayasi 	writefile ${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
    165  1.40  uebayasi 
    166  1.40  uebayasi 	# TMPLASMSRCS = $(LIB1ASMSRC)
    167  1.40  uebayasi 	grep '\$(LIB1ASMSRC)' <$_tmplallsrcs | sort -u | \
    168  1.40  uebayasi 	writefile ${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*}
    169  1.40  uebayasi 
    170  1.40  uebayasi 	# TMPLSRCS is anything else; exclude TMPLFPSRCS and TMPLASMSRCS
    171  1.40  uebayasi 	cat $_tmplallsrcs | \
    172  1.40  uebayasi 	comm -23 /dev/stdin $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*} | \
    173  1.40  uebayasi 	comm -23 /dev/stdin $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*} | \
    174  1.40  uebayasi 	writefile ${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
    175  1.33  uebayasi 
    176  1.40  uebayasi 	rm -f $_tmplallsrcs
    177  1.33  uebayasi }
    178  1.33  uebayasi 
    179  1.35  uebayasi get_libgcc_new_analyze () {
    180  1.35  uebayasi 	mkdir -p $_TOP/${_machine_arch_subdir}
    181  1.35  uebayasi 
    182  1.41  uebayasi 	touch $_TOP/${libgcc_db_funcs}.S
    183  1.35  uebayasi 	get_libgcc_list_funcs_asm | \
    184  1.35  uebayasi 	writefile ${libgcc_db_funcs}.S
    185  1.35  uebayasi 
    186  1.35  uebayasi 	for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
    187  1.41  uebayasi 		touch $_TOP/${libgcc_db_funcs}.${_lib%.*}
    188  1.35  uebayasi 		get_libgcc_list_funcs_lib $_lib | \
    189  1.35  uebayasi 		writefile ${libgcc_db_funcs}.${_lib%.*}
    190  1.35  uebayasi 	done
    191  1.35  uebayasi 
    192  1.35  uebayasi 	get_libgcc_list_objs_libs | writefile ${libgcc_db_objs_libs}
    193  1.35  uebayasi 	get_libgcc_list_objs_srcs | writefile ${libgcc_db_objs_srcs}
    194  1.40  uebayasi 	get_libgcc_list_objs_tmplsrcs | writefile ${libgcc_db_objs_tmplsrcs}
    195  1.35  uebayasi 	get_libgcc_list_objs_cppflags | writefile ${libgcc_db_objs_cppflags}
    196  1.35  uebayasi 	get_libgcc_list_objs_copts | writefile ${libgcc_db_objs_copts}
    197  1.35  uebayasi 
    198  1.35  uebayasi 	for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
    199  1.40  uebayasi 		get_libgcc_list_tmplsrcs $_lib
    200  1.35  uebayasi 	done
    201  1.35  uebayasi }
    202  1.35  uebayasi 
    203  1.35  uebayasi #####
    204  1.35  uebayasi 
    205  1.40  uebayasi get_libgcc_gen_tmplsrcs_tmplsrcs () {
    206  1.37  uebayasi 	local _lib=$1
    207  1.37  uebayasi 
    208  1.37  uebayasi 	printf '\n'
    209  1.40  uebayasi 	printf 'TMPLSRCS.%s = \\\n' $_lib
    210  1.40  uebayasi 	sed -e 's,^,	,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplsrcs.${_lib%.*}
    211  1.37  uebayasi }
    212  1.37  uebayasi 
    213  1.40  uebayasi get_libgcc_gen_tmplsrcs_tmplfpsrcs () {
    214  1.37  uebayasi 	local _lib=$1
    215  1.37  uebayasi 
    216  1.37  uebayasi 	printf '\n'
    217  1.40  uebayasi 	printf 'TMPLFPSRCS.%s = \\\n' $_lib
    218  1.40  uebayasi 	sed -e 's,^,	,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplfpsrcs.${_lib%.*}
    219  1.37  uebayasi }
    220  1.37  uebayasi 
    221  1.40  uebayasi get_libgcc_gen_tmplsrcs_tmplasmsrcs () {
    222  1.37  uebayasi 	local _lib=$1
    223  1.37  uebayasi 
    224  1.37  uebayasi 	printf '\n'
    225  1.40  uebayasi 	printf 'TMPLASMSRCS.%s = \\\n' $_lib
    226  1.40  uebayasi 	sed -e 's,^,	,; s,$, \\,' $_TOP/${libgcc_db_tmplsrcs}.tmplasmsrcs.${_lib%.*} | \
    227  1.37  uebayasi 	sed -e 's,LIB1ASMSRC,G_&,'
    228  1.37  uebayasi }
    229  1.37  uebayasi 
    230  1.36  uebayasi get_libgcc_gen_srcs () {
    231  1.36  uebayasi 	local _lib=$1
    232  1.36  uebayasi 
    233  1.36  uebayasi 	printf '\n'
    234  1.36  uebayasi 	printf 'SRCS.%s = \\\n' $_lib
    235  1.41  uebayasi 	if [ -e $_TOP/${libgcc_db_funcs}.S ]; then
    236  1.36  uebayasi 		comm -23 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
    237  1.36  uebayasi 		sed -e 's,$,.c,; s,^,tmp_,'
    238  1.36  uebayasi 		comm -12 $_TOP/${libgcc_db_funcs}.${_lib%.*} $_TOP/${libgcc_db_funcs}.S | \
    239  1.36  uebayasi 		sed -e 's,$,.S,; s,^,tmp_,'
    240  1.41  uebayasi 	else
    241  1.41  uebayasi 		cat $_TOP/${libgcc_db_funcs}.${_lib%.*} | \
    242  1.41  uebayasi 		sed -e 's,$,.c,; s,^,tmp_,'
    243  1.41  uebayasi 	fi | sort | \
    244  1.36  uebayasi 	sed -e 's,^,	,; s,$, \\,'
    245  1.36  uebayasi }
    246  1.36  uebayasi 
    247  1.38  uebayasi _lookup_objs () {
    248  1.38  uebayasi 	local _obj=$1; local _key=$2
    249  1.38  uebayasi 
    250  1.38  uebayasi 	eval grep \^$_obj\\\	 \$_TOP/\${libgcc_db_objs_${_key}} | cut -f2
    251  1.38  uebayasi }
    252  1.38  uebayasi 
    253  1.40  uebayasi get_libgcc_gen_srcs_tmplsrcs () {
    254  1.38  uebayasi 	cut -f1 $_TOP/${libgcc_db_objs_libs} | \
    255  1.38  uebayasi 	while read _obj; do
    256  1.38  uebayasi 		printf 'SRCS.tmp_%s=%s\n' \
    257  1.38  uebayasi 			"$( _lookup_objs $_obj srcs )" \
    258  1.40  uebayasi 			"$( _lookup_objs $_obj tmplsrcs )"
    259  1.38  uebayasi 	done | \
    260  1.38  uebayasi 	sed -e 's,\$(\(.*\)),${G_\1},'
    261  1.38  uebayasi }
    262  1.38  uebayasi 
    263  1.38  uebayasi get_libgcc_gen_srcs_cppflags () {
    264  1.38  uebayasi 	cut -f1 $_TOP/${libgcc_db_objs_libs} | \
    265  1.38  uebayasi 	while read _obj; do
    266  1.38  uebayasi 		printf '_CPPFLAGS.tmp_%s=%s\n' \
    267  1.38  uebayasi 			"$( _lookup_objs $_obj srcs )" \
    268  1.38  uebayasi 			"$( _lookup_objs $_obj cppflags | xargs )"
    269  1.38  uebayasi 	done
    270  1.38  uebayasi }
    271  1.38  uebayasi 
    272  1.38  uebayasi get_libgcc_gen_srcs_copts () {
    273  1.38  uebayasi 	cut -f1 $_TOP/${libgcc_db_objs_libs} | \
    274  1.38  uebayasi 	while read _obj; do
    275  1.38  uebayasi 		printf 'COPTS.tmp_%s=%s\n' \
    276  1.38  uebayasi 			"$( _lookup_objs $_obj srcs )" \
    277  1.38  uebayasi 			"$( _lookup_objs $_obj copts | xargs )"
    278  1.38  uebayasi 	done
    279  1.38  uebayasi }
    280  1.38  uebayasi 
    281  1.35  uebayasi get_libgcc_new_generate () {
    282  1.36  uebayasi 	for _lib in libgcc_s.so libgcc.a libgcc_eh.a libgcov.a; do
    283  1.40  uebayasi 		for _tmpl in tmplsrcs tmplfpsrcs tmplasmsrcs; do
    284  1.40  uebayasi 			eval get_libgcc_gen_tmplsrcs_${_tmpl} $_lib | \
    285  1.40  uebayasi 			write_mk ${libgcc_libs_mk}.${_lib%.*}.tmplsrcs.${_tmpl}.mk
    286  1.37  uebayasi 		done
    287  1.37  uebayasi 
    288  1.36  uebayasi 		get_libgcc_gen_srcs $_lib | \
    289  1.39  uebayasi 		write_mk ${libgcc_libs_mk}.${_lib%.*}.srcs.mk
    290  1.36  uebayasi 	done
    291  1.38  uebayasi 
    292  1.40  uebayasi 	for _arg in tmplsrcs cppflags copts; do
    293  1.38  uebayasi 		eval get_libgcc_gen_srcs_${_arg} | \
    294  1.38  uebayasi 		eval writefile \$libgcc_srcs_mk_${_arg}
    295  1.38  uebayasi 	done
    296  1.35  uebayasi }
    297  1.35  uebayasi 
    298  1.33  uebayasi #####
    299  1.33  uebayasi 
    300  1.28  uebayasi get_libgcc_new () {
    301  1.28  uebayasi 	_subdir="$1"
    302  1.27  uebayasi 
    303  1.29  uebayasi 	# List of generated files.
    304  1.29  uebayasi 
    305  1.28  uebayasi 	_machine_arch_subdir=gnu/lib/lib$_subdir/arch${_archsubdir}/$MACHINE_ARCH
    306  1.27  uebayasi 
    307  1.28  uebayasi 	libgcc_db_funcs=${_machine_arch_subdir}/funcs
    308  1.40  uebayasi 	libgcc_db_tmplsrcs=${_machine_arch_subdir}/tmplsrcs
    309  1.28  uebayasi 	libgcc_db_objs_libs=${_machine_arch_subdir}/objs.libs
    310  1.28  uebayasi 	libgcc_db_objs_srcs=${_machine_arch_subdir}/objs.srcs
    311  1.40  uebayasi 	libgcc_db_objs_tmplsrcs=${_machine_arch_subdir}/objs.tmplsrcs
    312  1.28  uebayasi 	libgcc_db_objs_cppflags=${_machine_arch_subdir}/objs.cppflags
    313  1.28  uebayasi 	libgcc_db_objs_copts=${_machine_arch_subdir}/objs.copts
    314  1.28  uebayasi 
    315  1.36  uebayasi 	get_libgcc_new_analyze
    316  1.36  uebayasi 
    317  1.39  uebayasi 	libgcc_libs_mk=${_machine_arch_subdir}/libs
    318  1.28  uebayasi 	libgcc_srcs_mk=${_machine_arch_subdir}/srcs.mk
    319  1.40  uebayasi 	libgcc_srcs_mk_tmplsrcs=${_machine_arch_subdir}/srcs.tmplsrcs.mk
    320  1.28  uebayasi 	libgcc_srcs_mk_cppflags=${_machine_arch_subdir}/srcs.cppflags.mk
    321  1.28  uebayasi 	libgcc_srcs_mk_copts=${_machine_arch_subdir}/srcs.copts.mk
    322  1.28  uebayasi 
    323  1.35  uebayasi 	get_libgcc_new_generate
    324  1.26  uebayasi }
    325  1.26  uebayasi 
    326   1.1       mrg get_libgcc () {
    327  1.16       mrg 	_subdir="$1"
    328  1.16       mrg 	mkdir -p $_TOP/gnu/lib/lib$_subdir/arch
    329  1.16       mrg 
    330  1.16       mrg 	case "$_subdir" in
    331  1.16       mrg 	gcc3)
    332  1.16       mrg 		_extravars="USE_COLLECT2 LIB2FUNCS_1 LIB2FUNCS_2 xm_file"
    333  1.16       mrg 		_archsubdir=""
    334  1.16       mrg 		;;
    335  1.16       mrg 	gcc4)
    336  1.16       mrg 		_extravars="COLLECT2 UNWIND_H xm_include_list"
    337  1.16       mrg 		_archsubdir=""
    338  1.16       mrg 		;;
    339  1.16       mrg 	esac
    340   1.1       mrg 
    341   1.1       mrg 	# DPBIT, FPBIT only used on mn10[23]00, we don't need them.
    342   1.4       mrg 	# XXX we should probably grab everything Just In Case for
    343   1.4       mrg 	# the future.
    344  1.16       mrg 	{
    345  1.16       mrg 		getvars gcc/Makefile \
    346  1.16       mrg 			INCLUDES LIB2ADD LIB2ADDEH \
    347  1.16       mrg 			LIB1ASMFUNCS LIB1ASMSRC \
    348  1.16       mrg 			LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
    349  1.16       mrg 			LIBGCC2_CFLAGS \
    350  1.16       mrg 			SHLIB_MKMAP SHLIB_MKMAP_OPTS \
    351  1.16       mrg 			SHLIB_MAPFILES SHLIB_NM_FLAGS \
    352  1.16       mrg 			EXTRA_HEADERS xm_defines \
    353  1.16       mrg 			tm_defines ${_extravars}
    354  1.16       mrg 	} | write_mk gnu/lib/lib$_subdir/arch${_archsubdir}/$MACHINE_ARCH.mk
    355  1.26  uebayasi 
    356  1.26  uebayasi 	# Generate new style files.
    357  1.27  uebayasi 	if [ -n "${MKNATIVE_LIBGCC_NEW}" ]; then
    358  1.28  uebayasi 		get_libgcc_new $_subdir
    359  1.26  uebayasi 	fi
    360   1.1       mrg }
    361   1.1       mrg 
    362  1.24     skrll ##### gnu/lib/libgcov #####
    363  1.24     skrll 
    364  1.24     skrll get_libgcov () {
    365  1.24     skrll 	_subdir="$1"
    366  1.24     skrll 
    367  1.24     skrll 	mkdir -p $_TOP/gnu/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH
    368  1.24     skrll 
    369  1.24     skrll 	{
    370  1.24     skrll 		getvars gcc/Makefile \
    371  1.24     skrll 			LIBGCOV
    372  1.24     skrll 	} | write_mk gnu/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/defs.mk
    373  1.24     skrll 
    374  1.24     skrll 	write_c gnu/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/gcov-iov.h \
    375  1.24     skrll 	   <$_TMPDIR/gcc/gcov-iov.h
    376  1.24     skrll 
    377  1.24     skrll }
    378  1.24     skrll 
    379  1.16       mrg ##### gnu/usr.bin/gcc[34]/libiberty #####
    380   1.1       mrg 
    381  1.16       mrg get_gcc_libiberty () {
    382  1.16       mrg 	_subdir="$1"
    383  1.16       mrg 	mkdir -p $_TOP/gnu/usr.bin/$_subdir/libiberty/arch/$MACHINE_ARCH
    384   1.1       mrg 
    385   1.1       mrg 	getvars libiberty/Makefile \
    386   1.1       mrg 		ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
    387  1.16       mrg 		| write_mk gnu/usr.bin/$_subdir/libiberty/defs.mk
    388   1.1       mrg 
    389  1.16       mrg 	write_c gnu/usr.bin/$_subdir/libiberty/arch/$MACHINE_ARCH/config.h \
    390   1.1       mrg 		<$_TMPDIR/libiberty/config.h
    391   1.1       mrg }
    392   1.1       mrg 
    393   1.1       mrg ##### gnu/lib/libobjc #####
    394   1.1       mrg 
    395   1.1       mrg get_libobjc () {
    396  1.18       mrg 	case "$1" in
    397  1.18       mrg 	*4)
    398  1.18       mrg 		_subdir="$1/arch/$MACHINE_ARCH"
    399  1.18       mrg 		_options="ALL_OPT_FILES"
    400  1.20     skrll 		_unwind="UNWIND_H"
    401  1.18       mrg 		;;
    402  1.18       mrg 	*)
    403  1.18       mrg 		_subdir="$1"
    404  1.18       mrg 		_options=""
    405  1.20     skrll 		_unwind=""
    406  1.18       mrg 		;;
    407  1.18       mrg 	esac
    408  1.18       mrg 
    409  1.16       mrg 	mkdir -p $_TOP/gnu/lib/$_subdir
    410   1.1       mrg 
    411  1.16       mrg 	{
    412  1.18       mrg 		if [ -n "$_options" ]; then
    413  1.18       mrg 			getvars gcc/Makefile $_options
    414  1.18       mrg 		fi
    415  1.16       mrg 		getvars $_PLATFORM/libobjc/Makefile \
    416  1.16       mrg 			ALL_CFLAGS INCLUDES OBJS OBJC_H \
    417  1.16       mrg 			| sed "s,$_GNU_DIST,\${GNUHOSTDIST},g"
    418  1.20     skrll 		if [ -n "$_unwind" ]; then
    419  1.20     skrll 			getvars gcc/Makefile $_unwind
    420  1.20     skrll 		fi
    421  1.16       mrg 	} | write_mk gnu/lib/$_subdir/defs.mk
    422  1.23     skrll 
    423  1.23     skrll 	write_c gnu/lib/$_subdir/config.h \
    424  1.23     skrll 		<$_TMPDIR/$_PLATFORM/libobjc/config.h
    425   1.1       mrg }
    426   1.1       mrg 
    427   1.1       mrg ##### gnu/lib/libstdc++-v3 #####
    428   1.1       mrg 
    429   1.1       mrg get_libstdcxx_v3 () {
    430  1.16       mrg 	_subdir="$1"
    431  1.16       mrg 	mkdir -p $_TOP/gnu/lib/$_subdir/arch/$MACHINE_ARCH
    432   1.1       mrg 
    433  1.16       mrg 	case ${_subdir} in
    434  1.16       mrg 	*4)
    435  1.16       mrg 		_src_CC_files="atomicity_file CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_CC CLOCALE_CC BASIC_FILE_CC"
    436  1.16       mrg 		_headers1="host_headers debug_headers tr1_headers c_compatibility_headers_extra"
    437  1.16       mrg 		_headers2="thread_host_headers host_headers_extra"
    438  1.19       mrg 		_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"
    439  1.20     skrll 		_unwind="UNWIND_H"
    440  1.16       mrg 		;;
    441  1.16       mrg 	*)
    442  1.16       mrg 		_src_CC_files=""
    443  1.16       mrg 		_headers1="target_headers"
    444  1.16       mrg 		_headers2="thread_target_headers target_headers_extra"
    445  1.19       mrg 		_build_headers="c++config.h gthr-default.h gthr-posix.h gthr-single.h gthr.h"
    446  1.20     skrll 		_unwind=""
    447  1.16       mrg 		;;
    448  1.16       mrg 	esac
    449  1.16       mrg 
    450  1.19       mrg 	# build files
    451  1.19       mrg 	for h in $_build_headers; do
    452  1.19       mrg 		write_c gnu/lib/$_subdir/arch/$MACHINE_ARCH/$h \
    453  1.19       mrg 			<$_TMPDIR/$_PLATFORM/libstdc++-v3/include/$_PLATFORM/bits/$h
    454  1.19       mrg 	done
    455  1.19       mrg 
    456  1.16       mrg 	write_c gnu/lib/$_subdir/arch/$MACHINE_ARCH/config.h \
    457   1.6       mrg 		<$_TMPDIR/$_PLATFORM/libstdc++-v3/config.h
    458   1.6       mrg 
    459   1.1       mrg 	{
    460   1.1       mrg 		# libmath
    461   1.1       mrg 		getvars $_PLATFORM/libstdc++-v3/libmath/Makefile \
    462   1.1       mrg 			libmath_la_SOURCES libmath_la_LIBADD
    463   1.1       mrg 
    464   1.1       mrg 		# libsupc++
    465   1.1       mrg 		getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
    466   1.1       mrg 			sources | sed 's/^G_sources=/G_LIBSUPCXX_SOURCES=/'
    467   1.1       mrg 		getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
    468   1.1       mrg 			c_sources | sed 's/^G_c_sources=/G_LIBSUPCXX_C_SOURCES=/'
    469   1.1       mrg 
    470   1.1       mrg 		# src
    471   1.1       mrg 		getvars $_PLATFORM/libstdc++-v3/src/Makefile \
    472  1.16       mrg 			sources $_src_CC_files SECTION_FLAGS | sed 's/^G_sources=/G_SRC_SOURCES=/'
    473   1.1       mrg 
    474   1.1       mrg 		# include
    475   1.1       mrg 		getvars $_PLATFORM/libstdc++-v3/include/Makefile \
    476   1.1       mrg 			c_base_headers_rename std_headers_rename
    477   1.1       mrg 		getvars $_PLATFORM/libstdc++-v3/include/Makefile \
    478   1.1       mrg 			bits_headers backward_headers ext_headers c_base_headers_extra \
    479  1.17       mrg 			$_headers1 | sed -e 's#/[^ 	][^ 	]*/##g' -e 's/\${GNUHOSTDIST}//g'
    480   1.1       mrg 		getvars $_PLATFORM/libstdc++-v3/include/Makefile \
    481  1.17       mrg 			$_headers2 | sed -e 's#\./[^ 	][^ 	]*/##g' -e 's/\${GNUHOSTDIST}//g'
    482  1.16       mrg 
    483  1.20     skrll 		if [ -n "$_unwind" ]; then
    484  1.20     skrll 			getvars gcc/Makefile $_unwind
    485  1.20     skrll 		fi
    486  1.16       mrg 	} | write_mk gnu/lib/$_subdir/arch/$MACHINE_ARCH/defs.mk
    487   1.1       mrg }
    488   1.1       mrg 
    489   1.1       mrg ##### gnu/usr.bin/gcc3 #####
    490   1.1       mrg 
    491   1.1       mrg get_gcc () {
    492  1.16       mrg 	_subdir="$1"
    493  1.16       mrg 	mkdir -p $_TOP/gnu/usr.bin/$_subdir/arch/$MACHINE_ARCH
    494  1.19       mrg 	case ${_subdir} in
    495  1.19       mrg 	gcc4)
    496  1.19       mrg 		mkdir -p $_TOP/gnu/usr.bin/$_subdir/libcpp/arch/$MACHINE_ARCH
    497  1.19       mrg 		_buildname="BUILD_"
    498  1.19       mrg 		_libcppsubdir=""
    499  1.20     skrll 		_extravars="TM_H ALL_OPT_FILES"
    500  1.20     skrll 		_hconfig_h=""
    501  1.20     skrll 		_extravars2="tm_file_list build_xm_include_list"
    502  1.20     skrll 		_extravars3="tm_p_include_list"
    503  1.20     skrll 		
    504  1.19       mrg 		;;
    505  1.19       mrg 	*)
    506  1.19       mrg 		_buildname="HOST_"
    507  1.19       mrg 		_libcppsubdir="gcc/"
    508  1.20     skrll 		_extravars=""
    509  1.20     skrll 		_hconfig_h="HCONFIG_H"
    510  1.20     skrll 		_extravars2=""
    511  1.20     skrll 		_extravars3=""
    512  1.19       mrg 		;;
    513  1.19       mrg 	esac
    514   1.1       mrg 
    515   1.1       mrg 	{
    516   1.1       mrg 		getvars gcc/Makefile \
    517  1.19       mrg 			${_buildname}EARLY_SUPPORT ${_buildname}ERRORS ${_buildname}PRINT \
    518  1.19       mrg 			${_buildname}RTL ${_buildname}SUPPORT ${_buildname}VARRAY | \
    519  1.16       mrg 		    sed -e 's#build/errors.o#build-errors.o#g' \
    520  1.16       mrg 			-e 's#build/print-rtl.o#build-print-rtl.o#g' \
    521  1.16       mrg 			-e 's#build/rtl.o#build-rtl.o#g' \
    522  1.16       mrg 			-e 's#build/varray.o#build-varray.o#g' \
    523  1.22       mrg 			-e 's#build/ggc-none.o#build-ggc-none.o#g' \
    524  1.16       mrg 			-e 's#build/##g'
    525  1.16       mrg 		getvars gcc/Makefile \
    526   1.1       mrg 			ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
    527  1.20     skrll 			GCOV_OBJS PROTO_OBJS ${_extravars1} \
    528   1.1       mrg 			INCLUDES md_file OBJC_OBJS OBJS out_file version \
    529  1.20     skrll 			BUILD_PREFIX RTL_H TREE_H ${_hconfig_h} BASIC_BLOCK_H GCC_H \
    530   1.1       mrg 			GTFILES_SRCDIR GTFILES_FILES_FILES GTFILES_FILES_LANGS \
    531   1.1       mrg 			GTFILES GTFILES_LANG_DIR_NAMES \
    532   1.1       mrg 			tm_defines host_xm_file host_xm_defines tm_p_file \
    533  1.21       mrg 			target_cpu_default ${_extravars} ${_extravars2} \
    534  1.20     skrll 			lang_specs_files ${_extravars3}
    535   1.1       mrg 		getvars gcc/Makefile \
    536   1.1       mrg 			LIB2ADDEHDEP | sed 's/unwind.inc//'
    537   1.1       mrg 		getvars gcc/Makefile \
    538   1.1       mrg 			CXX_OBJS CXX_C_OBJS | sed 's/cp\///g'
    539   1.1       mrg 		getvars gcc/Makefile \
    540   1.1       mrg 			F77_OBJS | sed 's/f\///g'
    541  1.19       mrg 		case ${_subdir} in
    542  1.19       mrg 		gcc4)
    543  1.19       mrg 			getvars libcpp/Makefile \
    544  1.19       mrg 				libcpp_a_OBJS
    545  1.19       mrg 			;;
    546  1.19       mrg 		gcc3)
    547  1.19       mrg 			getvars gcc/Makefile \
    548  1.19       mrg 				LIBCPP_OBJS LIBCPP_H
    549  1.19       mrg 			;;
    550  1.19       mrg 		esac
    551  1.12     skrll 		getvars gcc/Makefile \
    552  1.16       mrg 			ENABLE_SHARED
    553  1.20     skrll 		case ${_subdir} in
    554  1.20     skrll 		gcc4)
    555  1.20     skrll 			echo G_SHLIB_LINK="$CC -shared"
    556  1.20     skrll 			echo G_SHLIB_MULTILIB=.
    557  1.20     skrll 			;;
    558  1.20     skrll 		gcc3)
    559  1.20     skrll 			getvars gcc/Makefile \
    560  1.20     skrll 				SHLIB_LINK SHLIB_MULTILIB
    561  1.20     skrll 			;;
    562  1.20     skrll 		esac
    563  1.16       mrg 	} | write_mk gnu/usr.bin/$_subdir/arch/$MACHINE_ARCH/defs.mk
    564  1.16       mrg 
    565  1.16       mrg 	case "$_subdir" in
    566  1.16       mrg 	gcc3)
    567  1.16       mrg 		hfiles='auto-host configargs cs-hconfig gencheck hconfig gthr-default'
    568  1.16       mrg 		;;
    569  1.16       mrg 	gcc4)
    570  1.16       mrg 		write_c gnu/usr.bin/$_subdir/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
    571  1.25       mrg 		hfiles='auto-host configargs gencheck gthr-default tm bconfig config multilib'
    572  1.16       mrg 		;;
    573  1.16       mrg 	esac
    574  1.16       mrg 	for f in $hfiles; do
    575  1.16       mrg 		write_c gnu/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
    576   1.1       mrg 	done
    577   1.1       mrg }
    578   1.1       mrg 
    579   1.1       mrg ##### main #####
    580   1.1       mrg 
    581  1.16       mrg case "$1" in
    582  1.16       mrg # .mk and .h files for libgcc bootstrap (from host build)
    583  1.16       mrg libgcc)
    584  1.16       mrg 	get_libgcc gcc3
    585  1.16       mrg 	get_crtstuff crtstuff3
    586  1.16       mrg 	exit 0
    587  1.16       mrg 	;;
    588  1.16       mrg 
    589  1.16       mrg libgcc4)
    590  1.16       mrg 	get_libgcc gcc4
    591  1.16       mrg 	get_crtstuff crtstuff4
    592  1.16       mrg 	exit 0
    593  1.16       mrg 	;;
    594  1.16       mrg 
    595  1.16       mrg # gcc files
    596  1.16       mrg gcc4)
    597  1.16       mrg 	get_gcc gcc4
    598  1.16       mrg 	get_libgcc gcc4
    599  1.24     skrll 	get_libgcov gcc4
    600  1.16       mrg 	get_crtstuff crtstuff4
    601  1.16       mrg 	get_gcc_libiberty gcc4
    602  1.16       mrg 	get_libobjc libobjc4
    603  1.16       mrg 	get_libstdcxx_v3 libstdc++-v3_4
    604   1.1       mrg 	exit 0
    605   1.1       mrg 	;;
    606   1.1       mrg 
    607   1.1       mrg gcc3)
    608  1.16       mrg 	get_gcc gcc3
    609   1.1       mrg 	get_libg2c
    610  1.20     skrll 	get_libgcc gcc3
    611  1.16       mrg 	get_crtstuff crtstuff3
    612  1.20     skrll 	get_gcc_libiberty gcc3
    613  1.16       mrg 	get_libobjc libobjc3
    614  1.16       mrg 	get_libstdcxx_v3 libstdc++-v3
    615   1.1       mrg 	exit 0
    616   1.1       mrg 	;;
    617   1.1       mrg 
    618   1.1       mrg *)	echo invalid arguments; exit 1;;
    619   1.1       mrg esac
    620