OSDN Git Service

* Makefile.in (libgcc.mk): Depend on xgcc$(exeext) for
[pf3gnuchains/gcc-fork.git] / gcc / mklibgcc.in
1 #!/bin/sh
2 # Construct makefile for libgcc.
3 #   Copyright (C) 2000 Free Software Foundation, Inc.
4 #
5 # This file is part of GNU CC.
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 # OLDCC
12 # LIBGCC1
13 # LIB1FUNCS
14 # LIB1ASMFUNCS
15 # LIB1FUNCS_EXTRA
16 # LIB2FUNCS
17 # LIB2FUNCS_EH
18 # LIB2ADD
19 # FPBIT
20 # FPBIT_FUNCS
21 # DPBIT
22 # DPBIT_FUNCS
23 # LIBGCC
24 # MULTILIBS
25 # EXTRA_MULTILIB_PARTS
26
27 # Make needs VPATH to be literal.
28 echo 'srcdir = @srcdir@'
29 echo 'VPATH = @srcdir@'
30 echo 'EQ = ='
31 echo
32
33 # Detect gcc as OLDCC.  This indicates a target for which LIB1FUNCS
34 # is not needed.  This is not quite the same as libgcc1.null, even
35 # on a target not using libgcc1-asm.a.
36
37 if [ "@build_canonical@" = "@target@" ]; then
38   tmp="tmp-$$.c"
39   cat > $tmp <<EOF
40 #ifdef __GNUC__
41   yes;
42 #endif
43 EOF
44   if $OLDCC -E $tmp | grep yes > /dev/null 2>&1; then
45     LIB1FUNCS=""
46   fi
47   rm -f $tmp
48 fi
49
50
51 # Build lines.
52
53 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
54 oldcc_compile='$(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
55 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
56           AR_FOR_TARGET="$(AR_FOR_TARGET)" \
57           AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
58           AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
59           AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
60           CC="$(CC)" CFLAGS="$(CFLAGS)" \
61           HOST_PREFIX="$(HOST_PREFIX)" \
62           HOST_PREFIX_1="$(HOST_PREFIX_1)" \
63           LANGUAGES="$(LANGUAGES)"'
64
65 # Dependancies for libgcc1.c
66 libgcc1_c_dep='$(srcdir)/libgcc1.c $(CONFIG_H)'
67
68 # Dependancies for libgcc2.c
69 libgcc2_c_dep='$(srcdir)/libgcc2.c $(CONFIG_H) $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'
70
71 # Dependancies for fp-bit.c
72 fpbit_c_dep='config.status tsystem.h'
73
74 #
75 # Build libgcc1 components.
76 #
77
78 libgcc1_objs=""
79
80 case X"$LIBGCC1" in
81   Xlibgcc1.null | X)
82     ;;
83
84   Xlibgcc1.cross)
85     echo "You must find a way to make libgcc1 components yourself" 1>&2
86     ;;
87
88   Xlibgcc1-asm.a)
89     for name in $LIB1ASMFUNCS; do
90       for ml in $MULTILIBS; do
91         dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
92         flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
93         out="libgcc/${dir}/${name}${objext}"
94
95         if [ $dir = . ]; then
96           libgccdir="libgcc"
97         else
98           libgccdir="libgcc/${dir}"
99         fi
100         echo ${out}: ${libgccdir} '$(srcdir)/config/$(LIB1ASMSRC)'
101         echo "  $gcc_compile" $flags -DL$name -xassembler-with-cpp \
102           -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
103       done
104       libgcc1_objs="$libgcc1_objs ${name}${objext}"
105     done
106     ;;
107
108   Xlibgcc1.a)
109     for name in $LIB1FUNCS; do
110       out="libgcc/${name}${objext}"
111
112       echo $out: $libgcc1_c_dep
113       if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
114         echo "  $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
115       else
116         echo "  $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
117         echo "  mv libgcc1${objext} $out"
118       fi
119
120       libgcc1_objs="$libgcc1_objs ${name}${objext}"
121     done
122
123     for file in $LIB1FUNCS_EXTRA; do
124       name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
125       out="libgcc/${name}${objext}"
126
127       echo $out: $file
128       if [ ${name}.asm = $file ]; then
129         echo "  cp $file ${name}.s"
130         file=${name}.s
131       fi
132
133       if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
134         echo "  $oldcc_compile" -c $file -o $out
135       else
136         echo "  $oldcc_compile" -c $file
137         tmp=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
138         echo "  mv $tmp $out"
139       fi
140
141       libgcc1_objs="$libgcc1_objs ${name}${objext}"
142     done
143     ;;
144   *)
145     echo "I'm confused about libgcc1." 1>&2
146     exit 1
147     ;;
148 esac
149
150 #
151 # Build libgcc2 components.
152 #
153
154 libgcc2_objs=""
155
156 for name in $LIB2FUNCS; do
157   for ml in $MULTILIBS; do
158     dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
159     flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
160     out="libgcc/${dir}/${name}${objext}"
161
162     if [ $dir = . ]; then
163       libgccdir="libgcc"
164     else
165       libgccdir="libgcc/${dir}"
166     fi
167     echo $out: $libgccdir $libgcc2_c_dep
168     echo "      $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
169       -c '$(srcdir)/libgcc2.c' -o $out
170   done
171   libgcc2_objs="$libgcc2_objs ${name}${objext}"
172 done
173
174 for name in $LIB2FUNCS_EH; do
175   for ml in $MULTILIBS; do
176     dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
177     flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
178     out="libgcc/${dir}/${name}${objext}"
179
180     if [ $dir = . ]; then
181       libgccdir="libgcc"
182     else
183       libgccdir="libgcc/${dir}"
184     fi
185     echo $out: $libgccdir $libgcc2_c_dep
186     echo "      $gcc_compile" '$(MAYBE_USE_COLLECT2)' -fexceptions \
187       $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
188   done
189   libgcc2_objs="$libgcc2_objs ${name}${objext}"
190 done
191
192 if [ "$FPBIT" ]; then
193   for name in $FPBIT_FUNCS; do
194     for ml in $MULTILIBS; do
195       dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
196       flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
197       out="libgcc/${dir}/${name}${objext}"
198
199       if [ $dir = . ]; then
200         libgccdir="libgcc"
201       else
202         libgccdir="libgcc/${dir}"
203       fi
204       echo $out: $libgccdir $FPBIT $fpbit_c_dep
205       echo "    $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
206         -c $FPBIT -o $out
207     done
208     libgcc2_objs="$libgcc2_objs ${name}${objext}"
209   done
210 fi
211
212 if [ "$DPBIT" ]; then
213   for name in $DPBIT_FUNCS; do
214     for ml in $MULTILIBS; do
215       dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
216       flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
217       out="libgcc/${dir}/${name}${objext}"
218
219       if [ $dir = . ]; then
220         libgccdir="libgcc"
221       else
222         libgccdir="libgcc/${dir}"
223       fi
224       echo $out: $libgccdir $DPBIT $fpbit_c_dep
225       echo "    $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
226         -c $DPBIT -o $out
227     done
228     libgcc2_objs="$libgcc2_objs ${name}${objext}"
229   done
230 fi
231
232 for file in $LIB2ADD; do
233   name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
234   oname=`echo $name | sed -e 's,.*/,,'`
235
236   if [ ${name}.txt = ${file} ]; then
237     fprime=`cat $file`
238     for f in $fprime; do
239
240       lastout=""
241       for ml in $MULTILIBS; do
242         dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
243         flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
244         out="libgcc/${dir}/${f}"
245
246         # Depend on previous out to serialize all sub-makes of this
247         # target file.  This because ./$f is used as a temporary in
248         # each case before being moved to libgcc/$dir/.
249         echo $out: $lastout
250         echo "  $make_compile" \\
251         echo '    LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
252         echo '    MULTILIB_CFLAGS="'$flags'"' $f
253         echo "  mv $f $out"
254
255         lastout="$out"
256       done
257
258       libgcc2_objs="$libgcc2_objs $f"
259     done
260   else
261     for ml in $MULTILIBS; do
262       dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
263       flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
264       out="libgcc/${dir}/${oname}${objext}"
265       if [ ${name}.asm = ${file} ]; then
266         flags="$flags -xassembler-with-cpp"
267       fi
268
269       if [ $dir = . ]; then
270         libgccdir="libgcc"
271       else
272         libgccdir="libgcc/${dir}"
273       fi
274       echo $out: $libgccdir $file
275       echo "    $gcc_compile" $flags -c $file -o $out
276     done
277     libgcc2_objs="$libgcc2_objs ${oname}${objext}"
278   fi
279 done
280
281 for ml in $MULTILIBS; do
282   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
283
284   libgcc_objs=""
285   for o in $libgcc1_objs; do
286     if [ "$LIBGCC1" = libgcc1-asm.a ]; then
287       libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
288     else
289       libgcc_objs="$libgcc_objs libgcc/$o"
290     fi
291   done
292   for o in $libgcc2_objs; do
293     libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
294   done
295
296   echo ""
297   echo "${dir}/libgcc.a: $libgcc_objs"
298   echo "        -rm -rf ${dir}/libgcc.a"
299   echo '        $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs
300   echo '        if $(RANLIB_TEST_FOR_TARGET) ; then' \\
301   echo '          $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
302   echo '        else true; fi;'
303 done
304
305 echo ""
306 all=""
307
308 echo "libgcc:; -mkdir libgcc"
309 for ml in $MULTILIBS; do
310   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
311   if [ $dir != . ]; then
312     echo "libgcc/${dir}: libgcc; -mkdir libgcc/${dir}"
313   fi
314   all="$all ${dir}/libgcc.a"
315 done
316
317 for f in $EXTRA_MULTILIB_PARTS; do
318   lastout=""
319   for ml in $MULTILIBS; do
320     dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
321     flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
322     out="$dir/$f"
323
324     # Depend on previous out to serialize all sub-makes of this
325     # target file.  This because ./$f is used as a temporary in
326     # each case before being moved to libgcc/$dir/.
327     echo $out: $lastout
328     echo "      $make_compile" \\
329     echo '        LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
330     echo '        MULTILIB_CFLAGS="'$flags'"' T=t t$f
331     echo "      mv t$f $out"
332
333     all="$all $out"
334     lastout="$out"
335   done
336 done
337
338 echo ""
339 echo "all: $all"