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