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
35 # SHLIB_SLIBDIR_SUFFIXES
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) $(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 "$SHLIB_SLIBDIR_SUFFIXES" ]; then
321 if [ "$dir" != .
]; then
323 for suffix_pair
in $SHLIB_SLIBDIR_SUFFIXES ; do
324 base_ml_dir
=`echo ${suffix_pair} | sed -e 's/:.*$//' -e 's/=/$(EQ)/g'`
325 if [ "$dir" = "$base_ml_dir" ]; then
326 shlib_so_name
=libgcc_s
329 canon_dir
=`echo $dir | sed -n -e "s:$base_ml_dir/::p"`
330 if [ -n "$canon_dir" ]; then
331 shlib_so_name
=libgcc_s_
`echo $canon_dir | sed s,/,_,g`
339 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
340 echo " $SHLIB_LINK" \
341 |
sed -e "s%@multilib_flags@%$flags%g" \
342 -e "s%@multilib_dir@%$dir%g" \
343 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
344 -e "s%@shlib_base_name@%$shlib_base_name%g" \
345 -e "s%@shlib_map_file@%$mapfile%g" \
346 -e "s%@shlib_so_name@%$shlib_so_name%g" \
347 -e "s%@shlib_dir@%$shlib_dir%g"
348 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
349 shlib_base_name
="libgcc_s";
351 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
352 echo " $SHLIB_LINK" \
353 |
sed -e "s%@multilib_flags@%$flags%g" \
354 -e "s%@multilib_dir@%$dir%g" \
355 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
356 -e "s%@shlib_base_name@%$shlib_base_name%g" \
357 -e "s%@shlib_map_file@%$mapfile%g" \
358 -e "s%@shlib_so_name@%$shlib_base_name%g" \
359 -e "s%@shlib_dir@%%g"
365 for ml
in $MULTILIBS; do
366 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
367 if [ $dir != .
]; then
368 dirs="$dirs libgcc/${dir}"
372 echo 'libgcc-stage-start:'
373 echo ' for dir in '"${dirs}"'; do \'
374 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
376 echo ' -for dir in '"${dirs}"'; do \'
377 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
384 for ml
in $MULTILIBS; do
385 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
386 if [ $dir != .
]; then
387 dirs="$dirs ${dir} libgcc/${dir}"
389 all
="$all ${dir}/libgcc.a"
390 if [ "$SHLIB_LINK" ]; then
391 all
="$all ${dir}/libgcc_eh.a"
392 if [ -z "$SHLIB_MULTILIB" ]; then
393 if [ "$dir" = "." ]; then
396 suff
=_
`echo $dir | sed s,/,_,g`
398 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
399 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
400 all
="$all libgcc_s${SHLIB_EXT}"
405 echo 'stmp-dirs: force'
406 echo ' for d in '"$dirs"'; do \'
407 echo ' if [ -d $
$d ]; then true
; else '$mkinstalldirs' $
$d; fi; \'
409 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
411 for f
in $EXTRA_MULTILIB_PARTS; do
412 for ml
in $MULTILIBS; do
413 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
414 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
417 *) out
=$dir/$f ; t
=$dir/ ;;
420 # Prevent `make' from interpreting $out as a macro assignment
421 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
426 echo " $make_compile" \\
427 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
428 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
439 for ml
in $MULTILIBS; do
440 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
441 if [ $dir != .
]; then
442 ldir
='$(libsubdir)'/$dir
443 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
447 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
448 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
450 if [ "$SHLIB_LINK" ]; then
451 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a
${ldir}/
452 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
454 if [ -z "$SHLIB_MULTILIB" ]; then
455 if [ "$dir" = .
]; then
456 shlib_base_name
=libgcc_s
458 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
460 shlib_so_name
="$shlib_base_name"
463 if [ -n "$SHLIB_SLIBDIR_SUFFIXES" ]; then
464 shlib_slibdir_qual
=none
465 if [ "$dir" != .
]; then
467 for suffix_pair
in $SHLIB_SLIBDIR_SUFFIXES ; do
468 base_ml_dir
=`echo ${suffix_pair} | sed -e 's/:.*$//' -e 's/=/$(EQ)/g'`
469 if [ "$dir" = "$base_ml_dir" ]; then
470 shlib_so_name
=libgcc_s
471 shlib_slibdir_qual
=`echo ${suffix_pair} | sed -e 's/^[^:]*://'`
474 canon_dir
=`echo $dir | sed -n -e "s:$base_ml_dir/::p"`
475 if [ -n "$canon_dir" ]; then
476 shlib_so_name
=libgcc_s_
`echo $canon_dir | sed s,/,_,g`
477 shlib_slibdir_qual
=`echo ${suffix_pair} | sed -e 's/^[^:]*://'`
483 if [ "$shlib_slibdir_qual" = none
]; then
484 for suffix_pair
in $SHLIB_SLIBDIR_SUFFIXES ; do
485 base_ml_dir
=`echo ${suffix_pair} | sed -e 's/:.*$//' -e 's/=/$(EQ)/g'`
486 shlib_slibdir_qual
=`echo ${suffix_pair} | sed -e 's/^[^:]*://'`
487 for ml2
in $MULTILIBS; do
488 dir2
=`echo ${ml2} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
489 if [ "$base_ml_dir" = "$dir2" ]; then
494 if [ -n "$shlib_slibdir_qual" ]; then break; fi
498 echo " $SHLIB_INSTALL" \
499 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
500 -e "s%@shlib_so_name@%$shlib_so_name%g" \
501 -e "s%@shlib_dir@%$shlib_dir%g" \
502 -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
503 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
504 shlib_base_name
="libgcc_s";
505 echo " $SHLIB_INSTALL" \
506 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
507 -e "s%@shlib_so_name@%$shlib_base_name%g" \
508 -e "s%@shlib_dir@%%g" \
509 -e "s%@shlib_slibdir_qual@%%g"
513 for f
in $EXTRA_MULTILIB_PARTS; do
514 for ml
in $MULTILIBS; do
515 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
516 if [ $dir != .
]; then
518 ldir
='$(libsubdir)'/$dir
523 echo ' $(INSTALL_DATA)' $out $ldir/