OSDN Git Service

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