OSDN Git Service

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