151dd4977531ea32cc1cf8db8832aa6a5bbe5c4d
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.
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 that are defined as optimized
83 # assembly code in LIB1ASMFUNCS.
84 LIB2FUNCS
=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
88 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
92 # Build libgcc2 components.
98 for name
in $LIB2FUNCS; do
99 for ml
in $MULTILIBS; do
100 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
101 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
102 out
="libgcc/${dir}/${name}${objext}"
104 echo $out: $libgcc2_c_dep
105 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
106 -c '$(srcdir)/libgcc2.c' -o $out
108 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
111 for name
in $LIB2FUNCS_ST; do
112 for ml
in $MULTILIBS; do
113 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
114 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
115 out
="libgcc/${dir}/${name}${objext}"
117 echo $out: $libgcc2_c_dep
118 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
119 -c '$(srcdir)/libgcc2.c' -o $out
121 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
124 for name
in $LIB2_DIVMOD_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: $libgcc2_c_dep
131 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
132 -c '$(srcdir)/libgcc2.c' -fexceptions -fnon-call-exceptions -o $out
134 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
137 if [ "$FPBIT" ]; then
138 for name
in $FPBIT_FUNCS; do
139 for ml
in $MULTILIBS; do
140 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
141 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
142 out
="libgcc/${dir}/${name}${objext}"
144 echo $out: $FPBIT $fpbit_c_dep
145 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
148 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
152 if [ "$DPBIT" ]; then
153 for name
in $DPBIT_FUNCS; do
154 for ml
in $MULTILIBS; do
155 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
156 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
157 out
="libgcc/${dir}/${name}${objext}"
159 echo $out: $DPBIT $fpbit_c_dep
160 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
163 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
167 for file in $LIB2ADD; do
168 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
169 oname
=`echo $name | sed -e 's,.*/,,'`
171 for ml
in $MULTILIBS; do
172 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
173 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
174 out
="libgcc/${dir}/${oname}${objext}"
175 if [ ${name}.asm
= ${file} ]; then
176 flags
="$flags -xassembler-with-cpp"
179 echo $out: stmp-dirs
$file
180 echo " $gcc_compile" $flags -c $file -o $out
182 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
185 for file in $LIB2ADDEH; do
186 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
187 oname
=`echo $name | sed -e 's,.*/,,'`
189 for ml
in $MULTILIBS; do
190 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
191 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
192 out
="libgcc/${dir}/${oname}${objext}"
193 if [ ${name}.asm
= ${file} ]; then
194 flags
="$flags -xassembler-with-cpp"
197 echo $out: stmp-dirs
$file
198 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
200 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
203 for file in $LIB2ADD_ST; do
204 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
205 oname
=`echo $name | sed -e 's,.*/,,'`
207 for ml
in $MULTILIBS; do
208 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
209 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
210 out
="libgcc/${dir}/${oname}${objext}"
211 if [ ${name}.asm
= ${file} ]; then
212 flags
="$flags -xassembler-with-cpp"
215 echo $out: stmp-dirs
$file
216 echo " $gcc_compile" $flags -c $file -o $out
218 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
223 for ml
in $MULTILIBS; do
224 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
225 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
228 for o
in $libgcc1_objs; do
229 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
231 for o
in $libgcc2_objs; do
232 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
234 shlib_deps
="$libgcc_objs"
237 for o
in $libgcc2_st_objs; do
238 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
241 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
244 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
245 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
248 shlib_deps
="$shlib_deps $mapfile"
250 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
251 # usually are put in a true multilib situation.
252 for f
in $EXTRA_MULTILIB_PARTS; do
253 shlib_deps
="$shlib_deps $dir/$f"
257 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
258 echo " -rm -rf ${dir}/libgcc.a"
259 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_objs $libgcc_st_objs
260 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
261 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
262 echo ' else true; fi;'
264 if [ "$SHLIB_LINK" ]; then
265 if [ -z "$SHLIB_MULTILIB" ]; then
266 if [ "$dir" = "." ]; then
267 shlib_base_name
="libgcc_s";
269 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
272 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
273 echo " $SHLIB_LINK" \
274 |
sed -e "s%@multilib_flags@%$flags%g" \
275 -e "s%@multilib_dir@%$dir%g" \
276 -e "s%@shlib_objs@%$libgcc_objs%g" \
277 -e "s%@shlib_base_name@%$shlib_base_name%g" \
278 -e "s%@shlib_map_file@%$mapfile%g"
279 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
280 shlib_base_name
="libgcc_s";
282 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
283 echo " $SHLIB_LINK" \
284 |
sed -e "s%@multilib_flags@%$flags%g" \
285 -e "s%@multilib_dir@%$dir%g" \
286 -e "s%@shlib_objs@%$libgcc_objs%g" \
287 -e "s%@shlib_base_name@%$shlib_base_name%g" \
288 -e "s%@shlib_map_file@%$mapfile%g"
294 for ml
in $MULTILIBS; do
295 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
296 if [ $dir != .
]; then
297 dirs="$dirs libgcc/${dir}"
301 echo 'libgcc-stage-start:'
302 echo ' for dir in '"${dirs}"'; do \'
303 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
305 echo ' -for dir in '"${dirs}"'; do \'
306 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
313 for ml
in $MULTILIBS; do
314 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
315 if [ $dir != .
]; then
316 dirs="$dirs ${dir} libgcc/${dir}"
318 all
="$all ${dir}/libgcc.a"
319 if [ "$SHLIB_LINK" ]; then
320 if [ -z "$SHLIB_MULTILIB" ]; then
321 if [ "$dir" = "." ]; then
324 suff
=_
`echo $dir | sed s,/,_,g`
326 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
327 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
328 all
="$all libgcc_s${SHLIB_EXT}"
333 echo 'stmp-dirs: force'
334 echo ' for d in '"$dirs"'; do \'
335 echo ' if [ -d $
$d ]; then true
; else mkdir $
$d; fi \'
337 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
339 for f
in $EXTRA_MULTILIB_PARTS; do
340 for ml
in $MULTILIBS; do
341 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
342 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
345 *) out
=$dir/$f ; t
=$dir/ ;;
348 # Prevent `make' from interpreting $out as a macro assignment
349 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
354 echo " $make_compile" \\
355 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
356 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
367 for ml
in $MULTILIBS; do
368 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
369 if [ $dir != .
]; then
370 ldir
='$(libsubdir)'/$dir
371 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
375 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
376 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
378 if [ "$SHLIB_LINK" ]; then
379 if [ -z "$SHLIB_MULTILIB" ]; then
380 if [ "$dir" = "." ]; then
381 shlib_base_name
="libgcc_s";
383 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
385 echo " $SHLIB_INSTALL" \
386 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
387 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
388 shlib_base_name
="libgcc_s";
389 echo " $SHLIB_INSTALL" \
390 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
394 for f
in $EXTRA_MULTILIB_PARTS; do
395 for ml
in $MULTILIBS; do
396 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
397 if [ $dir != .
]; then
399 ldir
='$(libsubdir)'/$dir
404 echo ' $(INSTALL_DATA)' $out $ldir/