6034867136fe874c4e9e2b7a3f70bee6f9a89007
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.
27 # EXTRA_MULTILIB_PARTS
36 # Make needs VPATH to be literal.
37 echo 'srcdir = @srcdir@'
38 echo 'VPATH = @srcdir@'
44 # Detect gcc as OLDCC. This indicates a target for which LIB1FUNCS
45 # is not needed. This is not quite the same as libgcc1.null, even
46 # on a target not using libgcc1-asm.a.
48 if [ "@build_canonical@" = "@target@" ]; then
55 if $OLDCC -E $tmp |
grep yes > /dev
/null
2>&1; then
61 # Disable SHLIB_LINK if shared libgcc not enabled.
62 if [ "@enable_shared@" = "no" ]; then
68 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
69 oldcc_compile
='$(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
70 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
71 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
72 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
73 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
74 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
75 CC="$(CC)" CFLAGS="$(CFLAGS)" \
76 HOST_PREFIX="$(HOST_PREFIX)" \
77 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
78 LANGUAGES="$(LANGUAGES)"'
80 # Dependancies for libgcc1.c
81 libgcc1_c_dep
='stmp-dirs $(srcdir)/libgcc1.c $(CONFIG_H)'
83 # Dependancies for libgcc2.c
84 libgcc2_c_dep
='stmp-dirs $(srcdir)/libgcc2.c $(CONFIG_H) $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'" $LIB2ADDEHDEP"
86 # Dependancies for fp-bit.c
87 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
90 # Build libgcc1 components.
100 echo "You must find a way to make libgcc1 components yourself" 1>&2
104 for name
in $LIB1ASMFUNCS; do
105 for ml
in $MULTILIBS; do
106 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
107 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
108 out
="libgcc/${dir}/${name}${objext}"
110 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
111 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
112 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
114 # Remove any objects from LIB2FUNCS that are defined as optimized
115 # assembly code in LIB1ASMFUNCS.
116 LIB2FUNCS
=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
117 -e 's/ '$name' / /' \
120 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
125 for name
in $LIB1FUNCS; do
126 out
="libgcc/${name}${objext}"
128 echo $out: $libgcc1_c_dep
129 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
130 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
132 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
133 echo " mv libgcc1${objext} $out"
136 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
139 for file in $LIB1FUNCS_EXTRA; do
140 name
=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
141 out
="libgcc/${name}${objext}"
144 if [ ${name}.asm
= $file ]; then
145 echo " cp $file ${name}.s"
149 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
150 echo " $oldcc_compile" -c $file -o $out
152 echo " $oldcc_compile" -c $file
153 tmp
=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
157 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
161 echo "I'm confused about libgcc1." 1>&2
167 # Build libgcc2 components.
172 for name
in $LIB2FUNCS; do
173 for ml
in $MULTILIBS; do
174 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
175 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
176 out
="libgcc/${dir}/${name}${objext}"
178 echo $out: $libgcc2_c_dep
179 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
180 -c '$(srcdir)/libgcc2.c' -o $out
182 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
185 if [ "$FPBIT" ]; then
186 for name
in $FPBIT_FUNCS; do
187 for ml
in $MULTILIBS; do
188 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
189 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
190 out
="libgcc/${dir}/${name}${objext}"
192 echo $out: $FPBIT $fpbit_c_dep
193 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
196 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
200 if [ "$DPBIT" ]; then
201 for name
in $DPBIT_FUNCS; do
202 for ml
in $MULTILIBS; do
203 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
204 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
205 out
="libgcc/${dir}/${name}${objext}"
207 echo $out: $DPBIT $fpbit_c_dep
208 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
211 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
215 for file in $LIB2ADD; do
216 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
217 oname
=`echo $name | sed -e 's,.*/,,'`
219 for ml
in $MULTILIBS; do
220 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
221 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
222 out
="libgcc/${dir}/${oname}${objext}"
223 if [ ${name}.asm
= ${file} ]; then
224 flags
="$flags -xassembler-with-cpp"
227 echo $out: stmp-dirs
$file
228 echo " $gcc_compile" $flags -c $file -o $out
230 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
233 for file in $LIB2ADDEH; do
234 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
235 oname
=`echo $name | sed -e 's,.*/,,'`
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"
245 echo $out: stmp-dirs
$file
246 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
248 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
253 for file in $LIB2ADD_ST; do
254 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
255 oname
=`echo $name | sed -e 's,.*/,,'`
257 for ml
in $MULTILIBS; do
258 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
259 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
260 out
="libgcc/${dir}/${oname}${objext}"
261 if [ ${name}.asm
= ${file} ]; then
262 flags
="$flags -xassembler-with-cpp"
265 echo $out: stmp-dirs
$file
266 echo " $gcc_compile" $flags -c $file -o $out
268 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
273 for ml
in $MULTILIBS; do
274 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
275 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
278 for o
in $libgcc1_objs; do
279 if [ "$LIBGCC1" = libgcc1-asm.a
]; then
280 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
282 libgcc_objs
="$libgcc_objs libgcc/$o"
285 for o
in $libgcc2_objs; do
286 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
288 shlib_deps
="$libgcc_objs"
291 for o
in $libgcc2_st_objs; do
292 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
295 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
298 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
299 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
302 shlib_deps
="$shlib_deps $mapfile"
304 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
305 # usually are put in a true multilib situation.
306 for f
in $EXTRA_MULTILIB_PARTS; do
307 shlib_deps
="$shlib_deps $dir/$f"
311 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
312 echo " -rm -rf ${dir}/libgcc.a"
313 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_objs $libgcc_st_objs
314 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
315 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
316 echo ' else true; fi;'
318 if [ "$SHLIB_LINK" ]; then
319 if [ -z "$SHLIB_MULTILIB" ]; then
320 if [ "$dir" = "." ]; then
321 shlib_base_name
="libgcc_s";
323 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
326 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
327 echo " $SHLIB_LINK" \
328 |
sed -e "s%@multilib_flags@%$flags%g" \
329 -e "s%@multilib_dir@%$dir%g" \
330 -e "s%@shlib_objs@%$libgcc_objs%g" \
331 -e "s%@shlib_base_name@%$shlib_base_name%g" \
332 -e "s%@shlib_map_file@%$mapfile%g"
333 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
334 shlib_base_name
="libgcc_s";
336 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
337 echo " $SHLIB_LINK" \
338 |
sed -e "s%@multilib_flags@%$flags%g" \
339 -e "s%@multilib_dir@%$dir%g" \
340 -e "s%@shlib_objs@%$libgcc_objs%g" \
341 -e "s%@shlib_base_name@%$shlib_base_name%g" \
342 -e "s%@shlib_map_file@%$mapfile%g"
348 for ml
in $MULTILIBS; do
349 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
350 if [ $dir != .
]; then
351 dirs="$dirs libgcc/${dir}"
355 echo 'libgcc-stage-start:'
356 echo ' for dir in '"${dirs}"'; do \'
357 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
359 echo ' -for dir in '"${dirs}"'; do \'
360 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
367 for ml
in $MULTILIBS; do
368 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
369 if [ $dir != .
]; then
370 dirs="$dirs ${dir} libgcc/${dir}"
372 all
="$all ${dir}/libgcc.a"
373 if [ "$SHLIB_LINK" ]; then
374 if [ -z "$SHLIB_MULTILIB" ]; then
375 if [ "$dir" = "." ]; then
378 suff
=_
`echo $dir | sed s,/,_,g`
380 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
381 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
382 all
="$all libgcc_s${SHLIB_EXT}"
387 echo 'stmp-dirs: force'
388 echo ' for d in '"$dirs"'; do \'
389 echo ' if [ -d $
$d ]; then true
; else mkdir $
$d; fi \'
391 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
393 for f
in $EXTRA_MULTILIB_PARTS; do
394 for ml
in $MULTILIBS; do
395 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
396 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
399 *) out
=$dir/$f ; t
=$dir/ ;;
402 # Prevent `make' from interpreting $out as a macro assignment
403 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
408 echo " $make_compile" \\
409 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
410 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
421 for ml
in $MULTILIBS; do
422 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
423 if [ $dir != .
]; then
424 ldir
='$(libsubdir)'/$dir
425 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
429 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
430 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
432 if [ "$SHLIB_LINK" ]; then
433 if [ -z "$SHLIB_MULTILIB" ]; then
434 if [ "$dir" = "." ]; then
435 shlib_base_name
="libgcc_s";
437 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
439 echo " $SHLIB_INSTALL" \
440 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
441 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
442 shlib_base_name
="libgcc_s";
443 echo " $SHLIB_INSTALL" \
444 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
448 for f
in $EXTRA_MULTILIB_PARTS; do
449 for ml
in $MULTILIBS; do
450 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
451 if [ $dir != .
]; then
453 ldir
='$(libsubdir)'/$dir
458 echo ' $(INSTALL_DATA)' $out $ldir/