* arm-protos.h (arm_dllexport_name_p, arm_dllimport_name_p): Constify.
[official-gcc.git] / gcc / mklibgcc.in
blobaa4b955571e353a3abee964b714f506e4ccf6b03
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_EH
18 # LIB2ADD
19 # FPBIT
20 # FPBIT_FUNCS
21 # DPBIT
22 # DPBIT_FUNCS
23 # LIBGCC
24 # MULTILIBS
25 # EXTRA_MULTILIB_PARTS
27 # Make needs VPATH to be literal.
28 echo 'srcdir = @srcdir@'
29 echo 'VPATH = @srcdir@'
30 echo
32 # Detect gcc as OLDCC. This indicates a target for which LIB1FUNCS
33 # is not needed. This is not quite the same as libgcc1.null, even
34 # on a target not using libgcc1-asm.a.
36 if [ "@build_canonical@" = "@target@" ]; then
37 tmp="tmp-$$.c"
38 cat > $tmp <<EOF
39 #ifdef __GNUC__
40 yes;
41 #endif
42 EOF
43 if $OLDCC -E $tmp | grep yes > /dev/null 2>&1; then
44 LIB1FUNCS=""
46 rm -f $tmp
51 # Utility functions
54 emit_gcc_compile() {
55 dst=$1; shift
56 src=$1; shift
57 flags=$*
59 echo ' $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)' \
60 $flags -c $src -o $dst
63 emit_oldcc_compile() {
64 dst=$1; shift
65 src=$1; shift
66 flags=$*
68 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
69 echo ' $(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)' \
70 $flags -c $src -o $dst
71 else
72 echo ' $(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
73 $flags -c $src
74 tmp=`echo $src | sed -e 's/[.]c$/'${objext}/ -e 's,.*/,,'`
75 echo " mv $tmp $dst"
79 emit_make_compile() {
80 dst=$1; shift
81 tgt=$1; shift
82 tmp="";
83 if [ "$1" = "T=t" ]; then
84 tmp="T=t"; tgt="t$tgt"; shift
86 flags=$*
88 echo ' $(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)"' \\
89 echo ' AR_FOR_TARGET="$(AR_FOR_TARGET)"' \\
90 echo ' AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)"' \\
91 echo ' AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)"' \\
92 echo ' AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)"' \\
93 echo ' CC="$(CC)" CFLAGS="$(CFLAGS)"' \\
94 echo ' HOST_PREFIX="$(HOST_PREFIX)"' \\
95 echo ' HOST_PREFIX_1="$(HOST_PREFIX_1)"' \\
96 echo ' LANGUAGES="$(LANGUAGES)"' \\
97 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
98 echo ' MULTILIB_CFLAGS="'$flags'"' $tmp $tgt
99 echo " mv ${tgt} ${dst}"
102 # Dependancies for libgcc1.c
103 libgcc1_c_dep='$(srcdir)/libgcc1.c $(CONFIG_H)'
105 # Dependancies for libgcc2.c
106 libgcc2_c_dep='$(srcdir)/libgcc2.c $(CONFIG_H) $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'
108 # Dependancies for fp-bit.c
109 fpbit_c_dep='$(srcdir)/config/fp-bit.c config.status tsystem.h'
112 # Build libgcc1 components.
115 libgcc1_objs=""
117 case X"$LIBGCC1" in
118 Xlibgcc1.null | X)
121 Xlibgcc1.cross)
122 echo "You must find a way to make libgcc1 components yourself" 1>&2
125 Xlibgcc1-asm.a)
126 for name in $LIB1ASMFUNCS; do
127 for ml in $MULTILIBS; do
128 dir=`echo ${ml} | sed -e 's/;.*$//'`
129 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
130 out="libgcc/${dir}/${name}${objext}"
132 echo ${out}: '$(srcdir)/config/$(LIB1ASMSRC)'
133 emit_gcc_compile $out '$(srcdir)/config/$(LIB1ASMSRC)' \
134 $flags -DL$name -xassembler-with-cpp
135 done
136 libgcc1_objs="$libgcc1_objs ${name}${objext}"
137 done
140 Xlibgcc1.a)
141 for name in $LIB1FUNCS; do
142 out="libgcc/${name}${objext}"
144 echo $out: $libgcc1_c_dep
145 emit_oldcc_compile $out '$(srcdir)/libgcc1.c' -DL${name}
146 libgcc1_objs="$libgcc1_objs ${name}${objext}"
147 done
149 for file in $LIB1FUNCS_EXTRA; do
150 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
151 out="libgcc/${name}${objext}"
153 echo $out: $file
154 if [ ${name}.asm = $file ]; then
155 echo " cp $file ${name}.s"
156 file=${name}.s
158 emit_oldcc_compile $out $file
159 libgcc1_objs="$libgcc1_objs ${name}${objext}"
160 done
163 echo "I'm confused about libgcc1." 1>&2
164 exit 1
166 esac
169 # Build libgcc2 components.
172 libgcc2_objs=""
174 for name in $LIB2FUNCS; do
175 for ml in $MULTILIBS; do
176 dir=`echo ${ml} | sed -e 's/;.*$//'`
177 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
178 out="libgcc/${dir}/${name}${objext}"
180 echo $out: $libgcc2_c_dep
181 emit_gcc_compile $out '$(srcdir)/libgcc2.c' '$(MAYBE_USE_COLLECT2)' \
182 $flags -DL$name
183 done
184 libgcc2_objs="$libgcc2_objs ${name}${objext}"
185 done
187 for name in $LIB2FUNCS_EH; do
188 for ml in $MULTILIBS; do
189 dir=`echo ${ml} | sed -e 's/;.*$//'`
190 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
191 out="libgcc/${dir}/${name}${objext}"
193 echo $out: $libgcc2_c_dep
194 emit_gcc_compile $out '$(srcdir)/libgcc2.c' '$(MAYBE_USE_COLLECT2)' \
195 -fexceptions $flags -DL$name
196 done
197 libgcc2_objs="$libgcc2_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/;.*$//'`
204 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
205 out="libgcc/${dir}/${name}${objext}"
207 echo $out: $fpbit_c_dep
208 emit_gcc_compile $out '$(srcdir)/config/fp-bit.c' \
209 -DFLOAT -DFINE_GRAINED_LIBRARIES $flags -DL$name
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/;.*$//'`
219 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
220 out="libgcc/${dir}/${name}${objext}"
222 echo $out: $fpbit_c_dep
223 emit_gcc_compile $out '$(srcdir)/config/fp-bit.c' \
224 -DFINE_GRAINED_LIBRARIES $flags -DL$name
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 if [ ${name}.txt = ${file} ]; then
235 fprime=`cat $file`
236 for f in $fprime; do
238 lastout=""
239 for ml in $MULTILIBS; do
240 dir=`echo ${ml} | sed -e 's/;.*$//'`
241 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
242 out="libgcc/${dir}/${f}"
244 # Depend on previous out to serialize all sub-makes of this
245 # target file. This because ./$f is used as a temporary in
246 # each case before being moved to libgcc/$dir/.
247 echo $out: $lastout
248 emit_make_compile $out $f $flags
250 lastout="$out"
251 done
253 libgcc2_objs="$libgcc2_objs $f"
254 done
255 else
256 for ml in $MULTILIBS; do
257 dir=`echo ${ml} | sed -e 's/;.*$//'`
258 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
259 out="libgcc/${dir}/${oname}${objext}"
260 if [ ${name}.asm = ${file} ]; then
261 flags="$flags -xassembler-with-cpp"
264 echo $out: $file
265 emit_gcc_compile $out $file $flags
266 done
267 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
269 done
271 for ml in $MULTILIBS; do
272 dir=`echo ${ml} | sed -e 's/;.*$//'`
274 libgcc_objs=""
275 for o in $libgcc1_objs; do
276 if [ "$LIBGCC1" = libgcc1-asm.a ]; then
277 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
278 else
279 libgcc_objs="$libgcc_objs libgcc/$o"
281 done
282 for o in $libgcc2_objs; do
283 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
284 done
286 echo ""
287 echo "${dir}/libgcc.a: $libgcc_objs"
288 echo " -rm -rf ${dir}/libgcc.a"
289 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs
290 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
291 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
292 echo ' else true; fi;'
293 done
295 echo ""
296 all=""
298 for ml in $MULTILIBS; do
299 dir=`echo ${ml} | sed -e 's/;.*$//'`
300 if [ $dir = . ]; then
301 echo "libgcc:; mkdir libgcc"
302 all="$all libgcc"
303 else
304 echo "${dir}:; mkdir ${dir}"
305 echo "libgcc/${dir}:; mkdir libgcc/${dir}"
306 all="$all libgcc/${dir} ${dir}"
308 all="$all ${dir}/libgcc.a"
309 done
311 for f in $EXTRA_MULTILIB_PARTS; do
312 lastout=""
313 for ml in $MULTILIBS; do
314 dir=`echo ${ml} | sed -e 's/;.*$//'`
315 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
316 out="$dir/$f"
318 # Depend on previous out to serialize all sub-makes of this
319 # target file. This because ./$f is used as a temporary in
320 # each case before being moved to libgcc/$dir/.
321 echo $out: $lastout
322 emit_make_compile $out $f T=t $flags
324 all="$all $out"
325 lastout="$out"
326 done
327 done
329 echo ""
330 echo "all: $all"