Use MODE_BASE_REG_CLASS in legitimize macros.
[official-gcc.git] / gcc / mklibgcc.in
blob8f9174a0f5d6e052f685a88758102d91be5cdcdd
1 #!/bin/sh
2 # Construct makefile for libgcc.
3 # Copyright (C) 2000 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
13 # LIB2FUNCS_ST
14 # LIB2ADD
15 # LIB2ADD_ST
16 # LIB2ADDEH
17 # LIB2ADDEHDEP
18 # FPBIT
19 # FPBIT_FUNCS
20 # LIB2_DIVMOD_FUNCS
21 # DPBIT
22 # DPBIT_FUNCS
23 # LIBGCC
24 # MULTILIBS
25 # EXTRA_MULTILIB_PARTS
26 # SHLIB_EXT
27 # SHLIB_LINK
28 # SHLIB_MULTILIB
29 # SHLIB_MKMAP
30 # SHLIB_MAPFILES
31 # SHLIB_NM_FLAGS
32 # SHLIB_INSTALL
34 # Make needs VPATH to be literal.
35 echo 'srcdir = @srcdir@'
36 echo 'VPATH = @srcdir@'
37 echo 'EQ = ='
38 echo
39 echo 'force:'
40 echo
42 # Disable SHLIB_LINK if shared libgcc not enabled.
43 if [ "@enable_shared@" = "no" ]; then
44 SHLIB_LINK=""
47 # Build lines.
49 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
50 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
51 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
52 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
53 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
54 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
55 CC="$(CC)" CFLAGS="$(CFLAGS)" \
56 HOST_PREFIX="$(HOST_PREFIX)" \
57 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
58 LANGUAGES="$(LANGUAGES)"'
60 # Dependencies for libgcc2.c
61 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"
63 # Dependencies for fp-bit.c
64 fpbit_c_dep='stmp-dirs config.status tsystem.h'
67 # Build libgcc1 components.
70 libgcc1_objs=""
72 for name in $LIB1ASMFUNCS; do
73 for ml in $MULTILIBS; do
74 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
75 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
76 out="libgcc/${dir}/${name}${objext}"
78 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
79 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
80 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
82 # Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
83 # defined as optimized assembly code in LIB1ASMFUNCS.
84 LIB2FUNCS=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
85 -e 's/ '$name' / /' \
86 -e 's/ '$name'$//'`
87 LIB2_DIVMOD_FUNCS=`echo $LIB2_DIVMOD_FUNCS | sed -e 's/^'$name' //' \
88 -e 's/ '$name' / /' \
89 -e 's/ '$name'$//'`
90 done
91 libgcc1_objs="$libgcc1_objs ${name}${objext}"
92 done
95 # Build libgcc2 components.
98 libgcc2_objs=""
99 libgcc2_st_objs=""
100 libgcc2_eh_objs=""
102 for name in $LIB2FUNCS; do
103 for ml in $MULTILIBS; do
104 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
105 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
106 out="libgcc/${dir}/${name}${objext}"
108 echo $out: $libgcc2_c_dep
109 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
110 -c '$(srcdir)/libgcc2.c' -o $out
111 done
112 libgcc2_objs="$libgcc2_objs ${name}${objext}"
113 done
115 for name in $LIB2FUNCS_ST; do
116 for ml in $MULTILIBS; do
117 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
118 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
119 out="libgcc/${dir}/${name}${objext}"
121 echo $out: $libgcc2_c_dep
122 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
123 -c '$(srcdir)/libgcc2.c' -o $out
124 done
125 libgcc2_st_objs="$libgcc2_st_objs ${name}${objext}"
126 done
128 for name in $LIB2_DIVMOD_FUNCS; do
129 for ml in $MULTILIBS; do
130 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
131 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
132 out="libgcc/${dir}/${name}${objext}"
134 echo $out: $libgcc2_c_dep
135 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
136 -c '$(srcdir)/libgcc2.c' -fexceptions -fnon-call-exceptions -o $out
137 done
138 libgcc2_objs="$libgcc2_objs ${name}${objext}"
139 done
141 if [ "$FPBIT" ]; then
142 for name in $FPBIT_FUNCS; do
143 for ml in $MULTILIBS; do
144 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
145 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
146 out="libgcc/${dir}/${name}${objext}"
148 echo $out: $FPBIT $fpbit_c_dep
149 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
150 -c $FPBIT -o $out
151 done
152 libgcc2_objs="$libgcc2_objs ${name}${objext}"
153 done
156 if [ "$DPBIT" ]; then
157 for name in $DPBIT_FUNCS; do
158 for ml in $MULTILIBS; do
159 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
160 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
161 out="libgcc/${dir}/${name}${objext}"
163 echo $out: $DPBIT $fpbit_c_dep
164 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
165 -c $DPBIT -o $out
166 done
167 libgcc2_objs="$libgcc2_objs ${name}${objext}"
168 done
171 for file in $LIB2ADD; do
172 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
173 oname=`echo $name | sed -e 's,.*/,,'`
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}/${oname}${objext}"
179 if [ ${name}.asm = ${file} ]; then
180 flags="$flags -xassembler-with-cpp"
183 echo $out: stmp-dirs $file
184 echo " $gcc_compile" $flags -c $file -o $out
185 done
186 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
187 done
189 for file in $LIB2ADDEH; do
190 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
191 oname=`echo $name | sed -e 's,.*/,,'`
193 for ml in $MULTILIBS; do
194 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
195 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
196 out="libgcc/${dir}/${oname}${objext}"
197 if [ ${name}.asm = ${file} ]; then
198 flags="$flags -xassembler-with-cpp"
201 echo $out: stmp-dirs $file
202 echo " $gcc_compile" $flags -fexceptions -c $file -o $out
203 done
204 if [ "$SHLIB_LINK" ]; then
205 libgcc2_eh_objs="$libgcc2_eh_objs ${oname}${objext}"
206 else
207 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
209 done
211 for file in $LIB2ADD_ST; do
212 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
213 oname=`echo $name | sed -e 's,.*/,,'`
215 for ml in $MULTILIBS; do
216 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
217 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
218 out="libgcc/${dir}/${oname}${objext}"
219 if [ ${name}.asm = ${file} ]; then
220 flags="$flags -xassembler-with-cpp"
223 echo $out: stmp-dirs $file
224 echo " $gcc_compile" $flags -c $file -o $out
225 done
226 libgcc2_st_objs="$libgcc2_st_objs ${oname}${objext}"
227 done
229 # SHLIB_MKMAP
230 # SHLIB_MAPFILES
231 for ml in $MULTILIBS; do
232 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
233 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
235 libgcc_objs=""
236 libgcc_eh_objs=""
237 for o in $libgcc1_objs; do
238 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
239 done
240 for o in $libgcc2_objs; do
241 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
242 done
243 for o in $libgcc2_eh_objs; do
244 libgcc_eh_objs="$libgcc_eh_objs libgcc/${dir}/$o"
245 done
246 libgcc_sh_objs="$libgcc_objs $libgcc_eh_objs"
247 shlib_deps="$libgcc_sh_objs"
249 libgcc_st_objs=""
250 for o in $libgcc2_st_objs; do
251 libgcc_st_objs="$libgcc_st_objs libgcc/${dir}/$o"
252 done
254 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
255 mapfile="libgcc.map"
256 echo ""
257 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_sh_objs"
258 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_sh_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
259 echo ' mv tmp-$@ $@'
261 shlib_deps="$shlib_deps $mapfile"
263 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
264 # usually are put in a true multilib situation.
265 for f in $EXTRA_MULTILIB_PARTS; do
266 shlib_deps="$shlib_deps $dir/$f"
267 done
269 echo ""
270 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
271 echo " -rm -rf ${dir}/libgcc.a"
272 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs $libgcc_st_objs
273 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
274 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
275 echo ' else true; fi;'
277 if [ "$SHLIB_LINK" ]; then
279 echo ""
280 echo "${dir}/libgcc_eh.a: $libgcc_eh_objs"
281 echo " -rm -rf ${dir}/libgcc_eh.a"
282 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc_eh.a $libgcc_eh_objs
283 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
284 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc_eh.a ';' \\
285 echo ' else true; fi;'
287 if [ -z "$SHLIB_MULTILIB" ]; then
288 if [ "$dir" = "." ]; then
289 shlib_base_name="libgcc_s";
290 else
291 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
293 echo ""
294 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
295 echo " $SHLIB_LINK" \
296 | sed -e "s%@multilib_flags@%$flags%g" \
297 -e "s%@multilib_dir@%$dir%g" \
298 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
299 -e "s%@shlib_base_name@%$shlib_base_name%g" \
300 -e "s%@shlib_map_file@%$mapfile%g"
301 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
302 shlib_base_name="libgcc_s";
303 echo ""
304 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
305 echo " $SHLIB_LINK" \
306 | sed -e "s%@multilib_flags@%$flags%g" \
307 -e "s%@multilib_dir@%$dir%g" \
308 -e "s%@shlib_objs@%$libgcc_sh_objs%g" \
309 -e "s%@shlib_base_name@%$shlib_base_name%g" \
310 -e "s%@shlib_map_file@%$mapfile%g"
313 done
315 dirs=libgcc
316 for ml in $MULTILIBS; do
317 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
318 if [ $dir != . ]; then
319 dirs="$dirs libgcc/${dir}"
321 done
322 echo ''
323 echo 'libgcc-stage-start:'
324 echo ' for dir in '"${dirs}"'; do \'
325 echo ' if [ -d $(stage)/$$dir ]; then true; else mkdir $(stage)/$$dir; fi; \'
326 echo ' done'
327 echo ' -for dir in '"${dirs}"'; do \'
328 echo ' mv $$dir/*'"${objext}"' $(stage)/$$dir; \'
329 echo ' done'
331 echo ""
332 all=stmp-dirs
333 dirs=libgcc
335 for ml in $MULTILIBS; do
336 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
337 if [ $dir != . ]; then
338 dirs="$dirs ${dir} libgcc/${dir}"
340 all="$all ${dir}/libgcc.a"
341 if [ "$SHLIB_LINK" ]; then
342 all="$all ${dir}/libgcc_eh.a"
343 if [ -z "$SHLIB_MULTILIB" ]; then
344 if [ "$dir" = "." ]; then
345 suff="";
346 else
347 suff=_`echo $dir | sed s,/,_,g`
349 all="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
350 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
351 all="$all libgcc_s${SHLIB_EXT}"
354 done
356 echo 'stmp-dirs: force'
357 echo ' for d in '"$dirs"'; do \'
358 echo ' if [ -d $$d ]; then true; else '$mkinstalldirs' $$d; fi; \'
359 echo ' done'
360 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
362 for f in $EXTRA_MULTILIB_PARTS; do
363 for ml in $MULTILIBS; do
364 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
365 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
366 case $dir in
367 .) out=$f ; t= ;;
368 *) out=$dir/$f ; t=$dir/ ;;
369 esac
370 case $out in
371 # Prevent `make' from interpreting $out as a macro assignment
372 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
373 *) targ=$out ;;
374 esac
376 echo $out: stmp-dirs
377 echo " $make_compile" \\
378 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
379 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $targ
381 all="$all $out"
382 done
383 done
385 echo ""
386 echo "all: $all"
388 echo ""
389 echo "install: $all"
390 for ml in $MULTILIBS; do
391 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
392 if [ $dir != . ]; then
393 ldir='$(libsubdir)'/$dir
394 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
395 else
396 ldir='$(libsubdir)'
398 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
399 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
401 if [ "$SHLIB_LINK" ]; then
402 echo ' $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
403 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
405 if [ -z "$SHLIB_MULTILIB" ]; then
406 if [ "$dir" = "." ]; then
407 shlib_base_name="libgcc_s";
408 else
409 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
411 echo " $SHLIB_INSTALL" \
412 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
413 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
414 shlib_base_name="libgcc_s";
415 echo " $SHLIB_INSTALL" \
416 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
419 done
420 for f in $EXTRA_MULTILIB_PARTS; do
421 for ml in $MULTILIBS; do
422 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
423 if [ $dir != . ]; then
424 out=${dir}/$f
425 ldir='$(libsubdir)'/$dir
426 else
427 out=$f
428 ldir='$(libsubdir)'
430 echo ' $(INSTALL_DATA)' $out $ldir/
431 done
432 done