OSDN Git Service

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