cselib.c (cselib_current_insn_in_libcall): New static variable.
[official-gcc.git] / gcc / mklibgcc.in
blob820230b94c324b9c68f899073ff5f26724134242
1 #!/bin/sh
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.
10 # objext
11 # LIB1ASMFUNCS
12 # LIB2FUNCS_1
13 # LIB2FUNCS_2
14 # LIB2FUNCS_ST
15 # LIB2ADD
16 # LIB2ADD_ST
17 # LIB2ADDEH
18 # LIB2ADDEHDEP
19 # FPBIT
20 # FPBIT_FUNCS
21 # LIB2_DIVMOD_FUNCS
22 # DPBIT
23 # DPBIT_FUNCS
24 # LIBGCC
25 # MULTILIBS
26 # EXTRA_MULTILIB_PARTS
27 # SHLIB_EXT
28 # SHLIB_LINK
29 # SHLIB_MULTILIB
30 # SHLIB_MKMAP
31 # SHLIB_MKMAP_OPTS
32 # SHLIB_MAPFILES
33 # SHLIB_NM_FLAGS
34 # SHLIB_INSTALL
35 # MULTILIB_OSDIRNAMES
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 # Disable SHLIB_LINK if shared libgcc not enabled.
46 if [ "@enable_shared@" = "no" ]; then
47 SHLIB_LINK=""
50 # Build lines.
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.
73 libgcc1_objs=""
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' //' \
88 -e 's/ '$name' / /' \
89 -e 's/ '$name'$//'`
90 LIB2FUNCS_2=`echo $LIB2FUNCS_2 | sed -e 's/^'$name' //' \
91 -e 's/ '$name' / /' \
92 -e 's/ '$name'$//'`
93 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
94 -e 's/ '$name' / /' \
95 -e 's/ '$name'$//'`
96 done
97 libgcc1_objs="$libgcc1_objs ${name}${objext}"
98 done
101 # Build libgcc2 components.
104 libgcc2_objs=""
105 libgcc2_st_objs=""
106 libgcc2_eh_objs=""
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
117 done
118 libgcc2_objs="$libgcc2_objs ${name}${objext}"
119 done
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
130 done
131 libgcc2_st_objs="$libgcc2_st_objs ${name}${objext}"
132 done
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
143 done
144 libgcc2_objs="$libgcc2_objs ${name}${objext}"
145 done
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 \
156 -c $FPBIT -o $out
157 done
158 libgcc2_objs="$libgcc2_objs ${name}${objext}"
159 done
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 \
171 -c $DPBIT -o $out
172 done
173 libgcc2_objs="$libgcc2_objs ${name}${objext}"
174 done
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
191 done
192 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
193 done
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
209 done
210 if [ "$SHLIB_LINK" ]; then
211 libgcc2_eh_objs="$libgcc2_eh_objs ${oname}${objext}"
212 else
213 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
215 done
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
231 done
232 libgcc2_st_objs="$libgcc2_st_objs ${oname}${objext}"
233 done
235 # SHLIB_MKMAP
236 # SHLIB_MKMAP_OPTS
237 # SHLIB_MAPFILES
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'`;
242 libgcc_objs=""
243 libgcc_eh_objs=""
244 for o in $libgcc1_objs; do
245 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
246 done
247 for o in $libgcc2_objs; do
248 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
249 done
250 for o in $libgcc2_eh_objs; do
251 libgcc_eh_objs="$libgcc_eh_objs libgcc/${dir}/$o"
252 done
253 libgcc_sh_objs="$libgcc_objs $libgcc_eh_objs"
254 shlib_deps="$libgcc_sh_objs"
256 libgcc_st_objs=""
257 for o in $libgcc2_st_objs; do
258 libgcc_st_objs="$libgcc_st_objs libgcc/${dir}/$o"
259 done
261 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" ]; then
262 mapfile="libgcc/${dir}/libgcc.map"
263 tmpmapfile="libgcc/${dir}/tmp-libgcc.map"
264 echo ""
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"
278 done
280 libgcc_a_objs="$libgcc_objs $libgcc_st_objs"
282 if [ "@libgcc_visibility@" = yes -a "$SHLIB_LINK" ]; then
283 libgcc_a_objs=
284 echo ""
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}"
291 done
294 echo ""
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
304 echo ""
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
315 else
316 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
318 shlib_so_name="$shlib_base_name"
319 shlib_dir=
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`
324 shlib_dir="$dir"/
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
329 else
330 shlib_so_name=libgcc_s_`echo $gcc_multilib_sup | sed s,/,_,g`
334 echo ""
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";
346 echo ""
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"
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 all="$all ${dir}/libgcc_eh.a"
388 if [ -z "$SHLIB_MULTILIB" ]; then
389 if [ "$dir" = "." ]; then
390 suff="";
391 else
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}"
399 done
401 echo 'stmp-dirs: force'
402 echo ' for d in '"$dirs"'; do \'
403 echo ' if [ -d $$d ]; then true; else '$mkinstalldirs' $$d; fi; \'
404 echo ' done'
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'`;
411 case $dir in
412 .) out=$f ; t= ;;
413 *) out=$dir/$f ; t=$dir/ ;;
414 esac
415 case $out in
416 # Prevent `make' from interpreting $out as a macro assignment
417 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
418 *) targ=$out ;;
419 esac
421 echo $out: stmp-dirs
422 echo " $make_compile" \\
423 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
424 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $targ
426 all="$all $out"
427 done
428 done
430 echo ""
431 echo "all: $all"
433 echo ""
434 echo "install: $all"
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;"
441 else
442 ldir='$(libsubdir)'
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
454 else
455 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
457 shlib_so_name="$shlib_base_name"
458 shlib_dir=
459 shlib_slibdir_qual=
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
464 shlib_dir="$dir"/
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"
473 else
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"
492 done
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
497 out=${dir}/$f
498 ldir='$(libsubdir)'/$dir
499 else
500 out=$f
501 ldir='$(libsubdir)'
503 echo ' $(INSTALL_DATA)' $out $ldir/
504 done
505 done