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.
28 # EXTRA_MULTILIB_PARTS
37 # Make needs VPATH to be literal.
38 echo 'srcdir = @srcdir@'
39 echo 'VPATH = @srcdir@'
45 # Detect gcc as OLDCC. This indicates a target for which LIB1FUNCS
46 # is not needed. This is not quite the same as libgcc1.null, even
47 # on a target not using libgcc1-asm.a.
49 if [ "@build_canonical@" = "@target@" ]; then
56 if $OLDCC -E $tmp |
grep yes > /dev
/null
2>&1; then
62 # Disable SHLIB_LINK if shared libgcc not enabled.
63 if [ "@enable_shared@" = "no" ]; then
69 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
70 oldcc_compile
='$(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
71 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
72 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
73 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
74 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
75 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
76 CC="$(CC)" CFLAGS="$(CFLAGS)" \
77 HOST_PREFIX="$(HOST_PREFIX)" \
78 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
79 LANGUAGES="$(LANGUAGES)"'
81 # Dependancies for libgcc1.c
82 libgcc1_c_dep
='stmp-dirs $(srcdir)/libgcc1.c $(CONFIG_H)'
84 # Dependancies for libgcc2.c
85 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"
87 # Dependancies for fp-bit.c
88 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
91 # Build libgcc1 components.
101 echo "You must find a way to make libgcc1 components yourself" 1>&2
105 for name
in $LIB1ASMFUNCS; do
106 for ml
in $MULTILIBS; do
107 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
108 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
109 out
="libgcc/${dir}/${name}${objext}"
111 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
112 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
113 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
115 # Remove any objects from LIB2FUNCS that are defined as optimized
116 # assembly code in LIB1ASMFUNCS.
117 LIB2FUNCS
=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
118 -e 's/ '$name' / /' \
121 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
126 for name
in $LIB1FUNCS; do
127 out
="libgcc/${name}${objext}"
129 echo $out: $libgcc1_c_dep
130 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
131 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
133 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
134 echo " mv libgcc1${objext} $out"
137 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
140 for file in $LIB1FUNCS_EXTRA; do
141 name
=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
142 out
="libgcc/${name}${objext}"
145 if [ ${name}.asm
= $file ]; then
146 echo " cp $file ${name}.s"
150 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
151 echo " $oldcc_compile" -c $file -o $out
153 echo " $oldcc_compile" -c $file
154 tmp
=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
158 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
162 echo "I'm confused about libgcc1." 1>&2
168 # Build libgcc2 components.
174 for name
in $LIB2FUNCS; 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 echo $out: $libgcc2_c_dep
181 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
182 -c '$(srcdir)/libgcc2.c' -o $out
184 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
187 for name
in $LIB2FUNCS_ST; do
188 for ml
in $MULTILIBS; do
189 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
190 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
191 out
="libgcc/${dir}/${name}${objext}"
193 echo $out: $libgcc2_c_dep
194 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
195 -c '$(srcdir)/libgcc2.c' -o $out
197 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
200 if [ "$FPBIT" ]; then
201 for name
in $FPBIT_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: $FPBIT $fpbit_c_dep
208 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
211 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
215 if [ "$DPBIT" ]; then
216 for name
in $DPBIT_FUNCS; do
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}/${name}${objext}"
222 echo $out: $DPBIT $fpbit_c_dep
223 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
226 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
230 for file in $LIB2ADD; do
231 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
232 oname
=`echo $name | sed -e 's,.*/,,'`
234 for ml
in $MULTILIBS; do
235 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
236 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
237 out
="libgcc/${dir}/${oname}${objext}"
238 if [ ${name}.asm
= ${file} ]; then
239 flags
="$flags -xassembler-with-cpp"
242 echo $out: stmp-dirs
$file
243 echo " $gcc_compile" $flags -c $file -o $out
245 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
248 for file in $LIB2ADDEH; do
249 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
250 oname
=`echo $name | sed -e 's,.*/,,'`
252 for ml
in $MULTILIBS; do
253 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
254 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
255 out
="libgcc/${dir}/${oname}${objext}"
256 if [ ${name}.asm
= ${file} ]; then
257 flags
="$flags -xassembler-with-cpp"
260 echo $out: stmp-dirs
$file
261 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
263 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
266 for file in $LIB2ADD_ST; do
267 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
268 oname
=`echo $name | sed -e 's,.*/,,'`
270 for ml
in $MULTILIBS; do
271 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
272 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
273 out
="libgcc/${dir}/${oname}${objext}"
274 if [ ${name}.asm
= ${file} ]; then
275 flags
="$flags -xassembler-with-cpp"
278 echo $out: stmp-dirs
$file
279 echo " $gcc_compile" $flags -c $file -o $out
281 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
286 for ml
in $MULTILIBS; do
287 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
288 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
291 for o
in $libgcc1_objs; do
292 if [ "$LIBGCC1" = libgcc1-asm.a
]; then
293 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
295 libgcc_objs
="$libgcc_objs libgcc/$o"
298 for o
in $libgcc2_objs; do
299 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
301 shlib_deps
="$libgcc_objs"
304 for o
in $libgcc2_st_objs; do
305 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
308 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
311 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
312 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
315 shlib_deps
="$shlib_deps $mapfile"
317 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
318 # usually are put in a true multilib situation.
319 for f
in $EXTRA_MULTILIB_PARTS; do
320 shlib_deps
="$shlib_deps $dir/$f"
324 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
325 echo " -rm -rf ${dir}/libgcc.a"
326 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_objs $libgcc_st_objs
327 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
328 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
329 echo ' else true; fi;'
331 if [ "$SHLIB_LINK" ]; then
332 if [ -z "$SHLIB_MULTILIB" ]; then
333 if [ "$dir" = "." ]; then
334 shlib_base_name
="libgcc_s";
336 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
339 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
340 echo " $SHLIB_LINK" \
341 |
sed -e "s%@multilib_flags@%$flags%g" \
342 -e "s%@multilib_dir@%$dir%g" \
343 -e "s%@shlib_objs@%$libgcc_objs%g" \
344 -e "s%@shlib_base_name@%$shlib_base_name%g" \
345 -e "s%@shlib_map_file@%$mapfile%g"
346 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
347 shlib_base_name
="libgcc_s";
349 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
350 echo " $SHLIB_LINK" \
351 |
sed -e "s%@multilib_flags@%$flags%g" \
352 -e "s%@multilib_dir@%$dir%g" \
353 -e "s%@shlib_objs@%$libgcc_objs%g" \
354 -e "s%@shlib_base_name@%$shlib_base_name%g" \
355 -e "s%@shlib_map_file@%$mapfile%g"
361 for ml
in $MULTILIBS; do
362 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
363 if [ $dir != .
]; then
364 dirs="$dirs libgcc/${dir}"
368 echo 'libgcc-stage-start:'
369 echo ' for dir in '"${dirs}"'; do \'
370 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
372 echo ' -for dir in '"${dirs}"'; do \'
373 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
380 for ml
in $MULTILIBS; do
381 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
382 if [ $dir != .
]; then
383 dirs="$dirs ${dir} libgcc/${dir}"
385 all
="$all ${dir}/libgcc.a"
386 if [ "$SHLIB_LINK" ]; then
387 if [ -z "$SHLIB_MULTILIB" ]; then
388 if [ "$dir" = "." ]; then
391 suff
=_
`echo $dir | sed s,/,_,g`
393 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
394 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
395 all
="$all libgcc_s${SHLIB_EXT}"
400 echo 'stmp-dirs: force'
401 echo ' for d in '"$dirs"'; do \'
402 echo ' if [ -d $
$d ]; then true
; else mkdir $
$d; fi \'
404 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
406 for f
in $EXTRA_MULTILIB_PARTS; do
407 for ml
in $MULTILIBS; do
408 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
409 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
412 *) out
=$dir/$f ; t
=$dir/ ;;
415 # Prevent `make' from interpreting $out as a macro assignment
416 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
421 echo " $make_compile" \\
422 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
423 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
434 for ml
in $MULTILIBS; do
435 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
436 if [ $dir != .
]; then
437 ldir
='$(libsubdir)'/$dir
438 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
442 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
443 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
445 if [ "$SHLIB_LINK" ]; then
446 if [ -z "$SHLIB_MULTILIB" ]; then
447 if [ "$dir" = "." ]; then
448 shlib_base_name
="libgcc_s";
450 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
452 echo " $SHLIB_INSTALL" \
453 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
454 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
455 shlib_base_name
="libgcc_s";
456 echo " $SHLIB_INSTALL" \
457 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
461 for f
in $EXTRA_MULTILIB_PARTS; do
462 for ml
in $MULTILIBS; do
463 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
464 if [ $dir != .
]; then
466 ldir
='$(libsubdir)'/$dir
471 echo ' $(INSTALL_DATA)' $out $ldir/