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@'
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.
37 if [ "@build_canonical@" = "@target@" ]; then
44 if $OLDCC -E $tmp | grep yes > /dev/null 2>&1; then
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)"'
65 # Dependancies for libgcc1.c
66 libgcc1_c_dep='$(srcdir)/libgcc1.c $(CONFIG_H)'
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'
71 # Dependancies for fp-bit.c
72 fpbit_c_dep='config.status tsystem.h'
75 # Build libgcc1 components.
85 echo "You must find a way to make libgcc1 components yourself" 1>&2
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}"
98 libgccdir="libgcc/${dir}"
100 echo ${out}: ${libgccdir} '$(srcdir)/config/$(LIB1ASMSRC)'
101 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
102 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
104 libgcc1_objs="$libgcc1_objs ${name}${objext}"
109 for name in $LIB1FUNCS; do
110 out="libgcc/${name}${objext}"
112 echo $out: $libgcc1_c_dep
113 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
114 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
116 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
117 echo " mv libgcc1${objext} $out"
120 libgcc1_objs="$libgcc1_objs ${name}${objext}"
123 for file in $LIB1FUNCS_EXTRA; do
124 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
125 out="libgcc/${name}${objext}"
128 if [ ${name}.asm = $file ]; then
129 echo " cp $file ${name}.s"
133 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
134 echo " $oldcc_compile" -c $file -o $out
136 echo " $oldcc_compile" -c $file
137 tmp=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
141 libgcc1_objs="$libgcc1_objs ${name}${objext}"
145 echo "I'm confused about libgcc1." 1>&2
151 # Build libgcc2 components.
156 for name in $LIB2FUNCS; do
157 for ml in $MULTILIBS; do
158 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
159 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
160 out="libgcc/${dir}/${name}${objext}"
162 if [ $dir = . ]; then
165 libgccdir="libgcc/${dir}"
167 echo $out: $libgccdir $libgcc2_c_dep
168 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
169 -c '$(srcdir)/libgcc2.c' -o $out
171 libgcc2_objs="$libgcc2_objs ${name}${objext}"
174 for name in $LIB2FUNCS_EH; do
175 for ml in $MULTILIBS; do
176 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
177 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
178 out="libgcc/${dir}/${name}${objext}"
180 if [ $dir = . ]; then
183 libgccdir="libgcc/${dir}"
185 echo $out: $libgccdir $libgcc2_c_dep
186 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' -fexceptions \
187 $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
189 libgcc2_objs="$libgcc2_objs ${name}${objext}"
192 if [ "$FPBIT" ]; then
193 for name in $FPBIT_FUNCS; do
194 for ml in $MULTILIBS; do
195 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
196 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
197 out="libgcc/${dir}/${name}${objext}"
199 if [ $dir = . ]; then
202 libgccdir="libgcc/${dir}"
204 echo $out: $libgccdir $FPBIT $fpbit_c_dep
205 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
208 libgcc2_objs="$libgcc2_objs ${name}${objext}"
212 if [ "$DPBIT" ]; then
213 for name in $DPBIT_FUNCS; do
214 for ml in $MULTILIBS; do
215 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
216 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
217 out="libgcc/${dir}/${name}${objext}"
219 if [ $dir = . ]; then
222 libgccdir="libgcc/${dir}"
224 echo $out: $libgccdir $DPBIT $fpbit_c_dep
225 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
228 libgcc2_objs="$libgcc2_objs ${name}${objext}"
232 for file in $LIB2ADD; do
233 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
234 oname=`echo $name | sed -e 's,.*/,,'`
236 if [ ${name}.txt = ${file} ]; then
241 for ml in $MULTILIBS; do
242 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
243 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
244 out="libgcc/${dir}/${f}"
246 # Depend on previous out to serialize all sub-makes of this
247 # target file. This because ./$f is used as a temporary in
248 # each case before being moved to libgcc/$dir/.
250 echo " $make_compile" \\
251 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
252 echo ' MULTILIB_CFLAGS="'$flags'"' $f
258 libgcc2_objs="$libgcc2_objs $f"
261 for ml in $MULTILIBS; do
262 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
263 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
264 out="libgcc/${dir}/${oname}${objext}"
265 if [ ${name}.asm = ${file} ]; then
266 flags="$flags -xassembler-with-cpp"
269 if [ $dir = . ]; then
272 libgccdir="libgcc/${dir}"
274 echo $out: $libgccdir $file
275 echo " $gcc_compile" $flags -c $file -o $out
277 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
281 for ml in $MULTILIBS; do
282 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
285 for o in $libgcc1_objs; do
286 if [ "$LIBGCC1" = libgcc1-asm.a ]; then
287 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
289 libgcc_objs="$libgcc_objs libgcc/$o"
292 for o in $libgcc2_objs; do
293 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
297 echo "${dir}/libgcc.a: $libgcc_objs"
298 echo " -rm -rf ${dir}/libgcc.a"
299 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs
300 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
301 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
302 echo ' else true; fi;'
308 echo "libgcc:; -mkdir libgcc"
309 for ml in $MULTILIBS; do
310 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
311 if [ $dir != . ]; then
312 echo "libgcc/${dir}: libgcc; -mkdir libgcc/${dir}"
313 echo "${dir}:; -mkdir ${dir}"
314 all="$all ${dir} libgcc/${dir}"
316 all="$all ${dir}/libgcc.a"
319 for f in $EXTRA_MULTILIB_PARTS; do
321 for ml in $MULTILIBS; do
322 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
323 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
326 # Depend on previous out to serialize all sub-makes of this
327 # target file. This because ./$f is used as a temporary in
328 # each case before being moved to libgcc/$dir/.
330 echo " $make_compile" \\
331 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
332 echo ' MULTILIB_CFLAGS="'$flags'"' T=t t$f