Daily bump.
[official-gcc.git] / gcc / mklibgcc.in
blobbcc03e26c3b061b833eaff3d820019d2e9d2ddef
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_MAPFILES
32 # SHLIB_NM_FLAGS
33 # SHLIB_INSTALL
35 # Make needs VPATH to be literal.
36 echo 'srcdir = @srcdir@'
37 echo 'VPATH = @srcdir@'
38 echo 'EQ = ='
39 echo
40 echo 'force:'
41 echo
43 # Disable SHLIB_LINK if shared libgcc not enabled.
44 if [ "@enable_shared@" = "no" ]; then
45 SHLIB_LINK=""
48 # Build lines.
50 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
51 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
52 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
53 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
54 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
55 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
56 CC="$(CC)" CFLAGS="$(CFLAGS)" \
57 HOST_PREFIX="$(HOST_PREFIX)" \
58 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
59 LANGUAGES="$(LANGUAGES)"'
61 # Dependencies for libgcc2.c
62 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"
64 # Dependencies for fp-bit.c
65 fpbit_c_dep='stmp-dirs config.status tsystem.h'
68 # Build libgcc1 components.
71 libgcc1_objs=""
73 for name in $LIB1ASMFUNCS; do
74 for ml in $MULTILIBS; do
75 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
76 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
77 out="libgcc/${dir}/${name}${objext}"
79 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
80 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
81 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
83 # Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
84 # defined as optimized assembly code in LIB1ASMFUNCS.
85 LIB2FUNCS_1=`echo $LIB2FUNCS_1 | sed -e 's/^'$name' //' \
86 -e 's/ '$name' / /' \
87 -e 's/ '$name'$//'`
88 LIB2FUNCS_2=`echo $LIB2FUNCS_2 | sed -e 's/^'$name' //' \
89 -e 's/ '$name' / /' \
90 -e 's/ '$name'$//'`
91 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
92 -e 's/ '$name' / /' \
93 -e 's/ '$name'$//'`
94 done
95 libgcc1_objs="$libgcc1_objs ${name}${objext}"
96 done
99 # Build libgcc2 components.
102 libgcc2_objs=""
103 libgcc2_st_objs=""
104 libgcc2_eh_objs=""
106 for name in $LIB2FUNCS_1 $LIB2FUNCS_2; do
107 for ml in $MULTILIBS; do
108 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
109 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
110 out="libgcc/${dir}/${name}${objext}"
112 echo $out: $libgcc2_c_dep
113 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
114 -c '$(srcdir)/libgcc2.c' -o $out
115 done
116 libgcc2_objs="$libgcc2_objs ${name}${objext}"
117 done
119 for name in $LIB2FUNCS_ST; 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
128 done
129 libgcc2_st_objs="$libgcc2_st_objs ${name}${objext}"
130 done
132 for name in $LIB2_DIVMOD_FUNCS; 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' -fexceptions -fnon-call-exceptions -o $out
141 done
142 libgcc2_objs="$libgcc2_objs ${name}${objext}"
143 done
145 if [ "$FPBIT" ]; then
146 for name in $FPBIT_FUNCS; do
147 for ml in $MULTILIBS; do
148 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
149 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
150 out="libgcc/${dir}/${name}${objext}"
152 echo $out: $FPBIT $fpbit_c_dep
153 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
154 -c $FPBIT -o $out
155 done
156 libgcc2_objs="$libgcc2_objs ${name}${objext}"
157 done
160 if [ "$DPBIT" ]; then
161 for name in $DPBIT_FUNCS; do
162 for ml in $MULTILIBS; do
163 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
164 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
165 out="libgcc/${dir}/${name}${objext}"
167 echo $out: $DPBIT $fpbit_c_dep
168 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
169 -c $DPBIT -o $out
170 done
171 libgcc2_objs="$libgcc2_objs ${name}${objext}"
172 done
175 for file in $LIB2ADD; do
176 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
177 oname=`echo $name | sed -e 's,.*/,,'`
179 for ml in $MULTILIBS; do
180 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
181 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
182 out="libgcc/${dir}/${oname}${objext}"
183 if [ ${name}.asm = ${file} ]; then
184 flags="$flags -xassembler-with-cpp"
187 echo $out: stmp-dirs $file
188 echo " $gcc_compile" $flags -c $file -o $out
189 done
190 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
191 done
193 for file in $LIB2ADDEH; do
194 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
195 oname=`echo $name | sed -e 's,.*/,,'`
197 for ml in $MULTILIBS; do
198 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
199 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
200 out="libgcc/${dir}/${oname}${objext}"
201 if [ ${name}.asm = ${file} ]; then
202 flags="$flags -xassembler-with-cpp"
205 echo $out: stmp-dirs $file
206 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
207 done
208 if [ "$SHLIB_LINK" ]; then
209 libgcc2_eh_objs="$libgcc2_eh_objs ${oname}${objext}"
210 else
211 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
213 done
215 for file in $LIB2ADD_ST; do
216 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
217 oname=`echo $name | sed -e 's,.*/,,'`
219 for ml in $MULTILIBS; do
220 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
221 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
222 out="libgcc/${dir}/${oname}${objext}"
223 if [ ${name}.asm = ${file} ]; then
224 flags="$flags -xassembler-with-cpp"
227 echo $out: stmp-dirs $file
228 echo " $gcc_compile" $flags -c $file -o $out
229 done
230 libgcc2_st_objs="$libgcc2_st_objs ${oname}${objext}"
231 done
233 # SHLIB_MKMAP
234 # SHLIB_MAPFILES
235 for ml in $MULTILIBS; do
236 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
237 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
239 libgcc_objs=""
240 libgcc_eh_objs=""
241 for o in $libgcc1_objs; do
242 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
243 done
244 for o in $libgcc2_objs; do
245 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
246 done
247 for o in $libgcc2_eh_objs; do
248 libgcc_eh_objs="$libgcc_eh_objs libgcc/${dir}/$o"
249 done
250 libgcc_sh_objs="$libgcc_objs $libgcc_eh_objs"
251 shlib_deps="$libgcc_sh_objs"
253 libgcc_st_objs=""
254 for o in $libgcc2_st_objs; do
255 libgcc_st_objs="$libgcc_st_objs libgcc/${dir}/$o"
256 done
258 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
259 mapfile="libgcc.map"
260 echo ""
261 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_sh_objs"
262 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_sh_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
263 echo ' mv tmp-$@ $@'
265 shlib_deps="$shlib_deps $mapfile"
267 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
268 # usually are put in a true multilib situation.
269 for f in $EXTRA_MULTILIB_PARTS; do
270 shlib_deps="$shlib_deps $dir/$f"
271 done
273 echo ""
274 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
275 echo " -rm -rf ${dir}/libgcc.a"
276 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs $libgcc_st_objs
277 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
278 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
279 echo ' else true; fi;'
281 if [ "$SHLIB_LINK" ]; then
283 echo ""
284 echo "${dir}/libgcc_eh.a: $libgcc_eh_objs"
285 echo " -rm -rf ${dir}/libgcc_eh.a"
286 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a $libgcc_eh_objs
287 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
288 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a ';' \\
289 echo ' else true; fi;'
291 if [ -z "$SHLIB_MULTILIB" ]; then
292 if [ "$dir" = "." ]; then
293 shlib_base_name="libgcc_s";
294 else
295 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
297 echo ""
298 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
299 echo " $SHLIB_LINK" \
300 | sed -e "s%@multilib_flags@%$flags%g" \
301 -e "s%@multilib_dir@%$dir%g" \
302 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
303 -e "s%@shlib_base_name@%$shlib_base_name%g" \
304 -e "s%@shlib_map_file@%$mapfile%g"
305 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
306 shlib_base_name="libgcc_s";
307 echo ""
308 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
309 echo " $SHLIB_LINK" \
310 | sed -e "s%@multilib_flags@%$flags%g" \
311 -e "s%@multilib_dir@%$dir%g" \
312 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
313 -e "s%@shlib_base_name@%$shlib_base_name%g" \
314 -e "s%@shlib_map_file@%$mapfile%g"
317 done
319 dirs=libgcc
320 for ml in $MULTILIBS; do
321 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
322 if [ $dir != . ]; then
323 dirs="$dirs libgcc/${dir}"
325 done
326 echo ''
327 echo 'libgcc-stage-start:'
328 echo ' for dir in '"${dirs}"'; do \'
329 echo ' if [ -d $(stage)/$$dir ]; then true; else mkdir $(stage)/$$dir; fi; \'
330 echo ' done'
331 echo ' -for dir in '"${dirs}"'; do \'
332 echo ' mv $$dir/*'"${objext}"' $(stage)/$$dir; \'
333 echo ' done'
335 echo ""
336 all=stmp-dirs
337 dirs=libgcc
339 for ml in $MULTILIBS; do
340 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
341 if [ $dir != . ]; then
342 dirs="$dirs ${dir} libgcc/${dir}"
344 all="$all ${dir}/libgcc.a"
345 if [ "$SHLIB_LINK" ]; then
346 all="$all ${dir}/libgcc_eh.a"
347 if [ -z "$SHLIB_MULTILIB" ]; then
348 if [ "$dir" = "." ]; then
349 suff="";
350 else
351 suff=_`echo $dir | sed s,/,_,g`
353 all="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
354 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
355 all="$all libgcc_s${SHLIB_EXT}"
358 done
360 echo 'stmp-dirs: force'
361 echo ' for d in '"$dirs"'; do \'
362 echo ' if [ -d $$d ]; then true; else '$mkinstalldirs' $$d; fi; \'
363 echo ' done'
364 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
366 for f in $EXTRA_MULTILIB_PARTS; do
367 for ml in $MULTILIBS; do
368 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
369 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
370 case $dir in
371 .) out=$f ; t= ;;
372 *) out=$dir/$f ; t=$dir/ ;;
373 esac
374 case $out in
375 # Prevent `make' from interpreting $out as a macro assignment
376 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
377 *) targ=$out ;;
378 esac
380 echo $out: stmp-dirs
381 echo " $make_compile" \\
382 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
383 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $targ
385 all="$all $out"
386 done
387 done
389 echo ""
390 echo "all: $all"
392 echo ""
393 echo "install: $all"
394 for ml in $MULTILIBS; do
395 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
396 if [ $dir != . ]; then
397 ldir='$(libsubdir)'/$dir
398 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
399 else
400 ldir='$(libsubdir)'
402 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
403 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
405 if [ "$SHLIB_LINK" ]; then
406 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
407 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
409 if [ -z "$SHLIB_MULTILIB" ]; then
410 if [ "$dir" = "." ]; then
411 shlib_base_name="libgcc_s";
412 else
413 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
415 echo " $SHLIB_INSTALL" \
416 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
417 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
418 shlib_base_name="libgcc_s";
419 echo " $SHLIB_INSTALL" \
420 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
423 done
424 for f in $EXTRA_MULTILIB_PARTS; do
425 for ml in $MULTILIBS; do
426 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
427 if [ $dir != . ]; then
428 out=${dir}/$f
429 ldir='$(libsubdir)'/$dir
430 else
431 out=$f
432 ldir='$(libsubdir)'
434 echo ' $(INSTALL_DATA)' $out $ldir/
435 done
436 done