2006-03-15 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / mklibgcc.in
blob8ec9e4037b1ee08b83bee1da916628f09d825c24
1 #!/bin/sh
2 # Construct makefile for libgcc.
3 # Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006
4 # Free Software Foundation, Inc.
6 # This file is part of GCC.
8 # Arguments, taken from the environment, since there are a lot
9 # of them, and positional args becomes quite ugly.
11 # objext
12 # LIB1ASMFUNCS
13 # LIB2FUNCS_ST
14 # LIBGCOV
15 # LIB2ADD
16 # LIB2ADD_ST
17 # LIB2ADDEH
18 # LIB2ADDEHSTATIC
19 # LIB2ADDEHSHARED
20 # LIB2ADDEHDEP
21 # LIBUNWIND
22 # LIBUNWINDDEP
23 # SHLIBUNWIND_LINK
24 # SHLIBUNWIND_INSTALL
25 # FPBIT
26 # FPBIT_FUNCS
27 # LIB2_DIVMOD_FUNCS
28 # DFP_ENABLE
29 # DFP_CFLAGS
30 # DPBIT
31 # DPBIT_FUNCS
32 # TPBIT
33 # TPBIT_FUNCS
34 # D32PBIT
35 # D32PBIT_FUNCS
36 # D64PBIT
37 # D64PBIT_FUNCS
38 # D128PBIT
39 # D128PBIT_FUNCS
40 # LIBGCC
41 # MULTILIBS
42 # EXTRA_MULTILIB_PARTS
43 # SHLIB_EXT
44 # SHLIB_LINK
45 # SHLIB_MKMAP
46 # SHLIB_MKMAP_OPTS
47 # SHLIB_MAPFILES
48 # SHLIB_NM_FLAGS
49 # SHLIB_INSTALL
50 # MULTILIB_OSDIRNAMES
51 # ASM_HIDDEN_OP
52 # GCC_FOR_TARGET
54 # Make needs VPATH to be literal.
55 echo 'srcdir = @srcdir@'
56 echo 'VPATH = @srcdir@'
57 echo 'EQ = ='
58 echo 'objects = $(filter %'$objext',$^)'
59 echo
60 echo '# Dependencies are accumulated as we go.'
61 echo 'all: stmp-dirs'
62 echo 'dirs = libgcc'
63 echo
65 # Library members defined in libgcc2.c.
66 lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
67 _cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi
68 _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi
69 _floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf _clear_cache
70 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3
71 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
72 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
73 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
74 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
75 _divxc3 _divtc3 _floatundidf _floatundisf _floatundixf _floatunditf'
77 # Disable SHLIB_LINK if shared libgcc not enabled.
78 if [ "@enable_shared@" = "no" ]; then
79 SHLIB_LINK=""
82 # Build lines.
84 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
85 gcc_s_compile="$gcc_compile -DSHARED"
86 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
87 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
88 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
89 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
90 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
91 CC="$(CC)" CFLAGS="$(CFLAGS)" \
92 BUILD_PREFIX="$(BUILD_PREFIX)" \
93 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
94 LANGUAGES="$(LANGUAGES)"'
96 # Generic dependencies for libgcc
97 libgcc_dep='$(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h config.status stmp-int-hdrs tsystem.h'
99 # Dependencies for libgcc2.c
100 libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(srcdir)/libgcc2.h gbl-ctors.h'" $libgcc_dep"
102 # Dependencies for libgcov.c
103 libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h'" $libgcc_dep"
105 # Dependencies for fp-bit.c
106 fpbit_c_dep='stmp-dirs config.status tsystem.h'
108 # Dependencies for decnumber and friends. This is an overzealous set,
109 # but at least we can be sure to recompile if anything gets modified.
110 decnumber_dep='stmp-dirs $(srcdir)/../libdecnumber/decContext.h $(srcdir)/../libdecnumber/decNumber.h
111 $(srcdir)/../libdecnumber/decNumberLocal.h $(srcdir)/../libdecnumber/decimal32.h $(srcdir)/../libdecnumber/decimal64.h
112 $(srcdir)/../libdecnumber/decimal128.h $(srcdir)/../libdecnumber/decDPD.h $(srcdir)/../libdecnumber/decUtility.h'
114 # Flag whether we need eh_dummy.c
115 need_eh_dummy=
117 if [ "$SHLIB_LINK" ]; then
118 # Test -fvisibility=hidden. We need both a -fvisibility=hidden on
119 # the command line, and a #define to prevent libgcc2.h etc from
120 # overriding that with #pragmas. The dance with @ is to prevent
121 # echo from seeing anything it might take for an option.
122 # echo turns the \$\$\$\$ into $$$$ and when make sees it it
123 # becomes $$ and the shell substitutes the pid. Makes for a
124 # slightly safer temp file.
125 echo "vis_hide := \$(strip \$(subst @,-,\\"
126 echo " \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
127 echo " $gcc_compile -fvisibility=hidden -Werror \\"
128 echo " -c -xc - -o vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
129 echo " then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
130 echo " rm vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
131 echo " fi)))"
132 echo
134 # If we have -fvisibility=hidden, then we need to generate hide
135 # lists for object files implemented in assembly. The default
136 # pseudo-op for this is ".hidden", but can be overridden with
137 # ASM_HIDDEN_OP.
138 [ "$ASM_HIDDEN_OP" ] || ASM_HIDDEN_OP=".hidden"
140 echo "ifneq (,\$(vis_hide))"
141 echo "define gen-hide-list"
142 echo "\$(NM_FOR_TARGET) ${SHLIB_NM_FLAGS} \$< | \\"
143 # non-GNU nm emits three fields even for undefined and typeless symbols,
144 # so explicitly omit them
145 echo " \$(AWK) 'NF == 3 && \$\$2 !~ /^[UN]\$\$/ { print \"\\t${ASM_HIDDEN_OP}\", \$\$3 }' > \$@T"
146 echo "mv -f \$@T \$@"
147 echo "endef"
148 echo "else"
149 echo "gen-hide-list = echo > \$@"
150 echo "endif"
151 echo
152 else
153 # It is too hard to guarantee that vis_hide and gen-hide-list will never
154 # be referenced if SHLIB_LINK is not set, so set them to the values they'd
155 # have if SHLIB_LINK were set and we didn't have visibility support.
156 echo "vis_hide ="
157 echo "gen-hide-list = echo > \$@"
160 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
161 # defined as optimized assembly code in LIB1ASMFUNCS.
162 for name in $LIB1ASMFUNCS; do
163 lib2funcs=`echo $lib2funcs | sed -e 's/^'$name' //' \
164 -e 's/ '$name' / /' \
165 -e 's/ '$name'$//'`
166 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
167 -e 's/ '$name' / /' \
168 -e 's/ '$name'$//'`
169 done
172 # Rules to generate object files.
175 for ml in $MULTILIBS; do
177 # Work out relevant parameters that depend only on the multilib.
178 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
179 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
180 shlib_slibdir_qual=
181 libgcc_a=$dir/libgcc.a
182 libgcov_a=$dir/libgcov.a
183 libgcc_eh_a=
184 libgcc_s_so=
185 libunwind_a=
186 libunwind_so=
188 if [ "$LIBUNWIND" ]; then
189 libunwind_a=$dir/libunwind.a
191 if [ "$SHLIB_LINK" ]; then
192 libgcc_eh_a=$dir/libgcc_eh.a
193 libgcc_s_so=$dir/libgcc_s${SHLIB_EXT}
194 if [ "$LIBUNWIND" ]; then
195 libunwind_so=$dir/libunwind${SHLIB_EXT}
197 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
198 if [ "$os_multilib_dir" != . ]; then
199 shlib_slibdir_qual="/$os_multilib_dir"
203 libgcc_s_so_extra=
204 libunwind_so_extra=
206 echo
207 echo \#
208 echo \# ml: $ml
209 echo \# dir: $dir
210 echo \# flags: $flags
211 echo \# libgcc_a: $libgcc_a
212 echo \# libgcov_a: $libgcov_a
213 echo \# libgcc_eh_a: $libgcc_eh_a
214 echo \# libunwind_a: $libunwind_a
215 echo \#
216 echo \# shlib_slibdir_qual: $shlib_slibdir_qual
217 echo \# libgcc_s_so: $libgcc_s_so
218 echo \# libunwind_so: $libunwind_so
219 echo \#
220 echo
222 # Update list of directories.
223 if [ $dir != . ]; then
224 echo "dirs += ${dir} libgcc/${dir}"
225 echo
229 # Build libgcc1 components.
231 for name in $LIB1ASMFUNCS; do
232 if [ "$libgcc_s_so" ]; then
233 out="libgcc/${dir}/${name}${objext}"
234 outS="libgcc/${dir}/${name}_s${objext}"
235 outV="libgcc/${dir}/${name}.vis"
237 echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
238 echo " $gcc_s_compile" $flags -DL$name -xassembler-with-cpp \
239 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
241 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
242 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
243 -c '$(srcdir)/config/$(LIB1ASMSRC)' -include $outV -o $out
245 echo "${outV}: ${outS}; \$(gen-hide-list)"
247 echo $libgcc_a: $out
248 echo $libgcc_s_so: $outS
249 if [ "$SHLIB_MKMAP" ]; then
250 echo libgcc/${dir}/libgcc.map: $outS
252 else
253 out="libgcc/${dir}/${name}${objext}"
254 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
255 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
256 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
257 echo $libgcc_a: $out
259 done
262 # Build libgcc2 components.
265 for name in $lib2funcs; do
266 if [ "$libgcc_s_so" ]; then
267 out="libgcc/${dir}/${name}${objext}"
268 outS="libgcc/${dir}/${name}_s${objext}"
270 echo $outS: $libgcc2_c_dep
271 echo " $gcc_s_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' \
272 -o $outS
274 echo $out: $libgcc2_c_dep
275 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
276 -c '$(srcdir)/libgcc2.c' -o $out
278 echo $libgcc_a: $out
279 echo $libgcc_s_so: $outS
280 if [ "$SHLIB_MKMAP" ]; then
281 echo libgcc/${dir}/libgcc.map: $outS
283 else
284 out="libgcc/${dir}/${name}${objext}"
285 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
286 echo " $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
287 echo $libgcc_a: $out
289 done
291 for name in $LIB2FUNCS_ST; do
292 out="libgcc/${dir}/${name}${objext}"
294 echo $out: $libgcc2_c_dep
295 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
296 -c '$(srcdir)/libgcc2.c' -o $out
297 echo ${dir}/libgcc.a: $out
298 done
300 for name in $LIB2_DIVMOD_FUNCS; do
301 if [ "$libgcc_s_so" ]; then
302 out="libgcc/${dir}/${name}${objext}"
303 outS="libgcc/${dir}/${name}_s${objext}"
305 echo $outS: $libgcc2_c_dep
306 echo " $gcc_s_compile" $flags -DL$name \
307 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
309 echo $out: $libgcc2_c_dep
310 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
311 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
313 echo $libgcc_a: $out
314 echo $libgcc_s_so: $outS
315 if [ "$SHLIB_MKMAP" ]; then
316 echo libgcc/${dir}/libgcc.map: $outS
318 else
319 out="libgcc/${dir}/${name}${objext}"
320 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
321 echo " $gcc_compile" $flags -DL$name \
322 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
323 echo $libgcc_a: $out
325 done
328 # Build software floating point functions.
331 for fpbit_var in FPBIT DPBIT TPBIT ; do
332 fpfuncs_var="${fpbit_var}_FUNCS"
333 eval fpbit=\$$fpbit_var
334 eval fpfuncs=\$$fpfuncs_var
336 if [ "$fpbit" ] ; then
337 for name in $fpfuncs; do
338 case "$name" in
339 # _sf_to_tf and _df_to_tf require tp-bit.c
340 # being compiled in.
341 _[sd]f_to_tf) [ -z "$TPBIT" ] && continue;;
342 esac
343 if [ "$libgcc_s_so" ]; then
344 out="libgcc/${dir}/${name}${objext}"
345 outS="libgcc/${dir}/${name}_s${objext}"
347 echo $outS: $fpbit $fpbit_c_dep
348 echo " $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
349 -c $fpbit -o $outS
351 echo $out: $fpbit $fpbit_c_dep
352 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
353 '$(vis_hide)' -c $fpbit -o $out
355 echo $libgcc_a: $out
356 echo $libgcc_s_so: $outS
357 if [ "$SHLIB_MKMAP" ]; then
358 echo libgcc/${dir}/libgcc.map: $outS
360 else
361 out="libgcc/${dir}/${name}${objext}"
362 echo $out: $fpbit $fpbit_c_dep
363 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
364 -c $fpbit -o $out
366 echo $libgcc_a: $out
368 done
370 done
372 if [ "@enable_decimal_float@" = "yes" -a -z "$libgcc_so" ]; then
373 # If $DFP_ENABLE is set, then we want all data type sizes.
374 if [ "$DFP_ENABLE" ] ; then
375 D32PBIT=1; D64PBIT=1; D128PBIT=1
378 # Bring in the DFP support code if D32PBIT, D64PBIT or D128PBIT are set.
379 if [ -n "$D32PBIT" -o -n "$D64PBIT" -o -n "$D128PBIT" ] ; then
380 dec_filenames="decContext decNumber decRound decLibrary decUtility"
383 # Only bring in decimal*.c files for types we support.
384 if [ -n "$D32PBIT" ] ; then
385 dec_filenames="$dec_filenames decimal32"
387 if [ -n "$D64PBIT" ] ; then
388 dec_filenames="$dec_filenames decimal64"
390 if [ -n "$D128PBIT" ] ; then
391 dec_filenames="$dec_filenames decimal128"
394 for name in $dec_filenames ; do
395 out="libgcc/${dir}/${name}${objext}"
396 echo $out: "\$(srcdir)/../libdecnumber/${name}.c" $decnumber_dep
397 echo " $gcc_compile" $flags -c "\$(srcdir)/../libdecnumber/${name}.c" -o $out
398 echo $libgcc_a: $out
399 done
401 # For individual functions, loop over each variable by name.
402 for dpbit_var in D32PBIT D64PBIT D128PBIT ; do
403 dpfuncs_var="${dpbit_var}_FUNCS"
404 eval dpbit=\$$dpbit_var
405 eval dpfuncs=\$$dpfuncs_var
406 case "$dpbit_var" in
407 D32PBIT) dpwidth=32 ;;
408 D64PBIT) dpwidth=64 ;;
409 D128PBIT) dpwidth=128 ;;
410 esac
412 if [ "$dpbit" ]; then
413 for name in $dpfuncs; do
414 out="libgcc/${dir}/${name}${objext}"
415 echo $out: config/dfp-bit.h config/dfp-bit.c $fpbit_c_dep
416 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name -DWIDTH=$dpwidth \
417 $DFP_CFLAGS -c $\(srcdir\)/config/dfp-bit.c -o $out
418 echo $libgcc_a: $out
419 done
421 done
424 for file in $LIB2ADD; do
425 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
426 oname=`echo $name | sed -e 's,.*/,,'`
428 if [ "$libgcc_s_so" ]; then
429 out="libgcc/${dir}/${oname}${objext}"
430 outS="libgcc/${dir}/${oname}_s${objext}"
432 case $file in
433 *.c)
434 echo $outS: stmp-dirs $file $libgcc_dep
435 echo " $gcc_s_compile" $flags -c $file -o $outS
437 echo $out: stmp-dirs $file $libgcc_dep
438 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
441 *.asm | *.S)
442 outV="libgcc/${dir}/${oname}.vis"
444 echo $outS: stmp-dirs $file $libgcc_dep
445 echo " $gcc_s_compile" $flags -xassembler-with-cpp \
446 -c $file -o $outS
448 echo $out: stmp-dirs $file $libgcc_dep $outV
449 echo " $gcc_compile" $flags -xassembler-with-cpp \
450 -include $outV -c $file -o $out
451 echo "${outV}: ${outS}; \$(gen-hide-list)"
455 echo "Unhandled extension: $file" >&2
456 exit 1
458 esac
460 echo $libgcc_a: $out
461 echo $libgcc_s_so: $outS
462 if [ "$SHLIB_MKMAP" ]; then
463 echo libgcc/${dir}/libgcc.map: $outS
465 else
466 out="libgcc/${dir}/${oname}${objext}"
467 case $file in
468 *.c)
469 echo $out: stmp-dirs $file $libgcc_dep
470 echo " $gcc_compile" $flags -c $file -o $out
473 *.asm | *.S)
474 echo $out: stmp-dirs $file $libgcc_dep
475 echo " $gcc_compile" $flags -xassembler-with-cpp \
476 -c $file -o $out
480 echo "Unhandled extension: $file" >&2
481 exit 1
483 esac
485 echo $libgcc_a: $out
487 done
490 for file in $LIB2ADD_ST; do
491 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
492 oname=`echo $name | sed -e 's,.*/,,'`
493 out="libgcc/${dir}/${oname}${objext}"
495 case $file in
496 *.c)
497 echo $out: stmp-dirs $file $libgcc_dep
498 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
501 *.asm | *.S)
502 # We may have to compile it twice in order to establish the list
503 # of symbols to be marked hidden.
504 if [ "$libgcc_so" ]; then
505 outV="libgcc/${dir}/${oname}.vis"
506 outT="libgcc/${dir}/${oname}_t${objext}"
507 echo ${outT}: stmp-dirs $file $libgcc_dep
508 echo " $gcc_compile" $flags -xassembler-with-cpp \
509 -c $file -o ${outT}
510 echo $out: stmp-dirs $file $libgcc_dep $outV
511 echo " $gcc_compile" $flags -xassembler-with-cpp \
512 -include $outV -c $file -o $out
513 echo "${outV}: ${outT}; \$(gen-hide-list)"
514 else
515 echo $out: stmp-dirs $file $libgcc_dep
516 echo " $gcc_compile" $flags -xassembler-with-cpp \
517 -c $file -o $out
522 echo "Unhandled extension: $file" >&2
523 exit 1
525 esac
526 echo $libgcc_a: $out
527 done
529 # If we don't have libgcc_eh.a, only LIB2ADDEH matters. If we do, only
530 # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter. (Usually all three are
531 # identical.)
533 if [ "$libgcc_eh_a" ]; then
534 for file in $LIB2ADDEHSTATIC; do
535 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
536 oname=`echo $name | sed -e 's,.*/,,'`
537 out="libgcc/${dir}/${oname}${objext}"
539 case $file in
540 *.c)
541 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
542 echo " $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
544 *.asm | *.S)
545 # We have to compile it twice in order to establish the list
546 # of symbols to be marked hidden.
547 outV="libgcc/${dir}/${oname}.vis"
548 outT="libgcc/${dir}/${oname}_t${objext}"
549 echo ${outT}: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
550 echo " $gcc_compile" $flags -xassembler-with-cpp \
551 -c $file -o ${outT}
552 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep $outV
553 echo " $gcc_compile" $flags -xassembler-with-cpp \
554 -include $outV -c $file -o $out
555 echo "${outV}: ${outT}; \$(gen-hide-list)"
557 *) echo "Unhandled extension: $file">&2; exit 1 ;;
558 esac
560 echo $libgcc_eh_a: $out
561 done
563 for file in $LIB2ADDEHSHARED; do
564 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
565 oname=`echo $name | sed -e 's,.*/,,'`
566 outS="libgcc/${dir}/${oname}_s${objext}"
568 case $file in
569 *.c)
570 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
571 echo " $gcc_s_compile" $flags -fexceptions -c $file -o $outS
573 *.asm | *.S)
574 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
575 echo " $gcc_s_compile" $flags -xassembler-with-cpp -c $file -o $outS
577 *) echo "Unhandled extension: $file">&2; exit 1 ;;
578 esac
580 echo $libgcc_s_so: $outS
581 if [ "$SHLIB_MKMAP" ]; then
582 echo libgcc/${dir}/libgcc.map: $outS
584 done
586 # If nothing went into libgcc_eh.a, create a dummy object -
587 # some linkers don't like totally empty archives.
588 if [ -z "$LIB2ADDEHSTATIC" ]; then
589 file=eh_dummy.c
590 out="libgcc/${dir}/eh_dummy${objext}"
591 need_eh_dummy=1
593 echo $out: stmp-dirs $file
594 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
595 echo $libgcc_eh_a: $out
599 else # no libgcc_eh.a
600 for file in $LIB2ADDEH; do
601 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
602 oname=`echo $name | sed -e 's,.*/,,'`
603 out="libgcc/${dir}/${oname}${objext}"
605 case $file in
606 *.c)
607 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
608 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
610 *.asm | *.S)
611 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
612 echo " $gcc_compile" $flags -xassembler-with-cpp \
613 -c $file -o $out
615 *) echo "Unhandled extension: $file">&2; exit 1 ;;
616 esac
618 echo $libgcc_a: $out
619 done
622 # We do _not_ handle assembly files in this context.
623 if [ "$LIBUNWIND" ]; then
624 for file in $LIBUNWIND; do
625 case $file in
626 *.c) ;;
627 *) echo "Unhandled extension: $file">&2; exit 1 ;;
628 esac
630 name=`echo $file | sed -e 's/[.]c$//'`
631 oname=`echo $name | sed -e 's,.*/,,'`
633 if [ "$libunwind_so" ]; then
634 out="libgcc/${dir}/${oname}${objext}"
635 outS="libgcc/${dir}/${oname}_s${objext}"
637 echo $out: stmp-dirs $file $LIBUNWINDDEP
638 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
640 echo $outS: stmp-dirs $file $LIBUNWINDDEP
641 echo " $gcc_s_compile $flags -fexceptions -c $file -o $outS"
643 echo $libunwind_a: $out
644 echo $libunwind_so: $outS
645 else
646 out="libgcc/${dir}/${oname}${objext}"
647 echo $out: stmp-dirs $file $LIBUNWINDDEP
648 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
649 echo $libunwind_a: $out
651 done
655 # build libgcov components
657 for name in $LIBGCOV; do
658 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
659 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
660 out="libgcc/${dir}/${name}${objext}"
662 echo $out: $libgcov_c_dep
663 echo " $gcc_compile $flags -DL$name -c \$(srcdir)/libgcov.c -o $out"
664 echo $libgcov_a: $out
665 done
667 # EXTRA_MULTILIB_PARTS.
668 if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
669 # Each of the EXTRA_MULTILIB_PARTS is built by recursive invocation
670 # of the parent Makefile. We must do this just once for each
671 # multilib, passing it all the EXTRA_MULTILIB_PARTS as
672 # simultaneous goal targets, so that rules which cannot execute
673 # simultaneously are properly serialized.
675 extra=
676 echo
677 for f in $EXTRA_MULTILIB_PARTS; do
678 case $dir in
679 .) out=$f ; t= ;;
680 *) out=$dir/$f ; t=$dir/ ;;
681 esac
682 case $out in
683 # Prevent `make' from interpreting $out as a macro assignment
684 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
685 *) targ=$out ;;
686 esac
687 extra="$extra $targ"
688 done
690 if [ "$dir" = . ]; then
691 suffix=
692 else
693 suffix=`echo $dir | sed s,/,_,g`
695 echo extra$suffix: stmp-dirs
696 echo " $make_compile" \\
697 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
698 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $extra
699 echo "all: extra$suffix"
701 # Make libunwind.so and libgcc_s.so depend on these, since they
702 # are likely to be implicitly used by the link process.
703 if [ "$libgcc_s_so" ]; then
704 echo "$libgcc_s_so: extra$suffix"
706 if [ "$libunwind_so" ]; then
707 echo "$libunwind_so: extra$suffix"
711 # Library build rules.
712 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
713 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
715 # Map-file generation.
716 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
717 mapfile="libgcc/${dir}/libgcc.map"
718 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
719 # This uses a here document instead of echos because some shells
720 # will convert the \1 in the second sed command to a control-A.
721 # The behavior of here documents is more predictable.
722 cat <<EOF
724 ${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES
725 { \$(NM_FOR_TARGET) $SHLIB_NM_FLAGS \$(objects); echo %%; \\
726 cat $SHLIB_MAPFILES \\
727 | sed -e '/^[ ]*#/d' \\
728 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \\
729 | $gcc_compile $flags -E -xassembler-with-cpp -; \\
730 } | \$(AWK) -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}
731 mv '$tmpmapfile' \$@
732 $libgcc_s_so: ${mapfile}
736 # Static libraries.
738 # Each of these .a files depends on stmp-dirs. It would seem that
739 # this dependency is redundant, since each of the object files
740 # itself depends on stmp-dirs. However, it is possible that there
741 # are in fact no object files. In that case, the stmp-dirs
742 # dependency is required; the directory containing the archive must
743 # exist before the archive itself can be created.
744 echo ""
745 echo "$libgcc_a: stmp-dirs"
746 echo " -rm -f $libgcc_a"
747 echo ' $(AR_CREATE_FOR_TARGET)' $libgcc_a '$(objects)'
748 echo ' $(RANLIB_FOR_TARGET)' $libgcc_a
749 echo "all: $libgcc_a"
751 echo ""
752 echo "$libgcov_a: stmp-dirs"
753 echo " -rm -f $libgcov_a"
754 echo ' $(AR_CREATE_FOR_TARGET)' $libgcov_a '$(objects)'
755 echo ' $(RANLIB_FOR_TARGET)' $libgcov_a
756 echo "all: $libgcov_a"
758 # These libraries are not always built.
759 if [ "$libunwind_a" ]; then
760 echo ""
761 echo "$libunwind_a: stmp-dirs"
762 echo " -rm -f $libunwind_a"
763 echo ' $(AR_CREATE_FOR_TARGET)' $libunwind_a '$(objects)'
764 echo ' $(RANLIB_FOR_TARGET)' $libunwind_a
765 echo "all: $libunwind_a"
768 if [ "$libgcc_eh_a" ]; then
769 echo ""
770 echo "${dir}/libgcc_eh.a: stmp-dirs"
771 echo " -rm -f ${dir}/libgcc_eh.a"
772 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a '$(objects)'
773 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
774 echo "all: $libgcc_eh_a"
777 # Shared libraries.
778 if [ "$libgcc_s_so" ]; then
779 echo ""
780 echo "$libgcc_s_so: stmp-dirs $libunwind_so"
781 echo " $SHLIB_LINK" \
782 | sed -e "s%@multilib_flags@%$flags%g" \
783 -e "s%@multilib_dir@%$dir%g" \
784 -e "s%@shlib_objs@%\$(objects)%g" \
785 -e "s%@shlib_base_name@%libgcc_s%g" \
786 -e "s%@shlib_map_file@%$mapfile%g" \
787 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
788 echo "all: $libgcc_s_so"
791 if [ "$libunwind_so" ]; then
792 echo ""
793 echo "$libunwind_so: stmp-dirs"
794 echo " $SHLIBUNWIND_LINK" \
795 | sed -e "s%@multilib_flags@%$flags%g" \
796 -e "s%@multilib_dir@%$dir%g" \
797 -e "s%@shlib_objs@%\$(objects)%g" \
798 -e "s%@shlib_base_name@%libunwind%g" \
799 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
800 echo "all: $libunwind_so"
803 done # ml in MULTILIBS
805 echo
806 echo "libgcc-stage-start:"
807 echo " for dir in \$(dirs); do \\"
808 echo " if [ -d \$(stage)/\$\$dir ]; then :; \\"
809 echo " else $mkinstalldirs \$(stage)/\$\$dir; fi; \\"
810 echo " done"
811 echo " -for dir in \$(dirs); do \\"
812 echo " mv \$\$dir/*${objext} \$(stage)/\$\$dir; \\"
813 echo " mv \$\$dir/*.vis \$(stage)/\$\$dir; \\"
814 echo " mv \$\$dir/*.map \$(stage)/\$\$dir; \\"
815 echo " test ! -f \$\$dir/libgcc.a || mv \$\$dir/lib* \$(stage)/\$\$dir; \\"
816 echo " done"
818 echo
819 echo "stmp-dirs:"
820 echo " for d in \$(dirs); do \\"
821 echo " if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
822 echo " done"
823 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
825 if [ "$need_eh_dummy" ]; then
826 echo "eh_dummy.c:"
827 echo " echo 'int __libgcc_eh_dummy;' > \$@"
830 echo ""
831 echo "install: all"
832 for ml in $MULTILIBS; do
833 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
834 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
835 if [ $dir != . ]; then
836 ldir='$(DESTDIR)$(libsubdir)'/$dir
837 echo " if [ -d $ldir ]; then true; else $mkinstalldirs $ldir; chmod a+rx $ldir; fi;"
838 else
839 ldir='$(DESTDIR)$(libsubdir)'
841 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
842 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
843 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a ${ldir}/
844 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
846 if [ "$SHLIB_LINK" ]; then
847 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
848 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
850 shlib_slibdir_qual=
851 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
852 if [ "$os_multilib_dir" != . ]; then
853 shlib_slibdir_qual="/$os_multilib_dir"
855 echo " $SHLIB_INSTALL" \
856 | sed -e "s%@multilib_dir@%$dir%g" \
857 -e "s%@shlib_base_name@%libgcc_s%g" \
858 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
859 if [ "$LIBUNWIND" ]; then
860 echo " $SHLIBUNWIND_INSTALL" \
861 | sed -e "s%@multilib_dir@%$dir%g" \
862 -e "s%@shlib_base_name@%libunwind%g" \
863 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
864 libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
865 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
866 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
869 done
870 for f in $EXTRA_MULTILIB_PARTS; do
871 for ml in $MULTILIBS; do
872 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
873 if [ $dir != . ]; then
874 out=${dir}/$f
875 ldir='$(DESTDIR)$(libsubdir)'/$dir
876 else
877 out=$f
878 ldir='$(DESTDIR)$(libsubdir)'
880 echo ' $(INSTALL_DATA)' $out $ldir/
881 done
882 done
884 echo '.PHONY: all install'