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
33 # Make needs VPATH to be literal.
34 echo 'srcdir = @srcdir@'
35 echo 'VPATH = @srcdir@'
41 # Detect gcc as OLDCC. This indicates a target for which LIB1FUNCS
42 # is not needed. This is not quite the same as libgcc1.null, even
43 # on a target not using libgcc1-asm.a.
45 if [ "@build_canonical@" = "@target@" ]; then
52 if $OLDCC -E $tmp |
grep yes > /dev
/null
2>&1; then
58 # Disable SHLIB_LINK if shared libgcc not enabled.
59 if [ "@enable_shared@" = "no" ]; then
65 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
66 oldcc_compile
='$(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
67 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
68 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
69 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
70 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
71 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
72 CC="$(CC)" CFLAGS="$(CFLAGS)" \
73 HOST_PREFIX="$(HOST_PREFIX)" \
74 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
75 LANGUAGES="$(LANGUAGES)"'
77 # Dependancies for libgcc1.c
78 libgcc1_c_dep
='stmp-dirs $(srcdir)/libgcc1.c $(CONFIG_H)'
80 # Dependancies for libgcc2.c
81 libgcc2_c_dep
='stmp-dirs $(srcdir)/libgcc2.c $(CONFIG_H) $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'
83 # Dependancies for fp-bit.c
84 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
87 # Build libgcc1 components.
97 echo "You must find a way to make libgcc1 components yourself" 1>&2
101 for name
in $LIB1ASMFUNCS; do
102 for ml
in $MULTILIBS; do
103 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
104 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
105 out
="libgcc/${dir}/${name}${objext}"
107 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
108 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
109 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
111 # Remove any objects from LIB2FUNCS that are defined as optimized
112 # assembly code in LIB1ASMFUNCS.
113 LIB2FUNCS
=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
114 -e 's/ '$name' / /' \
117 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
122 for name
in $LIB1FUNCS; do
123 out
="libgcc/${name}${objext}"
125 echo $out: $libgcc1_c_dep
126 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
127 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
129 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
130 echo " mv libgcc1${objext} $out"
133 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
136 for file in $LIB1FUNCS_EXTRA; do
137 name
=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
138 out
="libgcc/${name}${objext}"
141 if [ ${name}.asm
= $file ]; then
142 echo " cp $file ${name}.s"
146 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
147 echo " $oldcc_compile" -c $file -o $out
149 echo " $oldcc_compile" -c $file
150 tmp
=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
154 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
158 echo "I'm confused about libgcc1." 1>&2
164 # Build libgcc2 components.
169 for name
in $LIB2FUNCS; do
170 for ml
in $MULTILIBS; do
171 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
172 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
173 out
="libgcc/${dir}/${name}${objext}"
175 echo $out: $libgcc2_c_dep
176 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
177 -c '$(srcdir)/libgcc2.c' -o $out
179 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
182 for name
in $LIB2FUNCS_EH; do
183 for ml
in $MULTILIBS; do
184 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
185 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
186 out
="libgcc/${dir}/${name}${objext}"
188 echo $out: $libgcc2_c_dep
189 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' -fexceptions \
190 $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
192 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
195 if [ "$FPBIT" ]; then
196 for name
in $FPBIT_FUNCS; do
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}/${name}${objext}"
202 echo $out: $FPBIT $fpbit_c_dep
203 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
206 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
210 if [ "$DPBIT" ]; then
211 for name
in $DPBIT_FUNCS; do
212 for ml
in $MULTILIBS; do
213 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
214 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
215 out
="libgcc/${dir}/${name}${objext}"
217 echo $out: $DPBIT $fpbit_c_dep
218 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
221 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
225 for file in $LIB2ADD; do
226 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
227 oname
=`echo $name | sed -e 's,.*/,,'`
229 for ml
in $MULTILIBS; do
230 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
231 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
232 out
="libgcc/${dir}/${oname}${objext}"
233 if [ ${name}.asm
= ${file} ]; then
234 flags
="$flags -xassembler-with-cpp"
237 echo $out: stmp-dirs
$file
238 echo " $gcc_compile" $flags -c $file -o $out
240 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
245 for ml
in $MULTILIBS; do
246 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
247 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
250 for o
in $libgcc1_objs; do
251 if [ "$LIBGCC1" = libgcc1-asm.a
]; then
252 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
254 libgcc_objs
="$libgcc_objs libgcc/$o"
257 for o
in $libgcc2_objs; do
258 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
260 shlib_deps
="$libgcc_objs"
262 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
265 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
266 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
269 shlib_deps
="$shlib_deps $mapfile"
271 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
272 # usually are put in a true multilib situation.
273 for f
in $EXTRA_MULTILIB_PARTS; do
274 shlib_deps
="$shlib_deps $dir/$f"
278 echo "${dir}/libgcc.a: $libgcc_objs"
279 echo " -rm -rf ${dir}/libgcc.a"
280 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_objs
281 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
282 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
283 echo ' else true; fi;'
285 if [ "$SHLIB_LINK" ]; then
286 if [ -z "$SHLIB_MULTILIB" ]; then
287 if [ "$dir" = "." ]; then
288 shlib_base_name
="libgcc_s";
290 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
293 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
294 echo " $SHLIB_LINK" \
295 |
sed -e "s%@multilib_flags@%$flags%g" \
296 -e "s%@multilib_dir@%$dir%g" \
297 -e "s%@shlib_objs@%$libgcc_objs%g" \
298 -e "s%@shlib_base_name@%$shlib_base_name%g" \
299 -e "s%@shlib_map_file@%$mapfile%g"
300 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
301 shlib_base_name
="libgcc_s";
303 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
304 echo " $SHLIB_LINK" \
305 |
sed -e "s%@multilib_flags@%$flags%g" \
306 -e "s%@multilib_dir@%$dir%g" \
307 -e "s%@shlib_objs@%$libgcc_objs%g" \
308 -e "s%@shlib_base_name@%$shlib_base_name%g" \
309 -e "s%@shlib_map_file@%$mapfile%g"
315 for ml
in $MULTILIBS; do
316 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
317 if [ $dir != .
]; then
318 dirs="$dirs libgcc/${dir}"
322 echo 'libgcc-stage-start:'
323 echo ' for dir in '"${dirs}"'; do \'
324 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
326 echo ' -for dir in '"${dirs}"'; do \'
327 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
334 for ml
in $MULTILIBS; do
335 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
336 if [ $dir != .
]; then
337 dirs="$dirs ${dir} libgcc/${dir}"
339 all
="$all ${dir}/libgcc.a"
340 if [ "$SHLIB_LINK" ]; then
341 if [ -z "$SHLIB_MULTILIB" ]; then
342 if [ "$dir" = "." ]; then
345 suff
=_
`echo $dir | sed s,/,_,g`
347 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
348 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
349 all
="$all libgcc_s${SHLIB_EXT}"
354 echo 'stmp-dirs: force'
355 echo ' for d in '"$dirs"'; do \'
356 echo ' if [ -d $
$d ]; then true
; else mkdir $
$d; fi \'
358 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
360 for f
in $EXTRA_MULTILIB_PARTS; do
361 for ml
in $MULTILIBS; do
362 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
363 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
366 *) out
=$dir/$f ; t
=$dir/ ;;
369 # Prevent `make' from interpreting $out as a macro assignment
370 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
375 echo " $make_compile" \\
376 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
377 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ