Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / mklibgcc.in
blobbd4c7cf2fdac579182369316f20b577c84d3ed59
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 # LIB2_SIDITI_CONV_FUNCS
28 # DPBIT
29 # DPBIT_FUNCS
30 # TPBIT
31 # TPBIT_FUNCS
32 # LIBGCC
33 # MULTILIBS
34 # EXTRA_MULTILIB_PARTS
35 # SHLIB_EXT
36 # SHLIB_LINK
37 # SHLIB_MKMAP
38 # SHLIB_MKMAP_OPTS
39 # SHLIB_MAPFILES
40 # SHLIB_NM_FLAGS
41 # SHLIB_INSTALL
42 # MULTILIB_OSDIRNAMES
43 # ASM_HIDDEN_OP
44 # GCC_FOR_TARGET
46 # Make needs VPATH to be literal.
47 echo 'srcdir = @srcdir@'
48 echo 'VPATH = @srcdir@'
49 echo 'EQ = ='
50 echo 'objects = $(filter %'$objext',$^)'
51 echo
52 echo '# Dependencies are accumulated as we go.'
53 echo 'all: stmp-dirs'
54 echo 'dirs = libgcc'
55 echo
57 # The floating-point conversion routines that involve a single-word integer.
58 # XX stands for the integer mode.
59 swfloatfuncs=
60 for mode in sf df xf; do
61 swfloatfuncs="$swfloatfuncs _fixuns${mode}XX"
62 done
64 # Likewise double-word routines.
65 dwfloatfuncs=
66 for mode in sf df xf tf; do
67 dwfloatfuncs="$dwfloatfuncs _fix${mode}XX _fixuns${mode}XX"
68 dwfloatfuncs="$dwfloatfuncs _floatXX${mode}"
69 done
71 # Entries of the form <objfile>:<func>:<wordsize> indicate that libgcc2.c
72 # should be compiled with L<func> defined and with LIBGCC2_UNITS_PER_WORD
73 # set to <wordsize>. <objfile> is the name of the associated object file
75 lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
76 _cmpdi2 _ucmpdi2 _clear_cache
77 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3
78 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
79 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
80 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
81 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
82 _divxc3 _divtc3'
84 if [ "$LIB2_SIDITI_CONV_FUNCS" ]; then
85 for func in $swfloatfuncs; do
86 sifunc=`echo $func | sed -e 's/XX/si/'`
87 lib2funcs="$lib2funcs $sifunc:$sifunc:4"
88 done
89 for func in $dwfloatfuncs; do
90 difunc=`echo $func | sed -e 's/XX/di/'`
91 tifunc=`echo $func | sed -e 's/XX/ti/'`
92 lib2funcs="$lib2funcs $difunc:$difunc:4 $tifunc:$difunc:8"
93 done
94 else
95 lib2funcs="$lib2funcs `echo $swfloatfuncs | sed -e 's/XX/si/g'`"
96 lib2funcs="$lib2funcs `echo $dwfloatfuncs | sed -e 's/XX/di/g'`"
99 # Disable SHLIB_LINK if shared libgcc not enabled.
100 if [ "@enable_shared@" = "no" ]; then
101 SHLIB_LINK=""
104 # Build lines.
106 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
107 gcc_s_compile="$gcc_compile -DSHARED"
108 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
109 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
110 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
111 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
112 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
113 CC="$(CC)" CFLAGS="$(CFLAGS)" \
114 BUILD_PREFIX="$(BUILD_PREFIX)" \
115 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
116 LANGUAGES="$(LANGUAGES)"'
118 # Generic dependencies for libgcc
119 libgcc_dep='$(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h config.status stmp-int-hdrs tsystem.h'
121 # Dependencies for libgcc2.c
122 libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(srcdir)/libgcc2.h gbl-ctors.h'" $libgcc_dep"
124 # Dependencies for libgcov.c
125 libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h'" $libgcc_dep"
127 # Dependencies for fp-bit.c
128 fpbit_c_dep='stmp-dirs config.status tsystem.h'
130 # Flag whether we need eh_dummy.c
131 need_eh_dummy=
133 if [ "$SHLIB_LINK" ]; then
134 # Test -fvisibility=hidden. We need both a -fvisibility=hidden on
135 # the command line, and a #define to prevent libgcc2.h etc from
136 # overriding that with #pragmas. The dance with @ is to prevent
137 # echo from seeing anything it might take for an option.
138 # echo turns the \$\$\$\$ into $$$$ and when make sees it it
139 # becomes $$ and the shell substitutes the pid. Makes for a
140 # slightly safer temp file.
141 echo "vis_hide := \$(strip \$(subst @,-,\\"
142 echo " \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
143 echo " $gcc_compile -fvisibility=hidden -Werror \\"
144 echo " -c -xc - -o vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
145 echo " then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
146 echo " rm vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
147 echo " fi)))"
148 echo
150 # If we have -fvisibility=hidden, then we need to generate hide
151 # lists for object files implemented in assembly. The default
152 # pseudo-op for this is ".hidden", but can be overridden with
153 # ASM_HIDDEN_OP.
154 [ "$ASM_HIDDEN_OP" ] || ASM_HIDDEN_OP=".hidden"
156 echo "ifneq (,\$(vis_hide))"
157 echo "define gen-hide-list"
158 echo "\$(NM_FOR_TARGET) ${SHLIB_NM_FLAGS} \$< | \\"
159 # non-GNU nm emits three fields even for undefined and typeless symbols,
160 # so explicitly omit them
161 echo " \$(AWK) 'NF == 3 && \$\$2 !~ /^[UN]\$\$/ { print \"\\t${ASM_HIDDEN_OP}\", \$\$3 }' > \$@T"
162 echo "mv -f \$@T \$@"
163 echo "endef"
164 echo "else"
165 echo "gen-hide-list = echo > \$@"
166 echo "endif"
167 echo
168 else
169 # It is too hard to guarantee that vis_hide and gen-hide-list will never
170 # be referenced if SHLIB_LINK is not set, so set them to the values they'd
171 # have if SHLIB_LINK were set and we didn't have visibility support.
172 echo "vis_hide ="
173 echo "gen-hide-list = echo > \$@"
176 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
177 # defined as optimized assembly code in LIB1ASMFUNCS.
178 for name in $LIB1ASMFUNCS; do
179 lib2funcs=`echo $lib2funcs | sed -e 's/^'$name'[ :]//' \
180 -e 's/ '$name'[ :]/ /' \
181 -e 's/ '$name'$//'`
182 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
183 -e 's/ '$name' / /' \
184 -e 's/ '$name'$//'`
185 done
188 # Rules to generate object files.
191 for ml in $MULTILIBS; do
193 # Work out relevant parameters that depend only on the multilib.
194 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
195 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
196 shlib_slibdir_qual=
197 libgcc_a=$dir/libgcc.a
198 libgcov_a=$dir/libgcov.a
199 libgcc_eh_a=
200 libgcc_s_so=
201 libunwind_a=
202 libunwind_so=
204 if [ "$LIBUNWIND" ]; then
205 libunwind_a=$dir/libunwind.a
207 if [ "$SHLIB_LINK" ]; then
208 libgcc_eh_a=$dir/libgcc_eh.a
209 libgcc_s_so=$dir/libgcc_s${SHLIB_EXT}
210 if [ "$LIBUNWIND" ]; then
211 libunwind_so=$dir/libunwind${SHLIB_EXT}
213 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
214 if [ "$os_multilib_dir" != . ]; then
215 shlib_slibdir_qual="/$os_multilib_dir"
219 libgcc_s_so_extra=
220 libunwind_so_extra=
222 echo
223 echo \#
224 echo \# ml: $ml
225 echo \# dir: $dir
226 echo \# flags: $flags
227 echo \# libgcc_a: $libgcc_a
228 echo \# libgcov_a: $libgcov_a
229 echo \# libgcc_eh_a: $libgcc_eh_a
230 echo \# libunwind_a: $libunwind_a
231 echo \#
232 echo \# shlib_slibdir_qual: $shlib_slibdir_qual
233 echo \# libgcc_s_so: $libgcc_s_so
234 echo \# libunwind_so: $libunwind_so
235 echo \#
236 echo
238 # Update list of directories.
239 if [ $dir != . ]; then
240 echo "dirs += ${dir} libgcc/${dir}"
241 echo
245 # Build libgcc1 components.
247 for name in $LIB1ASMFUNCS; do
248 if [ "$libgcc_s_so" ]; then
249 out="libgcc/${dir}/${name}${objext}"
250 outS="libgcc/${dir}/${name}_s${objext}"
251 outV="libgcc/${dir}/${name}.vis"
253 echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
254 echo " $gcc_s_compile" $flags -DL$name -xassembler-with-cpp \
255 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
257 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
258 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
259 -c '$(srcdir)/config/$(LIB1ASMSRC)' -include $outV -o $out
261 echo "${outV}: ${outS}; \$(gen-hide-list)"
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 -xassembler-with-cpp \
272 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
273 echo $libgcc_a: $out
275 done
278 # Build libgcc2 components.
281 for name in $lib2funcs; do
282 case $name in
283 *:*:*)
284 defines=`echo $name | sed -e 's/.*:\(.*\):\(.*\)/-DL\1 -DLIBGCC2_UNITS_PER_WORD=\2/'`
285 name=`echo $name | sed -e 's/\(.*\):.*:.*/\1/'`
288 defines="-DL$name"
290 esac
291 if [ "$libgcc_s_so" ]; then
292 out="libgcc/${dir}/${name}${objext}"
293 outS="libgcc/${dir}/${name}_s${objext}"
295 echo $outS: $libgcc2_c_dep
296 echo " $gcc_s_compile" $flags $defines -c '$(srcdir)/libgcc2.c' \
297 -o $outS
299 echo $out: $libgcc2_c_dep
300 echo " $gcc_compile" $flags $defines '$(vis_hide)' \
301 -c '$(srcdir)/libgcc2.c' -o $out
303 echo $libgcc_a: $out
304 echo $libgcc_s_so: $outS
305 if [ "$SHLIB_MKMAP" ]; then
306 echo libgcc/${dir}/libgcc.map: $outS
308 else
309 out="libgcc/${dir}/${name}${objext}"
310 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
311 echo " $gcc_compile" $flags $defines -c '$(srcdir)/libgcc2.c' -o $out
312 echo $libgcc_a: $out
314 done
316 for name in $LIB2FUNCS_ST; do
317 out="libgcc/${dir}/${name}${objext}"
319 echo $out: $libgcc2_c_dep
320 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
321 -c '$(srcdir)/libgcc2.c' -o $out
322 echo ${dir}/libgcc.a: $out
323 done
325 for name in $LIB2_DIVMOD_FUNCS; do
326 if [ "$libgcc_s_so" ]; then
327 out="libgcc/${dir}/${name}${objext}"
328 outS="libgcc/${dir}/${name}_s${objext}"
330 echo $outS: $libgcc2_c_dep
331 echo " $gcc_s_compile" $flags -DL$name \
332 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
334 echo $out: $libgcc2_c_dep
335 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
336 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
338 echo $libgcc_a: $out
339 echo $libgcc_s_so: $outS
340 if [ "$SHLIB_MKMAP" ]; then
341 echo libgcc/${dir}/libgcc.map: $outS
343 else
344 out="libgcc/${dir}/${name}${objext}"
345 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
346 echo " $gcc_compile" $flags -DL$name \
347 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
348 echo $libgcc_a: $out
350 done
353 # Build software floating point functions.
356 if [ "$FPBIT" ]; then
357 for name in $FPBIT_FUNCS; do
358 [ "$name" = _sf_to_tf -a -z "$TPBIT" ] && continue
359 if [ "$libgcc_s_so" ]; then
360 out="libgcc/${dir}/${name}${objext}"
361 outS="libgcc/${dir}/${name}_s${objext}"
363 echo $outS: $FPBIT $fpbit_c_dep
364 echo " $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
365 -c $FPBIT -o $outS
367 echo $out: $FPBIT $fpbit_c_dep
368 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
369 '$(vis_hide)' -c $FPBIT -o $out
371 echo $libgcc_a: $out
372 echo $libgcc_s_so: $outS
373 if [ "$SHLIB_MKMAP" ]; then
374 echo libgcc/${dir}/libgcc.map: $outS
376 else
377 out="libgcc/${dir}/${name}${objext}"
378 echo $out: $FPBIT $fpbit_c_dep
379 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
380 -c $FPBIT -o $out
382 echo $libgcc_a: $out
384 done
387 if [ "$DPBIT" ]; then
388 for name in $DPBIT_FUNCS; do
389 [ "$name" = _df_to_tf -a -z "$TPBIT" ] && continue
390 if [ "$libgcc_s_so" ]; then
391 out="libgcc/${dir}/${name}${objext}"
392 outS="libgcc/${dir}/${name}_s${objext}"
394 echo $outS: $DPBIT $fpbit_c_dep
395 echo " $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
396 -c $DPBIT -o $outS
398 echo $out: $DPBIT $fpbit_c_dep
399 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
400 '$(vis_hide)' -c $DPBIT -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: $DPBIT $fpbit_c_dep
410 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
411 -c $DPBIT -o $out
413 echo $libgcc_a: $out
415 done
418 if [ "$TPBIT" ]; then
419 for name in $TPBIT_FUNCS; do
420 if [ "$libgcc_s_so" ]; then
421 out="libgcc/${dir}/${name}${objext}"
422 outS="libgcc/${dir}/${name}_s${objext}"
424 echo $outS: $TPBIT $fpbit_c_dep
425 echo " $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
426 -c $TPBIT -o $outS
428 echo $out: $TPBIT $fpbit_c_dep
429 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
430 '$(vis_hide)' -c $TPBIT -o $out
432 echo $libgcc_a: $out
433 echo $libgcc_s_so: $outS
434 if [ "$SHLIB_MKMAP" ]; then
435 echo libgcc/${dir}/libgcc.map: $outS
437 else
438 out="libgcc/${dir}/${name}${objext}"
439 echo $out: $TPBIT $fpbit_c_dep
440 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
441 -c $TPBIT -o $out
443 echo $libgcc_a: $out
445 done
448 for file in $LIB2ADD; do
449 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
450 oname=`echo $name | sed -e 's,.*/,,'`
452 if [ "$libgcc_s_so" ]; then
453 out="libgcc/${dir}/${oname}${objext}"
454 outS="libgcc/${dir}/${oname}_s${objext}"
456 case $file in
457 *.c)
458 echo $outS: stmp-dirs $file $libgcc_dep
459 echo " $gcc_s_compile" $flags -c $file -o $outS
461 echo $out: stmp-dirs $file $libgcc_dep
462 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
465 *.asm | *.S)
466 outV="libgcc/${dir}/${oname}.vis"
468 echo $outS: stmp-dirs $file $libgcc_dep
469 echo " $gcc_s_compile" $flags -xassembler-with-cpp \
470 -c $file -o $outS
472 echo $out: stmp-dirs $file $libgcc_dep $outV
473 echo " $gcc_compile" $flags -xassembler-with-cpp \
474 -include $outV -c $file -o $out
475 echo "${outV}: ${outS}; \$(gen-hide-list)"
479 echo "Unhandled extension: $file" >&2
480 exit 1
482 esac
484 echo $libgcc_a: $out
485 echo $libgcc_s_so: $outS
486 if [ "$SHLIB_MKMAP" ]; then
487 echo libgcc/${dir}/libgcc.map: $outS
489 else
490 out="libgcc/${dir}/${oname}${objext}"
491 case $file in
492 *.c)
493 echo $out: stmp-dirs $file $libgcc_dep
494 echo " $gcc_compile" $flags -c $file -o $out
497 *.asm | *.S)
498 echo $out: stmp-dirs $file $libgcc_dep
499 echo " $gcc_compile" $flags -xassembler-with-cpp \
500 -c $file -o $out
504 echo "Unhandled extension: $file" >&2
505 exit 1
507 esac
509 echo $libgcc_a: $out
511 done
514 for file in $LIB2ADD_ST; do
515 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
516 oname=`echo $name | sed -e 's,.*/,,'`
517 out="libgcc/${dir}/${oname}${objext}"
519 case $file in
520 *.c)
521 echo $out: stmp-dirs $file $libgcc_dep
522 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
525 *.asm | *.S)
526 # We may have to compile it twice in order to establish the list
527 # of symbols to be marked hidden.
528 if [ "$libgcc_so" ]; then
529 outV="libgcc/${dir}/${oname}.vis"
530 outT="libgcc/${dir}/${oname}_t${objext}"
531 echo ${outT}: stmp-dirs $file $libgcc_dep
532 echo " $gcc_compile" $flags -xassembler-with-cpp \
533 -c $file -o ${outT}
534 echo $out: stmp-dirs $file $libgcc_dep $outV
535 echo " $gcc_compile" $flags -xassembler-with-cpp \
536 -include $outV -c $file -o $out
537 echo "${outV}: ${outT}; \$(gen-hide-list)"
538 else
539 echo $out: stmp-dirs $file $libgcc_dep
540 echo " $gcc_compile" $flags -xassembler-with-cpp \
541 -c $file -o $out
546 echo "Unhandled extension: $file" >&2
547 exit 1
549 esac
550 echo $libgcc_a: $out
551 done
553 # If we don't have libgcc_eh.a, only LIB2ADDEH matters. If we do, only
554 # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter. (Usually all three are
555 # identical.)
557 if [ "$libgcc_eh_a" ]; then
558 for file in $LIB2ADDEHSTATIC; do
559 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
560 oname=`echo $name | sed -e 's,.*/,,'`
561 out="libgcc/${dir}/${oname}${objext}"
563 case $file in
564 *.c)
565 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
566 echo " $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
568 *.asm | *.S)
569 # We have to compile it twice in order to establish the list
570 # of symbols to be marked hidden.
571 outV="libgcc/${dir}/${oname}.vis"
572 outT="libgcc/${dir}/${oname}_t${objext}"
573 echo ${outT}: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
574 echo " $gcc_compile" $flags -xassembler-with-cpp \
575 -c $file -o ${outT}
576 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep $outV
577 echo " $gcc_compile" $flags -xassembler-with-cpp \
578 -include $outV -c $file -o $out
579 echo "${outV}: ${outT}; \$(gen-hide-list)"
581 *) echo "Unhandled extension: $file">&2; exit 1 ;;
582 esac
584 echo $libgcc_eh_a: $out
585 done
587 for file in $LIB2ADDEHSHARED; do
588 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
589 oname=`echo $name | sed -e 's,.*/,,'`
590 outS="libgcc/${dir}/${oname}_s${objext}"
592 case $file in
593 *.c)
594 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
595 echo " $gcc_s_compile" $flags -fexceptions -c $file -o $outS
597 *.asm | *.S)
598 echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
599 echo " $gcc_s_compile" $flags -xassembler-with-cpp -c $file -o $outS
601 *) echo "Unhandled extension: $file">&2; exit 1 ;;
602 esac
604 echo $libgcc_s_so: $outS
605 if [ "$SHLIB_MKMAP" ]; then
606 echo libgcc/${dir}/libgcc.map: $outS
608 done
610 # If nothing went into libgcc_eh.a, create a dummy object -
611 # some linkers don't like totally empty archives.
612 if [ -z "$LIB2ADDEHSTATIC" ]; then
613 file=eh_dummy.c
614 out="libgcc/${dir}/eh_dummy${objext}"
615 need_eh_dummy=1
617 echo $out: stmp-dirs $file
618 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
619 echo $libgcc_eh_a: $out
623 else # no libgcc_eh.a
624 for file in $LIB2ADDEH; do
625 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
626 oname=`echo $name | sed -e 's,.*/,,'`
627 out="libgcc/${dir}/${oname}${objext}"
629 case $file in
630 *.c)
631 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
632 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
634 *.asm | *.S)
635 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
636 echo " $gcc_compile" $flags -xassembler-with-cpp \
637 -c $file -o $out
639 *) echo "Unhandled extension: $file">&2; exit 1 ;;
640 esac
642 echo $libgcc_a: $out
643 done
646 # We do _not_ handle assembly files in this context.
647 if [ "$LIBUNWIND" ]; then
648 for file in $LIBUNWIND; do
649 case $file in
650 *.c) ;;
651 *) echo "Unhandled extension: $file">&2; exit 1 ;;
652 esac
654 name=`echo $file | sed -e 's/[.]c$//'`
655 oname=`echo $name | sed -e 's,.*/,,'`
657 if [ "$libunwind_so" ]; then
658 out="libgcc/${dir}/${oname}${objext}"
659 outS="libgcc/${dir}/${oname}_s${objext}"
661 echo $out: stmp-dirs $file $LIBUNWINDDEP
662 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
664 echo $outS: stmp-dirs $file $LIBUNWINDDEP
665 echo " $gcc_s_compile $flags -fexceptions -c $file -o $outS"
667 echo $libunwind_a: $out
668 echo $libunwind_so: $outS
669 else
670 out="libgcc/${dir}/${oname}${objext}"
671 echo $out: stmp-dirs $file $LIBUNWINDDEP
672 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
673 echo $libunwind_a: $out
675 done
679 # build libgcov components
681 for name in $LIBGCOV; do
682 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
683 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
684 out="libgcc/${dir}/${name}${objext}"
686 echo $out: $libgcov_c_dep
687 echo " $gcc_compile $flags -DL$name -c \$(srcdir)/libgcov.c -o $out"
688 echo $libgcov_a: $out
689 done
691 # EXTRA_MULTILIB_PARTS.
692 if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
693 # Each of the EXTRA_MULTILIB_PARTS is built by recursive invocation
694 # of the parent Makefile. We must do this just once for each
695 # multilib, passing it all the EXTRA_MULTILIB_PARTS as
696 # simultaneous goal targets, so that rules which cannot execute
697 # simultaneously are properly serialized.
699 extra=
700 echo
701 for f in $EXTRA_MULTILIB_PARTS; do
702 case $dir in
703 .) out=$f ; t= ;;
704 *) out=$dir/$f ; t=$dir/ ;;
705 esac
706 case $out in
707 # Prevent `make' from interpreting $out as a macro assignment
708 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
709 *) targ=$out ;;
710 esac
711 extra="$extra $targ"
712 done
714 if [ "$dir" = . ]; then
715 suffix=
716 else
717 suffix=`echo $dir | sed s,/,_,g`
719 echo extra$suffix: stmp-dirs
720 echo " $make_compile" \\
721 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
722 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $extra
723 echo "all: extra$suffix"
725 # Make libunwind.so and libgcc_s.so depend on these, since they
726 # are likely to be implicitly used by the link process.
727 if [ "$libgcc_s_so" ]; then
728 echo "$libgcc_s_so: extra$suffix"
730 if [ "$libunwind_so" ]; then
731 echo "$libunwind_so: extra$suffix"
735 # Library build rules.
736 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
737 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
739 # Map-file generation.
740 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
741 mapfile="libgcc/${dir}/libgcc.map"
742 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
743 # This uses a here document instead of echos because some shells
744 # will convert the \1 in the second sed command to a control-A.
745 # The behavior of here documents is more predictable.
746 cat <<EOF
748 ${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES
749 { \$(NM_FOR_TARGET) $SHLIB_NM_FLAGS \$(objects); echo %%; \\
750 cat $SHLIB_MAPFILES \\
751 | sed -e '/^[ ]*#/d' \\
752 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \\
753 | $gcc_compile $flags -E -xassembler-with-cpp -; \\
754 } | \$(AWK) -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}
755 mv '$tmpmapfile' \$@
756 $libgcc_s_so: ${mapfile}
760 # Static libraries.
762 # Each of these .a files depends on stmp-dirs. It would seem that
763 # this dependency is redundant, since each of the object files
764 # itself depends on stmp-dirs. However, it is possible that there
765 # are in fact no object files. In that case, the stmp-dirs
766 # dependency is required; the directory containing the archive must
767 # exist before the archive itself can be created.
768 echo ""
769 echo "$libgcc_a: stmp-dirs"
770 echo " -rm -f $libgcc_a"
771 echo ' $(AR_CREATE_FOR_TARGET)' $libgcc_a '$(objects)'
772 echo ' $(RANLIB_FOR_TARGET)' $libgcc_a
773 echo "all: $libgcc_a"
775 echo ""
776 echo "$libgcov_a: stmp-dirs"
777 echo " -rm -f $libgcov_a"
778 echo ' $(AR_CREATE_FOR_TARGET)' $libgcov_a '$(objects)'
779 echo ' $(RANLIB_FOR_TARGET)' $libgcov_a
780 echo "all: $libgcov_a"
782 # These libraries are not always built.
783 if [ "$libunwind_a" ]; then
784 echo ""
785 echo "$libunwind_a: stmp-dirs"
786 echo " -rm -f $libunwind_a"
787 echo ' $(AR_CREATE_FOR_TARGET)' $libunwind_a '$(objects)'
788 echo ' $(RANLIB_FOR_TARGET)' $libunwind_a
789 echo "all: $libunwind_a"
792 if [ "$libgcc_eh_a" ]; then
793 echo ""
794 echo "${dir}/libgcc_eh.a: stmp-dirs"
795 echo " -rm -f ${dir}/libgcc_eh.a"
796 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a '$(objects)'
797 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
798 echo "all: $libgcc_eh_a"
801 # Shared libraries.
802 if [ "$libgcc_s_so" ]; then
803 echo ""
804 echo "$libgcc_s_so: stmp-dirs $libunwind_so"
805 echo " $SHLIB_LINK" \
806 | sed -e "s%@multilib_flags@%$flags%g" \
807 -e "s%@multilib_dir@%$dir%g" \
808 -e "s%@shlib_objs@%\$(objects)%g" \
809 -e "s%@shlib_base_name@%libgcc_s%g" \
810 -e "s%@shlib_map_file@%$mapfile%g" \
811 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
812 echo "all: $libgcc_s_so"
815 if [ "$libunwind_so" ]; then
816 echo ""
817 echo "$libunwind_so: stmp-dirs"
818 echo " $SHLIBUNWIND_LINK" \
819 | sed -e "s%@multilib_flags@%$flags%g" \
820 -e "s%@multilib_dir@%$dir%g" \
821 -e "s%@shlib_objs@%\$(objects)%g" \
822 -e "s%@shlib_base_name@%libunwind%g" \
823 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
824 echo "all: $libunwind_so"
827 done # ml in MULTILIBS
829 echo
830 echo "libgcc-stage-start:"
831 echo " for dir in \$(dirs); do \\"
832 echo " if [ -d \$(stage)/\$\$dir ]; then :; \\"
833 echo " else $mkinstalldirs \$(stage)/\$\$dir; fi; \\"
834 echo " done"
835 echo " -for dir in \$(dirs); do \\"
836 echo " mv \$\$dir/*${objext} \$(stage)/\$\$dir; \\"
837 echo " mv \$\$dir/*.vis \$(stage)/\$\$dir; \\"
838 echo " mv \$\$dir/*.map \$(stage)/\$\$dir; \\"
839 echo " test ! -f \$\$dir/libgcc.a || mv \$\$dir/lib* \$(stage)/\$\$dir; \\"
840 echo " done"
842 echo
843 echo "stmp-dirs:"
844 echo " for d in \$(dirs); do \\"
845 echo " if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
846 echo " done"
847 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
849 if [ "$need_eh_dummy" ]; then
850 echo "eh_dummy.c:"
851 echo " echo 'int __libgcc_eh_dummy;' > \$@"
854 echo ""
855 echo "install: all"
856 for ml in $MULTILIBS; do
857 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
858 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
859 if [ $dir != . ]; then
860 ldir='$(DESTDIR)$(libsubdir)'/$dir
861 echo " if [ -d $ldir ]; then true; else $mkinstalldirs $ldir; chmod a+rx $ldir; fi;"
862 else
863 ldir='$(DESTDIR)$(libsubdir)'
865 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
866 echo ' chmod 644' ${ldir}/libgcc.a
867 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
868 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a ${ldir}/
869 echo ' chmod 644' ${ldir}/libgcov.a
870 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
872 if [ "$SHLIB_LINK" ]; then
873 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
874 echo ' chmod 644' ${ldir}/libgcc_eh.a
875 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
877 shlib_slibdir_qual=
878 os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
879 if [ "$os_multilib_dir" != . ]; then
880 shlib_slibdir_qual="/$os_multilib_dir"
882 echo " $SHLIB_INSTALL" \
883 | sed -e "s%@multilib_dir@%$dir%g" \
884 -e "s%@shlib_base_name@%libgcc_s%g" \
885 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
886 if [ "$LIBUNWIND" ]; then
887 echo " $SHLIBUNWIND_INSTALL" \
888 | sed -e "s%@multilib_dir@%$dir%g" \
889 -e "s%@shlib_base_name@%libunwind%g" \
890 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
891 libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
892 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
893 echo ' chmod 644' ${dir}/libunwind.a
894 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
897 done
898 for f in $EXTRA_MULTILIB_PARTS; do
899 for ml in $MULTILIBS; do
900 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
901 if [ $dir != . ]; then
902 out=${dir}/$f
903 ldir='$(DESTDIR)$(libsubdir)'/$dir
904 else
905 out=$f
906 ldir='$(DESTDIR)$(libsubdir)'
908 echo ' $(INSTALL_DATA)' $out $ldir/
909 done
910 done
912 echo '.PHONY: all install'