OSDN Git Service

* Makefile.in (libgcc.ready): Lose.
[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       done
101       libgcc1_objs="$libgcc1_objs ${name}${objext}"
102     done
103     ;;
104
105   Xlibgcc1.a)
106     for name in $LIB1FUNCS; do
107       out="libgcc/${name}${objext}"
108
109       echo $out: $libgcc1_c_dep
110       if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
111         echo "  $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
112       else
113         echo "  $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
114         echo "  mv libgcc1${objext} $out"
115       fi
116
117       libgcc1_objs="$libgcc1_objs ${name}${objext}"
118     done
119
120     for file in $LIB1FUNCS_EXTRA; do
121       name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
122       out="libgcc/${name}${objext}"
123
124       echo $out: $file
125       if [ ${name}.asm = $file ]; then
126         echo "  cp $file ${name}.s"
127         file=${name}.s
128       fi
129
130       if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
131         echo "  $oldcc_compile" -c $file -o $out
132       else
133         echo "  $oldcc_compile" -c $file
134         tmp=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
135         echo "  mv $tmp $out"
136       fi
137
138       libgcc1_objs="$libgcc1_objs ${name}${objext}"
139     done
140     ;;
141   *)
142     echo "I'm confused about libgcc1." 1>&2
143     exit 1
144     ;;
145 esac
146
147 #
148 # Build libgcc2 components.
149 #
150
151 libgcc2_objs=""
152
153 for name in $LIB2FUNCS; do
154   for ml in $MULTILIBS; do
155     dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
156     flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
157     out="libgcc/${dir}/${name}${objext}"
158
159     echo $out: $libgcc2_c_dep
160     echo "      $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
161       -c '$(srcdir)/libgcc2.c' -o $out
162   done
163   libgcc2_objs="$libgcc2_objs ${name}${objext}"
164 done
165
166 for name in $LIB2FUNCS_EH; do
167   for ml in $MULTILIBS; do
168     dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
169     flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
170     out="libgcc/${dir}/${name}${objext}"
171
172     echo $out: $libgcc2_c_dep
173     echo "      $gcc_compile" '$(MAYBE_USE_COLLECT2)' -fexceptions \
174       $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
175   done
176   libgcc2_objs="$libgcc2_objs ${name}${objext}"
177 done
178
179 if [ "$FPBIT" ]; then
180   for name in $FPBIT_FUNCS; do
181     for ml in $MULTILIBS; do
182       dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
183       flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
184       out="libgcc/${dir}/${name}${objext}"
185
186       echo $out: $FPBIT $fpbit_c_dep
187       echo "    $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
188         -c $FPBIT -o $out
189     done
190     libgcc2_objs="$libgcc2_objs ${name}${objext}"
191   done
192 fi
193
194 if [ "$DPBIT" ]; then
195   for name in $DPBIT_FUNCS; do
196     for ml in $MULTILIBS; do
197       dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
198       flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
199       out="libgcc/${dir}/${name}${objext}"
200
201       echo $out: $DPBIT $fpbit_c_dep
202       echo "    $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
203         -c $DPBIT -o $out
204     done
205     libgcc2_objs="$libgcc2_objs ${name}${objext}"
206   done
207 fi
208
209 for file in $LIB2ADD; do
210   name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
211   oname=`echo $name | sed -e 's,.*/,,'`
212
213   if [ ${name}.txt = ${file} ]; then
214     fprime=`cat $file`
215     for f in $fprime; do
216
217       lastout="stmp-dirs $file"
218       for ml in $MULTILIBS; do
219         dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
220         flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
221         out="libgcc/${dir}/${f}"
222
223         # Depend on previous out to serialize all sub-makes of this
224         # target file.  This because ./$f is used as a temporary in
225         # each case before being moved to libgcc/$dir/.
226         echo $out: $lastout
227         echo "  $make_compile" \\
228         echo '    LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
229         echo '    MULTILIB_CFLAGS="'$flags'"' $f
230         echo "  mv $f $out"
231
232         lastout="$out"
233       done
234
235       libgcc2_objs="$libgcc2_objs $f"
236     done
237   else
238     for ml in $MULTILIBS; do
239       dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
240       flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
241       out="libgcc/${dir}/${oname}${objext}"
242       if [ ${name}.asm = ${file} ]; then
243         flags="$flags -xassembler-with-cpp"
244       fi
245
246       echo $out: stmp-dirs $file
247       echo "    $gcc_compile" $flags -c $file -o $out
248     done
249     libgcc2_objs="$libgcc2_objs ${oname}${objext}"
250   fi
251 done
252
253 for ml in $MULTILIBS; do
254   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
255
256   libgcc_objs=""
257   for o in $libgcc1_objs; do
258     if [ "$LIBGCC1" = libgcc1-asm.a ]; then
259       libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
260     else
261       libgcc_objs="$libgcc_objs libgcc/$o"
262     fi
263   done
264   for o in $libgcc2_objs; do
265     libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
266   done
267
268   echo ""
269   echo "${dir}/libgcc.a: $libgcc_objs"
270   echo "        -rm -rf ${dir}/libgcc.a"
271   echo '        $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs
272   echo '        if $(RANLIB_TEST_FOR_TARGET) ; then' \\
273   echo '          $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
274   echo '        else true; fi;'
275 done
276
277 echo ""
278 all=stmp-dirs
279 dirs=libgcc
280
281 for ml in $MULTILIBS; do
282   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
283   if [ $dir != . ]; then
284     dirs="$dirs ${dir} libgcc/${dir}"
285   fi
286   all="$all ${dir}/libgcc.a"
287 done
288
289 echo 'stmp-dirs: force'
290 echo '  for d in '"$dirs"'; do \'
291 echo '    if [ -d $$d ]; then true; else mkdir $$d; fi \'
292 echo '  done'
293 echo '  if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
294
295 for f in $EXTRA_MULTILIB_PARTS; do
296   lastout="stmp-dirs force"
297   for ml in $MULTILIBS; do
298     dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
299     flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
300     out="$dir/$f"
301
302     # Depend on previous out to serialize all sub-makes of this
303     # target file.  This because ./$f is used as a temporary in
304     # each case before being moved to libgcc/$dir/.
305     echo $out: $lastout
306     echo "      $make_compile" \\
307     echo '        LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
308     echo '        MULTILIB_CFLAGS="'$flags'"' T=t t$f
309     echo "      mv t$f $out"
310
311     all="$all $out"
312     lastout="$out"
313   done
314 done
315
316 echo ""
317 echo "all: $all"