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