mklibgcc.in: Correct calculation of libgcc_s_soname and libunwind_soname.
[official-gcc.git] / gcc / mklibgcc.in
blobfa6930b1c60530f6f19909903df226efb1ebd078
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);' | \\"
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=
164 if [ "$LIBUNWIND" ]; then
165 libunwind_a=$dir/libunwind.a
167 if [ "$SHLIB_LINK" ]; then
168 if [ -z "$SHLIB_MULTILIB" ]; then
169 if [ "$dir" = . ]; then
170 libgcc_eh_a=$dir/libgcc_eh.a
171 libgcc_s_so_base=$dir/libgcc_s
172 libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
173 libgcc_s_soname=libgcc_s
174 if [ "$LIBUNWIND" ]; then
175 libunwind_so_base=$dir/libunwind
176 libunwind_so=${libunwind_so_base}${SHLIB_EXT}
177 libunwind_soname=libunwind
179 else
180 suffix=`echo $dir | sed s,/,_,g`
181 libgcc_eh_a=$dir/libgcc_eh.a
182 libgcc_s_so_base=$dir/libgcc_s_${suffix}
183 libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
184 libgcc_s_soname=libgcc_s_${suffix}
185 if [ "$LIBUNWIND" ]; then
186 libunwind_so_base=$dir/libunwind_${suffix}
187 libunwind_so=${libunwind_so_base}${SHLIB_EXT}
191 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
192 if [ "$dir" != . ]; then
193 gcc_multilib_dir=`./xgcc -B./ $flags --print-multi-directory`
194 os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
195 shlib_dir="$dir"/
196 gcc_multilib_sup=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
197 os_multilib_base=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
198 if [ -z "$os_multilib_base" ]; then
199 libgcc_s_soname=libgcc_s
200 libunwind_soname=libunwind
201 if [ "$os_multilib_dir" != "." ]; then
202 shlib_dir_qual="/$os_multilib_dir"
204 else
205 libgcc_s_soname=libgcc_s_`echo $gcc_multilib_sup | sed s,/,_,g`
206 libunwind_soname=libunwind_`echo $gcc_multilib_sup | sed s,/,_,g`
207 shlib_dir_qual="/$os_multilib_base"
212 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
213 libgcc_eh_a=$dir/libgcc_eh.a
214 libgcc_s_so_base=$dir/libgcc_s
215 libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
216 libgcc_s_soname=libgcc_s
217 if [ "$LIBUNWIND" ]; then
218 libunwind_so_base=$dir/libunwind
219 libunwind_so=${libunwind_so_base}${SHLIB_EXT}
220 libunwind_soname=libunwind
224 libgcc_s_so_extra=
225 libunwind_so_extra=
227 echo
228 echo \#
229 echo \# ml: $ml
230 echo \# dir: $dir
231 echo \# flags: $flags
232 echo \# libgcc_a: $libgcc_a
233 echo \# libgcov_a: $libgcov_a
234 echo \# libgcc_eh_a: $libgcc_eh_a
235 echo \# libunwind_a: $libunwind_a
236 echo \#
237 echo \# gcc_multilib_dir: $gcc_multilib_dir
238 echo \# gcc_multilib_sup: $gcc_multilib_sup
239 echo \# os_multilib_dir: $os_multilib_dir
240 echo \# os_multilib_base: $os_multilib_base
241 echo \# shlib_dir: $shlib_dir
242 echo \# shlib_dir_qual: $shlib_dir_qual
243 echo \#
244 echo \# libgcc_s_so: $libgcc_s_so
245 echo \# libgcc_s_so_base: $libgcc_s_so_base
246 echo \# libgcc_s_soname: $libgcc_s_soname
247 echo \#
248 echo \# libunwind_so: $libunwind_so
249 echo \# libunwind_so_base: $libunwind_so_base
250 echo \# libunwind_soname: $libunwind_soname
251 echo \#
252 echo
254 # Update list of directories.
255 if [ $dir != . ]; then
256 echo "dirs += ${dir} libgcc/${dir}"
257 echo
261 # Build libgcc1 components.
263 for name in $LIB1ASMFUNCS; do
264 if [ "$libgcc_s_so" ]; then
265 out="libgcc/${dir}/${name}${objext}"
266 outS="libgcc/${dir}/${name}_s${objext}"
267 outV="libgcc/${dir}/${name}.vis"
269 echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
270 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
271 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
273 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
274 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
275 -c '$(srcdir)/config/$(LIB1ASMSRC)' -include $outV -o $out
277 echo "${outV}: ${outS}; \$(gen-hide-list)"
279 echo $libgcc_a: $out
280 echo $libgcc_s_so: $outS
281 if [ "$SHLIB_MKMAP" ]; then
282 echo libgcc/${dir}/libgcc.map: $outS
284 else
285 out="libgcc/${dir}/${name}${objext}"
286 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
287 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
288 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
289 echo $libgcc_a: $out
291 done
294 # Build libgcc2 components.
297 for name in $lib2funcs; do
298 if [ "$libgcc_s_so" ]; then
299 out="libgcc/${dir}/${name}${objext}"
300 outS="libgcc/${dir}/${name}_s${objext}"
302 echo $outS: $libgcc2_c_dep
303 echo " $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $outS
305 echo $out: $libgcc2_c_dep
306 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
307 -c '$(srcdir)/libgcc2.c' -o $out
309 echo $libgcc_a: $out
310 echo $libgcc_s_so: $outS
311 if [ "$SHLIB_MKMAP" ]; then
312 echo libgcc/${dir}/libgcc.map: $outS
314 else
315 out="libgcc/${dir}/${name}${objext}"
316 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
317 echo " $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
318 echo $libgcc_a: $out
320 done
322 for name in $LIB2FUNCS_ST; do
323 out="libgcc/${dir}/${name}${objext}"
325 echo $out: $libgcc2_c_dep
326 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
327 -c '$(srcdir)/libgcc2.c' -o $out
328 echo ${dir}/libgcc.a: $out
329 done
331 for name in $LIB2_DIVMOD_FUNCS; do
332 if [ "$libgcc_s_so" ]; then
333 out="libgcc/${dir}/${name}${objext}"
334 outS="libgcc/${dir}/${name}_s${objext}"
336 echo $outS: $libgcc2_c_dep
337 echo " $gcc_compile" $flags -DL$name \
338 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
340 echo $out: $libgcc2_c_dep
341 echo " $gcc_compile" $flags -DL$name '$(vis_hide)' \
342 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
344 echo $libgcc_a: $out
345 echo $libgcc_s_so: $outS
346 if [ "$SHLIB_MKMAP" ]; then
347 echo libgcc/${dir}/libgcc.map: $outS
349 else
350 out="libgcc/${dir}/${name}${objext}"
351 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
352 echo " $gcc_compile" $flags -DL$name \
353 -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $out
354 echo $libgcc_a: $out
356 done
359 # Build software floating point functions.
362 if [ "$FPBIT" ]; then
363 for name in $FPBIT_FUNCS; do
364 if [ "$libgcc_s_so" ]; then
365 out="libgcc/${dir}/${name}${objext}"
366 outS="libgcc/${dir}/${name}_s${objext}"
368 echo $outS: $FPBIT $fpbit_c_dep
369 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
370 -c $FPBIT -o $outS
372 echo $out: $FPBIT $fpbit_c_dep
373 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
374 '$(vis_hide)' -c $FPBIT -o $out
376 echo $libgcc_a: $out
377 echo $libgcc_s_so: $outS
378 if [ "$SHLIB_MKMAP" ]; then
379 echo libgcc/${dir}/libgcc.map: $outS
381 else
382 out="libgcc/${dir}/${name}${objext}"
383 echo $out: $FPBIT $fpbit_c_dep
384 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
385 -c $FPBIT -o $out
387 echo $libgcc_a: $out
389 done
392 if [ "$DPBIT" ]; then
393 for name in $DPBIT_FUNCS; do
394 if [ "$libgcc_s_so" ]; then
395 out="libgcc/${dir}/${name}${objext}"
396 outS="libgcc/${dir}/${name}_s${objext}"
398 echo $outS: $DPBIT $fpbit_c_dep
399 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
400 -c $DPBIT -o $outS
402 echo $out: $DPBIT $fpbit_c_dep
403 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
404 '$(vis_hide)' -c $DPBIT -o $out
406 echo $libgcc_a: $out
407 echo $libgcc_s_so: $outS
408 if [ "$SHLIB_MKMAP" ]; then
409 echo libgcc/${dir}/libgcc.map: $outS
411 else
412 out="libgcc/${dir}/${name}${objext}"
413 echo $out: $DPBIT $fpbit_c_dep
414 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
415 -c $DPBIT -o $out
417 echo $libgcc_a: $out
419 done
422 if [ "$TPBIT" ]; then
423 for name in $TPBIT_FUNCS; do
424 if [ "$libgcc_s_so" ]; then
425 out="libgcc/${dir}/${name}${objext}"
426 outS="libgcc/${dir}/${name}_s${objext}"
428 echo $outS: $TPBIT $fpbit_c_dep
429 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
430 -c $TPBIT -o $outS
432 echo $out: $TPBIT $fpbit_c_dep
433 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
434 '$(vis_hide)' -c $TPBIT -o $out
436 echo $libgcc_a: $out
437 echo $libgcc_s_so: $outS
438 if [ "$SHLIB_MKMAP" ]; then
439 echo libgcc/${dir}/libgcc.map: $outS
441 else
442 out="libgcc/${dir}/${name}${objext}"
443 echo $out: $TPBIT $fpbit_c_dep
444 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
445 -c $TPBIT -o $out
447 echo $libgcc_a: $out
449 done
452 for file in $LIB2ADD; do
453 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
454 oname=`echo $name | sed -e 's,.*/,,'`
456 if [ "$libgcc_s_so" ]; then
457 out="libgcc/${dir}/${oname}${objext}"
458 outS="libgcc/${dir}/${oname}_s${objext}"
460 case $file in
461 *.c)
462 echo $outS: stmp-dirs $file $libgcc_dep
463 echo " $gcc_compile" $flags -c $file -o $outS
465 echo $out: stmp-dirs $file $libgcc_dep
466 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
469 *.asm | *.S)
470 outV="libgcc/${dir}/${oname}.vis"
472 echo $outS: stmp-dirs $file $libgcc_dep
473 echo " $gcc_compile" $flags -xassembler-with-cpp \
474 -c $file -o $outS
476 echo $out: stmp-dirs $file $libgcc_dep $outV
477 echo " $gcc_compile" $flags -xassembler-with-cpp \
478 -include $outV -c $file -o $out
479 echo "${outV}: ${outS}; \$(gen-hide-list)"
483 echo "Unhandled extension: $file" >&2
484 exit 1
486 esac
488 echo $libgcc_a: $out
489 echo $libgcc_s_so: $outS
490 if [ "$SHLIB_MKMAP" ]; then
491 echo libgcc/${dir}/libgcc.map: $outS
493 else
494 out="libgcc/${dir}/${oname}${objext}"
495 case $file in
496 *.c)
497 echo $out: stmp-dirs $file $libgcc_dep
498 echo " $gcc_compile" $flags -c $file -o $out
501 *.asm | *.S)
502 echo $out: stmp-dirs $file $libgcc_dep
503 echo " $gcc_compile" $flags -xassembler-with-cpp \
504 -c $file -o $out
508 echo "Unhandled extension: $file" >&2
509 exit 1
511 esac
513 echo $libgcc_a: $out
515 done
518 for file in $LIB2ADD_ST; do
519 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
520 oname=`echo $name | sed -e 's,.*/,,'`
521 out="libgcc/${dir}/${oname}${objext}"
523 case $file in
524 *.c)
525 echo $out: stmp-dirs $file $libgcc_dep
526 echo " $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
529 *.asm | *.S)
530 # We may have to compile it twice in order to establish the list
531 # of symbols to be marked hidden.
532 if [ "$libgcc_so" ]; then
533 outV="libgcc/${dir}/${oname}.vis"
534 outT="libgcc/${dir}/${oname}_t${objext}"
535 echo ${outT}: stmp-dirs $file $libgcc_dep
536 echo " $gcc_compile" $flags -xassembler-with-cpp \
537 -c $file -o ${outT}
538 echo $out: stmp-dirs $file $libgcc_dep $outV
539 echo " $gcc_compile" $flags -xassembler-with-cpp \
540 -include $outV -c $file -o $out
541 echo "${outV}: ${outT}; \$(gen-hide-list)"
542 else
543 echo $out: stmp-dirs $file $libgcc_dep
544 echo " $gcc_compile" $flags -xassembler-with-cpp \
545 -c $file -o $out
550 echo "Unhandled extension: $file" >&2
551 exit 1
553 esac
554 echo $libgcc_a: $out
555 done
557 # If we don't have libgcc_eh.a, only LIB2ADDEH matters. If we do, only
558 # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter. (Usually all three are
559 # identical.) We do _not_ handle assembly files in this context.
561 if [ "$libgcc_eh_a" ]; then
562 for file in $LIB2ADDEHSTATIC; do
563 case $file in
564 *.c) ;;
565 *) echo "Unhandled extension: $file">&2; exit 1 ;;
566 esac
568 name=`echo $file | sed -e 's/[.]c$//'`
569 oname=`echo $name | sed -e 's,.*/,,'`
570 out="libgcc/${dir}/${oname}${objext}"
572 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
573 echo " $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
574 echo $libgcc_eh_a: $out
575 done
577 for file in $LIB2ADDEHSHARED; do
578 case $file in
579 *.c) ;;
580 *) echo "Unhandled extension: $file">&2; exit 1 ;;
581 esac
583 name=`echo $file | sed -e 's/[.]c$//'`
584 oname=`echo $name | sed -e 's,.*/,,'`
585 out="libgcc/${dir}/${oname}_s${objext}"
587 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
588 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
589 echo $libgcc_s_so: $out
590 if [ "$SHLIB_MKMAP" ]; then
591 echo libgcc/${dir}/libgcc.map: $out
593 done
595 else # no libgcc_eh.a
596 for file in $LIB2ADDEH; do
597 case $file in
598 *.c) ;;
599 *) echo "Unhandled extension: $file">&2; exit 1 ;;
600 esac
602 name=`echo $file | sed -e 's/[.]c$//'`
603 oname=`echo $name | sed -e 's,.*/,,'`
604 out="libgcc/${dir}/${oname}${objext}"
606 echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
607 echo " $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
608 echo $libgcc_a: $out
609 done
612 # Again, this does not handle assembly.
613 if [ "$LIBUNWIND" ]; then
614 for file in $LIBUNWIND; do
615 case $file in
616 *.c) ;;
617 *) echo "Unhandled extension: $file">&2; exit 1 ;;
618 esac
620 name=`echo $file | sed -e 's/[.]c$//'`
621 oname=`echo $name | sed -e 's,.*/,,'`
623 if [ "$libunwind_so" ]; then
624 out="libgcc/${dir}/${oname}${objext}"
625 outS="libgcc/${dir}/${oname}_s${objext}"
627 echo $out: stmp-dirs $file $LIBUNWINDDEP
628 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
630 echo $outS: stmp-dirs $file $LIBUNWINDDEP
631 echo " $gcc_compile $flags -fexceptions -DSHARED -c $file -o $outS"
633 echo $libunwind_a: $out
634 echo $libunwind_so: $outS
635 else
636 out="libgcc/${dir}/${oname}${objext}"
637 echo $out: stmp-dirs $file $LIBUNWINDDEP
638 echo " $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
639 echo $libunwind_a: $out
641 done
645 # build libgcov components
647 for name in $LIBGCOV; do
648 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
649 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
650 out="libgcc/${dir}/${name}${objext}"
652 echo $out: $libgcov_c_dep
653 echo " $gcc_compile $flags -DL$name -c \$(srcdir)/libgcov.c -o $out"
654 echo $libgcov_a: $out
655 done
657 # EXTRA_MULTILIB_PARTS.
658 echo
659 for f in $EXTRA_MULTILIB_PARTS; do
660 case $dir in
661 .) out=$f ; t= ;;
662 *) out=$dir/$f ; t=$dir/ ;;
663 esac
664 case $out in
665 # Prevent `make' from interpreting $out as a macro assignment
666 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
667 *) targ=$out ;;
668 esac
670 echo $out: stmp-dirs
671 echo " $make_compile" \\
672 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
673 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $targ
674 echo "all: $out"
676 # Make libunwind.so and libgcc_s.so depend on these, since they are
677 # likely to be implicitly used by the link process. However, we must
678 # then arrange to remove them from the explicit object list generated
679 # from $^ - see below.
680 if [ "$libgcc_s_so" ]; then
681 libgcc_s_so_extra="$libgcc_s_so_extra $out"
682 echo "$libgcc_s_so: $out"
684 if [ "$libunwind_so" ]; then
685 libunwind_so_extra="$libunwind_so_extra $out"
686 echo "$libunwind_so: $out"
688 done
690 # Library build rules.
691 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
692 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
694 # Map-file generation.
695 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
696 mapfile="libgcc/${dir}/libgcc.map"
697 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
698 # This uses a here document instead of echos because some shells
699 # will convert the \1 in the second sed command to a control-A.
700 # The behavior of here documents is more predictable.
701 cat <<EOF
703 ${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES
704 { \$(NM_FOR_TARGET) $SHLIB_NM_FLAGS \$(objects); echo %%; \\
705 cat $SHLIB_MAPFILES \\
706 | sed -e '/^[ ]*#/d' \\
707 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \\
708 | $gcc_compile $flags -E -xassembler-with-cpp -; \\
709 } | \$(AWK) -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}
710 mv '$tmpmapfile' \$@
711 $libgcc_s_so: ${mapfile}
715 # Static libraries.
717 # Each of these .a files depends on stmp-dirs. It would seem that
718 # this dependency is redundant, since each of the object files
719 # itself depends on stmp-dirs. However, it is possible that there
720 # are in fact no object files. In that case, the stmp-dirs
721 # dependency is required; the directory containing the archive must
722 # exist before the archive itself can be created.
723 echo ""
724 echo "$libgcc_a: stmp-dirs"
725 echo " -rm -f $libgcc_a"
726 echo ' $(AR_CREATE_FOR_TARGET)' $libgcc_a '$(objects)'
727 echo ' $(RANLIB_FOR_TARGET)' $libgcc_a
728 echo "all: $libgcc_a"
730 echo ""
731 echo "$libgcov_a: stmp-dirs"
732 echo " -rm -f $libgcov_a"
733 echo ' $(AR_CREATE_FOR_TARGET)' $libgcov_a '$(objects)'
734 echo ' $(RANLIB_FOR_TARGET)' $libgcov_a
735 echo "all: $libgcov_a"
737 # These libraries are not always built.
738 if [ "$libunwind_a" ]; then
739 echo ""
740 echo "$libunwind_a: stmp-dirs"
741 echo " -rm -f $libunwind_a"
742 echo ' $(AR_CREATE_FOR_TARGET)' $libunwind_a '$(objects)'
743 echo ' $(RANLIB_FOR_TARGET)' $libunwind_a
744 echo "all: $libunwind_a"
747 if [ "$libgcc_eh_a" ]; then
748 echo ""
749 echo "${dir}/libgcc_eh.a: stmp-dirs"
750 echo " -rm -f ${dir}/libgcc_eh.a"
751 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a '$(objects)'
752 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
753 echo "all: $libgcc_eh_a"
756 # Shared libraries.
757 if [ "$libgcc_s_so" ]; then
758 echo ""
759 echo "$libgcc_s_so: stmp-dirs $libunwind_so"
760 echo " $SHLIB_LINK" \
761 | sed -e "s%@multilib_flags@%$flags%g" \
762 -e "s%@multilib_dir@%$dir%g" \
763 -e "s%@shlib_objs@%\$(filter-out $libgcc_s_so_extra,\$(objects))%g" \
764 -e "s%@shlib_base_name@%$libgcc_s_so_base%g" \
765 -e "s%@shlib_so_name@%$libgcc_s_soname%g" \
766 -e "s%@shlib_map_file@%$mapfile%g" \
767 -e "s%@shlib_dir@%$shlib_dir%g" \
768 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
769 echo "all: $libgcc_s_so"
772 if [ "$libunwind_so" ]; then
773 echo ""
774 echo "$libunwind_so: stmp-dirs"
775 echo " $SHLIBUNWIND_LINK" \
776 | sed -e "s%@multilib_flags@%$flags%g" \
777 -e "s%@multilib_dir@%$dir%g" \
778 -e "s%@shlib_objs@%\$(filter-out $libunwind_so_extra,\$(objects))%g" \
779 -e "s%@shlib_base_name@%$libunwind_so_base%g" \
780 -e "s%@shlib_so_name@%$libunwind_soname%g" \
781 -e "s%@shlib_dir@%$shlib_dir%g" \
782 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
783 echo "all: $libunwind_so"
786 done # ml in MULTILIBS
788 echo
789 echo "libgcc-stage-start:"
790 echo " for dir in \$(dirs); do \\"
791 echo " if [ -d \$(stage)/\$\$dir ]; then :; \\"
792 echo " else $mkinstalldirs \$(stage)/\$\$dir; fi; \\"
793 echo " done"
794 echo " -for dir in \$(dirs); do \\"
795 echo " mv \$\$dir/*${objext} \$(stage)/\$\$dir; \\"
796 echo " mv \$\$dir/*.vis \$(stage)/\$\$dir; \\"
797 echo " mv \$\$dir/*.map \$(stage)/\$\$dir; \\"
798 echo " test ! -f \$\$dir/libgcc.a || mv \$\$dir/lib* \$(stage)/\$\$dir; \\"
799 echo " done"
801 echo
802 echo "stmp-dirs:"
803 echo " for d in \$(dirs); do \\"
804 echo " if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
805 echo " done"
806 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
808 echo ""
809 echo "install: all"
810 for ml in $MULTILIBS; do
811 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
812 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
813 if [ $dir != . ]; then
814 ldir='$(DESTDIR)$(libsubdir)'/$dir
815 echo " if [ -d $ldir ]; then true; else $mkinstalldirs $ldir; chmod a+rx $ldir; fi;"
816 else
817 ldir='$(DESTDIR)$(libsubdir)'
819 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
820 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
821 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a ${ldir}/
822 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
824 if [ "$SHLIB_LINK" ]; then
825 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
826 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
828 if [ -z "$SHLIB_MULTILIB" ]; then
829 if [ "$dir" = . ]; then
830 shlib_base_name=libgcc_s
831 shlibunwind_base_name=libunwind
832 else
833 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
834 shlibunwind_base_name=libunwind_`echo $dir | sed s,/,_,g`
836 shlib_so_name="$shlib_base_name"
837 shlibunwind_so_name="$shlibunwind_base_name"
838 shlib_dir=
839 shlib_slibdir_qual=
840 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
841 gcc_multilib_dir=`./xgcc -B./ $flags --print-multi-directory`
842 os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
843 if [ "$dir" != . ]; then
844 shlib_dir="$dir"/
846 gcc_multilib_sup=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
847 os_multilib_base=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
848 if [ -z "$os_multilib_base" ]; then
849 shlib_so_name=libgcc_s
850 shlibunwind_so_name=libunwind
851 if [ "$os_multilib_dir" != "." ]; then
852 shlib_slibdir_qual="/$os_multilib_dir"
854 else
855 shlib_so_name=libgcc_s_`echo $gcc_multilib_sup | sed s,/,_,g`
856 shlibunwind_so_name=libunwind_`echo $gcc_multilib_sup | sed s,/,_,g`
857 shlib_slibdir_qual="/$os_multilib_base"
860 echo " $SHLIB_INSTALL" \
861 | sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
862 -e "s%@shlib_so_name@%$shlib_so_name%g" \
863 -e "s%@shlib_dir@%$shlib_dir%g" \
864 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
865 if [ "$LIBUNWIND" ]; then
866 echo " $SHLIBUNWIND_INSTALL" \
867 | sed -e "s%@shlib_base_name@%$shlibunwind_base_name%g" \
868 -e "s%@shlib_so_name@%$shlibunwind_so_name%g" \
869 -e "s%@shlib_dir@%$shlib_dir%g" \
870 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
871 libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
872 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
873 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
875 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
876 shlib_base_name="libgcc_s";
877 echo " $SHLIB_INSTALL" \
878 | sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
879 -e "s%@shlib_so_name@%$shlib_base_name%g" \
880 -e "s%@shlib_dir@%%g" \
881 -e "s%@shlib_slibdir_qual@%%g"
882 if [ "$LIBUNWIND" ]; then
883 echo " $SHLIBUNWIND_INSTALL" \
884 | sed -e "s%@shlib_base_name@%$shlibunwind_base_name%g" \
885 -e "s%@shlib_so_name@%$shlibunwind_base_name%g" \
886 -e "s%@shlib_dir@%%g" \
887 -e "s%@shlib_slibdir_qual@%%g"
888 libunwinddir='$(DESTDIR)$(slibdir)'
889 echo ' $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
890 echo ' $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
894 done
895 for f in $EXTRA_MULTILIB_PARTS; do
896 for ml in $MULTILIBS; do
897 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
898 if [ $dir != . ]; then
899 out=${dir}/$f
900 ldir='$(DESTDIR)$(libsubdir)'/$dir
901 else
902 out=$f
903 ldir='$(DESTDIR)$(libsubdir)'
905 echo ' $(INSTALL_DATA)' $out $ldir/
906 done
907 done
909 echo '.PHONY: all install'