2 # Construct makefile for libgcc.
3 # Copyright (C) 2000, 2002, 2003 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.
27 # EXTRA_MULTILIB_PARTS
38 # Make needs VPATH to be literal.
39 echo 'srcdir = @srcdir@'
40 echo 'VPATH = @srcdir@'
46 # Library members defined in libgcc2.c.
47 lib2funcs
='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
48 _cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi
49 _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi
50 _floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf _clear_cache
51 _trampoline __main _exit _absvsi2 _absvdi2 _addvsi3 _addvdi3
52 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
53 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
54 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2'
56 # Disable SHLIB_LINK if shared libgcc not enabled.
57 if [ "@enable_shared@" = "no" ]; then
63 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
64 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
65 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
66 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
67 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
68 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
69 CC="$(CC)" CFLAGS="$(CFLAGS)" \
70 BUILD_PREFIX="$(BUILD_PREFIX)" \
71 BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
72 LANGUAGES="$(LANGUAGES)"'
74 # Dependencies for libgcc2.c
75 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"
77 # Dependencies for libgcov.c
78 libgcov_c_dep
='stmp-dirs $(srcdir)/libgcov.c $(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'
80 # Dependencies for fp-bit.c
81 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
84 # Build libgcc1 components.
89 for name
in $LIB1ASMFUNCS; do
90 for ml
in $MULTILIBS; do
91 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
92 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
93 out
="libgcc/${dir}/${name}${objext}"
95 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
96 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
97 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
99 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
100 # defined as optimized assembly code in LIB1ASMFUNCS.
101 lib2funcs
=`echo $lib2funcs | sed -e 's/^'$name' //' \
102 -e 's/ '$name' / /' \
104 LIB2_DIVMOD_FUNCS
=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
105 -e 's/ '$name' / /' \
108 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
112 # Build libgcc2 components.
119 for name
in $lib2funcs; do
120 for ml
in $MULTILIBS; do
121 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
122 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
123 out
="libgcc/${dir}/${name}${objext}"
125 echo $out: $libgcc2_c_dep
126 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
127 -c '$(srcdir)/libgcc2.c' -o $out
129 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
132 for name
in $LIB2FUNCS_ST; do
133 for ml
in $MULTILIBS; do
134 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
135 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
136 out
="libgcc/${dir}/${name}${objext}"
138 echo $out: $libgcc2_c_dep
139 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
140 -c '$(srcdir)/libgcc2.c' -o $out
142 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
145 for name
in $LIB2_DIVMOD_FUNCS; do
146 for ml
in $MULTILIBS; do
147 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
148 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
149 out
="libgcc/${dir}/${name}${objext}"
151 echo $out: $libgcc2_c_dep
152 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
153 -c '$(srcdir)/libgcc2.c' -fexceptions -fnon-call-exceptions -o $out
155 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
158 if [ "$FPBIT" ]; then
159 for name
in $FPBIT_FUNCS; do
160 for ml
in $MULTILIBS; do
161 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
162 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
163 out
="libgcc/${dir}/${name}${objext}"
165 echo $out: $FPBIT $fpbit_c_dep
166 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
169 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
173 if [ "$DPBIT" ]; then
174 for name
in $DPBIT_FUNCS; do
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}/${name}${objext}"
180 echo $out: $DPBIT $fpbit_c_dep
181 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
184 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
188 if [ "$TPBIT" ]; then
189 for name
in $TPBIT_FUNCS; do
190 for ml
in $MULTILIBS; do
191 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
192 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
193 out
="libgcc/${dir}/${name}${objext}"
195 echo $out: $TPBIT $fpbit_c_dep
196 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
199 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
203 for file in $LIB2ADD; 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_objs
="$libgcc2_objs ${oname}${objext}"
221 for file in $LIB2ADDEH; do
222 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
223 oname
=`echo $name | sed -e 's,.*/,,'`
225 for ml
in $MULTILIBS; do
226 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
227 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
228 out
="libgcc/${dir}/${oname}${objext}"
229 if [ ${name}.asm
= ${file} ]; then
230 flags
="$flags -xassembler-with-cpp"
233 echo $out: stmp-dirs
$file
234 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
236 if [ "$SHLIB_LINK" ]; then
237 libgcc2_eh_objs
="$libgcc2_eh_objs ${oname}${objext}"
239 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
243 for file in $LIB2ADD_ST; do
244 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
245 oname
=`echo $name | sed -e 's,.*/,,'`
247 for ml
in $MULTILIBS; do
248 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
249 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
250 out
="libgcc/${dir}/${oname}${objext}"
251 if [ ${name}.asm
= ${file} ]; then
252 flags
="$flags -xassembler-with-cpp"
255 echo $out: stmp-dirs
$file
256 echo " $gcc_compile" $flags -c $file -o $out
258 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
262 # build libgcov components
267 for name
in $LIBGCOV; do
268 for ml
in $MULTILIBS; do
269 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
270 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
271 out
="libgcc/${dir}/${name}${objext}"
273 echo $out: $libgcov_c_dep
274 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
275 -c '$(srcdir)/libgcov.c' -o $out
277 libgcov_objs
="$libgcov_objs ${name}${objext}"
283 for ml
in $MULTILIBS; do
284 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
285 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
289 for o
in $libgcc1_objs; do
290 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
292 for o
in $libgcc2_objs; do
293 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
295 for o
in $libgcc2_eh_objs; do
296 libgcc_eh_objs
="$libgcc_eh_objs libgcc/${dir}/$o"
298 libgcc_sh_objs
="$libgcc_objs $libgcc_eh_objs"
299 shlib_deps
="$libgcc_sh_objs"
302 for o
in $libgcc2_st_objs; do
303 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
307 for o
in $libgcov_objs; do
308 libgcov_a_objs
="$libgcov_a_objs libgcc/${dir}/$o"
311 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
312 mapfile
="libgcc/${dir}/libgcc.map"
313 tmpmapfile
="libgcc/${dir}/tmp-libgcc.map"
315 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_sh_objs"
316 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_sh_objs; echo %%; \\"
317 echo " cat $SHLIB_MAPFILES | sed -e "'"/^[ ]*#/d" -e '\''s/^%\(if\|else\|elif\|endif\|define\)/#\1/'\'" \\"
318 echo " | $gcc_compile $flags -E -xassembler-with-cpp -; \\"
319 echo ' } | $(AWK)'" -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}"
320 echo ' mv '"$tmpmapfile"' $@'
322 shlib_deps
="$shlib_deps $mapfile"
324 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
325 # usually are put in a true multilib situation.
326 for f
in $EXTRA_MULTILIB_PARTS; do
327 shlib_deps
="$shlib_deps $dir/$f"
330 libgcc_a_objs
="$libgcc_objs $libgcc_st_objs"
332 if [ "@libgcc_visibility@" = yes -a "$SHLIB_LINK" ]; then
335 for o
in $libgcc_objs $libgcc_st_objs; do
336 # .oS objects will have all non-local symbol definitions .hidden
337 oS
=`echo ${o} | sed s~${objext}'$~.oS~g'`
338 echo "${oS}: stmp-dirs ${o}"
339 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 -'
340 libgcc_a_objs
="${libgcc_a_objs} ${oS}"
345 echo "${dir}/libgcc.a: $libgcc_a_objs"
346 echo " -rm -rf ${dir}/libgcc.a"
347 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_a_objs
348 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
351 echo "${dir}/libgcov.a: $libgcov_a_objs"
352 echo " -rm -rf ${dir}/libgcov.a"
353 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcov.a
$libgcov_a_objs
354 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcov.a
356 if [ "$SHLIB_LINK" ]; then
359 echo "${dir}/libgcc_eh.a: $libgcc_eh_objs"
360 echo " -rm -rf ${dir}/libgcc_eh.a"
361 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a
$libgcc_eh_objs
362 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
364 if [ -z "$SHLIB_MULTILIB" ]; then
365 if [ "$dir" = .
]; then
366 shlib_base_name
=libgcc_s
368 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
370 shlib_so_name
="$shlib_base_name"
372 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
373 if [ "$dir" != .
]; then
374 gcc_multilib_dir
=`./xgcc -B./ $flags --print-multi-directory`
375 os_multilib_dir
=`./xgcc -B./ $flags --print-multi-os-directory`
377 gcc_multilib_sup
=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
378 os_multilib_base
=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
379 if [ -z "$os_multilib_base" ]; then
380 shlib_so_name
=libgcc_s
382 shlib_so_name
=libgcc_s_
`echo $gcc_multilib_sup | sed s,/,_,g`
387 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
388 echo " $SHLIB_LINK" \
389 |
sed -e "s%@multilib_flags@%$flags%g" \
390 -e "s%@multilib_dir@%$dir%g" \
391 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
392 -e "s%@shlib_base_name@%$shlib_base_name%g" \
393 -e "s%@shlib_map_file@%$mapfile%g" \
394 -e "s%@shlib_so_name@%$shlib_so_name%g" \
395 -e "s%@shlib_dir@%$shlib_dir%g"
396 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
397 shlib_base_name
="libgcc_s";
399 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
400 echo " $SHLIB_LINK" \
401 |
sed -e "s%@multilib_flags@%$flags%g" \
402 -e "s%@multilib_dir@%$dir%g" \
403 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
404 -e "s%@shlib_base_name@%$shlib_base_name%g" \
405 -e "s%@shlib_map_file@%$mapfile%g" \
406 -e "s%@shlib_so_name@%$shlib_base_name%g" \
407 -e "s%@shlib_dir@%%g"
413 for ml
in $MULTILIBS; do
414 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
415 if [ $dir != .
]; then
416 dirs="$dirs libgcc/${dir}"
420 echo 'libgcc-stage-start:'
421 echo ' for dir in '"${dirs}"'; do \'
422 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
424 echo ' -for dir in '"${dirs}"'; do \'
425 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
432 for ml
in $MULTILIBS; do
433 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
434 if [ $dir != .
]; then
435 dirs="$dirs ${dir} libgcc/${dir}"
437 all
="$all ${dir}/libgcc.a ${dir}/libgcov.a"
438 if [ "$SHLIB_LINK" ]; then
439 all
="$all ${dir}/libgcc_eh.a"
440 if [ -z "$SHLIB_MULTILIB" ]; then
441 if [ "$dir" = "." ]; then
444 suff
=_
`echo $dir | sed s,/,_,g`
446 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
447 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
448 all
="$all libgcc_s${SHLIB_EXT}"
453 echo 'stmp-dirs: force'
454 echo ' for d in '"$dirs"'; do \'
455 echo ' if [ -d $
$d ]; then true
; else '$mkinstalldirs' $
$d; fi; \'
457 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
459 for f
in $EXTRA_MULTILIB_PARTS; do
460 for ml
in $MULTILIBS; do
461 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
462 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
465 *) out
=$dir/$f ; t
=$dir/ ;;
468 # Prevent `make' from interpreting $out as a macro assignment
469 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
474 echo " $make_compile" \\
475 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
476 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
487 for ml
in $MULTILIBS; do
488 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
489 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
490 if [ $dir != .
]; then
491 ldir
='$(DESTDIR)$(libsubdir)'/$dir
492 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
494 ldir
='$(DESTDIR)$(libsubdir)'
496 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
497 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
498 echo ' $(INSTALL_DATA)' ${dir}/libgcov.a
${ldir}/
499 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcov.a
501 if [ "$SHLIB_LINK" ]; then
502 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a
${ldir}/
503 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
505 if [ -z "$SHLIB_MULTILIB" ]; then
506 if [ "$dir" = .
]; then
507 shlib_base_name
=libgcc_s
509 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
511 shlib_so_name
="$shlib_base_name"
514 if [ -n "$MULTILIB_OSDIRNAMES" ]; then
515 gcc_multilib_dir
=`./xgcc -B./ $flags --print-multi-directory`
516 os_multilib_dir
=`./xgcc -B./ $flags --print-multi-os-directory`
517 if [ "$dir" != .
]; then
520 gcc_multilib_sup
=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
521 os_multilib_base
=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
522 if [ -z "$os_multilib_base" ]; then
523 shlib_so_name
=libgcc_s
524 if [ "$os_multilib_dir" != "." ]; then
525 shlib_slibdir_qual
="/$os_multilib_dir"
528 shlib_so_name
=libgcc_s_
`echo $gcc_multilib_sup | sed s,/,_,g`
529 shlib_slibdir_qual
="/$os_multilib_base"
532 echo " $SHLIB_INSTALL" \
533 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
534 -e "s%@shlib_so_name@%$shlib_so_name%g" \
535 -e "s%@shlib_dir@%$shlib_dir%g" \
536 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
537 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
538 shlib_base_name
="libgcc_s";
539 echo " $SHLIB_INSTALL" \
540 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
541 -e "s%@shlib_so_name@%$shlib_base_name%g" \
542 -e "s%@shlib_dir@%%g" \
543 -e "s%@shlib_slibdir_qual@%%g"
547 for f
in $EXTRA_MULTILIB_PARTS; do
548 for ml
in $MULTILIBS; do
549 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
550 if [ $dir != .
]; then
552 ldir
='$(DESTDIR)$(libsubdir)'/$dir
555 ldir
='$(DESTDIR)$(libsubdir)'
557 echo ' $(INSTALL_DATA)' $out $ldir/