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