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
37 # Make needs VPATH to be literal.
38 echo 'srcdir = @srcdir@'
39 echo 'VPATH = @srcdir@'
45 # Disable SHLIB_LINK if shared libgcc not enabled.
46 if [ "@enable_shared@" = "no" ]; then
52 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
53 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
54 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
55 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
56 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
57 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
58 CC="$(CC)" CFLAGS="$(CFLAGS)" \
59 BUILD_PREFIX="$(BUILD_PREFIX)" \
60 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
61 LANGUAGES="$(LANGUAGES)"'
63 # Dependencies for libgcc2.c
64 libgcc2_c_dep
='stmp-dirs $(srcdir)/libgcc2.c $(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'" $LIB2ADDEHDEP"
66 # Dependencies for fp-bit.c
67 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
70 # Build libgcc1 components.
75 for name
in $LIB1ASMFUNCS; do
76 for ml
in $MULTILIBS; do
77 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
78 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
79 out
="libgcc/${dir}/${name}${objext}"
81 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
82 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
83 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
85 # Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
86 # defined as optimized assembly code in LIB1ASMFUNCS.
87 LIB2FUNCS_1
=`echo $LIB2FUNCS_1 | sed -e 's/^'$name' //' \
90 LIB2FUNCS_2
=`echo $LIB2FUNCS_2 | sed -e 's/^'$name' //' \
93 LIB2_DIVMOD_FUNCS
=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
97 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
101 # Build libgcc2 components.
108 for name
in $LIB2FUNCS_1 $LIB2FUNCS_2; do
109 for ml
in $MULTILIBS; do
110 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
111 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
112 out
="libgcc/${dir}/${name}${objext}"
114 echo $out: $libgcc2_c_dep
115 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
116 -c '$(srcdir)/libgcc2.c' -o $out
118 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
121 for name
in $LIB2FUNCS_ST; do
122 for ml
in $MULTILIBS; do
123 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
124 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
125 out
="libgcc/${dir}/${name}${objext}"
127 echo $out: $libgcc2_c_dep
128 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
129 -c '$(srcdir)/libgcc2.c' -o $out
131 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
134 for name
in $LIB2_DIVMOD_FUNCS; do
135 for ml
in $MULTILIBS; do
136 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
137 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
138 out
="libgcc/${dir}/${name}${objext}"
140 echo $out: $libgcc2_c_dep
141 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
142 -c '$(srcdir)/libgcc2.c' -fexceptions -fnon-call-exceptions -o $out
144 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
147 if [ "$FPBIT" ]; then
148 for name
in $FPBIT_FUNCS; do
149 for ml
in $MULTILIBS; do
150 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
151 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
152 out
="libgcc/${dir}/${name}${objext}"
154 echo $out: $FPBIT $fpbit_c_dep
155 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
158 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
162 if [ "$DPBIT" ]; then
163 for name
in $DPBIT_FUNCS; do
164 for ml
in $MULTILIBS; do
165 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
166 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
167 out
="libgcc/${dir}/${name}${objext}"
169 echo $out: $DPBIT $fpbit_c_dep
170 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
173 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
177 for file in $LIB2ADD; do
178 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
179 oname
=`echo $name | sed -e 's,.*/,,'`
181 for ml
in $MULTILIBS; do
182 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
183 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
184 out
="libgcc/${dir}/${oname}${objext}"
185 if [ ${name}.asm
= ${file} ]; then
186 flags
="$flags -xassembler-with-cpp"
189 echo $out: stmp-dirs
$file
190 echo " $gcc_compile" $flags -c $file -o $out
192 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
195 for file in $LIB2ADDEH; do
196 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
197 oname
=`echo $name | sed -e 's,.*/,,'`
199 for ml
in $MULTILIBS; do
200 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
201 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
202 out
="libgcc/${dir}/${oname}${objext}"
203 if [ ${name}.asm
= ${file} ]; then
204 flags
="$flags -xassembler-with-cpp"
207 echo $out: stmp-dirs
$file
208 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
210 if [ "$SHLIB_LINK" ]; then
211 libgcc2_eh_objs
="$libgcc2_eh_objs ${oname}${objext}"
213 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
217 for file in $LIB2ADD_ST; do
218 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
219 oname
=`echo $name | sed -e 's,.*/,,'`
221 for ml
in $MULTILIBS; do
222 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
223 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
224 out
="libgcc/${dir}/${oname}${objext}"
225 if [ ${name}.asm
= ${file} ]; then
226 flags
="$flags -xassembler-with-cpp"
229 echo $out: stmp-dirs
$file
230 echo " $gcc_compile" $flags -c $file -o $out
232 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
238 for ml
in $MULTILIBS; do
239 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
240 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
244 for o
in $libgcc1_objs; do
245 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
247 for o
in $libgcc2_objs; do
248 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
250 for o
in $libgcc2_eh_objs; do
251 libgcc_eh_objs
="$libgcc_eh_objs libgcc/${dir}/$o"
253 libgcc_sh_objs
="$libgcc_objs $libgcc_eh_objs"
254 shlib_deps
="$libgcc_sh_objs"
257 for o
in $libgcc2_st_objs; do
258 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
261 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
262 mapfile
="libgcc/${dir}/libgcc.map"
263 tmpmapfile
="libgcc/${dir}/tmp-libgcc.map"
265 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_sh_objs"
266 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_sh_objs; echo %%; \\"
267 echo " cat $SHLIB_MAPFILES | sed -e "'"/^[ ]*#/d" -e '\''s/^%\(if\|else\|elif\|endif\|define\)/#\1/'\'" \\"
268 echo " | $gcc_compile $flags -E -xassembler-with-cpp -; \\"
269 echo ' } | $(AWK)'" -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}"
270 echo ' mv '"$tmpmapfile"' $@'
272 shlib_deps
="$shlib_deps $mapfile"
274 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
275 # usually are put in a true multilib situation.
276 for f
in $EXTRA_MULTILIB_PARTS; do
277 shlib_deps
="$shlib_deps $dir/$f"
280 libgcc_a_objs
="$libgcc_objs $libgcc_st_objs"
282 if [ "@libgcc_visibility@" = yes -a "$SHLIB_LINK" ]; then
285 for o
in $libgcc_objs $libgcc_st_objs; do
286 # .oS objects will have all non-local symbol definitions .hidden
287 oS
=`echo ${o} | sed s~${objext}'$~.oS~g'`
288 echo "${oS}: stmp-dirs ${o}"
289 echo ' $(NM_FOR_TARGET) '${SHLIB_NM_FLAGS} ${o}' | $(AWK) '\''NF == 3 { print "\t.hidden", $$3 }'\'' | $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) '${flags}' -r -nostdinc -nostdlib -o $@ '${o}' -xassembler -'
290 libgcc_a_objs
="${libgcc_a_objs} ${oS}"
295 echo "${dir}/libgcc.a: $libgcc_a_objs"
296 echo " -rm -rf ${dir}/libgcc.a"
297 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_a_objs
298 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
299 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
300 echo ' else true; fi;'
302 if [ "$SHLIB_LINK" ]; then
305 echo "${dir}/libgcc_eh.a: $libgcc_eh_objs"
306 echo " -rm -rf ${dir}/libgcc_eh.a"
307 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a
$libgcc_eh_objs
308 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
309 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
';' \\
310 echo ' else true; fi;'
312 if [ -z "$SHLIB_MULTILIB" ]; then
313 if [ "$dir" = .
]; then
314 shlib_base_name
=libgcc_s
316 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
318 shlib_so_name
="$shlib_base_name"
320 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
321 if [ "$dir" != .
]; then
322 gcc_multilib_dir
=`./xgcc -B./ $flags --print-multi-directory`
323 os_multilib_dir
=`./xgcc -B./ $flags --print-multi-os-directory`
325 gcc_multilib_sup
=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
326 os_multilib_base
=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
327 if [ -z "$os_multilib_base" ]; then
328 shlib_so_name
=libgcc_s
330 shlib_so_name
=libgcc_s_
`echo $gcc_multilib_sup | sed s,/,_,g`
335 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
336 echo " $SHLIB_LINK" \
337 |
sed -e "s%@multilib_flags@%$flags%g" \
338 -e "s%@multilib_dir@%$dir%g" \
339 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
340 -e "s%@shlib_base_name@%$shlib_base_name%g" \
341 -e "s%@shlib_map_file@%$mapfile%g" \
342 -e "s%@shlib_so_name@%$shlib_so_name%g" \
343 -e "s%@shlib_dir@%$shlib_dir%g"
344 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
345 shlib_base_name
="libgcc_s";
347 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
348 echo " $SHLIB_LINK" \
349 |
sed -e "s%@multilib_flags@%$flags%g" \
350 -e "s%@multilib_dir@%$dir%g" \
351 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
352 -e "s%@shlib_base_name@%$shlib_base_name%g" \
353 -e "s%@shlib_map_file@%$mapfile%g" \
354 -e "s%@shlib_so_name@%$shlib_base_name%g" \
355 -e "s%@shlib_dir@%%g"
361 for ml
in $MULTILIBS; do
362 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
363 if [ $dir != .
]; then
364 dirs="$dirs libgcc/${dir}"
368 echo 'libgcc-stage-start:'
369 echo ' for dir in '"${dirs}"'; do \'
370 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
372 echo ' -for dir in '"${dirs}"'; do \'
373 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
380 for ml
in $MULTILIBS; do
381 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
382 if [ $dir != .
]; then
383 dirs="$dirs ${dir} libgcc/${dir}"
385 all
="$all ${dir}/libgcc.a"
386 if [ "$SHLIB_LINK" ]; then
387 all
="$all ${dir}/libgcc_eh.a"
388 if [ -z "$SHLIB_MULTILIB" ]; then
389 if [ "$dir" = "." ]; then
392 suff
=_
`echo $dir | sed s,/,_,g`
394 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
395 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
396 all
="$all libgcc_s${SHLIB_EXT}"
401 echo 'stmp-dirs: force'
402 echo ' for d in '"$dirs"'; do \'
403 echo ' if [ -d $
$d ]; then true
; else '$mkinstalldirs' $
$d; fi; \'
405 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
407 for f
in $EXTRA_MULTILIB_PARTS; do
408 for ml
in $MULTILIBS; do
409 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
410 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
413 *) out
=$dir/$f ; t
=$dir/ ;;
416 # Prevent `make' from interpreting $out as a macro assignment
417 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
422 echo " $make_compile" \\
423 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
424 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
435 for ml
in $MULTILIBS; do
436 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
437 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
438 if [ $dir != .
]; then
439 ldir
='$(libsubdir)'/$dir
440 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
444 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
445 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
447 if [ "$SHLIB_LINK" ]; then
448 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a
${ldir}/
449 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
451 if [ -z "$SHLIB_MULTILIB" ]; then
452 if [ "$dir" = .
]; then
453 shlib_base_name
=libgcc_s
455 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
457 shlib_so_name
="$shlib_base_name"
460 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
461 gcc_multilib_dir
=`./xgcc -B./ $flags --print-multi-directory`
462 os_multilib_dir
=`./xgcc -B./ $flags --print-multi-os-directory`
463 if [ "$dir" != .
]; then
466 gcc_multilib_sup
=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
467 os_multilib_base
=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
468 if [ -z "$os_multilib_base" ]; then
469 shlib_so_name
=libgcc_s
470 if [ "$os_multilib_dir" != "." ]; then
471 shlib_slibdir_qual
="/$os_multilib_dir"
474 shlib_so_name
=libgcc_s_
`echo $gcc_multilib_sup | sed s,/,_,g`
475 shlib_slibdir_qual
="/$os_multilib_base"
478 echo " $SHLIB_INSTALL" \
479 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
480 -e "s%@shlib_so_name@%$shlib_so_name%g" \
481 -e "s%@shlib_dir@%$shlib_dir%g" \
482 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
483 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
484 shlib_base_name
="libgcc_s";
485 echo " $SHLIB_INSTALL" \
486 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
487 -e "s%@shlib_so_name@%$shlib_base_name%g" \
488 -e "s%@shlib_dir@%%g" \
489 -e "s%@shlib_slibdir_qual@%%g"
493 for f
in $EXTRA_MULTILIB_PARTS; do
494 for ml
in $MULTILIBS; do
495 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
496 if [ $dir != .
]; then
498 ldir
='$(libsubdir)'/$dir
503 echo ' $(INSTALL_DATA)' $out $ldir/