gcc/
[official-gcc.git] / gcc / mklibgcc.in
blobbf320d9e5538e5bef243465d4d8d55070be5953b
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 # DFP_ENABLE
30 # DFP_CFLAGS
31 # DPBIT
32 # DPBIT_FUNCS
33 # TPBIT
34 # TPBIT_FUNCS
35 # D32PBIT
36 # D32PBIT_FUNCS
37 # D64PBIT
38 # D64PBIT_FUNCS
39 # D128PBIT
40 # D128PBIT_FUNCS
41 # LIBGCC
42 # MULTILIBS
43 # EXTRA_MULTILIB_PARTS
44 # SHLIB_EXT
45 # SHLIB_LINK
46 # SHLIB_MKMAP
47 # SHLIB_MKMAP_OPTS
48 # SHLIB_MAPFILES
49 # SHLIB_NM_FLAGS
50 # SHLIB_INSTALL
51 # MULTILIB_OSDIRNAMES
52 # ASM_HIDDEN_OP
53 # GCC_FOR_TARGET
55 # Make needs VPATH to be literal.
56 echo 'srcdir = @srcdir@'
57 echo 'VPATH = @srcdir@'
58 echo 'EQ = ='
59 echo 'objects = $(filter %'$objext',$^)'
60 echo
61 echo '# Dependencies are accumulated as we go.'
62 echo 'all: stmp-dirs'
63 echo 'dirs = libgcc'
64 echo
66 # Library members defined in libgcc2.c.
67 lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
68 _cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi
69 _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi
70 _floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf _clear_cache
71 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3
72 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
73 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
74 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
75 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
76 _divxc3 _divtc3 _floatundidf _floatundisf _floatundixf _floatunditf'
78 # Disable SHLIB_LINK if shared libgcc not enabled.
79 if [ "@enable_shared@" = "no" ]; then
80 SHLIB_LINK=""
83 # Build lines.
85 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
86 gcc_s_compile="$gcc_compile -DSHARED"
87 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
88 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
89 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
90 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
91 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
92 CC="$(CC)" CFLAGS="$(CFLAGS)" \
93 BUILD_PREFIX="$(BUILD_PREFIX)" \
94 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
95 LANGUAGES="$(LANGUAGES)"'
97 # Generic dependencies for libgcc
98 libgcc_dep='$(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h config.status stmp-int-hdrs tsystem.h'
100 # Dependencies for libgcc2.c
101 libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(srcdir)/libgcc2.h gbl-ctors.h'" $libgcc_dep"
103 # Dependencies for libgcov.c
104 libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h'" $libgcc_dep"
106 # Dependencies for fp-bit.c
107 fpbit_c_dep='stmp-dirs config.status tsystem.h'
109 # Dependencies for decnumber and friends. This is an overzealous set,
110 # but at least we can be sure to recompile if anything gets modified.
111 decnumber_dep='stmp-dirs $(srcdir)/../libdecnumber/decContext.h $(srcdir)/../libdecnumber/decNumber.h
112 $(srcdir)/../libdecnumber/decNumberLocal.h $(srcdir)/../libdecnumber/decimal32.h $(srcdir)/../libdecnumber/decimal64.h
113 $(srcdir)/../libdecnumber/decimal128.h $(srcdir)/../libdecnumber/decDPD.h $(srcdir)/../libdecnumber/decUtility.h'
115 # Flag whether we need eh_dummy.c
116 need_eh_dummy=
118 if [ "$SHLIB_LINK" ]; then
119 # Test -fvisibility=hidden. We need both a -fvisibility=hidden on
120 # the command line, and a #define to prevent libgcc2.h etc from
121 # overriding that with #pragmas. The dance with @ is to prevent
122 # echo from seeing anything it might take for an option.
123 # echo turns the \$\$\$\$ into $$$$ and when make sees it it
124 # becomes $$ and the shell substitutes the pid. Makes for a
125 # slightly safer temp file.
126 echo "vis_hide := \$(strip \$(subst @,-,\\"
127 echo " \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
128 echo " $gcc_compile -fvisibility=hidden -Werror \\"
129 echo " -c -xc - -o vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
130 echo " then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
131 echo " rm vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
132 echo " fi)))"
133 echo
135 # If we have -fvisibility=hidden, then we need to generate hide
136 # lists for object files implemented in assembly. The default
137 # pseudo-op for this is ".hidden", but can be overridden with
138 # ASM_HIDDEN_OP.
139 [ "$ASM_HIDDEN_OP" ] || ASM_HIDDEN_OP=".hidden"
141 echo "ifneq (,\$(vis_hide))"
142 echo "define gen-hide-list"
143 echo "\$(NM_FOR_TARGET) ${SHLIB_NM_FLAGS} \$< | \\"
144 # non-GNU nm emits three fields even for undefined and typeless symbols,
145 # so explicitly omit them
146 echo " \$(AWK) 'NF == 3 && \$\$2 !~ /^[UN]\$\$/ { print \"\\t${ASM_HIDDEN_OP}\", \$\$3 }' > \$@T"
147 echo "mv -f \$@T \$@"
148 echo "endef"
149 echo "else"
150 echo "gen-hide-list = echo > \$@"
151 echo "endif"
152 echo
153 else
154 # It is too hard to guarantee that vis_hide and gen-hide-list will never
155 # be referenced if SHLIB_LINK is not set, so set them to the values they'd
156 # have if SHLIB_LINK were set and we didn't have visibility support.
157 echo "vis_hide ="
158 echo "gen-hide-list = echo > \$@"
161 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
162 # defined as optimized assembly code in LIB1ASMFUNCS or as C code
163 # in LIB2FUNCS_EXCLUDE.
164 for name in $LIB1ASMFUNCS $LIB2FUNCS_EXCLUDE; do
165 lib2funcs=`echo $lib2funcs | sed -e 's/^'$name' //' \
166 -e 's/ '$name' / /' \
167 -e 's/ '$name'$//'`
168 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
169 -e 's/ '$name' / /' \
170 -e 's/ '$name'$//'`
171 done
174 # Rules to generate object files.
177 for ml in $MULTILIBS; do
179 # Work out relevant parameters that depend only on the multilib.
180 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
181 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
182 shlib_slibdir_qual=
183 libgcc_a=$dir/libgcc.a
184 libgcov_a=$dir/libgcov.a
185 libgcc_eh_a=
186 libgcc_s_so=
187 libunwind_a=
188 libunwind_so=
190 if [ "$LIBUNWIND" ]; then
191 libunwind_a=$dir/libunwind.a
193 if [ "$SHLIB_LINK" ]; then
194 libgcc_eh_a=$dir/libgcc_eh.a
195 libgcc_s_so=$dir/libgcc_s${SHLIB_EXT}
196 if [ "$LIBUNWIND" ]; then
197 libunwind_so=$dir/libunwind${SHLIB_EXT}
199 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
200 if [ "$os_multilib_dir" != . ]; then
201 shlib_slibdir_qual="/$os_multilib_dir"
205 libgcc_s_so_extra=
206 libunwind_so_extra=
208 echo
209 echo \#
210 echo \# ml: $ml
211 echo \# dir: $dir
212 echo \# flags: $flags
213 echo \# libgcc_a: $libgcc_a
214 echo \# libgcov_a: $libgcov_a
215 echo \# libgcc_eh_a: $libgcc_eh_a
216 echo \# libunwind_a: $libunwind_a
217 echo \#
218 echo \# shlib_slibdir_qual: $shlib_slibdir_qual
219 echo \# libgcc_s_so: $libgcc_s_so
220 echo \# libunwind_so: $libunwind_so
221 echo \#
222 echo
224 # Update list of directories.
225 if [ $dir != . ]; then
226 echo "dirs += ${dir} libgcc/${dir}"
227 echo
231 # Build libgcc1 components.
233 for name in $LIB1ASMFUNCS; do
234 if [ "$libgcc_s_so" ]; then
235 out="libgcc/${dir}/${name}${objext}"
236 outS="libgcc/${dir}/${name}_s${objext}"
237 outV="libgcc/${dir}/${name}.vis"
239 echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
240 echo " $gcc_s_compile" $flags -DL$name -xassembler-with-cpp \
241 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
243 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
244 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
245 -c '$(srcdir)/config/$(LIB1ASMSRC)' -include $outV -o $out
247 echo "${outV}: ${outS}; \$(gen-hide-list)"
249 echo $libgcc_a: $out
250 echo $libgcc_s_so: $outS
251 if [ "$SHLIB_MKMAP" ]; then
252 echo libgcc/${dir}/libgcc.map: $outS
254 else
255 out="libgcc/${dir}/${name}${objext}"
256 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
257 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
258 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
259 echo $libgcc_a: $out
261 done
264 # Build libgcc2 components.
267 for name in $lib2funcs; do
268 if [ "$libgcc_s_so" ]; then
269 out="libgcc/${dir}/${name}${objext}"
270 outS="libgcc/${dir}/${name}_s${objext}"
272 echo $outS: $libgcc2_c_dep
273 echo " $gcc_s_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' \
274 -o $outS
276 echo $out: $libgcc2_c_dep
277 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
278 -c '$(srcdir)/libgcc2.c' -o $out
280 echo $libgcc_a: $out
281 echo $libgcc_s_so: $outS
282 if [ "$SHLIB_MKMAP" ]; then
283 echo libgcc/${dir}/libgcc.map: $outS
285 else
286 out="libgcc/${dir}/${name}${objext}"
287 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
288 echo " $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
289 echo $libgcc_a: $out
291 done
293 for name in $LIB2FUNCS_ST; do
294 out="libgcc/${dir}/${name}${objext}"
296 echo $out: $libgcc2_c_dep
297 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
298 -c '$(srcdir)/libgcc2.c' -o $out
299 echo ${dir}/libgcc.a: $out
300 done
302 for name in $LIB2_DIVMOD_FUNCS; do
303 if [ "$libgcc_s_so" ]; then
304 out="libgcc/${dir}/${name}${objext}"
305 outS="libgcc/${dir}/${name}_s${objext}"
307 echo $outS: $libgcc2_c_dep
308 echo " $gcc_s_compile" $flags -DL$name \
309 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
311 echo $out: $libgcc2_c_dep
312 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
313 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
315 echo $libgcc_a: $out
316 echo $libgcc_s_so: $outS
317 if [ "$SHLIB_MKMAP" ]; then
318 echo libgcc/${dir}/libgcc.map: $outS
320 else
321 out="libgcc/${dir}/${name}${objext}"
322 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
323 echo " $gcc_compile" $flags -DL$name \
324 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
325 echo $libgcc_a: $out
327 done
330 # Build software floating point functions.
333 for fpbit_var in FPBIT DPBIT TPBIT ; do
334 fpfuncs_var="${fpbit_var}_FUNCS"
335 eval fpbit=\$$fpbit_var
336 eval fpfuncs=\$$fpfuncs_var
338 if [ "$fpbit" ] ; then
339 for name in $fpfuncs; do
340 case "$name" in
341 # _sf_to_tf and _df_to_tf require tp-bit.c
342 # being compiled in.
343 _[sd]f_to_tf) [ -z "$TPBIT" ] && continue;;
344 esac
345 if [ "$libgcc_s_so" ]; then
346 out="libgcc/${dir}/${name}${objext}"
347 outS="libgcc/${dir}/${name}_s${objext}"
349 echo $outS: $fpbit $fpbit_c_dep
350 echo " $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
351 -c $fpbit -o $outS
353 echo $out: $fpbit $fpbit_c_dep
354 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
355 '$(vis_hide)' -c $fpbit -o $out
357 echo $libgcc_a: $out
358 echo $libgcc_s_so: $outS
359 if [ "$SHLIB_MKMAP" ]; then
360 echo libgcc/${dir}/libgcc.map: $outS
362 else
363 out="libgcc/${dir}/${name}${objext}"
364 echo $out: $fpbit $fpbit_c_dep
365 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
366 -c $fpbit -o $out
368 echo $libgcc_a: $out
370 done
372 done
374 if [ "@enable_decimal_float@" = "yes" -a -z "$libgcc_so" ]; then
375 # If $DFP_ENABLE is set, then we want all data type sizes.
376 if [ "$DFP_ENABLE" ] ; then
377 D32PBIT=1; D64PBIT=1; D128PBIT=1
380 # Bring in the DFP support code if D32PBIT, D64PBIT or D128PBIT are set.
381 if [ -n "$D32PBIT" -o -n "$D64PBIT" -o -n "$D128PBIT" ] ; then
382 dec_filenames="decContext decNumber decRound decLibrary decUtility"
385 # Only bring in decimal*.c files for types we support.
386 if [ -n "$D32PBIT" ] ; then
387 dec_filenames="$dec_filenames decimal32"
389 if [ -n "$D64PBIT" ] ; then
390 dec_filenames="$dec_filenames decimal64"
392 if [ -n "$D128PBIT" ] ; then
393 dec_filenames="$dec_filenames decimal128"
396 for name in $dec_filenames ; do
397 out="libgcc/${dir}/${name}${objext}"
398 echo $out: "\$(srcdir)/../libdecnumber/${name}.c" $decnumber_dep
399 echo " $gcc_compile" $flags -c "\$(srcdir)/../libdecnumber/${name}.c" -o $out
400 echo $libgcc_a: $out
401 done
403 # For individual functions, loop over each variable by name.
404 for dpbit_var in D32PBIT D64PBIT D128PBIT ; do
405 dpfuncs_var="${dpbit_var}_FUNCS"
406 eval dpbit=\$$dpbit_var
407 eval dpfuncs=\$$dpfuncs_var
408 case "$dpbit_var" in
409 D32PBIT) dpwidth=32 ;;
410 D64PBIT) dpwidth=64 ;;
411 D128PBIT) dpwidth=128 ;;
412 esac
414 if [ "$dpbit" ]; then
415 for name in $dpfuncs; do
416 out="libgcc/${dir}/${name}${objext}"
417 echo $out: config/dfp-bit.h config/dfp-bit.c $fpbit_c_dep
418 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name -DWIDTH=$dpwidth \
419 $DFP_CFLAGS -c $\(srcdir\)/config/dfp-bit.c -o $out
420 echo $libgcc_a: $out
421 done
423 done
426 for file in $LIB2ADD; do
427 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
428 oname=`echo $name | sed -e 's,.*/,,'`
430 if [ "$libgcc_s_so" ]; then
431 out="libgcc/${dir}/${oname}${objext}"
432 outS="libgcc/${dir}/${oname}_s${objext}"
434 case $file in
435 *.c)
436 echo $outS: stmp-dirs $file $libgcc_dep
437 echo " $gcc_s_compile" $flags -c $file -o $outS
439 echo $out: stmp-dirs $file $libgcc_dep
440 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
443 *.asm | *.S)
444 outV="libgcc/${dir}/${oname}.vis"
446 echo $outS: stmp-dirs $file $libgcc_dep
447 echo " $gcc_s_compile" $flags -xassembler-with-cpp \
448 -c $file -o $outS
450 echo $out: stmp-dirs $file $libgcc_dep $outV
451 echo " $gcc_compile" $flags -xassembler-with-cpp \
452 -include $outV -c $file -o $out
453 echo "${outV}: ${outS}; \$(gen-hide-list)"
457 echo "Unhandled extension: $file" >&2
458 exit 1
460 esac
462 echo $libgcc_a: $out
463 echo $libgcc_s_so: $outS
464 if [ "$SHLIB_MKMAP" ]; then
465 echo libgcc/${dir}/libgcc.map: $outS
467 else
468 out="libgcc/${dir}/${oname}${objext}"
469 case $file in
470 *.c)
471 echo $out: stmp-dirs $file $libgcc_dep
472 echo " $gcc_compile" $flags -c $file -o $out
475 *.asm | *.S)
476 echo $out: stmp-dirs $file $libgcc_dep
477 echo " $gcc_compile" $flags -xassembler-with-cpp \
478 -c $file -o $out
482 echo "Unhandled extension: $file" >&2
483 exit 1
485 esac
487 echo $libgcc_a: $out
489 done
492 for file in $LIB2ADD_ST; do
493 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
494 oname=`echo $name | sed -e 's,.*/,,'`
495 out="libgcc/${dir}/${oname}${objext}"
497 case $file in
498 *.c)
499 echo $out: stmp-dirs $file $libgcc_dep
500 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
503 *.asm | *.S)
504 # We may have to compile it twice in order to establish the list
505 # of symbols to be marked hidden.
506 if [ "$libgcc_so" ]; then
507 outV="libgcc/${dir}/${oname}.vis"
508 outT="libgcc/${dir}/${oname}_t${objext}"
509 echo ${outT}: stmp-dirs $file $libgcc_dep
510 echo " $gcc_compile" $flags -xassembler-with-cpp \
511 -c $file -o ${outT}
512 echo $out: stmp-dirs $file $libgcc_dep $outV
513 echo " $gcc_compile" $flags -xassembler-with-cpp \
514 -include $outV -c $file -o $out
515 echo "${outV}: ${outT}; \$(gen-hide-list)"
516 else
517 echo $out: stmp-dirs $file $libgcc_dep
518 echo " $gcc_compile" $flags -xassembler-with-cpp \
519 -c $file -o $out
524 echo "Unhandled extension: $file" >&2
525 exit 1
527 esac
528 echo $libgcc_a: $out
529 done
531 # If we don't have libgcc_eh.a, only LIB2ADDEH matters. If we do, only
532 # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter. (Usually all three are
533 # identical.)
535 if [ "$libgcc_eh_a" ]; then
536 for file in $LIB2ADDEHSTATIC; do
537 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
538 oname=`echo $name | sed -e 's,.*/,,'`
539 out="libgcc/${dir}/${oname}${objext}"
541 case $file in
542 *.c)
543 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
544 echo " $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
546 *.asm | *.S)
547 # We have to compile it twice in order to establish the list
548 # of symbols to be marked hidden.
549 outV="libgcc/${dir}/${oname}.vis"
550 outT="libgcc/${dir}/${oname}_t${objext}"
551 echo ${outT}: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
552 echo " $gcc_compile" $flags -xassembler-with-cpp \
553 -c $file -o ${outT}
554 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep $outV
555 echo " $gcc_compile" $flags -xassembler-with-cpp \
556 -include $outV -c $file -o $out
557 echo "${outV}: ${outT}; \$(gen-hide-list)"
559 *) echo "Unhandled extension: $file">&2; exit 1 ;;
560 esac
562 echo $libgcc_eh_a: $out
563 done
565 for file in $LIB2ADDEHSHARED; do
566 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
567 oname=`echo $name | sed -e 's,.*/,,'`
568 outS="libgcc/${dir}/${oname}_s${objext}"
570 case $file in
571 *.c)
572 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
573 echo " $gcc_s_compile" $flags -fexceptions -c $file -o $outS
575 *.asm | *.S)
576 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
577 echo " $gcc_s_compile" $flags -xassembler-with-cpp -c $file -o $outS
579 *) echo "Unhandled extension: $file">&2; exit 1 ;;
580 esac
582 echo $libgcc_s_so: $outS
583 if [ "$SHLIB_MKMAP" ]; then
584 echo libgcc/${dir}/libgcc.map: $outS
586 done
588 # If nothing went into libgcc_eh.a, create a dummy object -
589 # some linkers don't like totally empty archives.
590 if [ -z "$LIB2ADDEHSTATIC" ]; then
591 file=eh_dummy.c
592 out="libgcc/${dir}/eh_dummy${objext}"
593 need_eh_dummy=1
595 echo $out: stmp-dirs $file
596 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
597 echo $libgcc_eh_a: $out
601 else # no libgcc_eh.a
602 for file in $LIB2ADDEH; do
603 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
604 oname=`echo $name | sed -e 's,.*/,,'`
605 out="libgcc/${dir}/${oname}${objext}"
607 case $file in
608 *.c)
609 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
610 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
612 *.asm | *.S)
613 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
614 echo " $gcc_compile" $flags -xassembler-with-cpp \
615 -c $file -o $out
617 *) echo "Unhandled extension: $file">&2; exit 1 ;;
618 esac
620 echo $libgcc_a: $out
621 done
624 # We do _not_ handle assembly files in this context.
625 if [ "$LIBUNWIND" ]; then
626 for file in $LIBUNWIND; do
627 case $file in
628 *.c) ;;
629 *) echo "Unhandled extension: $file">&2; exit 1 ;;
630 esac
632 name=`echo $file | sed -e 's/[.]c$//'`
633 oname=`echo $name | sed -e 's,.*/,,'`
635 if [ "$libunwind_so" ]; then
636 out="libgcc/${dir}/${oname}${objext}"
637 outS="libgcc/${dir}/${oname}_s${objext}"
639 echo $out: stmp-dirs $file $LIBUNWINDDEP
640 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
642 echo $outS: stmp-dirs $file $LIBUNWINDDEP
643 echo " $gcc_s_compile $flags -fexceptions -c $file -o $outS"
645 echo $libunwind_a: $out
646 echo $libunwind_so: $outS
647 else
648 out="libgcc/${dir}/${oname}${objext}"
649 echo $out: stmp-dirs $file $LIBUNWINDDEP
650 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
651 echo $libunwind_a: $out
653 done
657 # build libgcov components
659 for name in $LIBGCOV; do
660 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
661 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
662 out="libgcc/${dir}/${name}${objext}"
664 echo $out: $libgcov_c_dep
665 echo " $gcc_compile $flags -DL$name -c \$(srcdir)/libgcov.c -o $out"
666 echo $libgcov_a: $out
667 done
669 # EXTRA_MULTILIB_PARTS.
670 if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
671 # Each of the EXTRA_MULTILIB_PARTS is built by recursive invocation
672 # of the parent Makefile. We must do this just once for each
673 # multilib, passing it all the EXTRA_MULTILIB_PARTS as
674 # simultaneous goal targets, so that rules which cannot execute
675 # simultaneously are properly serialized.
677 extra=
678 echo
679 for f in $EXTRA_MULTILIB_PARTS; do
680 case $dir in
681 .) out=$f ; t= ;;
682 *) out=$dir/$f ; t=$dir/ ;;
683 esac
684 case $out in
685 # Prevent `make' from interpreting $out as a macro assignment
686 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
687 *) targ=$out ;;
688 esac
689 extra="$extra $targ"
690 done
692 if [ "$dir" = . ]; then
693 suffix=
694 else
695 suffix=`echo $dir | sed s,/,_,g`
697 echo extra$suffix: stmp-dirs
698 echo " $make_compile" \\
699 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
700 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $extra
701 echo "all: extra$suffix"
703 # Make libunwind.so and libgcc_s.so depend on these, since they
704 # are likely to be implicitly used by the link process.
705 if [ "$libgcc_s_so" ]; then
706 echo "$libgcc_s_so: extra$suffix"
708 if [ "$libunwind_so" ]; then
709 echo "$libunwind_so: extra$suffix"
713 # Library build rules.
714 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
715 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
717 # Map-file generation.
718 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
719 mapfile="libgcc/${dir}/libgcc.map"
720 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
721 # This uses a here document instead of echos because some shells
722 # will convert the \1 in the second sed command to a control-A.
723 # The behavior of here documents is more predictable.
724 cat <<EOF
726 ${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES
727 { \$(NM_FOR_TARGET) $SHLIB_NM_FLAGS \$(objects); echo %%; \\
728 cat $SHLIB_MAPFILES \\
729 | sed -e '/^[ ]*#/d' \\
730 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \\
731 | $gcc_compile $flags -E -xassembler-with-cpp -; \\
732 } | \$(AWK) -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}
733 mv '$tmpmapfile' \$@
734 $libgcc_s_so: ${mapfile}
738 # Static libraries.
740 # Each of these .a files depends on stmp-dirs. It would seem that
741 # this dependency is redundant, since each of the object files
742 # itself depends on stmp-dirs. However, it is possible that there
743 # are in fact no object files. In that case, the stmp-dirs
744 # dependency is required; the directory containing the archive must
745 # exist before the archive itself can be created.
746 echo ""
747 echo "$libgcc_a: stmp-dirs"
748 echo " -rm -f $libgcc_a"
749 echo ' $(AR_CREATE_FOR_TARGET)' $libgcc_a '$(objects)'
750 echo ' $(RANLIB_FOR_TARGET)' $libgcc_a
751 echo "all: $libgcc_a"
753 echo ""
754 echo "$libgcov_a: stmp-dirs"
755 echo " -rm -f $libgcov_a"
756 echo ' $(AR_CREATE_FOR_TARGET)' $libgcov_a '$(objects)'
757 echo ' $(RANLIB_FOR_TARGET)' $libgcov_a
758 echo "all: $libgcov_a"
760 # These libraries are not always built.
761 if [ "$libunwind_a" ]; then
762 echo ""
763 echo "$libunwind_a: stmp-dirs"
764 echo " -rm -f $libunwind_a"
765 echo ' $(AR_CREATE_FOR_TARGET)' $libunwind_a '$(objects)'
766 echo ' $(RANLIB_FOR_TARGET)' $libunwind_a
767 echo "all: $libunwind_a"
770 if [ "$libgcc_eh_a" ]; then
771 echo ""
772 echo "${dir}/libgcc_eh.a: stmp-dirs"
773 echo " -rm -f ${dir}/libgcc_eh.a"
774 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a '$(objects)'
775 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
776 echo "all: $libgcc_eh_a"
779 # Shared libraries.
780 if [ "$libgcc_s_so" ]; then
781 echo ""
782 echo "$libgcc_s_so: stmp-dirs $libunwind_so"
783 echo " $SHLIB_LINK" \
784 | sed -e "s%@multilib_flags@%$flags%g" \
785 -e "s%@multilib_dir@%$dir%g" \
786 -e "s%@shlib_objs@%\$(objects)%g" \
787 -e "s%@shlib_base_name@%libgcc_s%g" \
788 -e "s%@shlib_map_file@%$mapfile%g" \
789 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
790 echo "all: $libgcc_s_so"
793 if [ "$libunwind_so" ]; then
794 echo ""
795 echo "$libunwind_so: stmp-dirs"
796 echo " $SHLIBUNWIND_LINK" \
797 | sed -e "s%@multilib_flags@%$flags%g" \
798 -e "s%@multilib_dir@%$dir%g" \
799 -e "s%@shlib_objs@%\$(objects)%g" \
800 -e "s%@shlib_base_name@%libunwind%g" \
801 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
802 echo "all: $libunwind_so"
805 done # ml in MULTILIBS
807 echo
808 echo "libgcc-stage-start:"
809 echo " for dir in \$(dirs); do \\"
810 echo " if [ -d \$(stage)/\$\$dir ]; then :; \\"
811 echo " else $mkinstalldirs \$(stage)/\$\$dir; fi; \\"
812 echo " done"
813 echo " -for dir in \$(dirs); do \\"
814 echo " mv \$\$dir/*${objext} \$(stage)/\$\$dir; \\"
815 echo " mv \$\$dir/*.vis \$(stage)/\$\$dir; \\"
816 echo " mv \$\$dir/*.map \$(stage)/\$\$dir; \\"
817 echo " test ! -f \$\$dir/libgcc.a || mv \$\$dir/lib* \$(stage)/\$\$dir; \\"
818 echo " done"
820 echo
821 echo "stmp-dirs:"
822 echo " for d in \$(dirs); do \\"
823 echo " if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
824 echo " done"
825 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
827 if [ "$need_eh_dummy" ]; then
828 echo "eh_dummy.c:"
829 echo " echo 'int __libgcc_eh_dummy;' > \$@"
832 echo ""
833 echo "install: all"
834 for ml in $MULTILIBS; do
835 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
836 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
837 if [ $dir != . ]; then
838 ldir='$(DESTDIR)$(libsubdir)'/$dir
839 echo " if [ -d $ldir ]; then true; else $mkinstalldirs $ldir; chmod a+rx $ldir; fi;"
840 else
841 ldir='$(DESTDIR)$(libsubdir)'
843 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
844 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
845 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a ${ldir}/
846 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
848 if [ "$SHLIB_LINK" ]; then
849 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
850 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
852 shlib_slibdir_qual=
853 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
854 if [ "$os_multilib_dir" != . ]; then
855 shlib_slibdir_qual="/$os_multilib_dir"
857 echo " $SHLIB_INSTALL" \
858 | sed -e "s%@multilib_dir@%$dir%g" \
859 -e "s%@shlib_base_name@%libgcc_s%g" \
860 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
861 if [ "$LIBUNWIND" ]; then
862 echo " $SHLIBUNWIND_INSTALL" \
863 | sed -e "s%@multilib_dir@%$dir%g" \
864 -e "s%@shlib_base_name@%libunwind%g" \
865 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
866 libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
867 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
868 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
871 done
872 for f in $EXTRA_MULTILIB_PARTS; do
873 for ml in $MULTILIBS; do
874 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
875 if [ $dir != . ]; then
876 out=${dir}/$f
877 ldir='$(DESTDIR)$(libsubdir)'/$dir
878 else
879 out=$f
880 ldir='$(DESTDIR)$(libsubdir)'
882 echo ' $(INSTALL_DATA)' $out $ldir/
883 done
884 done
886 echo '.PHONY: all install'