2 # Construct makefile for libgcc.
3 # Copyright (C) 2000 Free Software Foundation, Inc.
5 # This file is part of GNU CC.
7 # Arguments, taken from the environment, since there are a lot
8 # of them, and positional args becomes quite ugly.
25 # EXTRA_MULTILIB_PARTS
27 # Make needs VPATH to be literal.
28 echo 'srcdir = @srcdir@'
29 echo 'VPATH = @srcdir@'
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.
39 if [ "@build_canonical@" = "@target@" ]; then
46 if $OLDCC -E $tmp | grep yes > /dev/null 2>&1; then
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)"'
67 # Dependancies for libgcc1.c
68 libgcc1_c_dep='$(srcdir)/libgcc1.c $(CONFIG_H)'
70 # Dependancies for libgcc2.c
71 libgcc2_c_dep='$(srcdir)/libgcc2.c $(CONFIG_H) $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'
73 # Dependancies for fp-bit.c
74 fpbit_c_dep='config.status tsystem.h'
77 # Build libgcc1 components.
87 echo "You must find a way to make libgcc1 components yourself" 1>&2
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}"
100 libgccdir="libgcc/${dir}"
102 echo ${out}: ${libgccdir} '$(srcdir)/config/$(LIB1ASMSRC)'
103 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
104 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
106 libgcc1_objs="$libgcc1_objs ${name}${objext}"
111 for name in $LIB1FUNCS; do
112 out="libgcc/${name}${objext}"
114 echo $out: $libgcc1_c_dep
115 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
116 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
118 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
119 echo " mv libgcc1${objext} $out"
122 libgcc1_objs="$libgcc1_objs ${name}${objext}"
125 for file in $LIB1FUNCS_EXTRA; do
126 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
127 out="libgcc/${name}${objext}"
130 if [ ${name}.asm = $file ]; then
131 echo " cp $file ${name}.s"
135 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
136 echo " $oldcc_compile" -c $file -o $out
138 echo " $oldcc_compile" -c $file
139 tmp=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
143 libgcc1_objs="$libgcc1_objs ${name}${objext}"
147 echo "I'm confused about libgcc1." 1>&2
153 # Build libgcc2 components.
158 for name in $LIB2FUNCS; do
159 for ml in $MULTILIBS; do
160 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
161 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
162 out="libgcc/${dir}/${name}${objext}"
164 if [ $dir = . ]; then
167 libgccdir="libgcc/${dir}"
169 echo $out: $libgccdir $libgcc2_c_dep
170 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
171 -c '$(srcdir)/libgcc2.c' -o $out
173 libgcc2_objs="$libgcc2_objs ${name}${objext}"
176 for name in $LIB2FUNCS_EH; do
177 for ml in $MULTILIBS; do
178 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
179 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
180 out="libgcc/${dir}/${name}${objext}"
182 if [ $dir = . ]; then
185 libgccdir="libgcc/${dir}"
187 echo $out: $libgccdir $libgcc2_c_dep
188 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' -fexceptions \
189 $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
191 libgcc2_objs="$libgcc2_objs ${name}${objext}"
194 if [ "$FPBIT" ]; then
195 for name in $FPBIT_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}"
201 if [ $dir = . ]; then
204 libgccdir="libgcc/${dir}"
206 echo $out: $libgccdir $FPBIT $fpbit_c_dep
207 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
210 libgcc2_objs="$libgcc2_objs ${name}${objext}"
214 if [ "$DPBIT" ]; then
215 for name in $DPBIT_FUNCS; do
216 for ml in $MULTILIBS; do
217 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
218 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
219 out="libgcc/${dir}/${name}${objext}"
221 if [ $dir = . ]; then
224 libgccdir="libgcc/${dir}"
226 echo $out: $libgccdir $DPBIT $fpbit_c_dep
227 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
230 libgcc2_objs="$libgcc2_objs ${name}${objext}"
234 for file in $LIB2ADD; do
235 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
236 oname=`echo $name | sed -e 's,.*/,,'`
238 if [ ${name}.txt = ${file} ]; then
243 for ml in $MULTILIBS; do
244 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
245 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
246 out="libgcc/${dir}/${f}"
248 # Depend on previous out to serialize all sub-makes of this
249 # target file. This because ./$f is used as a temporary in
250 # each case before being moved to libgcc/$dir/.
252 echo " $make_compile" \\
253 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
254 echo ' MULTILIB_CFLAGS="'$flags'"' $f
260 libgcc2_objs="$libgcc2_objs $f"
263 for ml in $MULTILIBS; do
264 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
265 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
266 out="libgcc/${dir}/${oname}${objext}"
267 if [ ${name}.asm = ${file} ]; then
268 flags="$flags -xassembler-with-cpp"
271 if [ $dir = . ]; then
274 libgccdir="libgcc/${dir}"
276 echo $out: $libgccdir $file
277 echo " $gcc_compile" $flags -c $file -o $out
279 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
283 for ml in $MULTILIBS; do
284 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
287 for o in $libgcc1_objs; do
288 if [ "$LIBGCC1" = libgcc1-asm.a ]; then
289 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
291 libgcc_objs="$libgcc_objs libgcc/$o"
294 for o in $libgcc2_objs; do
295 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
299 echo "${dir}/libgcc.a: $libgcc_objs"
300 echo " -rm -rf ${dir}/libgcc.a"
301 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs
302 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
303 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
304 echo ' else true; fi;'
310 echo "libgcc:; -mkdir libgcc"
311 for ml in $MULTILIBS; do
312 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
313 if [ $dir != . ]; then
314 echo "libgcc/${dir}: libgcc; -mkdir libgcc/${dir}"
315 echo "${dir}:; -mkdir ${dir}"
316 all="$all ${dir} libgcc/${dir}"
318 all="$all ${dir}/libgcc.a"
321 for f in $EXTRA_MULTILIB_PARTS; do
323 for ml in $MULTILIBS; do
324 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
325 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
328 # Depend on previous out to serialize all sub-makes of this
329 # target file. This because ./$f is used as a temporary in
330 # each case before being moved to libgcc/$dir/.
332 echo " $make_compile" \\
333 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
334 echo ' MULTILIB_CFLAGS="'$flags'"' T=t t$f