2 # Construct makefile for libgcc.
3 # Copyright (C) 2000 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.
25 # EXTRA_MULTILIB_PARTS
34 # Make needs VPATH to be literal.
35 echo 'srcdir = @srcdir@'
36 echo 'VPATH = @srcdir@'
42 # Disable SHLIB_LINK if shared libgcc not enabled.
43 if [ "@enable_shared@" = "no" ]; then
49 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
50 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
51 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
52 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
53 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
54 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
55 CC="$(CC)" CFLAGS="$(CFLAGS)" \
56 HOST_PREFIX="$(HOST_PREFIX)" \
57 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
58 LANGUAGES="$(LANGUAGES)"'
60 # Dependencies for libgcc2.c
61 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"
63 # Dependencies for fp-bit.c
64 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
67 # Build libgcc1 components.
72 for name
in $LIB1ASMFUNCS; do
73 for ml
in $MULTILIBS; do
74 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
75 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
76 out
="libgcc/${dir}/${name}${objext}"
78 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
79 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
80 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
82 # Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
83 # defined as optimized assembly code in LIB1ASMFUNCS.
84 LIB2FUNCS
=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
87 LIB2_DIVMOD_FUNCS
=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
91 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
95 # Build libgcc2 components.
102 for name
in $LIB2FUNCS; do
103 for ml
in $MULTILIBS; do
104 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
105 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
106 out
="libgcc/${dir}/${name}${objext}"
108 echo $out: $libgcc2_c_dep
109 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
110 -c '$(srcdir)/libgcc2.c' -o $out
112 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
115 for name
in $LIB2FUNCS_ST; do
116 for ml
in $MULTILIBS; do
117 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
118 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
119 out
="libgcc/${dir}/${name}${objext}"
121 echo $out: $libgcc2_c_dep
122 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
123 -c '$(srcdir)/libgcc2.c' -o $out
125 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
128 for name
in $LIB2_DIVMOD_FUNCS; do
129 for ml
in $MULTILIBS; do
130 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
131 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
132 out
="libgcc/${dir}/${name}${objext}"
134 echo $out: $libgcc2_c_dep
135 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
136 -c '$(srcdir)/libgcc2.c' -fexceptions -fnon-call-exceptions -o $out
138 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
141 if [ "$FPBIT" ]; then
142 for name
in $FPBIT_FUNCS; do
143 for ml
in $MULTILIBS; do
144 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
145 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
146 out
="libgcc/${dir}/${name}${objext}"
148 echo $out: $FPBIT $fpbit_c_dep
149 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
152 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
156 if [ "$DPBIT" ]; then
157 for name
in $DPBIT_FUNCS; do
158 for ml
in $MULTILIBS; do
159 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
160 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
161 out
="libgcc/${dir}/${name}${objext}"
163 echo $out: $DPBIT $fpbit_c_dep
164 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
167 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
171 for file in $LIB2ADD; do
172 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
173 oname
=`echo $name | sed -e 's,.*/,,'`
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}/${oname}${objext}"
179 if [ ${name}.asm
= ${file} ]; then
180 flags
="$flags -xassembler-with-cpp"
183 echo $out: stmp-dirs
$file
184 echo " $gcc_compile" $flags -c $file -o $out
186 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
189 for file in $LIB2ADDEH; do
190 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
191 oname
=`echo $name | sed -e 's,.*/,,'`
193 for ml
in $MULTILIBS; do
194 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
195 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
196 out
="libgcc/${dir}/${oname}${objext}"
197 if [ ${name}.asm
= ${file} ]; then
198 flags
="$flags -xassembler-with-cpp"
201 echo $out: stmp-dirs
$file
202 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
204 if [ "$SHLIB_LINK" ]; then
205 libgcc2_eh_objs
="$libgcc2_eh_objs ${oname}${objext}"
207 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
211 for file in $LIB2ADD_ST; do
212 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
213 oname
=`echo $name | sed -e 's,.*/,,'`
215 for ml
in $MULTILIBS; do
216 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
217 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
218 out
="libgcc/${dir}/${oname}${objext}"
219 if [ ${name}.asm
= ${file} ]; then
220 flags
="$flags -xassembler-with-cpp"
223 echo $out: stmp-dirs
$file
224 echo " $gcc_compile" $flags -c $file -o $out
226 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
231 for ml
in $MULTILIBS; do
232 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
233 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
237 for o
in $libgcc1_objs; do
238 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
240 for o
in $libgcc2_objs; do
241 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
243 for o
in $libgcc2_eh_objs; do
244 libgcc_eh_objs
="$libgcc_eh_objs libgcc/${dir}/$o"
246 libgcc_sh_objs
="$libgcc_objs $libgcc_eh_objs"
247 shlib_deps
="$libgcc_sh_objs"
250 for o
in $libgcc2_st_objs; do
251 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
254 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
257 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_sh_objs"
258 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_sh_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
261 shlib_deps
="$shlib_deps $mapfile"
263 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
264 # usually are put in a true multilib situation.
265 for f
in $EXTRA_MULTILIB_PARTS; do
266 shlib_deps
="$shlib_deps $dir/$f"
270 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
271 echo " -rm -rf ${dir}/libgcc.a"
272 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_objs $libgcc_st_objs
273 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
274 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
275 echo ' else true; fi;'
277 if [ "$SHLIB_LINK" ]; then
280 echo "${dir}/libgcc_eh.a: $libgcc_eh_objs"
281 echo " -rm -rf ${dir}/libgcc_eh.a"
282 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a
$libgcc_eh_objs
283 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
284 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
';' \\
285 echo ' else true; fi;'
287 if [ -z "$SHLIB_MULTILIB" ]; then
288 if [ "$dir" = "." ]; then
289 shlib_base_name
="libgcc_s";
291 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
294 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
295 echo " $SHLIB_LINK" \
296 |
sed -e "s%@multilib_flags@%$flags%g" \
297 -e "s%@multilib_dir@%$dir%g" \
298 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
299 -e "s%@shlib_base_name@%$shlib_base_name%g" \
300 -e "s%@shlib_map_file@%$mapfile%g"
301 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
302 shlib_base_name
="libgcc_s";
304 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
305 echo " $SHLIB_LINK" \
306 |
sed -e "s%@multilib_flags@%$flags%g" \
307 -e "s%@multilib_dir@%$dir%g" \
308 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
309 -e "s%@shlib_base_name@%$shlib_base_name%g" \
310 -e "s%@shlib_map_file@%$mapfile%g"
316 for ml
in $MULTILIBS; do
317 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
318 if [ $dir != .
]; then
319 dirs="$dirs libgcc/${dir}"
323 echo 'libgcc-stage-start:'
324 echo ' for dir in '"${dirs}"'; do \'
325 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
327 echo ' -for dir in '"${dirs}"'; do \'
328 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
335 for ml
in $MULTILIBS; do
336 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
337 if [ $dir != .
]; then
338 dirs="$dirs ${dir} libgcc/${dir}"
340 all
="$all ${dir}/libgcc.a"
341 if [ "$SHLIB_LINK" ]; then
342 all
="$all ${dir}/libgcc_eh.a"
343 if [ -z "$SHLIB_MULTILIB" ]; then
344 if [ "$dir" = "." ]; then
347 suff
=_
`echo $dir | sed s,/,_,g`
349 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
350 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
351 all
="$all libgcc_s${SHLIB_EXT}"
356 echo 'stmp-dirs: force'
357 echo ' for d in '"$dirs"'; do \'
358 echo ' if [ -d $
$d ]; then true
; else '$mkinstalldirs' $
$d; fi; \'
360 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
362 for f
in $EXTRA_MULTILIB_PARTS; do
363 for ml
in $MULTILIBS; do
364 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
365 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
368 *) out
=$dir/$f ; t
=$dir/ ;;
371 # Prevent `make' from interpreting $out as a macro assignment
372 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
377 echo " $make_compile" \\
378 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
379 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
390 for ml
in $MULTILIBS; do
391 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
392 if [ $dir != .
]; then
393 ldir
='$(libsubdir)'/$dir
394 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
398 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
399 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
401 if [ "$SHLIB_LINK" ]; then
402 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a
${ldir}/
403 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
405 if [ -z "$SHLIB_MULTILIB" ]; then
406 if [ "$dir" = "." ]; then
407 shlib_base_name
="libgcc_s";
409 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
411 echo " $SHLIB_INSTALL" \
412 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
413 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
414 shlib_base_name
="libgcc_s";
415 echo " $SHLIB_INSTALL" \
416 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
420 for f
in $EXTRA_MULTILIB_PARTS; do
421 for ml
in $MULTILIBS; do
422 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
423 if [ $dir != .
]; then
425 ldir
='$(libsubdir)'/$dir
430 echo ' $(INSTALL_DATA)' $out $ldir/