* c-parse.in (array_declarator): New. Handle C99 constructs.
[official-gcc.git] / gcc / mklibgcc.in
blob512529d9e9c1a879173526cbe916b401e9ca3a38
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 # LIB1ASMFUNCS
12 # LIB2FUNCS
13 # LIB2FUNCS_ST
14 # LIB2ADD
15 # LIB2ADD_ST
16 # LIB2ADDEH
17 # LIB2ADDEHDEP
18 # FPBIT
19 # FPBIT_FUNCS
20 # DPBIT
21 # DPBIT_FUNCS
22 # LIBGCC
23 # MULTILIBS
24 # EXTRA_MULTILIB_PARTS
25 # SHLIB_EXT
26 # SHLIB_LINK
27 # SHLIB_MULTILIB
28 # SHLIB_MKMAP
29 # SHLIB_MAPFILES
30 # SHLIB_NM_FLAGS
31 # SHLIB_INSTALL
33 # Make needs VPATH to be literal.
34 echo 'srcdir = @srcdir@'
35 echo 'VPATH = @srcdir@'
36 echo 'EQ = ='
37 echo
38 echo 'force:'
39 echo
41 # Disable SHLIB_LINK if shared libgcc not enabled.
42 if [ "@enable_shared@" = "no" ]; then
43 SHLIB_LINK=""
46 # Build lines.
48 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
49 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
50 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
51 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
52 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
53 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
54 CC="$(CC)" CFLAGS="$(CFLAGS)" \
55 HOST_PREFIX="$(HOST_PREFIX)" \
56 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
57 LANGUAGES="$(LANGUAGES)"'
59 # Dependencies for libgcc2.c
60 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"
62 # Dependencies for fp-bit.c
63 fpbit_c_dep='stmp-dirs config.status tsystem.h'
66 # Build libgcc1 components.
69 libgcc1_objs=""
71 for name in $LIB1ASMFUNCS; do
72 for ml in $MULTILIBS; do
73 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
74 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
75 out="libgcc/${dir}/${name}${objext}"
77 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
78 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
79 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
81 # Remove any objects from LIB2FUNCS that are defined as optimized
82 # assembly code in LIB1ASMFUNCS.
83 LIB2FUNCS=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
84 -e 's/ '$name' / /' \
85 -e 's/ '$name'$//'`
86 done
87 libgcc1_objs="$libgcc1_objs ${name}${objext}"
88 done
91 # Build libgcc2 components.
94 libgcc2_objs=""
95 libgcc2_st_objs=""
97 for name in $LIB2FUNCS; do
98 for ml in $MULTILIBS; do
99 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
100 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
101 out="libgcc/${dir}/${name}${objext}"
103 echo $out: $libgcc2_c_dep
104 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
105 -c '$(srcdir)/libgcc2.c' -o $out
106 done
107 libgcc2_objs="$libgcc2_objs ${name}${objext}"
108 done
110 for name in $LIB2FUNCS_ST; do
111 for ml in $MULTILIBS; do
112 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
113 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
114 out="libgcc/${dir}/${name}${objext}"
116 echo $out: $libgcc2_c_dep
117 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
118 -c '$(srcdir)/libgcc2.c' -o $out
119 done
120 libgcc2_st_objs="$libgcc2_st_objs ${name}${objext}"
121 done
123 if [ "$FPBIT" ]; then
124 for name in $FPBIT_FUNCS; do
125 for ml in $MULTILIBS; do
126 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
127 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
128 out="libgcc/${dir}/${name}${objext}"
130 echo $out: $FPBIT $fpbit_c_dep
131 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
132 -c $FPBIT -o $out
133 done
134 libgcc2_objs="$libgcc2_objs ${name}${objext}"
135 done
138 if [ "$DPBIT" ]; then
139 for name in $DPBIT_FUNCS; do
140 for ml in $MULTILIBS; do
141 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
142 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
143 out="libgcc/${dir}/${name}${objext}"
145 echo $out: $DPBIT $fpbit_c_dep
146 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
147 -c $DPBIT -o $out
148 done
149 libgcc2_objs="$libgcc2_objs ${name}${objext}"
150 done
153 for file in $LIB2ADD; do
154 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
155 oname=`echo $name | sed -e 's,.*/,,'`
157 for ml in $MULTILIBS; do
158 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
159 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
160 out="libgcc/${dir}/${oname}${objext}"
161 if [ ${name}.asm = ${file} ]; then
162 flags="$flags -xassembler-with-cpp"
165 echo $out: stmp-dirs $file
166 echo " $gcc_compile" $flags -c $file -o $out
167 done
168 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
169 done
171 for file in $LIB2ADDEH; 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 -fexceptions -c $file -o $out
185 done
186 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
187 done
189 for file in $LIB2ADD_ST; 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 -c $file -o $out
203 done
204 libgcc2_st_objs="$libgcc2_st_objs ${oname}${objext}"
205 done
207 # SHLIB_MKMAP
208 # SHLIB_MAPFILES
209 for ml in $MULTILIBS; do
210 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
211 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
213 libgcc_objs=""
214 for o in $libgcc1_objs; do
215 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
216 done
217 for o in $libgcc2_objs; do
218 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
219 done
220 shlib_deps="$libgcc_objs"
222 libgcc_st_objs=""
223 for o in $libgcc2_st_objs; do
224 libgcc_st_objs="$libgcc_st_objs libgcc/${dir}/$o"
225 done
227 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
228 mapfile="libgcc.map"
229 echo ""
230 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
231 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
232 echo ' mv tmp-$@ $@'
234 shlib_deps="$shlib_deps $mapfile"
236 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
237 # usually are put in a true multilib situation.
238 for f in $EXTRA_MULTILIB_PARTS; do
239 shlib_deps="$shlib_deps $dir/$f"
240 done
242 echo ""
243 echo "${dir}/libgcc.a: $libgcc_objs $libgcc_st_objs"
244 echo " -rm -rf ${dir}/libgcc.a"
245 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs $libgcc_st_objs
246 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
247 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
248 echo ' else true; fi;'
250 if [ "$SHLIB_LINK" ]; then
251 if [ -z "$SHLIB_MULTILIB" ]; then
252 if [ "$dir" = "." ]; then
253 shlib_base_name="libgcc_s";
254 else
255 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
257 echo ""
258 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
259 echo " $SHLIB_LINK" \
260 | sed -e "s%@multilib_flags@%$flags%g" \
261 -e "s%@multilib_dir@%$dir%g" \
262 -e "s%@shlib_objs@%$libgcc_objs%g" \
263 -e "s%@shlib_base_name@%$shlib_base_name%g" \
264 -e "s%@shlib_map_file@%$mapfile%g"
265 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
266 shlib_base_name="libgcc_s";
267 echo ""
268 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
269 echo " $SHLIB_LINK" \
270 | sed -e "s%@multilib_flags@%$flags%g" \
271 -e "s%@multilib_dir@%$dir%g" \
272 -e "s%@shlib_objs@%$libgcc_objs%g" \
273 -e "s%@shlib_base_name@%$shlib_base_name%g" \
274 -e "s%@shlib_map_file@%$mapfile%g"
277 done
279 dirs=libgcc
280 for ml in $MULTILIBS; do
281 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
282 if [ $dir != . ]; then
283 dirs="$dirs libgcc/${dir}"
285 done
286 echo ''
287 echo 'libgcc-stage-start:'
288 echo ' for dir in '"${dirs}"'; do \'
289 echo ' if [ -d $(stage)/$$dir ]; then true; else mkdir $(stage)/$$dir; fi; \'
290 echo ' done'
291 echo ' -for dir in '"${dirs}"'; do \'
292 echo ' mv $$dir/*'"${objext}"' $(stage)/$$dir; \'
293 echo ' done'
295 echo ""
296 all=stmp-dirs
297 dirs=libgcc
299 for ml in $MULTILIBS; do
300 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
301 if [ $dir != . ]; then
302 dirs="$dirs ${dir} libgcc/${dir}"
304 all="$all ${dir}/libgcc.a"
305 if [ "$SHLIB_LINK" ]; then
306 if [ -z "$SHLIB_MULTILIB" ]; then
307 if [ "$dir" = "." ]; then
308 suff="";
309 else
310 suff=_`echo $dir | sed s,/,_,g`
312 all="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
313 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
314 all="$all libgcc_s${SHLIB_EXT}"
317 done
319 echo 'stmp-dirs: force'
320 echo ' for d in '"$dirs"'; do \'
321 echo ' if [ -d $$d ]; then true; else mkdir $$d; fi \'
322 echo ' done'
323 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
325 for f in $EXTRA_MULTILIB_PARTS; do
326 for ml in $MULTILIBS; do
327 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
328 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
329 case $dir in
330 .) out=$f ; t= ;;
331 *) out=$dir/$f ; t=$dir/ ;;
332 esac
333 case $out in
334 # Prevent `make' from interpreting $out as a macro assignment
335 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
336 *) targ=$out ;;
337 esac
339 echo $out: stmp-dirs
340 echo " $make_compile" \\
341 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
342 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $targ
344 all="$all $out"
345 done
346 done
348 echo ""
349 echo "all: $all"
351 echo ""
352 echo "install: $all"
353 for ml in $MULTILIBS; do
354 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
355 if [ $dir != . ]; then
356 ldir='$(libsubdir)'/$dir
357 echo " if [ -d $ldir ]; then true; else mkdir $ldir; chmod a+rx $ldir; fi;"
358 else
359 ldir='$(libsubdir)'
361 echo ' $(INSTALL_DATA)' ${dir}/libgcc.a ${ldir}/
362 echo ' $(RANLIB_FOR_TARGET)' ${ldir}/libgcc.a
364 if [ "$SHLIB_LINK" ]; then
365 if [ -z "$SHLIB_MULTILIB" ]; then
366 if [ "$dir" = "." ]; then
367 shlib_base_name="libgcc_s";
368 else
369 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
371 echo " $SHLIB_INSTALL" \
372 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
373 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
374 shlib_base_name="libgcc_s";
375 echo " $SHLIB_INSTALL" \
376 | sed -e "s%@shlib_base_name@%$shlib_base_name%g"
379 done
380 for f in $EXTRA_MULTILIB_PARTS; do
381 for ml in $MULTILIBS; do
382 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
383 if [ $dir != . ]; then
384 out=${dir}/$f
385 ldir='$(libsubdir)'/$dir
386 else
387 out=$f
388 ldir='$(libsubdir)'
390 echo ' $(INSTALL_DATA)' $out $ldir/
391 done
392 done