OSDN Git Service

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