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@'
32 # Detect gcc as OLDCC. This indicates a target for which LIB1FUNCS
33 # is not needed. This is not quite the same as libgcc1.null, even
34 # on a target not using libgcc1-asm.a.
42 if $OLDCC -E $tmp | grep yes > /dev/null 2>&1; then
57 echo ' $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)' \
58 $flags -c $src -o $dst
61 emit_oldcc_compile() {
66 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
67 echo ' $(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)' \
68 $flags -c $src -o $dst
70 echo ' $(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
72 tmp=`echo $src | sed -e 's/[.]c$/'${objext}/ -e 's,.*/,,'`
81 if [ "$1" = "T=t" ]; then
82 tmp="T=t"; tgt="t$tgt"; shift
86 echo ' $(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)"' \\
87 echo ' AR_FOR_TARGET="$(AR_FOR_TARGET)"' \\
88 echo ' AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)"' \\
89 echo ' AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)"' \\
90 echo ' AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)"' \\
91 echo ' CC="$(CC)" CFLAGS="$(CFLAGS)"' \\
92 echo ' HOST_PREFIX="$(HOST_PREFIX)"' \\
93 echo ' HOST_PREFIX_1="$(HOST_PREFIX_1)"' \\
94 echo ' LANGUAGES="$(LANGUAGES)"' \\
95 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
96 echo ' MULTILIB_CFLAGS="'$flags'"' $tmp $tgt
97 echo " mv ${tgt} ${dst}"
100 # Dependancies for libgcc1.c
101 libgcc1_c_dep='$(srcdir)/libgcc1.c $(CONFIG_H)'
103 # Dependancies for libgcc2.c
104 libgcc2_c_dep='$(srcdir)/libgcc2.c $(CONFIG_H) $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'
106 # Dependancies for fp-bit.c
107 fpbit_c_dep='$(srcdir)/config/fp-bit.c config.status tsystem.h'
110 # Build libgcc1 components.
120 echo "You must find a way to make libgcc1 components yourself" 1>&2
124 for name in $LIB1ASMFUNCS; do
125 for ml in $MULTILIBS; do
126 dir=`echo ${ml} | sed -e 's/;.*$//'`
127 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
128 out="libgcc/${dir}/${name}${objext}"
130 echo ${out}: '$(srcdir)/config/$(LIB1ASMSRC)'
131 emit_gcc_compile $out '$(srcdir)/config/$(LIB1ASMSRC)' \
132 $flags -DL$name -xassembler-with-cpp
134 libgcc1_objs="$libgcc1_objs ${name}${objext}"
139 for name in $LIB1FUNCS; do
140 out="libgcc/${name}${objext}"
142 echo $out: $libgcc1_c_dep
143 emit_oldcc_compile $out '$(srcdir)/libgcc1.c' -DL${name}
144 libgcc1_objs="$libgcc1_objs ${name}${objext}"
147 for file in $LIB1FUNCS_EXTRA; do
148 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
149 out="libgcc/${name}${objext}"
152 if [ ${name}.asm = $file ]; then
153 echo " cp $file ${name}.s"
156 emit_oldcc_compile $out $file
157 libgcc1_objs="$libgcc1_objs ${name}${objext}"
163 # Build libgcc2 components.
168 for name in $LIB2FUNCS; do
169 for ml in $MULTILIBS; do
170 dir=`echo ${ml} | sed -e 's/;.*$//'`
171 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
172 out="libgcc/${dir}/${name}${objext}"
174 echo $out: $libgcc2_c_dep
175 emit_gcc_compile $out '$(srcdir)/libgcc2.c' '$(MAYBE_USE_COLLECT2)' \
178 libgcc2_objs="$libgcc2_objs ${name}${objext}"
181 for name in $LIB2FUNCS_EH; do
182 for ml in $MULTILIBS; do
183 dir=`echo ${ml} | sed -e 's/;.*$//'`
184 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
185 out="libgcc/${dir}/${name}${objext}"
187 echo $out: $libgcc2_c_dep
188 emit_gcc_compile $out '$(srcdir)/libgcc2.c' '$(MAYBE_USE_COLLECT2)' \
189 -fexceptions $flags -DL$name
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/;.*$//'`
198 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
199 out="libgcc/${dir}/${name}${objext}"
201 echo $out: $fpbit_c_dep
202 emit_gcc_compile $out '$(srcdir)/config/fp-bit.c' \
203 -DFLOAT -DFINE_GRAINED_LIBRARIES $flags -DL$name
205 libgcc2_objs="$libgcc2_objs ${name}${objext}"
209 if [ "$DPBIT" ]; then
210 for name in $DPBIT_FUNCS; do
211 for ml in $MULTILIBS; do
212 dir=`echo ${ml} | sed -e 's/;.*$//'`
213 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
214 out="libgcc/${dir}/${name}${objext}"
216 echo $out: $fpbit_c_dep
217 emit_gcc_compile $out '$(srcdir)/config/fp-bit.c' \
218 -DFINE_GRAINED_LIBRARIES $flags -DL$name
220 libgcc2_objs="$libgcc2_objs ${name}${objext}"
224 for file in $LIB2ADD; do
225 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
226 oname=`echo $name | sed -e 's,.*/,,'`
228 if [ ${name}.txt = ${file} ]; then
233 for ml in $MULTILIBS; do
234 dir=`echo ${ml} | sed -e 's/;.*$//'`
235 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
236 out="libgcc/${dir}/${f}"
238 # Depend on previous out to serialize all sub-makes of this
239 # target file. This because ./$f is used as a temporary in
240 # each case before being moved to libgcc/$dir/.
242 emit_make_compile $out $f $flags
247 libgcc2_objs="$libgcc2_objs $f"
250 for ml in $MULTILIBS; do
251 dir=`echo ${ml} | sed -e 's/;.*$//'`
252 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
253 out="libgcc/${dir}/${oname}${objext}"
254 if [ ${name}.asm = ${file} ]; then
255 flags="$flags -xassembler-with-cpp"
259 emit_gcc_compile $out $file $flags
261 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
265 for ml in $MULTILIBS; do
266 dir=`echo ${ml} | sed -e 's/;.*$//'`
269 for o in $libgcc1_objs; do
270 if [ "$LIBGCC1" = libgcc1-asm.a ]; then
271 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
273 libgcc_objs="$libgcc_objs libgcc/$o"
276 for o in $libgcc2_objs; do
277 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
281 echo "${dir}/libgcc.a: $libgcc_objs"
282 echo " -rm -rf ${dir}/libgcc.a"
283 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs
284 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
285 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
286 echo ' else true; fi;'
292 for ml in $MULTILIBS; do
293 dir=`echo ${ml} | sed -e 's/;.*$//'`
294 if [ $dir = . ]; then
295 echo "libgcc:; mkdir libgcc"
298 echo "${dir}:; mkdir ${dir}"
299 echo "libgcc/${dir}:; mkdir libgcc/${dir}"
300 all="$all libgcc/${dir} ${dir}"
302 all="$all ${dir}/libgcc.a"
305 for f in $EXTRA_MULTILIB_PARTS; do
307 for ml in $MULTILIBS; do
308 dir=`echo ${ml} | sed -e 's/;.*$//'`
309 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
312 # Depend on previous out to serialize all sub-makes of this
313 # target file. This because ./$f is used as a temporary in
314 # each case before being moved to libgcc/$dir/.
316 emit_make_compile $out $f T=t $flags