2 # Construct makefile for libgcc.
3 # Copyright (C) 2000, 2002 Free Software Foundation, Inc.
5 # This file is part of GCC.
7 # Arguments, taken from the environment, since there are a lot
8 # of them, and positional args becomes quite ugly.
26 # EXTRA_MULTILIB_PARTS
35 # Make needs VPATH to be literal.
36 echo 'srcdir = @srcdir@'
37 echo 'VPATH = @srcdir@'
43 # Disable SHLIB_LINK if shared libgcc not enabled.
44 if [ "@enable_shared@" = "no" ]; then
50 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
51 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
52 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
53 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
54 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
55 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
56 CC="$(CC)" CFLAGS="$(CFLAGS)" \
57 HOST_PREFIX="$(HOST_PREFIX)" \
58 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
59 LANGUAGES="$(LANGUAGES)"'
61 # Dependencies for libgcc2.c
62 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"
64 # Dependencies for fp-bit.c
65 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
68 # Build libgcc1 components.
73 for name
in $LIB1ASMFUNCS; do
74 for ml
in $MULTILIBS; do
75 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
76 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
77 out
="libgcc/${dir}/${name}${objext}"
79 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
80 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
81 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
83 # Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
84 # defined as optimized assembly code in LIB1ASMFUNCS.
85 LIB2FUNCS_1
=`echo $LIB2FUNCS_1 | sed -e 's/^'$name' //' \
88 LIB2FUNCS_2
=`echo $LIB2FUNCS_2 | sed -e 's/^'$name' //' \
91 LIB2_DIVMOD_FUNCS
=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
95 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
99 # Build libgcc2 components.
106 for name
in $LIB2FUNCS_1 $LIB2FUNCS_2; do
107 for ml
in $MULTILIBS; do
108 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
109 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
110 out
="libgcc/${dir}/${name}${objext}"
112 echo $out: $libgcc2_c_dep
113 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
114 -c '$(srcdir)/libgcc2.c' -o $out
116 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
119 for name
in $LIB2FUNCS_ST; do
120 for ml
in $MULTILIBS; do
121 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
122 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
123 out
="libgcc/${dir}/${name}${objext}"
125 echo $out: $libgcc2_c_dep
126 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
127 -c '$(srcdir)/libgcc2.c' -o $out
129 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
132 for name
in $LIB2_DIVMOD_FUNCS; do
133 for ml
in $MULTILIBS; do
134 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
135 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
136 out
="libgcc/${dir}/${name}${objext}"
138 echo $out: $libgcc2_c_dep
139 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
140 -c '$(srcdir)/libgcc2.c' -fexceptions -fnon-call-exceptions -o $out
142 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
145 if [ "$FPBIT" ]; then
146 for name
in $FPBIT_FUNCS; do
147 for ml
in $MULTILIBS; do
148 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
149 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
150 out
="libgcc/${dir}/${name}${objext}"
152 echo $out: $FPBIT $fpbit_c_dep
153 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
156 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
160 if [ "$DPBIT" ]; then
161 for name
in $DPBIT_FUNCS; do
162 for ml
in $MULTILIBS; do
163 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
164 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
165 out
="libgcc/${dir}/${name}${objext}"
167 echo $out: $DPBIT $fpbit_c_dep
168 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
171 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
175 for file in $LIB2ADD; do
176 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
177 oname
=`echo $name | sed -e 's,.*/,,'`
179 for ml
in $MULTILIBS; do
180 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
181 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
182 out
="libgcc/${dir}/${oname}${objext}"
183 if [ ${name}.asm
= ${file} ]; then
184 flags
="$flags -xassembler-with-cpp"
187 echo $out: stmp-dirs
$file
188 echo " $gcc_compile" $flags -c $file -o $out
190 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
193 for file in $LIB2ADDEH; do
194 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
195 oname
=`echo $name | sed -e 's,.*/,,'`
197 for ml
in $MULTILIBS; do
198 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
199 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
200 out
="libgcc/${dir}/${oname}${objext}"
201 if [ ${name}.asm
= ${file} ]; then
202 flags
="$flags -xassembler-with-cpp"
205 echo $out: stmp-dirs
$file
206 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
208 if [ "$SHLIB_LINK" ]; then
209 libgcc2_eh_objs
="$libgcc2_eh_objs ${oname}${objext}"
211 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
215 for file in $LIB2ADD_ST; 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_st_objs
="$libgcc2_st_objs ${oname}${objext}"
235 for ml
in $MULTILIBS; do
236 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
237 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
241 for o
in $libgcc1_objs; do
242 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
244 for o
in $libgcc2_objs; do
245 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
247 for o
in $libgcc2_eh_objs; do
248 libgcc_eh_objs
="$libgcc_eh_objs libgcc/${dir}/$o"
250 libgcc_sh_objs
="$libgcc_objs $libgcc_eh_objs"
251 shlib_deps
="$libgcc_sh_objs"
254 for o
in $libgcc2_st_objs; do
255 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
258 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
261 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_sh_objs"
262 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_sh_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
265 shlib_deps
="$shlib_deps $mapfile"
267 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
268 # usually are put in a true multilib situation.
269 for f
in $EXTRA_MULTILIB_PARTS; do
270 shlib_deps
="$shlib_deps $dir/$f"
274 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
275 echo " -rm -rf ${dir}/libgcc.a"
276 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_objs $libgcc_st_objs
277 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
278 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
279 echo ' else true; fi;'
281 if [ "$SHLIB_LINK" ]; then
284 echo "${dir}/libgcc_eh.a: $libgcc_eh_objs"
285 echo " -rm -rf ${dir}/libgcc_eh.a"
286 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a
$libgcc_eh_objs
287 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
288 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
';' \\
289 echo ' else true; fi;'
291 if [ -z "$SHLIB_MULTILIB" ]; then
292 if [ "$dir" = "." ]; then
293 shlib_base_name
="libgcc_s";
295 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
298 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
299 echo " $SHLIB_LINK" \
300 |
sed -e "s%@multilib_flags@%$flags%g" \
301 -e "s%@multilib_dir@%$dir%g" \
302 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
303 -e "s%@shlib_base_name@%$shlib_base_name%g" \
304 -e "s%@shlib_map_file@%$mapfile%g"
305 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
306 shlib_base_name
="libgcc_s";
308 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
309 echo " $SHLIB_LINK" \
310 |
sed -e "s%@multilib_flags@%$flags%g" \
311 -e "s%@multilib_dir@%$dir%g" \
312 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
313 -e "s%@shlib_base_name@%$shlib_base_name%g" \
314 -e "s%@shlib_map_file@%$mapfile%g"
320 for ml
in $MULTILIBS; do
321 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
322 if [ $dir != .
]; then
323 dirs="$dirs libgcc/${dir}"
327 echo 'libgcc-stage-start:'
328 echo ' for dir in '"${dirs}"'; do \'
329 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
331 echo ' -for dir in '"${dirs}"'; do \'
332 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
339 for ml
in $MULTILIBS; do
340 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
341 if [ $dir != .
]; then
342 dirs="$dirs ${dir} libgcc/${dir}"
344 all
="$all ${dir}/libgcc.a"
345 if [ "$SHLIB_LINK" ]; then
346 all
="$all ${dir}/libgcc_eh.a"
347 if [ -z "$SHLIB_MULTILIB" ]; then
348 if [ "$dir" = "." ]; then
351 suff
=_
`echo $dir | sed s,/,_,g`
353 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
354 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
355 all
="$all libgcc_s${SHLIB_EXT}"
360 echo 'stmp-dirs: force'
361 echo ' for d in '"$dirs"'; do \'
362 echo ' if [ -d $
$d ]; then true
; else '$mkinstalldirs' $
$d; fi; \'
364 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
366 for f
in $EXTRA_MULTILIB_PARTS; do
367 for ml
in $MULTILIBS; do
368 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
369 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
372 *) out
=$dir/$f ; t
=$dir/ ;;
375 # Prevent `make' from interpreting $out as a macro assignment
376 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
381 echo " $make_compile" \\
382 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
383 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
394 for ml
in $MULTILIBS; do
395 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
396 if [ $dir != .
]; then
397 ldir
='$(libsubdir)'/$dir
398 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
402 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
403 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
405 if [ "$SHLIB_LINK" ]; then
406 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a
${ldir}/
407 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
409 if [ -z "$SHLIB_MULTILIB" ]; then
410 if [ "$dir" = "." ]; then
411 shlib_base_name
="libgcc_s";
413 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
415 echo " $SHLIB_INSTALL" \
416 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
417 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
418 shlib_base_name
="libgcc_s";
419 echo " $SHLIB_INSTALL" \
420 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
424 for f
in $EXTRA_MULTILIB_PARTS; do
425 for ml
in $MULTILIBS; do
426 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
427 if [ $dir != .
]; then
429 ldir
='$(libsubdir)'/$dir
434 echo ' $(INSTALL_DATA)' $out $ldir/