2005-12-13 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / mklibgcc.in
blobba853636ac7df364f7f01009f8c3a5a14b564f03
1 #!/bin/sh
2 # Construct makefile for libgcc.
3 # Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 # This file is part of GCC.
7 # Arguments, taken from the environment, since there are a lot
8 # of them, and positional args becomes quite ugly.
10 # objext
11 # LIB1ASMFUNCS
12 # LIB2FUNCS_ST
13 # LIBGCOV
14 # LIB2ADD
15 # LIB2ADD_ST
16 # LIB2ADDEH
17 # LIB2ADDEHSTATIC
18 # LIB2ADDEHSHARED
19 # LIB2ADDEHDEP
20 # LIBUNWIND
21 # LIBUNWINDDEP
22 # SHLIBUNWIND_LINK
23 # SHLIBUNWIND_INSTALL
24 # FPBIT
25 # FPBIT_FUNCS
26 # LIB2_DIVMOD_FUNCS
27 # DPBIT
28 # DPBIT_FUNCS
29 # TPBIT
30 # TPBIT_FUNCS
31 # LIBGCC
32 # MULTILIBS
33 # EXTRA_MULTILIB_PARTS
34 # SHLIB_EXT
35 # SHLIB_LINK
36 # SHLIB_MKMAP
37 # SHLIB_MKMAP_OPTS
38 # SHLIB_MAPFILES
39 # SHLIB_NM_FLAGS
40 # SHLIB_INSTALL
41 # MULTILIB_OSDIRNAMES
42 # ASM_HIDDEN_OP
43 # GCC_FOR_TARGET
45 # Make needs VPATH to be literal.
46 echo 'srcdir = @srcdir@'
47 echo 'VPATH = @srcdir@'
48 echo 'EQ = ='
49 echo 'objects = $(filter %'$objext',$^)'
50 echo
51 echo '# Dependencies are accumulated as we go.'
52 echo 'all: stmp-dirs'
53 echo 'dirs = libgcc'
54 echo
56 # Library members defined in libgcc2.c.
57 lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
58 _cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi
59 _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi
60 _floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf _clear_cache
61 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3
62 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
63 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
64 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
65 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
66 _divxc3 _divtc3 _floatundidf _floatundisf _floatundixf _floatunditf'
68 # Disable SHLIB_LINK if shared libgcc not enabled.
69 if [ "@enable_shared@" = "no" ]; then
70 SHLIB_LINK=""
73 # Build lines.
75 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
76 gcc_s_compile="$gcc_compile -DSHARED"
77 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
78 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
79 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
80 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
81 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
82 CC="$(CC)" CFLAGS="$(CFLAGS)" \
83 BUILD_PREFIX="$(BUILD_PREFIX)" \
84 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
85 LANGUAGES="$(LANGUAGES)"'
87 # Generic dependencies for libgcc
88 libgcc_dep='$(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h config.status stmp-int-hdrs tsystem.h'
90 # Dependencies for libgcc2.c
91 libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(srcdir)/libgcc2.h gbl-ctors.h'" $libgcc_dep"
93 # Dependencies for libgcov.c
94 libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h'" $libgcc_dep"
96 # Dependencies for fp-bit.c
97 fpbit_c_dep='stmp-dirs config.status tsystem.h'
99 # Flag whether we need eh_dummy.c
100 need_eh_dummy=
102 if [ "$SHLIB_LINK" ]; then
103 # Test -fvisibility=hidden. We need both a -fvisibility=hidden on
104 # the command line, and a #define to prevent libgcc2.h etc from
105 # overriding that with #pragmas. The dance with @ is to prevent
106 # echo from seeing anything it might take for an option.
107 # echo turns the \$\$\$\$ into $$$$ and when make sees it it
108 # becomes $$ and the shell substitutes the pid. Makes for a
109 # slightly safer temp file.
110 echo "vis_hide := \$(strip \$(subst @,-,\\"
111 echo " \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
112 echo " $gcc_compile -fvisibility=hidden -Werror \\"
113 echo " -c -xc - -o vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
114 echo " then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
115 echo " rm vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
116 echo " fi)))"
117 echo
119 # If we have -fvisibility=hidden, then we need to generate hide
120 # lists for object files implemented in assembly. The default
121 # pseudo-op for this is ".hidden", but can be overridden with
122 # ASM_HIDDEN_OP.
123 [ "$ASM_HIDDEN_OP" ] || ASM_HIDDEN_OP=".hidden"
125 echo "ifneq (,\$(vis_hide))"
126 echo "define gen-hide-list"
127 echo "\$(NM_FOR_TARGET) ${SHLIB_NM_FLAGS} \$< | \\"
128 # non-GNU nm emits three fields even for undefined and typeless symbols,
129 # so explicitly omit them
130 echo " \$(AWK) 'NF == 3 && \$\$2 !~ /^[UN]\$\$/ { print \"\\t${ASM_HIDDEN_OP}\", \$\$3 }' > \$@T"
131 echo "mv -f \$@T \$@"
132 echo "endef"
133 echo "else"
134 echo "gen-hide-list = echo > \$@"
135 echo "endif"
136 echo
137 else
138 # It is too hard to guarantee that vis_hide and gen-hide-list will never
139 # be referenced if SHLIB_LINK is not set, so set them to the values they'd
140 # have if SHLIB_LINK were set and we didn't have visibility support.
141 echo "vis_hide ="
142 echo "gen-hide-list = echo > \$@"
145 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
146 # defined as optimized assembly code in LIB1ASMFUNCS.
147 for name in $LIB1ASMFUNCS; do
148 lib2funcs=`echo $lib2funcs | sed -e 's/^'$name' //' \
149 -e 's/ '$name' / /' \
150 -e 's/ '$name'$//'`
151 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
152 -e 's/ '$name' / /' \
153 -e 's/ '$name'$//'`
154 done
157 # Rules to generate object files.
160 for ml in $MULTILIBS; do
162 # Work out relevant parameters that depend only on the multilib.
163 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
164 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
165 shlib_slibdir_qual=
166 libgcc_a=$dir/libgcc.a
167 libgcov_a=$dir/libgcov.a
168 libgcc_eh_a=
169 libgcc_s_so=
170 libunwind_a=
171 libunwind_so=
173 if [ "$LIBUNWIND" ]; then
174 libunwind_a=$dir/libunwind.a
176 if [ "$SHLIB_LINK" ]; then
177 libgcc_eh_a=$dir/libgcc_eh.a
178 libgcc_s_so=$dir/libgcc_s${SHLIB_EXT}
179 if [ "$LIBUNWIND" ]; then
180 libunwind_so=$dir/libunwind${SHLIB_EXT}
182 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
183 if [ "$os_multilib_dir" != . ]; then
184 shlib_slibdir_qual="/$os_multilib_dir"
188 libgcc_s_so_extra=
189 libunwind_so_extra=
191 echo
192 echo \#
193 echo \# ml: $ml
194 echo \# dir: $dir
195 echo \# flags: $flags
196 echo \# libgcc_a: $libgcc_a
197 echo \# libgcov_a: $libgcov_a
198 echo \# libgcc_eh_a: $libgcc_eh_a
199 echo \# libunwind_a: $libunwind_a
200 echo \#
201 echo \# shlib_slibdir_qual: $shlib_slibdir_qual
202 echo \# libgcc_s_so: $libgcc_s_so
203 echo \# libunwind_so: $libunwind_so
204 echo \#
205 echo
207 # Update list of directories.
208 if [ $dir != . ]; then
209 echo "dirs += ${dir} libgcc/${dir}"
210 echo
214 # Build libgcc1 components.
216 for name in $LIB1ASMFUNCS; do
217 if [ "$libgcc_s_so" ]; then
218 out="libgcc/${dir}/${name}${objext}"
219 outS="libgcc/${dir}/${name}_s${objext}"
220 outV="libgcc/${dir}/${name}.vis"
222 echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
223 echo " $gcc_s_compile" $flags -DL$name -xassembler-with-cpp \
224 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
226 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
227 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
228 -c '$(srcdir)/config/$(LIB1ASMSRC)' -include $outV -o $out
230 echo "${outV}: ${outS}; \$(gen-hide-list)"
232 echo $libgcc_a: $out
233 echo $libgcc_s_so: $outS
234 if [ "$SHLIB_MKMAP" ]; then
235 echo libgcc/${dir}/libgcc.map: $outS
237 else
238 out="libgcc/${dir}/${name}${objext}"
239 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
240 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
241 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
242 echo $libgcc_a: $out
244 done
247 # Build libgcc2 components.
250 for name in $lib2funcs; do
251 if [ "$libgcc_s_so" ]; then
252 out="libgcc/${dir}/${name}${objext}"
253 outS="libgcc/${dir}/${name}_s${objext}"
255 echo $outS: $libgcc2_c_dep
256 echo " $gcc_s_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' \
257 -o $outS
259 echo $out: $libgcc2_c_dep
260 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
261 -c '$(srcdir)/libgcc2.c' -o $out
263 echo $libgcc_a: $out
264 echo $libgcc_s_so: $outS
265 if [ "$SHLIB_MKMAP" ]; then
266 echo libgcc/${dir}/libgcc.map: $outS
268 else
269 out="libgcc/${dir}/${name}${objext}"
270 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
271 echo " $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
272 echo $libgcc_a: $out
274 done
276 for name in $LIB2FUNCS_ST; do
277 out="libgcc/${dir}/${name}${objext}"
279 echo $out: $libgcc2_c_dep
280 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
281 -c '$(srcdir)/libgcc2.c' -o $out
282 echo ${dir}/libgcc.a: $out
283 done
285 for name in $LIB2_DIVMOD_FUNCS; do
286 if [ "$libgcc_s_so" ]; then
287 out="libgcc/${dir}/${name}${objext}"
288 outS="libgcc/${dir}/${name}_s${objext}"
290 echo $outS: $libgcc2_c_dep
291 echo " $gcc_s_compile" $flags -DL$name \
292 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
294 echo $out: $libgcc2_c_dep
295 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
296 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
298 echo $libgcc_a: $out
299 echo $libgcc_s_so: $outS
300 if [ "$SHLIB_MKMAP" ]; then
301 echo libgcc/${dir}/libgcc.map: $outS
303 else
304 out="libgcc/${dir}/${name}${objext}"
305 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
306 echo " $gcc_compile" $flags -DL$name \
307 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
308 echo $libgcc_a: $out
310 done
313 # Build software floating point functions.
316 for fpbit_var in FPBIT DPBIT TPBIT ; do
317 fpfuncs_var="${fpbit_var}_FUNCS"
318 eval fpbit=\$$fpbit_var
319 eval fpfuncs=\$$fpfuncs_var
321 if [ "$fpbit" ] ; then
322 for name in $fpfuncs; do
323 if [ "$libgcc_s_so" ]; then
324 out="libgcc/${dir}/${name}${objext}"
325 outS="libgcc/${dir}/${name}_s${objext}"
327 echo $outS: $fpbit $fpbit_c_dep
328 echo " $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
329 -c $fpbit -o $outS
331 echo $out: $fpbit $fpbit_c_dep
332 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
333 '$(vis_hide)' -c $fpbit -o $out
335 echo $libgcc_a: $out
336 echo $libgcc_s_so: $outS
337 if [ "$SHLIB_MKMAP" ]; then
338 echo libgcc/${dir}/libgcc.map: $outS
340 else
341 out="libgcc/${dir}/${name}${objext}"
342 echo $out: $fpbit $fpbit_c_dep
343 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
344 -c $fpbit -o $out
346 echo $libgcc_a: $out
348 done
350 done
352 for file in $LIB2ADD; do
353 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
354 oname=`echo $name | sed -e 's,.*/,,'`
356 if [ "$libgcc_s_so" ]; then
357 out="libgcc/${dir}/${oname}${objext}"
358 outS="libgcc/${dir}/${oname}_s${objext}"
360 case $file in
361 *.c)
362 echo $outS: stmp-dirs $file $libgcc_dep
363 echo " $gcc_s_compile" $flags -c $file -o $outS
365 echo $out: stmp-dirs $file $libgcc_dep
366 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
369 *.asm | *.S)
370 outV="libgcc/${dir}/${oname}.vis"
372 echo $outS: stmp-dirs $file $libgcc_dep
373 echo " $gcc_s_compile" $flags -xassembler-with-cpp \
374 -c $file -o $outS
376 echo $out: stmp-dirs $file $libgcc_dep $outV
377 echo " $gcc_compile" $flags -xassembler-with-cpp \
378 -include $outV -c $file -o $out
379 echo "${outV}: ${outS}; \$(gen-hide-list)"
383 echo "Unhandled extension: $file" >&2
384 exit 1
386 esac
388 echo $libgcc_a: $out
389 echo $libgcc_s_so: $outS
390 if [ "$SHLIB_MKMAP" ]; then
391 echo libgcc/${dir}/libgcc.map: $outS
393 else
394 out="libgcc/${dir}/${oname}${objext}"
395 case $file in
396 *.c)
397 echo $out: stmp-dirs $file $libgcc_dep
398 echo " $gcc_compile" $flags -c $file -o $out
401 *.asm | *.S)
402 echo $out: stmp-dirs $file $libgcc_dep
403 echo " $gcc_compile" $flags -xassembler-with-cpp \
404 -c $file -o $out
408 echo "Unhandled extension: $file" >&2
409 exit 1
411 esac
413 echo $libgcc_a: $out
415 done
418 for file in $LIB2ADD_ST; do
419 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
420 oname=`echo $name | sed -e 's,.*/,,'`
421 out="libgcc/${dir}/${oname}${objext}"
423 case $file in
424 *.c)
425 echo $out: stmp-dirs $file $libgcc_dep
426 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
429 *.asm | *.S)
430 # We may have to compile it twice in order to establish the list
431 # of symbols to be marked hidden.
432 if [ "$libgcc_so" ]; then
433 outV="libgcc/${dir}/${oname}.vis"
434 outT="libgcc/${dir}/${oname}_t${objext}"
435 echo ${outT}: stmp-dirs $file $libgcc_dep
436 echo " $gcc_compile" $flags -xassembler-with-cpp \
437 -c $file -o ${outT}
438 echo $out: stmp-dirs $file $libgcc_dep $outV
439 echo " $gcc_compile" $flags -xassembler-with-cpp \
440 -include $outV -c $file -o $out
441 echo "${outV}: ${outT}; \$(gen-hide-list)"
442 else
443 echo $out: stmp-dirs $file $libgcc_dep
444 echo " $gcc_compile" $flags -xassembler-with-cpp \
445 -c $file -o $out
450 echo "Unhandled extension: $file" >&2
451 exit 1
453 esac
454 echo $libgcc_a: $out
455 done
457 # If we don't have libgcc_eh.a, only LIB2ADDEH matters. If we do, only
458 # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter. (Usually all three are
459 # identical.)
461 if [ "$libgcc_eh_a" ]; then
462 for file in $LIB2ADDEHSTATIC; do
463 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
464 oname=`echo $name | sed -e 's,.*/,,'`
465 out="libgcc/${dir}/${oname}${objext}"
467 case $file in
468 *.c)
469 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
470 echo " $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
472 *.asm | *.S)
473 # We have to compile it twice in order to establish the list
474 # of symbols to be marked hidden.
475 outV="libgcc/${dir}/${oname}.vis"
476 outT="libgcc/${dir}/${oname}_t${objext}"
477 echo ${outT}: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
478 echo " $gcc_compile" $flags -xassembler-with-cpp \
479 -c $file -o ${outT}
480 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep $outV
481 echo " $gcc_compile" $flags -xassembler-with-cpp \
482 -include $outV -c $file -o $out
483 echo "${outV}: ${outT}; \$(gen-hide-list)"
485 *) echo "Unhandled extension: $file">&2; exit 1 ;;
486 esac
488 echo $libgcc_eh_a: $out
489 done
491 for file in $LIB2ADDEHSHARED; do
492 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
493 oname=`echo $name | sed -e 's,.*/,,'`
494 outS="libgcc/${dir}/${oname}_s${objext}"
496 case $file in
497 *.c)
498 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
499 echo " $gcc_s_compile" $flags -fexceptions -c $file -o $outS
501 *.asm | *.S)
502 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
503 echo " $gcc_s_compile" $flags -xassembler-with-cpp -c $file -o $outS
505 *) echo "Unhandled extension: $file">&2; exit 1 ;;
506 esac
508 echo $libgcc_s_so: $outS
509 if [ "$SHLIB_MKMAP" ]; then
510 echo libgcc/${dir}/libgcc.map: $outS
512 done
514 # If nothing went into libgcc_eh.a, create a dummy object -
515 # some linkers don't like totally empty archives.
516 if [ -z "$LIB2ADDEHSTATIC" ]; then
517 file=eh_dummy.c
518 out="libgcc/${dir}/eh_dummy${objext}"
519 need_eh_dummy=1
521 echo $out: stmp-dirs $file
522 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
523 echo $libgcc_eh_a: $out
527 else # no libgcc_eh.a
528 for file in $LIB2ADDEH; do
529 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
530 oname=`echo $name | sed -e 's,.*/,,'`
531 out="libgcc/${dir}/${oname}${objext}"
533 case $file in
534 *.c)
535 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
536 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
538 *.asm | *.S)
539 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
540 echo " $gcc_compile" $flags -xassembler-with-cpp \
541 -c $file -o $out
543 *) echo "Unhandled extension: $file">&2; exit 1 ;;
544 esac
546 echo $libgcc_a: $out
547 done
550 # We do _not_ handle assembly files in this context.
551 if [ "$LIBUNWIND" ]; then
552 for file in $LIBUNWIND; do
553 case $file in
554 *.c) ;;
555 *) echo "Unhandled extension: $file">&2; exit 1 ;;
556 esac
558 name=`echo $file | sed -e 's/[.]c$//'`
559 oname=`echo $name | sed -e 's,.*/,,'`
561 if [ "$libunwind_so" ]; then
562 out="libgcc/${dir}/${oname}${objext}"
563 outS="libgcc/${dir}/${oname}_s${objext}"
565 echo $out: stmp-dirs $file $LIBUNWINDDEP
566 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
568 echo $outS: stmp-dirs $file $LIBUNWINDDEP
569 echo " $gcc_s_compile $flags -fexceptions -c $file -o $outS"
571 echo $libunwind_a: $out
572 echo $libunwind_so: $outS
573 else
574 out="libgcc/${dir}/${oname}${objext}"
575 echo $out: stmp-dirs $file $LIBUNWINDDEP
576 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
577 echo $libunwind_a: $out
579 done
583 # build libgcov components
585 for name in $LIBGCOV; do
586 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
587 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
588 out="libgcc/${dir}/${name}${objext}"
590 echo $out: $libgcov_c_dep
591 echo " $gcc_compile $flags -DL$name -c \$(srcdir)/libgcov.c -o $out"
592 echo $libgcov_a: $out
593 done
595 # EXTRA_MULTILIB_PARTS.
596 if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
597 # Each of the EXTRA_MULTILIB_PARTS is built by recursive invocation
598 # of the parent Makefile. We must do this just once for each
599 # multilib, passing it all the EXTRA_MULTILIB_PARTS as
600 # simultaneous goal targets, so that rules which cannot execute
601 # simultaneously are properly serialized.
603 extra=
604 echo
605 for f in $EXTRA_MULTILIB_PARTS; do
606 case $dir in
607 .) out=$f ; t= ;;
608 *) out=$dir/$f ; t=$dir/ ;;
609 esac
610 case $out in
611 # Prevent `make' from interpreting $out as a macro assignment
612 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
613 *) targ=$out ;;
614 esac
615 extra="$extra $targ"
616 done
618 if [ "$dir" = . ]; then
619 suffix=
620 else
621 suffix=`echo $dir | sed s,/,_,g`
623 echo extra$suffix: stmp-dirs
624 echo " $make_compile" \\
625 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
626 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $extra
627 echo "all: extra$suffix"
629 # Make libunwind.so and libgcc_s.so depend on these, since they
630 # are likely to be implicitly used by the link process.
631 if [ "$libgcc_s_so" ]; then
632 echo "$libgcc_s_so: extra$suffix"
634 if [ "$libunwind_so" ]; then
635 echo "$libunwind_so: extra$suffix"
639 # Library build rules.
640 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
641 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
643 # Map-file generation.
644 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
645 mapfile="libgcc/${dir}/libgcc.map"
646 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
647 # This uses a here document instead of echos because some shells
648 # will convert the \1 in the second sed command to a control-A.
649 # The behavior of here documents is more predictable.
650 cat <<EOF
652 ${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES
653 { \$(NM_FOR_TARGET) $SHLIB_NM_FLAGS \$(objects); echo %%; \\
654 cat $SHLIB_MAPFILES \\
655 | sed -e '/^[ ]*#/d' \\
656 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \\
657 | $gcc_compile $flags -E -xassembler-with-cpp -; \\
658 } | \$(AWK) -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}
659 mv '$tmpmapfile' \$@
660 $libgcc_s_so: ${mapfile}
664 # Static libraries.
666 # Each of these .a files depends on stmp-dirs. It would seem that
667 # this dependency is redundant, since each of the object files
668 # itself depends on stmp-dirs. However, it is possible that there
669 # are in fact no object files. In that case, the stmp-dirs
670 # dependency is required; the directory containing the archive must
671 # exist before the archive itself can be created.
672 echo ""
673 echo "$libgcc_a: stmp-dirs"
674 echo " -rm -f $libgcc_a"
675 echo ' $(AR_CREATE_FOR_TARGET)' $libgcc_a '$(objects)'
676 echo ' $(RANLIB_FOR_TARGET)' $libgcc_a
677 echo "all: $libgcc_a"
679 echo ""
680 echo "$libgcov_a: stmp-dirs"
681 echo " -rm -f $libgcov_a"
682 echo ' $(AR_CREATE_FOR_TARGET)' $libgcov_a '$(objects)'
683 echo ' $(RANLIB_FOR_TARGET)' $libgcov_a
684 echo "all: $libgcov_a"
686 # These libraries are not always built.
687 if [ "$libunwind_a" ]; then
688 echo ""
689 echo "$libunwind_a: stmp-dirs"
690 echo " -rm -f $libunwind_a"
691 echo ' $(AR_CREATE_FOR_TARGET)' $libunwind_a '$(objects)'
692 echo ' $(RANLIB_FOR_TARGET)' $libunwind_a
693 echo "all: $libunwind_a"
696 if [ "$libgcc_eh_a" ]; then
697 echo ""
698 echo "${dir}/libgcc_eh.a: stmp-dirs"
699 echo " -rm -f ${dir}/libgcc_eh.a"
700 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a '$(objects)'
701 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
702 echo "all: $libgcc_eh_a"
705 # Shared libraries.
706 if [ "$libgcc_s_so" ]; then
707 echo ""
708 echo "$libgcc_s_so: stmp-dirs $libunwind_so"
709 echo " $SHLIB_LINK" \
710 | sed -e "s%@multilib_flags@%$flags%g" \
711 -e "s%@multilib_dir@%$dir%g" \
712 -e "s%@shlib_objs@%\$(objects)%g" \
713 -e "s%@shlib_base_name@%libgcc_s%g" \
714 -e "s%@shlib_map_file@%$mapfile%g" \
715 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
716 echo "all: $libgcc_s_so"
719 if [ "$libunwind_so" ]; then
720 echo ""
721 echo "$libunwind_so: stmp-dirs"
722 echo " $SHLIBUNWIND_LINK" \
723 | sed -e "s%@multilib_flags@%$flags%g" \
724 -e "s%@multilib_dir@%$dir%g" \
725 -e "s%@shlib_objs@%\$(objects)%g" \
726 -e "s%@shlib_base_name@%libunwind%g" \
727 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
728 echo "all: $libunwind_so"
731 done # ml in MULTILIBS
733 echo
734 echo "libgcc-stage-start:"
735 echo " for dir in \$(dirs); do \\"
736 echo " if [ -d \$(stage)/\$\$dir ]; then :; \\"
737 echo " else $mkinstalldirs \$(stage)/\$\$dir; fi; \\"
738 echo " done"
739 echo " -for dir in \$(dirs); do \\"
740 echo " mv \$\$dir/*${objext} \$(stage)/\$\$dir; \\"
741 echo " mv \$\$dir/*.vis \$(stage)/\$\$dir; \\"
742 echo " mv \$\$dir/*.map \$(stage)/\$\$dir; \\"
743 echo " test ! -f \$\$dir/libgcc.a || mv \$\$dir/lib* \$(stage)/\$\$dir; \\"
744 echo " done"
746 echo
747 echo "stmp-dirs:"
748 echo " for d in \$(dirs); do \\"
749 echo " if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
750 echo " done"
751 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
753 if [ "$need_eh_dummy" ]; then
754 echo "eh_dummy.c:"
755 echo " echo 'int __libgcc_eh_dummy;' > \$@"
758 echo ""
759 echo "install: all"
760 for ml in $MULTILIBS; do
761 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
762 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
763 if [ $dir != . ]; then
764 ldir='$(DESTDIR)$(libsubdir)'/$dir
765 echo " if [ -d $ldir ]; then true; else $mkinstalldirs $ldir; chmod a+rx $ldir; fi;"
766 else
767 ldir='$(DESTDIR)$(libsubdir)'
769 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
770 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
771 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a ${ldir}/
772 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
774 if [ "$SHLIB_LINK" ]; then
775 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
776 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
778 shlib_slibdir_qual=
779 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
780 if [ "$os_multilib_dir" != . ]; then
781 shlib_slibdir_qual="/$os_multilib_dir"
783 echo " $SHLIB_INSTALL" \
784 | sed -e "s%@multilib_dir@%$dir%g" \
785 -e "s%@shlib_base_name@%libgcc_s%g" \
786 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
787 if [ "$LIBUNWIND" ]; then
788 echo " $SHLIBUNWIND_INSTALL" \
789 | sed -e "s%@multilib_dir@%$dir%g" \
790 -e "s%@shlib_base_name@%libunwind%g" \
791 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
792 libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
793 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
794 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
797 done
798 for f in $EXTRA_MULTILIB_PARTS; do
799 for ml in $MULTILIBS; do
800 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
801 if [ $dir != . ]; then
802 out=${dir}/$f
803 ldir='$(DESTDIR)$(libsubdir)'/$dir
804 else
805 out=$f
806 ldir='$(DESTDIR)$(libsubdir)'
808 echo ' $(INSTALL_DATA)' $out $ldir/
809 done
810 done
812 echo '.PHONY: all install'