Daily bump.
[official-gcc.git] / gcc / mklibgcc.in
blob8987ff9a2ade26bf22c70c6f88297461234d742b
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 # LIB2FUNCS_EXCLUDE
15 # LIBGCOV
16 # LIB2ADD
17 # LIB2ADD_ST
18 # LIB2ADDEH
19 # LIB2ADDEHSTATIC
20 # LIB2ADDEHSHARED
21 # LIB2ADDEHDEP
22 # LIBUNWIND
23 # LIBUNWINDDEP
24 # SHLIBUNWIND_LINK
25 # SHLIBUNWIND_INSTALL
26 # FPBIT
27 # FPBIT_FUNCS
28 # LIB2_DIVMOD_FUNCS
29 # LIB2_SIDITI_CONV_FUNCS
30 # DFP_ENABLE
31 # DFP_CFLAGS
32 # DPBIT
33 # DPBIT_FUNCS
34 # TPBIT
35 # TPBIT_FUNCS
36 # D32PBIT
37 # D32PBIT_FUNCS
38 # D64PBIT
39 # D64PBIT_FUNCS
40 # D128PBIT
41 # D128PBIT_FUNCS
42 # LIBGCC
43 # MULTILIBS
44 # EXTRA_MULTILIB_PARTS
45 # SHLIB_EXT
46 # SHLIB_LINK
47 # SHLIB_MKMAP
48 # SHLIB_MKMAP_OPTS
49 # SHLIB_MAPFILES
50 # SHLIB_NM_FLAGS
51 # SHLIB_INSTALL
52 # MULTILIB_OSDIRNAMES
53 # ASM_HIDDEN_OP
54 # GCC_FOR_TARGET
56 # Make needs VPATH to be literal.
57 echo 'srcdir = @srcdir@'
58 echo 'VPATH = @srcdir@'
59 echo 'EQ = ='
60 echo 'objects = $(filter %'$objext',$^)'
61 echo
62 echo '# Dependencies are accumulated as we go.'
63 echo 'all: stmp-dirs'
64 echo 'dirs = libgcc'
65 echo
67 # Library members defined in libgcc2.c.
69 # The floating-point conversion routines that involve a single-word integer.
70 # XX stands for the integer mode.
71 swfloatfuncs=
72 for mode in sf df xf; do
73 swfloatfuncs="$swfloatfuncs _fixuns${mode}XX"
74 done
76 # Likewise double-word routines.
77 dwfloatfuncs=
78 for mode in sf df xf tf; do
79 dwfloatfuncs="$dwfloatfuncs _fix${mode}XX _fixuns${mode}XX"
80 dwfloatfuncs="$dwfloatfuncs _floatXX${mode} _floatunXX${mode}"
81 done
83 # Entries of the form <objfile>:<func>:<wordsize> indicate that libgcc2.c
84 # should be compiled with L<func> defined and with LIBGCC2_UNITS_PER_WORD
85 # set to <wordsize>. <objfile> is the name of the associated object file
87 lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
88 _cmpdi2 _ucmpdi2 _clear_cache
89 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3
90 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
91 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
92 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
93 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
94 _divxc3 _divtc3 _bswapsi2 _bswapdi2'
96 if [ "$LIB2_SIDITI_CONV_FUNCS" ]; then
97 for func in $swfloatfuncs; do
98 sifunc=`echo $func | sed -e 's/XX/si/'`
99 lib2funcs="$lib2funcs $sifunc:$sifunc:4"
100 done
101 for func in $dwfloatfuncs; do
102 difunc=`echo $func | sed -e 's/XX/di/'`
103 tifunc=`echo $func | sed -e 's/XX/ti/'`
104 lib2funcs="$lib2funcs $difunc:$difunc:4 $tifunc:$difunc:8"
105 done
106 else
107 lib2funcs="$lib2funcs `echo $swfloatfuncs | sed -e 's/XX/si/g'`"
108 lib2funcs="$lib2funcs `echo $dwfloatfuncs | sed -e 's/XX/di/g'`"
111 # Disable SHLIB_LINK if shared libgcc not enabled.
112 if [ "@enable_shared@" = "no" ]; then
113 SHLIB_LINK=""
116 # Build lines.
118 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
119 gcc_s_compile="$gcc_compile -DSHARED"
120 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
121 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
122 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
123 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
124 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
125 CC="$(CC)" CFLAGS="$(CFLAGS)" \
126 BUILD_PREFIX="$(BUILD_PREFIX)" \
127 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
128 LANGUAGES="$(LANGUAGES)"'
130 # Generic dependencies for libgcc
131 libgcc_dep='$(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h config.status stmp-int-hdrs tsystem.h'
133 # Dependencies for libgcc2.c
134 libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(srcdir)/libgcc2.h gbl-ctors.h'" $libgcc_dep"
136 # Dependencies for libgcov.c
137 libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h'" $libgcc_dep"
139 # Dependencies for fp-bit.c
140 fpbit_c_dep='stmp-dirs config.status tsystem.h'
142 # Dependencies for decnumber and friends. This is an overzealous set,
143 # but at least we can be sure to recompile if anything gets modified.
144 decnumber_dep='stmp-dirs $(srcdir)/../libdecnumber/decContext.h $(srcdir)/../libdecnumber/decNumber.h
145 $(srcdir)/../libdecnumber/decNumberLocal.h $(srcdir)/../libdecnumber/decimal32.h $(srcdir)/../libdecnumber/decimal64.h
146 $(srcdir)/../libdecnumber/decimal128.h $(srcdir)/../libdecnumber/decDPD.h $(srcdir)/../libdecnumber/decUtility.h'
148 # Dependencies for dfp-bit.c
149 dfpbit_c_dep='$(srcdir)/../libdecnumber/decRound.h'" $libgcc_dep $decnumber_dep"
151 # Flag whether we need eh_dummy.c
152 need_eh_dummy=
154 if [ "$SHLIB_LINK" ]; then
155 # Test -fvisibility=hidden. We need both a -fvisibility=hidden on
156 # the command line, and a #define to prevent libgcc2.h etc from
157 # overriding that with #pragmas. The dance with @ is to prevent
158 # echo from seeing anything it might take for an option.
159 # echo turns the \$\$\$\$ into $$$$ and when make sees it it
160 # becomes $$ and the shell substitutes the pid. Makes for a
161 # slightly safer temp file.
162 echo "vis_hide := \$(strip \$(subst @,-,\\"
163 echo " \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
164 echo " $gcc_compile -fvisibility=hidden -Werror \\"
165 echo " -c -xc - -o vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
166 echo " then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
167 echo " rm vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
168 echo " fi)))"
169 echo
171 # If we have -fvisibility=hidden, then we need to generate hide
172 # lists for object files implemented in assembly. The default
173 # pseudo-op for this is ".hidden", but can be overridden with
174 # ASM_HIDDEN_OP.
175 [ "$ASM_HIDDEN_OP" ] || ASM_HIDDEN_OP=".hidden"
177 echo "ifneq (,\$(vis_hide))"
178 echo "define gen-hide-list"
179 echo "\$(NM_FOR_TARGET) ${SHLIB_NM_FLAGS} \$< | \\"
180 # non-GNU nm emits three fields even for undefined and typeless symbols,
181 # so explicitly omit them
182 echo " \$(AWK) 'NF == 3 && \$\$2 !~ /^[UN]\$\$/ { print \"\\t${ASM_HIDDEN_OP}\", \$\$3 }' > \$@T"
183 echo "mv -f \$@T \$@"
184 echo "endef"
185 echo "else"
186 echo "gen-hide-list = echo > \$@"
187 echo "endif"
188 echo
189 else
190 # It is too hard to guarantee that vis_hide and gen-hide-list will never
191 # be referenced if SHLIB_LINK is not set, so set them to the values they'd
192 # have if SHLIB_LINK were set and we didn't have visibility support.
193 echo "vis_hide ="
194 echo "gen-hide-list = echo > \$@"
197 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
198 # defined as optimized assembly code in LIB1ASMFUNCS or as C code
199 # in LIB2FUNCS_EXCLUDE.
200 for name in $LIB1ASMFUNCS $LIB2FUNCS_EXCLUDE; do
201 lib2funcs=`echo $lib2funcs | sed -e 's/^'$name'[ :]//' \
202 -e 's/ '$name'[ :]/ /' \
203 -e 's/ '$name'$//'`
204 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
205 -e 's/ '$name' / /' \
206 -e 's/ '$name'$//'`
207 done
210 # Rules to generate object files.
213 for ml in $MULTILIBS; do
215 # Work out relevant parameters that depend only on the multilib.
216 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
217 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
218 shlib_slibdir_qual=
219 libgcc_a=$dir/libgcc.a
220 libgcov_a=$dir/libgcov.a
221 libgcc_eh_a=
222 libgcc_s_so=
223 libunwind_a=
224 libunwind_so=
226 if [ "$LIBUNWIND" ]; then
227 libunwind_a=$dir/libunwind.a
229 if [ "$SHLIB_LINK" ]; then
230 libgcc_eh_a=$dir/libgcc_eh.a
231 libgcc_s_so=$dir/libgcc_s${SHLIB_EXT}
232 if [ "$LIBUNWIND" ]; then
233 libunwind_so=$dir/libunwind${SHLIB_EXT}
235 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
236 if [ "$os_multilib_dir" != . ]; then
237 shlib_slibdir_qual="/$os_multilib_dir"
241 libgcc_s_so_extra=
242 libunwind_so_extra=
244 echo
245 echo \#
246 echo \# ml: $ml
247 echo \# dir: $dir
248 echo \# flags: $flags
249 echo \# libgcc_a: $libgcc_a
250 echo \# libgcov_a: $libgcov_a
251 echo \# libgcc_eh_a: $libgcc_eh_a
252 echo \# libunwind_a: $libunwind_a
253 echo \#
254 echo \# shlib_slibdir_qual: $shlib_slibdir_qual
255 echo \# libgcc_s_so: $libgcc_s_so
256 echo \# libunwind_so: $libunwind_so
257 echo \#
258 echo
260 # Update list of directories.
261 if [ $dir != . ]; then
262 echo "dirs += ${dir} libgcc/${dir}"
263 echo
267 # Build libgcc1 components.
269 for name in $LIB1ASMFUNCS; do
270 if [ "$libgcc_s_so" ]; then
271 out="libgcc/${dir}/${name}${objext}"
272 outS="libgcc/${dir}/${name}_s${objext}"
273 outV="libgcc/${dir}/${name}.vis"
275 echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
276 echo " $gcc_s_compile" $flags -DL$name -xassembler-with-cpp \
277 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
279 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
280 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
281 -c '$(srcdir)/config/$(LIB1ASMSRC)' -include $outV -o $out
283 echo "${outV}: ${outS}; \$(gen-hide-list)"
285 echo $libgcc_a: $out
286 echo $libgcc_s_so: $outS
287 if [ "$SHLIB_MKMAP" ]; then
288 echo libgcc/${dir}/libgcc.map: $outS
290 else
291 out="libgcc/${dir}/${name}${objext}"
292 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
293 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
294 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
295 echo $libgcc_a: $out
297 done
300 # Build libgcc2 components.
303 for name in $lib2funcs; do
304 case $name in
305 *:*:*)
306 defines=`echo $name | sed -e 's/.*:\(.*\):\(.*\)/-DL\1 -DLIBGCC2_UNITS_PER_WORD=\2/'`
307 name=`echo $name | sed -e 's/\(.*\):.*:.*/\1/'`
310 defines="-DL$name"
312 esac
313 if [ "$libgcc_s_so" ]; then
314 out="libgcc/${dir}/${name}${objext}"
315 outS="libgcc/${dir}/${name}_s${objext}"
317 echo $outS: $libgcc2_c_dep
318 echo " $gcc_s_compile" $flags $defines -c '$(srcdir)/libgcc2.c' \
319 -o $outS
321 echo $out: $libgcc2_c_dep
322 echo " $gcc_compile" $flags $defines '$(vis_hide)' \
323 -c '$(srcdir)/libgcc2.c' -o $out
325 echo $libgcc_a: $out
326 echo $libgcc_s_so: $outS
327 if [ "$SHLIB_MKMAP" ]; then
328 echo libgcc/${dir}/libgcc.map: $outS
330 else
331 out="libgcc/${dir}/${name}${objext}"
332 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
333 echo " $gcc_compile" $flags $defines -c '$(srcdir)/libgcc2.c' -o $out
334 echo $libgcc_a: $out
336 done
338 for name in $LIB2FUNCS_ST; do
339 out="libgcc/${dir}/${name}${objext}"
341 echo $out: $libgcc2_c_dep
342 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
343 -c '$(srcdir)/libgcc2.c' -o $out
344 echo ${dir}/libgcc.a: $out
345 done
347 for name in $LIB2_DIVMOD_FUNCS; do
348 if [ "$libgcc_s_so" ]; then
349 out="libgcc/${dir}/${name}${objext}"
350 outS="libgcc/${dir}/${name}_s${objext}"
352 echo $outS: $libgcc2_c_dep
353 echo " $gcc_s_compile" $flags -DL$name \
354 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
356 echo $out: $libgcc2_c_dep
357 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
358 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
360 echo $libgcc_a: $out
361 echo $libgcc_s_so: $outS
362 if [ "$SHLIB_MKMAP" ]; then
363 echo libgcc/${dir}/libgcc.map: $outS
365 else
366 out="libgcc/${dir}/${name}${objext}"
367 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
368 echo " $gcc_compile" $flags -DL$name \
369 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
370 echo $libgcc_a: $out
372 done
375 # Build software floating point functions.
378 for fpbit_var in FPBIT DPBIT TPBIT ; do
379 fpfuncs_var="${fpbit_var}_FUNCS"
380 eval fpbit=\$$fpbit_var
381 eval fpfuncs=\$$fpfuncs_var
383 if [ "$fpbit" ] ; then
384 for name in $fpfuncs; do
385 case "$name" in
386 # _sf_to_tf and _df_to_tf require tp-bit.c
387 # being compiled in.
388 _[sd]f_to_tf) [ -z "$TPBIT" ] && continue;;
389 esac
390 if [ "$libgcc_s_so" ]; then
391 out="libgcc/${dir}/${name}${objext}"
392 outS="libgcc/${dir}/${name}_s${objext}"
394 echo $outS: $fpbit $fpbit_c_dep
395 echo " $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
396 -c $fpbit -o $outS
398 echo $out: $fpbit $fpbit_c_dep
399 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
400 '$(vis_hide)' -c $fpbit -o $out
402 echo $libgcc_a: $out
403 echo $libgcc_s_so: $outS
404 if [ "$SHLIB_MKMAP" ]; then
405 echo libgcc/${dir}/libgcc.map: $outS
407 else
408 out="libgcc/${dir}/${name}${objext}"
409 echo $out: $fpbit $fpbit_c_dep
410 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
411 -c $fpbit -o $out
413 echo $libgcc_a: $out
415 done
417 done
419 if [ "@enable_decimal_float@" = "yes" -a -z "$libgcc_so" ]; then
420 # If $DFP_ENABLE is set, then we want all data type sizes.
421 if [ "$DFP_ENABLE" ] ; then
422 D32PBIT=1; D64PBIT=1; D128PBIT=1
425 # Bring in the DFP support code if D32PBIT, D64PBIT or D128PBIT are set.
426 if [ -n "$D32PBIT" -o -n "$D64PBIT" -o -n "$D128PBIT" ] ; then
427 dec_filenames="decContext decNumber decRound decLibrary decUtility"
430 # Only bring in decimal*.c files for types we support.
431 if [ -n "$D32PBIT" ] ; then
432 dec_filenames="$dec_filenames decimal32"
434 if [ -n "$D64PBIT" ] ; then
435 dec_filenames="$dec_filenames decimal64"
437 if [ -n "$D128PBIT" ] ; then
438 dec_filenames="$dec_filenames decimal128"
441 for name in $dec_filenames ; do
442 out="libgcc/${dir}/${name}${objext}"
443 echo $out: "\$(srcdir)/../libdecnumber/${name}.c" $decnumber_dep
444 echo " $gcc_compile" $flags -c "\$(srcdir)/../libdecnumber/${name}.c" -o $out
445 echo $libgcc_a: $out
446 done
448 # For individual functions, loop over each variable by name.
449 for dpbit_var in D32PBIT D64PBIT D128PBIT ; do
450 dpfuncs_var="${dpbit_var}_FUNCS"
451 eval dpbit=\$$dpbit_var
452 eval dpfuncs=\$$dpfuncs_var
453 case "$dpbit_var" in
454 D32PBIT) dpwidth=32 ;;
455 D64PBIT) dpwidth=64 ;;
456 D128PBIT) dpwidth=128 ;;
457 esac
459 if [ "$dpbit" ]; then
460 for name in $dpfuncs; do
461 out="libgcc/${dir}/${name}${objext}"
462 echo $out: config/dfp-bit.h config/dfp-bit.c $dfpbit_c_dep
463 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name -DWIDTH=$dpwidth \
464 $DFP_CFLAGS -c $\(srcdir\)/config/dfp-bit.c -o $out
465 echo $libgcc_a: $out
466 done
468 done
471 for file in $LIB2ADD; do
472 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
473 oname=`echo $name | sed -e 's,.*/,,'`
475 if [ "$libgcc_s_so" ]; then
476 out="libgcc/${dir}/${oname}${objext}"
477 outS="libgcc/${dir}/${oname}_s${objext}"
479 case $file in
480 *.c)
481 echo $outS: stmp-dirs $file $libgcc_dep
482 echo " $gcc_s_compile" $flags -c $file -o $outS
484 echo $out: stmp-dirs $file $libgcc_dep
485 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
488 *.asm | *.S)
489 outV="libgcc/${dir}/${oname}.vis"
491 echo $outS: stmp-dirs $file $libgcc_dep
492 echo " $gcc_s_compile" $flags -xassembler-with-cpp \
493 -c $file -o $outS
495 echo $out: stmp-dirs $file $libgcc_dep $outV
496 echo " $gcc_compile" $flags -xassembler-with-cpp \
497 -include $outV -c $file -o $out
498 echo "${outV}: ${outS}; \$(gen-hide-list)"
502 echo "Unhandled extension: $file" >&2
503 exit 1
505 esac
507 echo $libgcc_a: $out
508 echo $libgcc_s_so: $outS
509 if [ "$SHLIB_MKMAP" ]; then
510 echo libgcc/${dir}/libgcc.map: $outS
512 else
513 out="libgcc/${dir}/${oname}${objext}"
514 case $file in
515 *.c)
516 echo $out: stmp-dirs $file $libgcc_dep
517 echo " $gcc_compile" $flags -c $file -o $out
520 *.asm | *.S)
521 echo $out: stmp-dirs $file $libgcc_dep
522 echo " $gcc_compile" $flags -xassembler-with-cpp \
523 -c $file -o $out
527 echo "Unhandled extension: $file" >&2
528 exit 1
530 esac
532 echo $libgcc_a: $out
534 done
537 for file in $LIB2ADD_ST; do
538 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
539 oname=`echo $name | sed -e 's,.*/,,'`
540 out="libgcc/${dir}/${oname}${objext}"
542 case $file in
543 *.c)
544 echo $out: stmp-dirs $file $libgcc_dep
545 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
548 *.asm | *.S)
549 # We may have to compile it twice in order to establish the list
550 # of symbols to be marked hidden.
551 if [ "$libgcc_so" ]; then
552 outV="libgcc/${dir}/${oname}.vis"
553 outT="libgcc/${dir}/${oname}_t${objext}"
554 echo ${outT}: stmp-dirs $file $libgcc_dep
555 echo " $gcc_compile" $flags -xassembler-with-cpp \
556 -c $file -o ${outT}
557 echo $out: stmp-dirs $file $libgcc_dep $outV
558 echo " $gcc_compile" $flags -xassembler-with-cpp \
559 -include $outV -c $file -o $out
560 echo "${outV}: ${outT}; \$(gen-hide-list)"
561 else
562 echo $out: stmp-dirs $file $libgcc_dep
563 echo " $gcc_compile" $flags -xassembler-with-cpp \
564 -c $file -o $out
569 echo "Unhandled extension: $file" >&2
570 exit 1
572 esac
573 echo $libgcc_a: $out
574 done
576 # If we don't have libgcc_eh.a, only LIB2ADDEH matters. If we do, only
577 # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter. (Usually all three are
578 # identical.)
580 if [ "$libgcc_eh_a" ]; then
581 for file in $LIB2ADDEHSTATIC; do
582 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
583 oname=`echo $name | sed -e 's,.*/,,'`
584 out="libgcc/${dir}/${oname}${objext}"
586 case $file in
587 *.c)
588 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
589 echo " $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
591 *.asm | *.S)
592 # We have to compile it twice in order to establish the list
593 # of symbols to be marked hidden.
594 outV="libgcc/${dir}/${oname}.vis"
595 outT="libgcc/${dir}/${oname}_t${objext}"
596 echo ${outT}: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
597 echo " $gcc_compile" $flags -xassembler-with-cpp \
598 -c $file -o ${outT}
599 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep $outV
600 echo " $gcc_compile" $flags -xassembler-with-cpp \
601 -include $outV -c $file -o $out
602 echo "${outV}: ${outT}; \$(gen-hide-list)"
604 *) echo "Unhandled extension: $file">&2; exit 1 ;;
605 esac
607 echo $libgcc_eh_a: $out
608 done
610 for file in $LIB2ADDEHSHARED; do
611 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
612 oname=`echo $name | sed -e 's,.*/,,'`
613 outS="libgcc/${dir}/${oname}_s${objext}"
615 case $file in
616 *.c)
617 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
618 echo " $gcc_s_compile" $flags -fexceptions -c $file -o $outS
620 *.asm | *.S)
621 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
622 echo " $gcc_s_compile" $flags -xassembler-with-cpp -c $file -o $outS
624 *) echo "Unhandled extension: $file">&2; exit 1 ;;
625 esac
627 echo $libgcc_s_so: $outS
628 if [ "$SHLIB_MKMAP" ]; then
629 echo libgcc/${dir}/libgcc.map: $outS
631 done
633 # If nothing went into libgcc_eh.a, create a dummy object -
634 # some linkers don't like totally empty archives.
635 if [ -z "$LIB2ADDEHSTATIC" ]; then
636 file=eh_dummy.c
637 out="libgcc/${dir}/eh_dummy${objext}"
638 need_eh_dummy=1
640 echo $out: stmp-dirs $file
641 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
642 echo $libgcc_eh_a: $out
646 else # no libgcc_eh.a
647 for file in $LIB2ADDEH; do
648 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
649 oname=`echo $name | sed -e 's,.*/,,'`
650 out="libgcc/${dir}/${oname}${objext}"
652 case $file in
653 *.c)
654 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
655 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
657 *.asm | *.S)
658 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
659 echo " $gcc_compile" $flags -xassembler-with-cpp \
660 -c $file -o $out
662 *) echo "Unhandled extension: $file">&2; exit 1 ;;
663 esac
665 echo $libgcc_a: $out
666 done
669 # We do _not_ handle assembly files in this context.
670 if [ "$LIBUNWIND" ]; then
671 for file in $LIBUNWIND; do
672 case $file in
673 *.c) ;;
674 *) echo "Unhandled extension: $file">&2; exit 1 ;;
675 esac
677 name=`echo $file | sed -e 's/[.]c$//'`
678 oname=`echo $name | sed -e 's,.*/,,'`
680 if [ "$libunwind_so" ]; then
681 out="libgcc/${dir}/${oname}${objext}"
682 outS="libgcc/${dir}/${oname}_s${objext}"
684 echo $out: stmp-dirs $file $LIBUNWINDDEP
685 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
687 echo $outS: stmp-dirs $file $LIBUNWINDDEP
688 echo " $gcc_s_compile $flags -fexceptions -c $file -o $outS"
690 echo $libunwind_a: $out
691 echo $libunwind_so: $outS
692 else
693 out="libgcc/${dir}/${oname}${objext}"
694 echo $out: stmp-dirs $file $LIBUNWINDDEP
695 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
696 echo $libunwind_a: $out
698 done
702 # build libgcov components
704 for name in $LIBGCOV; do
705 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
706 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
707 out="libgcc/${dir}/${name}${objext}"
709 echo $out: $libgcov_c_dep
710 echo " $gcc_compile $flags -DL$name -c \$(srcdir)/libgcov.c -o $out"
711 echo $libgcov_a: $out
712 done
714 # EXTRA_MULTILIB_PARTS.
715 if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
716 # Each of the EXTRA_MULTILIB_PARTS is built by recursive invocation
717 # of the parent Makefile. We must do this just once for each
718 # multilib, passing it all the EXTRA_MULTILIB_PARTS as
719 # simultaneous goal targets, so that rules which cannot execute
720 # simultaneously are properly serialized.
722 extra=
723 echo
724 for f in $EXTRA_MULTILIB_PARTS; do
725 case $dir in
726 .) out=$f ; t= ;;
727 *) out=$dir/$f ; t=$dir/ ;;
728 esac
729 case $out in
730 # Prevent `make' from interpreting $out as a macro assignment
731 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
732 *) targ=$out ;;
733 esac
734 extra="$extra $targ"
735 done
737 if [ "$dir" = . ]; then
738 suffix=
739 else
740 suffix=`echo $dir | sed s,/,_,g`
742 echo extra$suffix: stmp-dirs
743 echo " $make_compile" \\
744 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
745 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $extra
746 echo "all: extra$suffix"
748 # Make libunwind.so and libgcc_s.so depend on these, since they
749 # are likely to be implicitly used by the link process.
750 if [ "$libgcc_s_so" ]; then
751 echo "$libgcc_s_so: extra$suffix"
753 if [ "$libunwind_so" ]; then
754 echo "$libunwind_so: extra$suffix"
758 # Library build rules.
759 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
760 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
762 # Map-file generation.
763 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
764 mapfile="libgcc/${dir}/libgcc.map"
765 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
766 # This uses a here document instead of echos because some shells
767 # will convert the \1 in the second sed command to a control-A.
768 # The behavior of here documents is more predictable.
769 cat <<EOF
771 ${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES
772 { \$(NM_FOR_TARGET) $SHLIB_NM_FLAGS \$(objects); echo %%; \\
773 cat $SHLIB_MAPFILES \\
774 | sed -e '/^[ ]*#/d' \\
775 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \\
776 | $gcc_compile $flags -E -xassembler-with-cpp -; \\
777 } | \$(AWK) -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}
778 mv '$tmpmapfile' \$@
779 $libgcc_s_so: ${mapfile}
783 # Static libraries.
785 # Each of these .a files depends on stmp-dirs. It would seem that
786 # this dependency is redundant, since each of the object files
787 # itself depends on stmp-dirs. However, it is possible that there
788 # are in fact no object files. In that case, the stmp-dirs
789 # dependency is required; the directory containing the archive must
790 # exist before the archive itself can be created.
791 echo ""
792 echo "$libgcc_a: stmp-dirs"
793 echo " -rm -f $libgcc_a"
794 echo ' $(AR_CREATE_FOR_TARGET)' $libgcc_a '$(objects)'
795 echo ' $(RANLIB_FOR_TARGET)' $libgcc_a
796 echo "all: $libgcc_a"
798 echo ""
799 echo "$libgcov_a: stmp-dirs"
800 echo " -rm -f $libgcov_a"
801 echo ' $(AR_CREATE_FOR_TARGET)' $libgcov_a '$(objects)'
802 echo ' $(RANLIB_FOR_TARGET)' $libgcov_a
803 echo "all: $libgcov_a"
805 # These libraries are not always built.
806 if [ "$libunwind_a" ]; then
807 echo ""
808 echo "$libunwind_a: stmp-dirs"
809 echo " -rm -f $libunwind_a"
810 echo ' $(AR_CREATE_FOR_TARGET)' $libunwind_a '$(objects)'
811 echo ' $(RANLIB_FOR_TARGET)' $libunwind_a
812 echo "all: $libunwind_a"
815 if [ "$libgcc_eh_a" ]; then
816 echo ""
817 echo "${dir}/libgcc_eh.a: stmp-dirs"
818 echo " -rm -f ${dir}/libgcc_eh.a"
819 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a '$(objects)'
820 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
821 echo "all: $libgcc_eh_a"
824 # Shared libraries.
825 if [ "$libgcc_s_so" ]; then
826 echo ""
827 echo "$libgcc_s_so: stmp-dirs $libunwind_so"
828 echo " $SHLIB_LINK" \
829 | sed -e "s%@multilib_flags@%$flags%g" \
830 -e "s%@multilib_dir@%$dir%g" \
831 -e "s%@shlib_objs@%\$(objects)%g" \
832 -e "s%@shlib_base_name@%libgcc_s%g" \
833 -e "s%@shlib_map_file@%$mapfile%g" \
834 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
835 echo "all: $libgcc_s_so"
838 if [ "$libunwind_so" ]; then
839 echo ""
840 echo "$libunwind_so: stmp-dirs"
841 echo " $SHLIBUNWIND_LINK" \
842 | sed -e "s%@multilib_flags@%$flags%g" \
843 -e "s%@multilib_dir@%$dir%g" \
844 -e "s%@shlib_objs@%\$(objects)%g" \
845 -e "s%@shlib_base_name@%libunwind%g" \
846 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
847 echo "all: $libunwind_so"
850 done # ml in MULTILIBS
852 echo
853 echo "libgcc-stage-start:"
854 echo " for dir in \$(dirs); do \\"
855 echo " if [ -d \$(stage)/\$\$dir ]; then :; \\"
856 echo " else $mkinstalldirs \$(stage)/\$\$dir; fi; \\"
857 echo " done"
858 echo " -for dir in \$(dirs); do \\"
859 echo " mv \$\$dir/*${objext} \$(stage)/\$\$dir; \\"
860 echo " mv \$\$dir/*.vis \$(stage)/\$\$dir; \\"
861 echo " mv \$\$dir/*.map \$(stage)/\$\$dir; \\"
862 echo " test ! -f \$\$dir/libgcc.a || mv \$\$dir/lib* \$(stage)/\$\$dir; \\"
863 echo " done"
865 echo
866 echo "stmp-dirs:"
867 echo " for d in \$(dirs); do \\"
868 echo " if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
869 echo " done"
870 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
872 if [ "$need_eh_dummy" ]; then
873 echo "eh_dummy.c:"
874 echo " echo 'int __libgcc_eh_dummy;' > \$@"
877 echo ""
878 echo "install: all"
879 for ml in $MULTILIBS; do
880 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
881 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
882 if [ $dir != . ]; then
883 ldir='$(DESTDIR)$(libsubdir)'/$dir
884 echo " if [ -d $ldir ]; then true; else $mkinstalldirs $ldir; chmod a+rx $ldir; fi;"
885 else
886 ldir='$(DESTDIR)$(libsubdir)'
888 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
889 echo ' chmod 644' ${ldir}/libgcc.a
890 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
891 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a ${ldir}/
892 echo ' chmod 644' ${ldir}/libgcov.a
893 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
895 if [ "$SHLIB_LINK" ]; then
896 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
897 echo ' chmod 644' ${ldir}/libgcc_eh.a
898 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
900 shlib_slibdir_qual=
901 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
902 if [ "$os_multilib_dir" != . ]; then
903 shlib_slibdir_qual="/$os_multilib_dir"
905 echo " $SHLIB_INSTALL" \
906 | sed -e "s%@multilib_dir@%$dir%g" \
907 -e "s%@shlib_base_name@%libgcc_s%g" \
908 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
909 if [ "$LIBUNWIND" ]; then
910 echo " $SHLIBUNWIND_INSTALL" \
911 | sed -e "s%@multilib_dir@%$dir%g" \
912 -e "s%@shlib_base_name@%libunwind%g" \
913 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
914 libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
915 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
916 echo ' chmod 644' ${dir}/libunwind.a
917 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
920 done
921 for f in $EXTRA_MULTILIB_PARTS; do
922 for ml in $MULTILIBS; do
923 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
924 if [ $dir != . ]; then
925 out=${dir}/$f
926 ldir='$(DESTDIR)$(libsubdir)'/$dir
927 else
928 out=$f
929 ldir='$(DESTDIR)$(libsubdir)'
931 echo ' $(INSTALL_DATA)' $out $ldir/
932 done
933 done
935 echo '.PHONY: all install'