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.
24 # EXTRA_MULTILIB_PARTS
33 # Make needs VPATH to be literal.
34 echo 'srcdir = @srcdir@'
35 echo 'VPATH = @srcdir@'
41 # Disable SHLIB_LINK if shared libgcc not enabled.
42 if [ "@enable_shared@" = "no" ]; then
48 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
49 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
50 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
51 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
52 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
53 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
54 CC="$(CC)" CFLAGS="$(CFLAGS)" \
55 HOST_PREFIX="$(HOST_PREFIX)" \
56 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
57 LANGUAGES="$(LANGUAGES)"'
59 # Dependencies for libgcc2.c
60 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"
62 # Dependencies for fp-bit.c
63 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
66 # Build libgcc1 components.
71 for name
in $LIB1ASMFUNCS; do
72 for ml
in $MULTILIBS; do
73 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
74 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
75 out
="libgcc/${dir}/${name}${objext}"
77 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
78 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
79 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
81 # Remove any objects from LIB2FUNCS that are defined as optimized
82 # assembly code in LIB1ASMFUNCS.
83 LIB2FUNCS
=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
87 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
91 # Build libgcc2 components.
97 for name
in $LIB2FUNCS; do
98 for ml
in $MULTILIBS; do
99 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
100 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
101 out
="libgcc/${dir}/${name}${objext}"
103 echo $out: $libgcc2_c_dep
104 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
105 -c '$(srcdir)/libgcc2.c' -o $out
107 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
110 for name
in $LIB2FUNCS_ST; do
111 for ml
in $MULTILIBS; do
112 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
113 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
114 out
="libgcc/${dir}/${name}${objext}"
116 echo $out: $libgcc2_c_dep
117 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
118 -c '$(srcdir)/libgcc2.c' -o $out
120 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
123 if [ "$FPBIT" ]; then
124 for name
in $FPBIT_FUNCS; do
125 for ml
in $MULTILIBS; do
126 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
127 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
128 out
="libgcc/${dir}/${name}${objext}"
130 echo $out: $FPBIT $fpbit_c_dep
131 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
134 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
138 if [ "$DPBIT" ]; then
139 for name
in $DPBIT_FUNCS; do
140 for ml
in $MULTILIBS; do
141 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
142 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
143 out
="libgcc/${dir}/${name}${objext}"
145 echo $out: $DPBIT $fpbit_c_dep
146 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
149 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
153 for file in $LIB2ADD; do
154 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
155 oname
=`echo $name | sed -e 's,.*/,,'`
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}/${oname}${objext}"
161 if [ ${name}.asm
= ${file} ]; then
162 flags
="$flags -xassembler-with-cpp"
165 echo $out: stmp-dirs
$file
166 echo " $gcc_compile" $flags -c $file -o $out
168 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
171 for file in $LIB2ADDEH; 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 -fexceptions -c $file -o $out
186 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
189 for file in $LIB2ADD_ST; 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 -c $file -o $out
204 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
209 for ml
in $MULTILIBS; do
210 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
211 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
214 for o
in $libgcc1_objs; do
215 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
217 for o
in $libgcc2_objs; do
218 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
220 shlib_deps
="$libgcc_objs"
223 for o
in $libgcc2_st_objs; do
224 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
227 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
230 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
231 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
234 shlib_deps
="$shlib_deps $mapfile"
236 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
237 # usually are put in a true multilib situation.
238 for f
in $EXTRA_MULTILIB_PARTS; do
239 shlib_deps
="$shlib_deps $dir/$f"
243 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
244 echo " -rm -rf ${dir}/libgcc.a"
245 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_objs $libgcc_st_objs
246 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
247 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
248 echo ' else true; fi;'
250 if [ "$SHLIB_LINK" ]; then
251 if [ -z "$SHLIB_MULTILIB" ]; then
252 if [ "$dir" = "." ]; then
253 shlib_base_name
="libgcc_s";
255 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
258 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
259 echo " $SHLIB_LINK" \
260 |
sed -e "s%@multilib_flags@%$flags%g" \
261 -e "s%@multilib_dir@%$dir%g" \
262 -e "s%@shlib_objs@%$libgcc_objs%g" \
263 -e "s%@shlib_base_name@%$shlib_base_name%g" \
264 -e "s%@shlib_map_file@%$mapfile%g"
265 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
266 shlib_base_name
="libgcc_s";
268 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
269 echo " $SHLIB_LINK" \
270 |
sed -e "s%@multilib_flags@%$flags%g" \
271 -e "s%@multilib_dir@%$dir%g" \
272 -e "s%@shlib_objs@%$libgcc_objs%g" \
273 -e "s%@shlib_base_name@%$shlib_base_name%g" \
274 -e "s%@shlib_map_file@%$mapfile%g"
280 for ml
in $MULTILIBS; do
281 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
282 if [ $dir != .
]; then
283 dirs="$dirs libgcc/${dir}"
287 echo 'libgcc-stage-start:'
288 echo ' for dir in '"${dirs}"'; do \'
289 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
291 echo ' -for dir in '"${dirs}"'; do \'
292 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
299 for ml
in $MULTILIBS; do
300 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
301 if [ $dir != .
]; then
302 dirs="$dirs ${dir} libgcc/${dir}"
304 all
="$all ${dir}/libgcc.a"
305 if [ "$SHLIB_LINK" ]; then
306 if [ -z "$SHLIB_MULTILIB" ]; then
307 if [ "$dir" = "." ]; then
310 suff
=_
`echo $dir | sed s,/,_,g`
312 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
313 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
314 all
="$all libgcc_s${SHLIB_EXT}"
319 echo 'stmp-dirs: force'
320 echo ' for d in '"$dirs"'; do \'
321 echo ' if [ -d $
$d ]; then true
; else mkdir $
$d; fi \'
323 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
325 for f
in $EXTRA_MULTILIB_PARTS; do
326 for ml
in $MULTILIBS; do
327 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
328 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
331 *) out
=$dir/$f ; t
=$dir/ ;;
334 # Prevent `make' from interpreting $out as a macro assignment
335 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
340 echo " $make_compile" \\
341 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
342 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
353 for ml
in $MULTILIBS; do
354 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
355 if [ $dir != .
]; then
356 ldir
='$(libsubdir)'/$dir
357 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
361 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
362 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
364 if [ "$SHLIB_LINK" ]; then
365 if [ -z "$SHLIB_MULTILIB" ]; then
366 if [ "$dir" = "." ]; then
367 shlib_base_name
="libgcc_s";
369 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
371 echo " $SHLIB_INSTALL" \
372 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
373 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
374 shlib_base_name
="libgcc_s";
375 echo " $SHLIB_INSTALL" \
376 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
380 for f
in $EXTRA_MULTILIB_PARTS; do
381 for ml
in $MULTILIBS; do
382 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
383 if [ $dir != .
]; then
385 ldir
='$(libsubdir)'/$dir
390 echo ' $(INSTALL_DATA)' $out $ldir/