* Makefile.am (AM_MAKEFLAGS): Remove duplicate LIBCFLAGS and
[official-gcc.git] / gcc / mklibgcc.in
blobd103f3642716ca020c45882fcfde2cb3d428bafa
1 #!/bin/sh
2 # Construct makefile for libgcc.
3 # Copyright (C) 2000, 2002, 2003 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_MULTILIB
37 # SHLIB_MKMAP
38 # SHLIB_MKMAP_OPTS
39 # SHLIB_MAPFILES
40 # SHLIB_NM_FLAGS
41 # SHLIB_INSTALL
42 # MULTILIB_OSDIRNAMES
43 # ASM_HIDDEN_OP
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'
66 # Disable SHLIB_LINK if shared libgcc not enabled.
67 if [ "@enable_shared@" = "no" ]; then
68 SHLIB_LINK=""
71 # Build lines.
73 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
74 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
75 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
76 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
77 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
78 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
79 CC="$(CC)" CFLAGS="$(CFLAGS)" \
80 BUILD_PREFIX="$(BUILD_PREFIX)" \
81 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
82 LANGUAGES="$(LANGUAGES)"'
84 # Generic dependencies for libgcc
85 libgcc_dep='$(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h config.status stmp-int-hdrs tsystem.h'
87 # Dependencies for libgcc2.c
88 libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c gbl-ctors.h'" $libgcc_dep"
90 # Dependencies for libgcov.c
91 libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h'" $libgcc_dep"
93 # Dependencies for fp-bit.c
94 fpbit_c_dep='stmp-dirs config.status tsystem.h'
96 if [ "$SHLIB_LINK" ]; then
97 # Test -fvisibility=hidden. We need both a -fvisibility=hidden on
98 # the command line, and a #define to prevent libgcc2.h etc from
99 # overriding that with #pragmas. The dance with @ is to prevent
100 # echo from seeing anything it might take for an option.
101 echo "vis_hide := \$(strip \$(subst @,-,\\"
102 echo " \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
103 echo " $gcc_compile -fvisibility=hidden -Werror \\"
104 echo " -c -xc - -o /dev/null 2> /dev/null; \\"
105 echo " then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
106 echo " fi)))"
107 echo
109 # If we have -fvisibility=hidden, then we need to generate hide
110 # lists for object files implemented in assembly. The default
111 # pseudo-op for this is ".hidden", but can be overridden with
112 # ASM_HIDDEN_OP.
113 [ "$ASM_HIDDEN_OP" ] || ASM_HIDDEN_OP=".hidden"
115 echo "ifneq (,\$(vis_hide))"
116 echo "define gen-hide-list"
117 echo "\$(NM_FOR_TARGET) ${SHLIB_NM_FLAGS} \$< | \\"
118 # non-GNU nm emits three fields even for undefined and typeless symbols,
119 # so explicitly omit them
120 echo " \$(AWK) 'NF == 3 && \$\$2 !~ /^[UN]\$\$/ { print \"\\t${ASM_HIDDEN_OP}\", \$\$3 }' > \$@T"
121 echo "mv -f \$@T \$@"
122 echo "endef"
123 echo "else"
124 echo "gen-hide-list = echo > \$@"
125 echo "endif"
126 echo
127 else
128 # It is too hard to guarantee that vis_hide and gen-hide-list will never
129 # be referenced if SHLIB_LINK is not set, so set them to the values they'd
130 # have if SHLIB_LINK were set and we didn't have visibility support.
131 echo "vis_hide ="
132 echo "gen-hide-list = echo > \$@"
135 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
136 # defined as optimized assembly code in LIB1ASMFUNCS.
137 for name in $LIB1ASMFUNCS; do
138 lib2funcs=`echo $lib2funcs | sed -e 's/^'$name' //' \
139 -e 's/ '$name' / /' \
140 -e 's/ '$name'$//'`
141 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
142 -e 's/ '$name' / /' \
143 -e 's/ '$name'$//'`
144 done
147 # Rules to generate object files.
150 for ml in $MULTILIBS; do
152 # Work out relevant parameters that depend only on the multilib.
153 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
154 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
155 shlib_dir=
156 shlib_dir_qual=
157 libgcc_a=$dir/libgcc.a
158 libgcov_a=$dir/libgcov.a
159 libgcc_eh_a=
160 libgcc_s_so=
161 libunwind_a=
162 libunwind_so=
163 if [ "$dir" = . ]; then
164 suffix=
165 else
166 suffix=`echo $dir | sed s,/,_,g`
169 if [ "$LIBUNWIND" ]; then
170 libunwind_a=$dir/libunwind.a
172 if [ "$SHLIB_LINK" ]; then
173 if [ -z "$SHLIB_MULTILIB" ]; then
174 if [ "$dir" = . ]; then
175 libgcc_eh_a=$dir/libgcc_eh.a
176 libgcc_s_so_base=libgcc_s
177 libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
178 libgcc_s_soname=libgcc_s
179 if [ "$LIBUNWIND" ]; then
180 libunwind_so_base=libunwind
181 libunwind_so=${libunwind_so_base}${SHLIB_EXT}
182 libunwind_soname=libunwind
184 else
185 libgcc_eh_a=$dir/libgcc_eh.a
186 libgcc_s_so_base=libgcc_s_${suffix}
187 libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
188 libgcc_s_soname=libgcc_s_${suffix}
189 if [ "$LIBUNWIND" ]; then
190 libunwind_so_base=libunwind_${suffix}
191 libunwind_so=${libunwind_so_base}${SHLIB_EXT}
195 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
196 if [ "$dir" != . ]; then
197 gcc_multilib_dir=`./xgcc -B./ $flags --print-multi-directory`
198 os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
199 shlib_dir="$dir"/
200 gcc_multilib_sup=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
201 os_multilib_base=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
202 if [ -z "$os_multilib_base" ]; then
203 libgcc_s_soname=libgcc_s
204 libunwind_soname=libunwind
205 if [ "$os_multilib_dir" != "." ]; then
206 shlib_dir_qual="/$os_multilib_dir"
208 else
209 libgcc_s_soname=libgcc_s_`echo $gcc_multilib_sup | sed s,/,_,g`
210 libunwind_soname=libunwind_`echo $gcc_multilib_sup | sed s,/,_,g`
211 shlib_dir_qual="/$os_multilib_base"
216 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
217 libgcc_eh_a=$dir/libgcc_eh.a
218 libgcc_s_so_base=libgcc_s
219 libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
220 libgcc_s_soname=libgcc_s
221 if [ "$LIBUNWIND" ]; then
222 libunwind_so_base=libunwind
223 libunwind_so=${libunwind_so_base}${SHLIB_EXT}
224 libunwind_soname=libunwind
228 libgcc_s_so_extra=
229 libunwind_so_extra=
231 echo
232 echo \#
233 echo \# ml: $ml
234 echo \# dir: $dir
235 echo \# flags: $flags
236 echo \# libgcc_a: $libgcc_a
237 echo \# libgcov_a: $libgcov_a
238 echo \# libgcc_eh_a: $libgcc_eh_a
239 echo \# libunwind_a: $libunwind_a
240 echo \#
241 echo \# gcc_multilib_dir: $gcc_multilib_dir
242 echo \# gcc_multilib_sup: $gcc_multilib_sup
243 echo \# os_multilib_dir: $os_multilib_dir
244 echo \# os_multilib_base: $os_multilib_base
245 echo \# shlib_dir: $shlib_dir
246 echo \# shlib_dir_qual: $shlib_dir_qual
247 echo \#
248 echo \# libgcc_s_so: $libgcc_s_so
249 echo \# libgcc_s_so_base: $libgcc_s_so_base
250 echo \# libgcc_s_soname: $libgcc_s_soname
251 echo \#
252 echo \# libunwind_so: $libunwind_so
253 echo \# libunwind_so_base: $libunwind_so_base
254 echo \# libunwind_soname: $libunwind_soname
255 echo \#
256 echo
258 # Update list of directories.
259 if [ $dir != . ]; then
260 echo "dirs += ${dir} libgcc/${dir}"
261 echo
265 # Build libgcc1 components.
267 for name in $LIB1ASMFUNCS; do
268 if [ "$libgcc_s_so" ]; then
269 out="libgcc/${dir}/${name}${objext}"
270 outS="libgcc/${dir}/${name}_s${objext}"
271 outV="libgcc/${dir}/${name}.vis"
273 echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
274 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
275 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
277 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
278 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
279 -c '$(srcdir)/config/$(LIB1ASMSRC)' -include $outV -o $out
281 echo "${outV}: ${outS}; \$(gen-hide-list)"
283 echo $libgcc_a: $out
284 echo $libgcc_s_so: $outS
285 if [ "$SHLIB_MKMAP" ]; then
286 echo libgcc/${dir}/libgcc.map: $outS
288 else
289 out="libgcc/${dir}/${name}${objext}"
290 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
291 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
292 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
293 echo $libgcc_a: $out
295 done
298 # Build libgcc2 components.
301 for name in $lib2funcs; do
302 if [ "$libgcc_s_so" ]; then
303 out="libgcc/${dir}/${name}${objext}"
304 outS="libgcc/${dir}/${name}_s${objext}"
306 echo $outS: $libgcc2_c_dep
307 echo " $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $outS
309 echo $out: $libgcc2_c_dep
310 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
311 -c '$(srcdir)/libgcc2.c' -o $out
313 echo $libgcc_a: $out
314 echo $libgcc_s_so: $outS
315 if [ "$SHLIB_MKMAP" ]; then
316 echo libgcc/${dir}/libgcc.map: $outS
318 else
319 out="libgcc/${dir}/${name}${objext}"
320 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
321 echo " $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
322 echo $libgcc_a: $out
324 done
326 for name in $LIB2FUNCS_ST; do
327 out="libgcc/${dir}/${name}${objext}"
329 echo $out: $libgcc2_c_dep
330 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
331 -c '$(srcdir)/libgcc2.c' -o $out
332 echo ${dir}/libgcc.a: $out
333 done
335 for name in $LIB2_DIVMOD_FUNCS; do
336 if [ "$libgcc_s_so" ]; then
337 out="libgcc/${dir}/${name}${objext}"
338 outS="libgcc/${dir}/${name}_s${objext}"
340 echo $outS: $libgcc2_c_dep
341 echo " $gcc_compile" $flags -DL$name \
342 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
344 echo $out: $libgcc2_c_dep
345 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
346 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
348 echo $libgcc_a: $out
349 echo $libgcc_s_so: $outS
350 if [ "$SHLIB_MKMAP" ]; then
351 echo libgcc/${dir}/libgcc.map: $outS
353 else
354 out="libgcc/${dir}/${name}${objext}"
355 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
356 echo " $gcc_compile" $flags -DL$name \
357 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
358 echo $libgcc_a: $out
360 done
363 # Build software floating point functions.
366 if [ "$FPBIT" ]; then
367 for name in $FPBIT_FUNCS; do
368 if [ "$libgcc_s_so" ]; then
369 out="libgcc/${dir}/${name}${objext}"
370 outS="libgcc/${dir}/${name}_s${objext}"
372 echo $outS: $FPBIT $fpbit_c_dep
373 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
374 -c $FPBIT -o $outS
376 echo $out: $FPBIT $fpbit_c_dep
377 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
378 '$(vis_hide)' -c $FPBIT -o $out
380 echo $libgcc_a: $out
381 echo $libgcc_s_so: $outS
382 if [ "$SHLIB_MKMAP" ]; then
383 echo libgcc/${dir}/libgcc.map: $outS
385 else
386 out="libgcc/${dir}/${name}${objext}"
387 echo $out: $FPBIT $fpbit_c_dep
388 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
389 -c $FPBIT -o $out
391 echo $libgcc_a: $out
393 done
396 if [ "$DPBIT" ]; then
397 for name in $DPBIT_FUNCS; do
398 if [ "$libgcc_s_so" ]; then
399 out="libgcc/${dir}/${name}${objext}"
400 outS="libgcc/${dir}/${name}_s${objext}"
402 echo $outS: $DPBIT $fpbit_c_dep
403 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
404 -c $DPBIT -o $outS
406 echo $out: $DPBIT $fpbit_c_dep
407 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
408 '$(vis_hide)' -c $DPBIT -o $out
410 echo $libgcc_a: $out
411 echo $libgcc_s_so: $outS
412 if [ "$SHLIB_MKMAP" ]; then
413 echo libgcc/${dir}/libgcc.map: $outS
415 else
416 out="libgcc/${dir}/${name}${objext}"
417 echo $out: $DPBIT $fpbit_c_dep
418 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
419 -c $DPBIT -o $out
421 echo $libgcc_a: $out
423 done
426 if [ "$TPBIT" ]; then
427 for name in $TPBIT_FUNCS; do
428 if [ "$libgcc_s_so" ]; then
429 out="libgcc/${dir}/${name}${objext}"
430 outS="libgcc/${dir}/${name}_s${objext}"
432 echo $outS: $TPBIT $fpbit_c_dep
433 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
434 -c $TPBIT -o $outS
436 echo $out: $TPBIT $fpbit_c_dep
437 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
438 '$(vis_hide)' -c $TPBIT -o $out
440 echo $libgcc_a: $out
441 echo $libgcc_s_so: $outS
442 if [ "$SHLIB_MKMAP" ]; then
443 echo libgcc/${dir}/libgcc.map: $outS
445 else
446 out="libgcc/${dir}/${name}${objext}"
447 echo $out: $TPBIT $fpbit_c_dep
448 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
449 -c $TPBIT -o $out
451 echo $libgcc_a: $out
453 done
456 for file in $LIB2ADD; do
457 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
458 oname=`echo $name | sed -e 's,.*/,,'`
460 if [ "$libgcc_s_so" ]; then
461 out="libgcc/${dir}/${oname}${objext}"
462 outS="libgcc/${dir}/${oname}_s${objext}"
464 case $file in
465 *.c)
466 echo $outS: stmp-dirs $file $libgcc_dep
467 echo " $gcc_compile" $flags -c $file -o $outS
469 echo $out: stmp-dirs $file $libgcc_dep
470 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
473 *.asm | *.S)
474 outV="libgcc/${dir}/${oname}.vis"
476 echo $outS: stmp-dirs $file $libgcc_dep
477 echo " $gcc_compile" $flags -xassembler-with-cpp \
478 -c $file -o $outS
480 echo $out: stmp-dirs $file $libgcc_dep $outV
481 echo " $gcc_compile" $flags -xassembler-with-cpp \
482 -include $outV -c $file -o $out
483 echo "${outV}: ${outS}; \$(gen-hide-list)"
487 echo "Unhandled extension: $file" >&2
488 exit 1
490 esac
492 echo $libgcc_a: $out
493 echo $libgcc_s_so: $outS
494 if [ "$SHLIB_MKMAP" ]; then
495 echo libgcc/${dir}/libgcc.map: $outS
497 else
498 out="libgcc/${dir}/${oname}${objext}"
499 case $file in
500 *.c)
501 echo $out: stmp-dirs $file $libgcc_dep
502 echo " $gcc_compile" $flags -c $file -o $out
505 *.asm | *.S)
506 echo $out: stmp-dirs $file $libgcc_dep
507 echo " $gcc_compile" $flags -xassembler-with-cpp \
508 -c $file -o $out
512 echo "Unhandled extension: $file" >&2
513 exit 1
515 esac
517 echo $libgcc_a: $out
519 done
522 for file in $LIB2ADD_ST; do
523 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
524 oname=`echo $name | sed -e 's,.*/,,'`
525 out="libgcc/${dir}/${oname}${objext}"
527 case $file in
528 *.c)
529 echo $out: stmp-dirs $file $libgcc_dep
530 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
533 *.asm | *.S)
534 # We may have to compile it twice in order to establish the list
535 # of symbols to be marked hidden.
536 if [ "$libgcc_so" ]; then
537 outV="libgcc/${dir}/${oname}.vis"
538 outT="libgcc/${dir}/${oname}_t${objext}"
539 echo ${outT}: stmp-dirs $file $libgcc_dep
540 echo " $gcc_compile" $flags -xassembler-with-cpp \
541 -c $file -o ${outT}
542 echo $out: stmp-dirs $file $libgcc_dep $outV
543 echo " $gcc_compile" $flags -xassembler-with-cpp \
544 -include $outV -c $file -o $out
545 echo "${outV}: ${outT}; \$(gen-hide-list)"
546 else
547 echo $out: stmp-dirs $file $libgcc_dep
548 echo " $gcc_compile" $flags -xassembler-with-cpp \
549 -c $file -o $out
554 echo "Unhandled extension: $file" >&2
555 exit 1
557 esac
558 echo $libgcc_a: $out
559 done
561 # If we don't have libgcc_eh.a, only LIB2ADDEH matters. If we do, only
562 # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter. (Usually all three are
563 # identical.) We do _not_ handle assembly files in this context.
565 if [ "$libgcc_eh_a" ]; then
566 for file in $LIB2ADDEHSTATIC; do
567 case $file in
568 *.c) ;;
569 *) echo "Unhandled extension: $file">&2; exit 1 ;;
570 esac
572 name=`echo $file | sed -e 's/[.]c$//'`
573 oname=`echo $name | sed -e 's,.*/,,'`
574 out="libgcc/${dir}/${oname}${objext}"
576 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
577 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
578 echo $libgcc_eh_a: $out
579 done
581 for file in $LIB2ADDEHSHARED; do
582 case $file in
583 *.c) ;;
584 *) echo "Unhandled extension: $file">&2; exit 1 ;;
585 esac
587 name=`echo $file | sed -e 's/[.]c$//'`
588 oname=`echo $name | sed -e 's,.*/,,'`
589 out="libgcc/${dir}/${oname}_s${objext}"
591 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
592 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
593 echo $libgcc_s_so: $out
594 if [ "$SHLIB_MKMAP" ]; then
595 echo libgcc/${dir}/libgcc.map: $out
597 done
599 else # no libgcc_eh.a
600 for file in $LIB2ADDEH; do
601 case $file in
602 *.c) ;;
603 *) echo "Unhandled extension: $file">&2; exit 1 ;;
604 esac
606 name=`echo $file | sed -e 's/[.]c$//'`
607 oname=`echo $name | sed -e 's,.*/,,'`
608 out="libgcc/${dir}/${oname}${objext}"
610 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
611 echo " $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
612 echo $libgcc_a: $out
613 done
616 # Again, this does not handle assembly.
617 if [ "$LIBUNWIND" ]; then
618 for file in $LIBUNWIND; do
619 case $file in
620 *.c) ;;
621 *) echo "Unhandled extension: $file">&2; exit 1 ;;
622 esac
624 name=`echo $file | sed -e 's/[.]c$//'`
625 oname=`echo $name | sed -e 's,.*/,,'`
627 if [ "$libunwind_so" ]; then
628 out="libgcc/${dir}/${oname}${objext}"
629 outS="libgcc/${dir}/${oname}_s${objext}"
631 echo $out: stmp-dirs $file $LIBUNWINDDEP
632 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
634 echo $outS: stmp-dirs $file $LIBUNWINDDEP
635 echo " $gcc_compile $flags -fexceptions -DSHARED -c $file -o $outS"
637 echo $libunwind_a: $out
638 echo $libunwind_so: $outS
639 else
640 out="libgcc/${dir}/${oname}${objext}"
641 echo $out: stmp-dirs $file $LIBUNWINDDEP
642 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
643 echo $libunwind_a: $out
645 done
649 # build libgcov components
651 for name in $LIBGCOV; do
652 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
653 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
654 out="libgcc/${dir}/${name}${objext}"
656 echo $out: $libgcov_c_dep
657 echo " $gcc_compile $flags -DL$name -c \$(srcdir)/libgcov.c -o $out"
658 echo $libgcov_a: $out
659 done
661 # EXTRA_MULTILIB_PARTS.
662 if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
663 # Each of the EXTRA_MULTILIB_PARTS is built by recursive invocation
664 # of the parent Makefile. We must do this just once for each
665 # multilib, passing it all the EXTRA_MULTILIB_PARTS as
666 # simultaneous goal targets, so that rules which cannot execute
667 # simultaneously are properly serialized.
669 extra=
670 echo
671 for f in $EXTRA_MULTILIB_PARTS; do
672 case $dir in
673 .) out=$f ; t= ;;
674 *) out=$dir/$f ; t=$dir/ ;;
675 esac
676 case $out in
677 # Prevent `make' from interpreting $out as a macro assignment
678 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
679 *) targ=$out ;;
680 esac
681 extra="$extra $targ"
682 done
684 echo extra$suffix: stmp-dirs
685 echo " $make_compile" \\
686 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
687 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $extra
688 echo "all: extra$suffix"
690 # Make libunwind.so and libgcc_s.so depend on these, since they
691 # are likely to be implicitly used by the link process.
692 if [ "$libgcc_s_so" ]; then
693 echo "$libgcc_s_so: extra$suffix"
695 if [ "$libunwind_so" ]; then
696 echo "$libunwind_so: extra$suffix"
700 # Library build rules.
701 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
702 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
704 # Map-file generation.
705 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
706 mapfile="libgcc/${dir}/libgcc.map"
707 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
708 # This uses a here document instead of echos because some shells
709 # will convert the \1 in the second sed command to a control-A.
710 # The behavior of here documents is more predictable.
711 cat <<EOF
713 ${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES
714 { \$(NM_FOR_TARGET) $SHLIB_NM_FLAGS \$(objects); echo %%; \\
715 cat $SHLIB_MAPFILES \\
716 | sed -e '/^[ ]*#/d' \\
717 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \\
718 | $gcc_compile $flags -E -xassembler-with-cpp -; \\
719 } | \$(AWK) -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}
720 mv '$tmpmapfile' \$@
721 $libgcc_s_so: ${mapfile}
725 # Static libraries.
727 # Each of these .a files depends on stmp-dirs. It would seem that
728 # this dependency is redundant, since each of the object files
729 # itself depends on stmp-dirs. However, it is possible that there
730 # are in fact no object files. In that case, the stmp-dirs
731 # dependency is required; the directory containing the archive must
732 # exist before the archive itself can be created.
733 echo ""
734 echo "$libgcc_a: stmp-dirs"
735 echo " -rm -f $libgcc_a"
736 echo ' $(AR_CREATE_FOR_TARGET)' $libgcc_a '$(objects)'
737 echo ' $(RANLIB_FOR_TARGET)' $libgcc_a
738 echo "all: $libgcc_a"
740 echo ""
741 echo "$libgcov_a: stmp-dirs"
742 echo " -rm -f $libgcov_a"
743 echo ' $(AR_CREATE_FOR_TARGET)' $libgcov_a '$(objects)'
744 echo ' $(RANLIB_FOR_TARGET)' $libgcov_a
745 echo "all: $libgcov_a"
747 # These libraries are not always built.
748 if [ "$libunwind_a" ]; then
749 echo ""
750 echo "$libunwind_a: stmp-dirs"
751 echo " -rm -f $libunwind_a"
752 echo ' $(AR_CREATE_FOR_TARGET)' $libunwind_a '$(objects)'
753 echo ' $(RANLIB_FOR_TARGET)' $libunwind_a
754 echo "all: $libunwind_a"
757 if [ "$libgcc_eh_a" ]; then
758 echo ""
759 echo "${dir}/libgcc_eh.a: stmp-dirs"
760 echo " -rm -f ${dir}/libgcc_eh.a"
761 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a '$(objects)'
762 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
763 echo "all: $libgcc_eh_a"
766 # Shared libraries.
767 if [ "$libgcc_s_so" ]; then
768 echo ""
769 echo "$libgcc_s_so: stmp-dirs $libunwind_so"
770 echo " $SHLIB_LINK" \
771 | sed -e "s%@multilib_flags@%$flags%g" \
772 -e "s%@multilib_dir@%$dir%g" \
773 -e "s%@shlib_objs@%\$(objects)%g" \
774 -e "s%@shlib_base_name@%$libgcc_s_so_base%g" \
775 -e "s%@shlib_so_name@%$libgcc_s_soname%g" \
776 -e "s%@shlib_map_file@%$mapfile%g" \
777 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
778 echo "all: $libgcc_s_so"
781 if [ "$libunwind_so" ]; then
782 echo ""
783 echo "$libunwind_so: stmp-dirs"
784 echo " $SHLIBUNWIND_LINK" \
785 | sed -e "s%@multilib_flags@%$flags%g" \
786 -e "s%@multilib_dir@%$dir%g" \
787 -e "s%@shlib_objs@%\$(objects)%g" \
788 -e "s%@shlib_base_name@%$libunwind_so_base%g" \
789 -e "s%@shlib_so_name@%$libunwind_soname%g" \
790 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
791 echo "all: $libunwind_so"
794 done # ml in MULTILIBS
796 echo
797 echo "libgcc-stage-start:"
798 echo " for dir in \$(dirs); do \\"
799 echo " if [ -d \$(stage)/\$\$dir ]; then :; \\"
800 echo " else $mkinstalldirs \$(stage)/\$\$dir; fi; \\"
801 echo " done"
802 echo " -for dir in \$(dirs); do \\"
803 echo " mv \$\$dir/*${objext} \$(stage)/\$\$dir; \\"
804 echo " mv \$\$dir/*.vis \$(stage)/\$\$dir; \\"
805 echo " mv \$\$dir/*.map \$(stage)/\$\$dir; \\"
806 echo " test ! -f \$\$dir/libgcc.a || mv \$\$dir/lib* \$(stage)/\$\$dir; \\"
807 echo " done"
809 echo
810 echo "stmp-dirs:"
811 echo " for d in \$(dirs); do \\"
812 echo " if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
813 echo " done"
814 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
816 echo ""
817 echo "install: all"
818 for ml in $MULTILIBS; do
819 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
820 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
821 if [ $dir != . ]; then
822 ldir='$(DESTDIR)$(libsubdir)'/$dir
823 echo " if [ -d $ldir ]; then true; else $mkinstalldirs $ldir; chmod a+rx $ldir; fi;"
824 else
825 ldir='$(DESTDIR)$(libsubdir)'
827 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
828 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
829 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a ${ldir}/
830 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
832 if [ "$SHLIB_LINK" ]; then
833 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
834 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
836 if [ -z "$SHLIB_MULTILIB" ]; then
837 if [ "$dir" = . ]; then
838 shlib_base_name=libgcc_s
839 shlibunwind_base_name=libunwind
840 else
841 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
842 shlibunwind_base_name=libunwind_`echo $dir | sed s,/,_,g`
844 shlib_so_name="$shlib_base_name"
845 shlibunwind_so_name="$shlibunwind_base_name"
846 shlib_dir=
847 shlib_slibdir_qual=
848 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
849 gcc_multilib_dir=`./xgcc -B./ $flags --print-multi-directory`
850 os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
851 if [ "$dir" != . ]; then
852 shlib_dir="$dir"/
854 gcc_multilib_sup=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
855 os_multilib_base=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
856 if [ -z "$os_multilib_base" ]; then
857 shlib_so_name=libgcc_s
858 shlibunwind_so_name=libunwind
859 if [ "$os_multilib_dir" != "." ]; then
860 shlib_slibdir_qual="/$os_multilib_dir"
862 else
863 shlib_so_name=libgcc_s_`echo $gcc_multilib_sup | sed s,/,_,g`
864 shlibunwind_so_name=libunwind_`echo $gcc_multilib_sup | sed s,/,_,g`
865 shlib_slibdir_qual="/$os_multilib_base"
868 echo " $SHLIB_INSTALL" \
869 | sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
870 -e "s%@shlib_so_name@%$shlib_so_name%g" \
871 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
872 if [ "$LIBUNWIND" ]; then
873 echo " $SHLIBUNWIND_INSTALL" \
874 | sed -e "s%@shlib_base_name@%$shlibunwind_base_name%g" \
875 -e "s%@shlib_so_name@%$shlibunwind_so_name%g" \
876 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
877 libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
878 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
879 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
881 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
882 shlib_base_name="libgcc_s";
883 echo " $SHLIB_INSTALL" \
884 | sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
885 -e "s%@shlib_so_name@%$shlib_base_name%g" \
886 -e "s%@shlib_slibdir_qual@%%g"
887 if [ "$LIBUNWIND" ]; then
888 echo " $SHLIBUNWIND_INSTALL" \
889 | sed -e "s%@shlib_base_name@%$shlibunwind_base_name%g" \
890 -e "s%@shlib_so_name@%$shlibunwind_base_name%g" \
891 -e "s%@shlib_slibdir_qual@%%g"
892 libunwinddir='$(DESTDIR)$(slibdir)'
893 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
894 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
898 done
899 for f in $EXTRA_MULTILIB_PARTS; do
900 for ml in $MULTILIBS; do
901 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
902 if [ $dir != . ]; then
903 out=${dir}/$f
904 ldir='$(DESTDIR)$(libsubdir)'/$dir
905 else
906 out=$f
907 ldir='$(DESTDIR)$(libsubdir)'
909 echo ' $(INSTALL_DATA)' $out $ldir/
910 done
911 done
913 echo '.PHONY: all install'