Do not create interworking functions if the target architecture does not
[official-gcc.git] / gcc / mklibgcc.in
blob1953da47288923a1808c614c3976b17590599886
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
26 # SHLIB_EXT
27 # SHLIB_LINK
28 # SHLIB_MULTILIB
29 # SHLIB_MKMAP
30 # SHLIB_MAPFILES
31 # SHLIB_NM_FLAGS
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 # Detect gcc as OLDCC. This indicates a target for which LIB1FUNCS
42 # is not needed. This is not quite the same as libgcc1.null, even
43 # on a target not using libgcc1-asm.a.
45 if [ "@build_canonical@" = "@target@" ]; then
46 tmp="tmp-$$.c"
47 cat > $tmp <<EOF
48 #ifdef __GNUC__
49 yes;
50 #endif
51 EOF
52 if $OLDCC -E $tmp | grep yes > /dev/null 2>&1; then
53 LIB1FUNCS=""
55 rm -f $tmp
58 # Disable SHLIB_LINK if shared libgcc not enabled.
59 if [ "@enable_shared@" = "no" ]; then
60 SHLIB_LINK=""
63 # Build lines.
65 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
66 oldcc_compile='$(OLDCC) -DIN_LIBGCC1 $(CCLIBFLAGS) $(INCLUDES)'
67 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
68 AR_FOR_TARGET="$(AR_FOR_TARGET)" \
69 AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
70 AR_EXTRACT_FOR_TARGET="$(AR_EXTRACT_FOR_TARGET)" \
71 AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
72 CC="$(CC)" CFLAGS="$(CFLAGS)" \
73 HOST_PREFIX="$(HOST_PREFIX)" \
74 HOST_PREFIX_1="$(HOST_PREFIX_1)" \
75 LANGUAGES="$(LANGUAGES)"'
77 # Dependancies for libgcc1.c
78 libgcc1_c_dep='stmp-dirs $(srcdir)/libgcc1.c $(CONFIG_H)'
80 # Dependancies for libgcc2.c
81 libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(CONFIG_H) $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'
83 # Dependancies for fp-bit.c
84 fpbit_c_dep='stmp-dirs config.status tsystem.h'
87 # Build libgcc1 components.
90 libgcc1_objs=""
92 case X"$LIBGCC1" in
93 Xlibgcc1.null | X)
96 Xlibgcc1.cross)
97 echo "You must find a way to make libgcc1 components yourself" 1>&2
100 Xlibgcc1-asm.a)
101 for name in $LIB1ASMFUNCS; do
102 for ml in $MULTILIBS; do
103 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
104 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
105 out="libgcc/${dir}/${name}${objext}"
107 echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
108 echo " $gcc_compile" $flags -DL$name -xassembler-with-cpp \
109 -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $out
111 # Remove any objects from LIB2FUNCS that are defined as optimized
112 # assembly code in LIB1ASMFUNCS.
113 LIB2FUNCS=`echo $LIB2FUNCS | sed -e 's/^'$name' //' \
114 -e 's/ '$name' / /' \
115 -e 's/ '$name'$//'`
116 done
117 libgcc1_objs="$libgcc1_objs ${name}${objext}"
118 done
121 Xlibgcc1.a)
122 for name in $LIB1FUNCS; do
123 out="libgcc/${name}${objext}"
125 echo $out: $libgcc1_c_dep
126 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
127 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c' -o $out
128 else
129 echo " $oldcc_compile" -DL$name $flags -c '$(srcdir)/libgcc1.c'
130 echo " mv libgcc1${objext} $out"
133 libgcc1_objs="$libgcc1_objs ${name}${objext}"
134 done
136 for file in $LIB1FUNCS_EXTRA; do
137 name=`echo $file | sed -e 's/[.][cS]$//' -e 's/[.]asm$//'`
138 out="libgcc/${name}${objext}"
140 echo $out: $file
141 if [ ${name}.asm = $file ]; then
142 echo " cp $file ${name}.s"
143 file=${name}.s
146 if [ -z "@NO_MINUS_C_MINUS_O@" ]; then
147 echo " $oldcc_compile" -c $file -o $out
148 else
149 echo " $oldcc_compile" -c $file
150 tmp=`echo $file | sed -e 's/[.][cs]$/'${objext}/ -e 's,.*/,,'`
151 echo " mv $tmp $out"
154 libgcc1_objs="$libgcc1_objs ${name}${objext}"
155 done
158 echo "I'm confused about libgcc1." 1>&2
159 exit 1
161 esac
164 # Build libgcc2 components.
167 libgcc2_objs=""
169 for name in $LIB2FUNCS; do
170 for ml in $MULTILIBS; do
171 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
172 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
173 out="libgcc/${dir}/${name}${objext}"
175 echo $out: $libgcc2_c_dep
176 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' $flags -DL$name \
177 -c '$(srcdir)/libgcc2.c' -o $out
178 done
179 libgcc2_objs="$libgcc2_objs ${name}${objext}"
180 done
182 for name in $LIB2FUNCS_EH; do
183 for ml in $MULTILIBS; do
184 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
185 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
186 out="libgcc/${dir}/${name}${objext}"
188 echo $out: $libgcc2_c_dep
189 echo " $gcc_compile" '$(MAYBE_USE_COLLECT2)' -fexceptions \
190 $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $out
191 done
192 libgcc2_objs="$libgcc2_objs ${name}${objext}"
193 done
195 if [ "$FPBIT" ]; then
196 for name in $FPBIT_FUNCS; do
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}/${name}${objext}"
202 echo $out: $FPBIT $fpbit_c_dep
203 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
204 -c $FPBIT -o $out
205 done
206 libgcc2_objs="$libgcc2_objs ${name}${objext}"
207 done
210 if [ "$DPBIT" ]; then
211 for name in $DPBIT_FUNCS; do
212 for ml in $MULTILIBS; do
213 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
214 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
215 out="libgcc/${dir}/${name}${objext}"
217 echo $out: $DPBIT $fpbit_c_dep
218 echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
219 -c $DPBIT -o $out
220 done
221 libgcc2_objs="$libgcc2_objs ${name}${objext}"
222 done
225 for file in $LIB2ADD; do
226 name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//' -e 's/[.]txt$//'`
227 oname=`echo $name | sed -e 's,.*/,,'`
229 for ml in $MULTILIBS; do
230 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
231 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
232 out="libgcc/${dir}/${oname}${objext}"
233 if [ ${name}.asm = ${file} ]; then
234 flags="$flags -xassembler-with-cpp"
237 echo $out: stmp-dirs $file
238 echo " $gcc_compile" $flags -c $file -o $out
239 done
240 libgcc2_objs="$libgcc2_objs ${oname}${objext}"
241 done
243 # SHLIB_MKMAP
244 # SHLIB_MAPFILES
245 for ml in $MULTILIBS; do
246 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
247 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
249 libgcc_objs=""
250 for o in $libgcc1_objs; do
251 if [ "$LIBGCC1" = libgcc1-asm.a ]; then
252 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
253 else
254 libgcc_objs="$libgcc_objs libgcc/$o"
256 done
257 for o in $libgcc2_objs; do
258 libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
259 done
260 shlib_deps="$libgcc_objs"
262 if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
263 mapfile="libgcc.map"
264 echo ""
265 echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
266 echo ' { $(NM_FOR_TARGET)'" $SHLIB_NM_FLAGS $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
267 echo ' mv tmp-$@ $@'
269 shlib_deps="$shlib_deps $mapfile"
271 # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
272 # usually are put in a true multilib situation.
273 for f in $EXTRA_MULTILIB_PARTS; do
274 shlib_deps="$shlib_deps $dir/$f"
275 done
277 echo ""
278 echo "${dir}/libgcc.a: $libgcc_objs"
279 echo " -rm -rf ${dir}/libgcc.a"
280 echo ' $(AR_CREATE_FOR_TARGET)' ${dir}/libgcc.a $libgcc_objs
281 echo ' if $(RANLIB_TEST_FOR_TARGET) ; then' \\
282 echo ' $(RANLIB_FOR_TARGET)' ${dir}/libgcc.a ';' \\
283 echo ' else true; fi;'
285 if [ "$SHLIB_LINK" ]; then
286 if [ -z "$SHLIB_MULTILIB" ]; then
287 if [ "$dir" = "." ]; then
288 shlib_base_name="libgcc_s";
289 else
290 shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
292 echo ""
293 echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
294 echo " $SHLIB_LINK" \
295 | sed -e "s%@multilib_flags@%$flags%g" \
296 -e "s%@multilib_dir@%$dir%g" \
297 -e "s%@shlib_objs@%$libgcc_objs%g" \
298 -e "s%@shlib_base_name@%$shlib_base_name%g" \
299 -e "s%@shlib_map_file@%$mapfile%g"
300 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
301 shlib_base_name="libgcc_s";
302 echo ""
303 echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
304 echo " $SHLIB_LINK" \
305 | sed -e "s%@multilib_flags@%$flags%g" \
306 -e "s%@multilib_dir@%$dir%g" \
307 -e "s%@shlib_objs@%$libgcc_objs%g" \
308 -e "s%@shlib_base_name@%$shlib_base_name%g" \
309 -e "s%@shlib_map_file@%$mapfile%g"
312 done
314 dirs=libgcc
315 for ml in $MULTILIBS; do
316 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
317 if [ $dir != . ]; then
318 dirs="$dirs libgcc/${dir}"
320 done
321 echo ''
322 echo 'libgcc-stage-start:'
323 echo ' for dir in '"${dirs}"'; do \'
324 echo ' if [ -d $(stage)/$$dir ]; then true; else mkdir $(stage)/$$dir; fi; \'
325 echo ' done'
326 echo ' -for dir in '"${dirs}"'; do \'
327 echo ' mv $$dir/*'"${objext}"' $(stage)/$$dir; \'
328 echo ' done'
330 echo ""
331 all=stmp-dirs
332 dirs=libgcc
334 for ml in $MULTILIBS; do
335 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
336 if [ $dir != . ]; then
337 dirs="$dirs ${dir} libgcc/${dir}"
339 all="$all ${dir}/libgcc.a"
340 if [ "$SHLIB_LINK" ]; then
341 if [ -z "$SHLIB_MULTILIB" ]; then
342 if [ "$dir" = "." ]; then
343 suff="";
344 else
345 suff=_`echo $dir | sed s,/,_,g`
347 all="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
348 elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
349 all="$all libgcc_s${SHLIB_EXT}"
352 done
354 echo 'stmp-dirs: force'
355 echo ' for d in '"$dirs"'; do \'
356 echo ' if [ -d $$d ]; then true; else mkdir $$d; fi \'
357 echo ' done'
358 echo ' if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi'
360 for f in $EXTRA_MULTILIB_PARTS; do
361 for ml in $MULTILIBS; do
362 dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
363 flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
364 case $dir in
365 .) out=$f ; t= ;;
366 *) out=$dir/$f ; t=$dir/ ;;
367 esac
368 case $out in
369 # Prevent `make' from interpreting $out as a macro assignment
370 *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
371 *) targ=$out ;;
372 esac
374 echo $out: stmp-dirs
375 echo " $make_compile" \\
376 echo ' LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
377 echo ' MULTILIB_CFLAGS="'$flags'"' T=$t $targ
379 all="$all $out"
380 done
381 done
383 echo ""
384 echo "all: $all"