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
36 # Make needs VPATH to be literal.
37 echo 'srcdir = @srcdir@'
38 echo 'VPATH = @srcdir@'
44 # Disable SHLIB_LINK if shared libgcc not enabled.
45 if [ "@enable_shared@" = "no" ]; then
51 gcc_compile
='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
52 make_compile
='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
53 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
54 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
55 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
56 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
57 CC="$(CC)" CFLAGS="$(CFLAGS)" \
58 HOST_PREFIX="$(HOST_PREFIX)" \
59 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
60 LANGUAGES="$(LANGUAGES)"'
62 # Dependencies for libgcc2.c
63 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"
65 # Dependencies for fp-bit.c
66 fpbit_c_dep
='stmp-dirs config.status tsystem.h'
69 # Build libgcc1 components.
74 for name
in $LIB1ASMFUNCS; do
75 for ml
in $MULTILIBS; do
76 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
77 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
78 out
="libgcc/${dir}/${name}${objext}"
80 echo ${out}: stmp-dirs
'$(srcdir)/config/$(LIB1ASMSRC)'
81 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
82 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
84 # Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
85 # defined as optimized assembly code in LIB1ASMFUNCS.
86 LIB2FUNCS_1
=`echo $LIB2FUNCS_1 | sed -e 's/^'$name' //' \
89 LIB2FUNCS_2
=`echo $LIB2FUNCS_2 | sed -e 's/^'$name' //' \
92 LIB2_DIVMOD_FUNCS
=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
96 libgcc1_objs
="$libgcc1_objs ${name}${objext}"
100 # Build libgcc2 components.
107 for name
in $LIB2FUNCS_1 $LIB2FUNCS_2; do
108 for ml
in $MULTILIBS; do
109 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
110 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
111 out
="libgcc/${dir}/${name}${objext}"
113 echo $out: $libgcc2_c_dep
114 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
115 -c '$(srcdir)/libgcc2.c' -o $out
117 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
120 for name
in $LIB2FUNCS_ST; do
121 for ml
in $MULTILIBS; do
122 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
123 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
124 out
="libgcc/${dir}/${name}${objext}"
126 echo $out: $libgcc2_c_dep
127 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
128 -c '$(srcdir)/libgcc2.c' -o $out
130 libgcc2_st_objs
="$libgcc2_st_objs ${name}${objext}"
133 for name
in $LIB2_DIVMOD_FUNCS; do
134 for ml
in $MULTILIBS; do
135 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
136 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
137 out
="libgcc/${dir}/${name}${objext}"
139 echo $out: $libgcc2_c_dep
140 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
141 -c '$(srcdir)/libgcc2.c' -fexceptions -fnon-call-exceptions -o $out
143 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
146 if [ "$FPBIT" ]; then
147 for name
in $FPBIT_FUNCS; do
148 for ml
in $MULTILIBS; do
149 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
150 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
151 out
="libgcc/${dir}/${name}${objext}"
153 echo $out: $FPBIT $fpbit_c_dep
154 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
157 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
161 if [ "$DPBIT" ]; then
162 for name
in $DPBIT_FUNCS; do
163 for ml
in $MULTILIBS; do
164 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
165 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
166 out
="libgcc/${dir}/${name}${objext}"
168 echo $out: $DPBIT $fpbit_c_dep
169 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
172 libgcc2_objs
="$libgcc2_objs ${name}${objext}"
176 for file in $LIB2ADD; do
177 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
178 oname
=`echo $name | sed -e 's,.*/,,'`
180 for ml
in $MULTILIBS; do
181 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
182 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
183 out
="libgcc/${dir}/${oname}${objext}"
184 if [ ${name}.asm
= ${file} ]; then
185 flags
="$flags -xassembler-with-cpp"
188 echo $out: stmp-dirs
$file
189 echo " $gcc_compile" $flags -c $file -o $out
191 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
194 for file in $LIB2ADDEH; do
195 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
196 oname
=`echo $name | sed -e 's,.*/,,'`
198 for ml
in $MULTILIBS; do
199 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
200 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
201 out
="libgcc/${dir}/${oname}${objext}"
202 if [ ${name}.asm
= ${file} ]; then
203 flags
="$flags -xassembler-with-cpp"
206 echo $out: stmp-dirs
$file
207 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
209 if [ "$SHLIB_LINK" ]; then
210 libgcc2_eh_objs
="$libgcc2_eh_objs ${oname}${objext}"
212 libgcc2_objs
="$libgcc2_objs ${oname}${objext}"
216 for file in $LIB2ADD_ST; do
217 name
=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
218 oname
=`echo $name | sed -e 's,.*/,,'`
220 for ml
in $MULTILIBS; do
221 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
222 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
223 out
="libgcc/${dir}/${oname}${objext}"
224 if [ ${name}.asm
= ${file} ]; then
225 flags
="$flags -xassembler-with-cpp"
228 echo $out: stmp-dirs
$file
229 echo " $gcc_compile" $flags -c $file -o $out
231 libgcc2_st_objs
="$libgcc2_st_objs ${oname}${objext}"
237 for ml
in $MULTILIBS; do
238 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
239 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
243 for o
in $libgcc1_objs; do
244 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
246 for o
in $libgcc2_objs; do
247 libgcc_objs
="$libgcc_objs libgcc/${dir}/$o"
249 for o
in $libgcc2_eh_objs; do
250 libgcc_eh_objs
="$libgcc_eh_objs libgcc/${dir}/$o"
252 libgcc_sh_objs
="$libgcc_objs $libgcc_eh_objs"
253 shlib_deps
="$libgcc_sh_objs"
256 for o
in $libgcc2_st_objs; do
257 libgcc_st_objs
="$libgcc_st_objs libgcc/${dir}/$o"
260 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
261 mapfile
="libgcc/${dir}/libgcc.map"
262 tmpmapfile
="libgcc/${dir}/tmp-libgcc.map"
264 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_sh_objs"
265 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_sh_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP $SHLIB_MKMAP_OPTS > ${tmpmapfile}"
266 echo ' mv '"$tmpmapfile"' $@'
268 shlib_deps
="$shlib_deps $mapfile"
270 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
271 # usually are put in a true multilib situation.
272 for f
in $EXTRA_MULTILIB_PARTS; do
273 shlib_deps
="$shlib_deps $dir/$f"
276 libgcc_a_objs
="$libgcc_objs $libgcc_st_objs"
278 if [ "@libgcc_visibility@" = yes -a "$SHLIB_LINK" ]; then
281 for o
in $libgcc_objs $libgcc_st_objs; do
282 # .oS objects will have all non-local symbol definitions .hidden
283 oS
=`echo ${o} | sed s~${objext}'$~.oS~g'`
284 echo "${oS}: stmp-dirs ${o}"
285 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 -'
286 libgcc_a_objs
="${libgcc_a_objs} ${oS}"
291 echo "${dir}/libgcc.a: $libgcc_a_objs"
292 echo " -rm -rf ${dir}/libgcc.a"
293 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a
$libgcc_a_objs
294 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
295 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a
';' \\
296 echo ' else true; fi;'
298 if [ "$SHLIB_LINK" ]; then
301 echo "${dir}/libgcc_eh.a: $libgcc_eh_objs"
302 echo " -rm -rf ${dir}/libgcc_eh.a"
303 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a
$libgcc_eh_objs
304 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
305 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a
';' \\
306 echo ' else true; fi;'
308 if [ -z "$SHLIB_MULTILIB" ]; then
309 if [ "$dir" = "." ]; then
310 shlib_base_name
="libgcc_s";
312 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
315 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
316 echo " $SHLIB_LINK" \
317 |
sed -e "s%@multilib_flags@%$flags%g" \
318 -e "s%@multilib_dir@%$dir%g" \
319 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
320 -e "s%@shlib_base_name@%$shlib_base_name%g" \
321 -e "s%@shlib_map_file@%$mapfile%g"
322 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
323 shlib_base_name
="libgcc_s";
325 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
326 echo " $SHLIB_LINK" \
327 |
sed -e "s%@multilib_flags@%$flags%g" \
328 -e "s%@multilib_dir@%$dir%g" \
329 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
330 -e "s%@shlib_base_name@%$shlib_base_name%g" \
331 -e "s%@shlib_map_file@%$mapfile%g"
337 for ml
in $MULTILIBS; do
338 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
339 if [ $dir != .
]; then
340 dirs="$dirs libgcc/${dir}"
344 echo 'libgcc-stage-start:'
345 echo ' for dir in '"${dirs}"'; do \'
346 echo ' if [ -d $
(stage
)/$
$dir ]; then true
; else mkdir $
(stage
)/$
$dir; fi; \'
348 echo ' -for dir in '"${dirs}"'; do \'
349 echo ' mv $
$dir/*'"${objext}"' $
(stage
)/$
$dir; \'
356 for ml
in $MULTILIBS; do
357 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
358 if [ $dir != .
]; then
359 dirs="$dirs ${dir} libgcc/${dir}"
361 all
="$all ${dir}/libgcc.a"
362 if [ "$SHLIB_LINK" ]; then
363 all
="$all ${dir}/libgcc_eh.a"
364 if [ -z "$SHLIB_MULTILIB" ]; then
365 if [ "$dir" = "." ]; then
368 suff
=_
`echo $dir | sed s,/,_,g`
370 all
="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
371 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
372 all
="$all libgcc_s${SHLIB_EXT}"
377 echo 'stmp-dirs: force'
378 echo ' for d in '"$dirs"'; do \'
379 echo ' if [ -d $
$d ]; then true
; else '$mkinstalldirs' $
$d; fi; \'
381 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
383 for f
in $EXTRA_MULTILIB_PARTS; do
384 for ml
in $MULTILIBS; do
385 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
386 flags
=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
389 *) out
=$dir/$f ; t
=$dir/ ;;
392 # Prevent `make' from interpreting $out as a macro assignment
393 *'$(EQ)'*) targ
="T_TARGET=$out T_TARGET" ;;
398 echo " $make_compile" \\
399 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
400 echo ' MULTILIB_CFLAGS="'$flags'"' T
=$t $targ
411 for ml
in $MULTILIBS; do
412 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
413 if [ $dir != .
]; then
414 ldir
='$(libsubdir)'/$dir
415 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
419 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a
${ldir}/
420 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
422 if [ "$SHLIB_LINK" ]; then
423 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a
${ldir}/
424 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
426 if [ -z "$SHLIB_MULTILIB" ]; then
427 if [ "$dir" = "." ]; then
428 shlib_base_name
="libgcc_s";
430 shlib_base_name
=libgcc_s_
`echo $dir | sed s,/,_,g`
432 echo " $SHLIB_INSTALL" \
433 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
434 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
435 shlib_base_name
="libgcc_s";
436 echo " $SHLIB_INSTALL" \
437 |
sed -e "s%@shlib_base_name@%$shlib_base_name%g"
441 for f
in $EXTRA_MULTILIB_PARTS; do
442 for ml
in $MULTILIBS; do
443 dir
=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
444 if [ $dir != .
]; then
446 ldir
='$(libsubdir)'/$dir
451 echo ' $(INSTALL_DATA)' $out $ldir/