* jump.c (mark_jump_label): Fix thinko in 2001-05-19 change.
[official-gcc.git] / gcc / mklibgcc.in
blobf2e8babcae1f6eab7fe98da01bcef49e1bdbdbb0
1 #!/bin/sh
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.
10 # objext
11 # OLDCC
12 # LIBGCC1
13 # LIB1FUNCS
14 # LIB1ASMFUNCS
15 # LIB1FUNCS_EXTRA
16 # LIB2FUNCS
17 # LIB2FUNCS_ST
18 # LIB2ADD
19 # LIB2ADDEH
20 # LIB2ADDEHDEP
21 # LIB2ADD_ST
22 # FPBIT
23 # FPBIT_FUNCS
24 # DPBIT
25 # DPBIT_FUNCS
26 # LIBGCC
27 # MULTILIBS
28 # EXTRA_MULTILIB_PARTS
29 # SHLIB_EXT
30 # SHLIB_LINK
31 # SHLIB_MULTILIB
32 # SHLIB_MKMAP
33 # SHLIB_MAPFILES
34 # SHLIB_NM_FLAGS
35 # SHLIB_INSTALL
37 # Make needs VPATH to be literal.
38 echo 'srcdir = @srcdir@'
39 echo 'VPATH = @srcdir@'
40 echo 'EQ = ='
41 echo
42 echo 'force:'
43 echo
45 # Detect gcc as OLDCC. This indicates a target for which LIB1FUNCS
46 # is not needed. This is not quite the same as libgcc1.null, even
47 # on a target not using libgcc1-asm.a.
49 if [ "@build_canonical@" = "@target@" ]; then
50 tmp="tmp-$$.c"
51 cat > $tmp <<EOF
52 #ifdef __GNUC__
53 yes;
54 #endif
55 EOF
56 if $OLDCC -E $tmp | grep yes > /dev/null 2>&1; then
57 LIB1FUNCS=""
59 rm -f $tmp
62 # Disable SHLIB_LINK if shared libgcc not enabled.
63 if [ "@enable_shared@" = "no" ]; then
64 SHLIB_LINK=""
67 # Build lines.
69 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
70 oldcc_compile='$(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
71 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
72 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
73 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
74 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
75 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
76 CC="$(CC)" CFLAGS="$(CFLAGS)" \
77 HOST_PREFIX="$(HOST_PREFIX)" \
78 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
79 LANGUAGES="$(LANGUAGES)"'
81 # Dependancies for libgcc1.c
82 libgcc1_c_dep='stmp-dirs $(srcdir)/libgcc1.c $(CONFIG_H)'
84 # Dependancies for libgcc2.c
85 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"
87 # Dependancies for fp-bit.c
88 fpbit_c_dep='stmp-dirs config.status tsystem.h'
91 # Build libgcc1 components.
94 libgcc1_objs=""
96 case X"$LIBGCC1" in
97 Xlibgcc1.null | X)
100 Xlibgcc1.cross)
101 echo "You must find a way to make libgcc1 components yourself" 1>&2
104 Xlibgcc1-asm.a)
105 for name in $LIB1ASMFUNCS; do
106 for ml in $MULTILIBS; do
107 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
108 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
109 out="libgcc/${dir}/${name}${objext}"
111 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
112 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
113 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
115 # Remove any objects from LIB2FUNCS that are defined as optimized
116 # assembly code in LIB1ASMFUNCS.
117 LIB2FUNCS=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
118 -e 's/ '$name' / /' \
119 -e 's/ '$name'$//'`
120 done
121 libgcc1_objs="$libgcc1_objs ${name}${objext}"
122 done
125 Xlibgcc1.a)
126 for name in $LIB1FUNCS; do
127 out="libgcc/${name}${objext}"
129 echo $out: $libgcc1_c_dep
130 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
131 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
132 else
133 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
134 echo " mv libgcc1${objext} $out"
137 libgcc1_objs="$libgcc1_objs ${name}${objext}"
138 done
140 for file in $LIB1FUNCS_EXTRA; do
141 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
142 out="libgcc/${name}${objext}"
144 echo $out: $file
145 if [ ${name}.asm = $file ]; then
146 echo " cp $file ${name}.s"
147 file=${name}.s
150 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
151 echo " $oldcc_compile" -c $file -o $out
152 else
153 echo " $oldcc_compile" -c $file
154 tmp=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
155 echo " mv $tmp $out"
158 libgcc1_objs="$libgcc1_objs ${name}${objext}"
159 done
162 echo "I'm confused about libgcc1." 1>&2
163 exit 1
165 esac
168 # Build libgcc2 components.
171 libgcc2_objs=""
172 libgcc2_st_objs=""
174 for name in $LIB2FUNCS; 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: $libgcc2_c_dep
181 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
182 -c '$(srcdir)/libgcc2.c' -o $out
183 done
184 libgcc2_objs="$libgcc2_objs ${name}${objext}"
185 done
187 for name in $LIB2FUNCS_ST; do
188 for ml in $MULTILIBS; do
189 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
190 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
191 out="libgcc/${dir}/${name}${objext}"
193 echo $out: $libgcc2_c_dep
194 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
195 -c '$(srcdir)/libgcc2.c' -o $out
196 done
197 libgcc2_st_objs="$libgcc2_st_objs ${name}${objext}"
198 done
200 if [ "$FPBIT" ]; then
201 for name in $FPBIT_FUNCS; do
202 for ml in $MULTILIBS; do
203 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
204 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
205 out="libgcc/${dir}/${name}${objext}"
207 echo $out: $FPBIT $fpbit_c_dep
208 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
209 -c $FPBIT -o $out
210 done
211 libgcc2_objs="$libgcc2_objs ${name}${objext}"
212 done
215 if [ "$DPBIT" ]; then
216 for name in $DPBIT_FUNCS; do
217 for ml in $MULTILIBS; do
218 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
219 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
220 out="libgcc/${dir}/${name}${objext}"
222 echo $out: $DPBIT $fpbit_c_dep
223 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
224 -c $DPBIT -o $out
225 done
226 libgcc2_objs="$libgcc2_objs ${name}${objext}"
227 done
230 for file in $LIB2ADD; do
231 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
232 oname=`echo $name | sed -e 's,.*/,,'`
234 for ml in $MULTILIBS; do
235 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
236 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
237 out="libgcc/${dir}/${oname}${objext}"
238 if [ ${name}.asm = ${file} ]; then
239 flags="$flags -xassembler-with-cpp"
242 echo $out: stmp-dirs $file
243 echo " $gcc_compile" $flags -c $file -o $out
244 done
245 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
246 done
248 for file in $LIB2ADDEH; do
249 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
250 oname=`echo $name | sed -e 's,.*/,,'`
252 for ml in $MULTILIBS; do
253 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
254 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
255 out="libgcc/${dir}/${oname}${objext}"
256 if [ ${name}.asm = ${file} ]; then
257 flags="$flags -xassembler-with-cpp"
260 echo $out: stmp-dirs $file
261 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
262 done
263 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
264 done
266 for file in $LIB2ADD_ST; do
267 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
268 oname=`echo $name | sed -e 's,.*/,,'`
270 for ml in $MULTILIBS; do
271 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
272 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
273 out="libgcc/${dir}/${oname}${objext}"
274 if [ ${name}.asm = ${file} ]; then
275 flags="$flags -xassembler-with-cpp"
278 echo $out: stmp-dirs $file
279 echo " $gcc_compile" $flags -c $file -o $out
280 done
281 libgcc2_st_objs="$libgcc2_st_objs ${oname}${objext}"
282 done
284 # SHLIB_MKMAP
285 # SHLIB_MAPFILES
286 for ml in $MULTILIBS; do
287 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
288 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
290 libgcc_objs=""
291 for o in $libgcc1_objs; do
292 if [ "$LIBGCC1" = libgcc1-asm.a ]; then
293 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
294 else
295 libgcc_objs="$libgcc_objs libgcc/$o"
297 done
298 for o in $libgcc2_objs; do
299 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
300 done
301 shlib_deps="$libgcc_objs"
303 libgcc_st_objs=""
304 for o in $libgcc2_st_objs; do
305 libgcc_st_objs="$libgcc_st_objs libgcc/${dir}/$o"
306 done
308 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
309 mapfile="libgcc.map"
310 echo ""
311 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
312 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
313 echo ' mv tmp-$@ $@'
315 shlib_deps="$shlib_deps $mapfile"
317 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
318 # usually are put in a true multilib situation.
319 for f in $EXTRA_MULTILIB_PARTS; do
320 shlib_deps="$shlib_deps $dir/$f"
321 done
323 echo ""
324 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
325 echo " -rm -rf ${dir}/libgcc.a"
326 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs $libgcc_st_objs
327 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
328 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
329 echo ' else true; fi;'
331 if [ "$SHLIB_LINK" ]; then
332 if [ -z "$SHLIB_MULTILIB" ]; then
333 if [ "$dir" = "." ]; then
334 shlib_base_name="libgcc_s";
335 else
336 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
338 echo ""
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_objs%g" \
344 -e "s%@shlib_base_name@%$shlib_base_name%g" \
345 -e "s%@shlib_map_file@%$mapfile%g"
346 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
347 shlib_base_name="libgcc_s";
348 echo ""
349 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
350 echo " $SHLIB_LINK" \
351 | sed -e "s%@multilib_flags@%$flags%g" \
352 -e "s%@multilib_dir@%$dir%g" \
353 -e "s%@shlib_objs@%$libgcc_objs%g" \
354 -e "s%@shlib_base_name@%$shlib_base_name%g" \
355 -e "s%@shlib_map_file@%$mapfile%g"
358 done
360 dirs=libgcc
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}"
366 done
367 echo ''
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; \'
371 echo ' done'
372 echo ' -for dir in '"${dirs}"'; do \'
373 echo ' mv $$dir/*'"${objext}"' $(stage)/$$dir; \'
374 echo ' done'
376 echo ""
377 all=stmp-dirs
378 dirs=libgcc
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 if [ -z "$SHLIB_MULTILIB" ]; then
388 if [ "$dir" = "." ]; then
389 suff="";
390 else
391 suff=_`echo $dir | sed s,/,_,g`
393 all="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
394 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
395 all="$all libgcc_s${SHLIB_EXT}"
398 done
400 echo 'stmp-dirs: force'
401 echo ' for d in '"$dirs"'; do \'
402 echo ' if [ -d $$d ]; then true; else mkdir $$d; fi \'
403 echo ' done'
404 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
406 for f in $EXTRA_MULTILIB_PARTS; do
407 for ml in $MULTILIBS; do
408 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
409 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
410 case $dir in
411 .) out=$f ; t= ;;
412 *) out=$dir/$f ; t=$dir/ ;;
413 esac
414 case $out in
415 # Prevent `make' from interpreting $out as a macro assignment
416 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
417 *) targ=$out ;;
418 esac
420 echo $out: stmp-dirs
421 echo " $make_compile" \\
422 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
423 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $targ
425 all="$all $out"
426 done
427 done
429 echo ""
430 echo "all: $all"
432 echo ""
433 echo "install: $all"
434 for ml in $MULTILIBS; do
435 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
436 if [ $dir != . ]; then
437 ldir='$(libsubdir)'/$dir
438 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
439 else
440 ldir='$(libsubdir)'
442 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
443 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
445 if [ "$SHLIB_LINK" ]; then
446 if [ -z "$SHLIB_MULTILIB" ]; then
447 if [ "$dir" = "." ]; then
448 shlib_base_name="libgcc_s";
449 else
450 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
452 echo " $SHLIB_INSTALL" \
453 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
454 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
455 shlib_base_name="libgcc_s";
456 echo " $SHLIB_INSTALL" \
457 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
460 done
461 for f in $EXTRA_MULTILIB_PARTS; do
462 for ml in $MULTILIBS; do
463 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
464 if [ $dir != . ]; then
465 out=${dir}/$f
466 ldir='$(libsubdir)'/$dir
467 else
468 out=$f
469 ldir='$(libsubdir)'
471 echo ' $(INSTALL_DATA)' $out $ldir/
472 done
473 done