OSDN Git Service

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