1 # configure.lang for GNU CC
2 # This script is run by configure for configuration of language
3 # subdirectories which conform to the old GCC configure mechansim
4 # for such subdirectories.
6 # Copyright (C) 1997 Free Software Foundation, Inc.
8 #This file is part of GNU CC.
10 #GNU CC is free software; you can redistribute it and/or modify
11 #it under the terms of the GNU General Public License as published by
12 #the Free Software Foundation; either version 2, or (at your option)
15 #GNU CC is distributed in the hope that it will be useful,
16 #but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 #GNU General Public License for more details.
20 #You should have received a copy of the GNU General Public License
21 #along with GNU CC; see the file COPYING. If not, write to
22 #the Free Software Foundation, 59 Temple Place - Suite 330,
23 #Boston, MA 02111-1307, USA.
26 for subdir in . $subdirs
38 srcdir=$oldsrcdir/$subdir
47 oldsrcdir=../${oldsrcdir}
48 srcdir=$oldsrcdir/$subdir
55 test -d $subdir || mkdir $subdir
58 # Create Makefile.tem from Makefile.in.
59 # Make it set VPATH if necessary so that the sources are found.
60 # Also change its value of srcdir.
61 # Also create a .gdbinit file which runs the one in srcdir
62 # and tells GDB to look there for source files.
64 . | ./$subdir | .././$subdir)
66 cp Makefile.in Makefile.tem
71 echo "VPATH = ${srcdir}" \
72 | cat - ${srcdir}/Makefile.in \
73 | sed "s@^srcdir = \.@srcdir = ${srcdir}@" > Makefile.tem
75 echo "dir ." > .gdbinit
76 echo "dir ${srcdir}" >> .gdbinit
77 if [ x$gdb_needs_out_file_path = xyes ]
79 echo "dir ${srcdir}/config/"`dirname ${out_file}` >> .gdbinit
81 if [ "x$subdirs" != x ]; then
84 echo "dir ${srcdir}/$s" >> .gdbinit
87 echo "source ${srcdir}/.gdbinit" >> .gdbinit
91 # Conditionalize the makefile for this host machine.
92 rm -f Makefile.xx Makefile.ll
94 for f in .. ${host_xmake_file}
96 if [ -f ${mainsrcdir}/config/$f ]
98 cat ${mainsrcdir}/config/$f >> Makefile.ll
99 if [ x"${merged_frags}" != x ]
101 merged_frags="${merged_frags} and "
103 merged_frags="${merged_frags}${f}"
106 if [ x"${merged_frags}" != x ]
108 sed -e "/####host/ r Makefile.ll" Makefile.tem > Makefile.xx
109 echo "Merged ${merged_frags}."
111 mv Makefile.xx Makefile.tem
115 # Add a definition for MAKE if system wants one.
119 (echo "$SET_MAKE"; cat Makefile.tem) >Makefile.xx
121 mv Makefile.xx Makefile.tem
124 # Add a definition for INSTALL if system wants one.
125 # This substitutes for lots of x-* files.
126 if [ x$build_broken_install = x ]
130 abssrcdir=`cd ${srcdir}; pwd`
131 sed "s|^INSTALL = .*|INSTALL = ${abssrcdir}/install.sh -c|" Makefile.tem > Makefile.xx
133 mv Makefile.xx Makefile.tem
136 # Some of the following don't make sense in the language makefiles,
137 # but rather than introduce another level of nesting, we leave them
140 # Set EXTRA_HEADERS according to extra_headers.
141 # This substitutes for lots of t-* files.
143 if [ "x$extra_headers" = x ]
147 sed "s|^EXTRA_HEADERS =|EXTRA_HEADERS = ${extra_headers_list}|" Makefile.tem > Makefile.xx
149 mv Makefile.xx Makefile.tem
152 # Set EXTRA_PASSES according to extra_passes.
153 # This substitutes for lots of t-* files.
154 if [ "x$extra_passes" = x ]
158 sed "s/^EXTRA_PASSES =/EXTRA_PASSES = $extra_passes/" Makefile.tem > Makefile.xx
160 mv Makefile.xx Makefile.tem
163 # Set EXTRA_PARTS according to extra_parts.
164 # This substitutes for lots of t-* files.
165 if [ "x$extra_parts" = x ]
169 sed "s/^EXTRA_PARTS =/EXTRA_PARTS = $extra_parts/" Makefile.tem > Makefile.xx
171 mv Makefile.xx Makefile.tem
174 # Set EXTRA_PROGRAMS according to extra_programs.
175 if [ "x$extra_programs" = x ]
179 sed "s/^EXTRA_PROGRAMS =/EXTRA_PROGRAMS = $extra_programs/" Makefile.tem > Makefile.xx
181 mv Makefile.xx Makefile.tem
184 # Set EXTRA_OBJS according to extra_objs.
185 # This substitutes for lots of t-* files.
186 if [ "x$extra_objs" = x ]
190 sed "s|^EXTRA_OBJS =|EXTRA_OBJS = $extra_objs|" Makefile.tem > Makefile.xx
192 mv Makefile.xx Makefile.tem
195 # Set EXTRA_GCC_OBJS according to host_extra_gcc_objs.
196 # This substitutes for lots of x-* files.
197 if [ "x$host_extra_gcc_objs" = x ]
201 sed "s|^EXTRA_GCC_OBJS =|EXTRA_GCC_OBJS = $host_extra_gcc_objs|"
202 Makefile.tem > Makefile.xx
204 mv Makefile.xx Makefile.tem
207 # Add a definition of USE_COLLECT2 if system wants one.
208 # Also tell toplev.c what to do.
209 # This substitutes for lots of t-* files.
210 if [ x$use_collect2 != x ]
213 (echo "USE_COLLECT2 = ld"; echo "MAYBE_USE_COLLECT2 = -DUSE_COLLECT2")\
214 | cat - Makefile.tem > Makefile.xx
216 mv Makefile.xx Makefile.tem
219 # Set MD_DEPS if the real md file is in md.pre-cpp.
220 # Set MD_CPP to the cpp to pass the md file through. Md files use ';'
221 # for line oriented comments, so we must always use a GNU cpp. If
222 # building gcc with a cross compiler, use the cross compiler just
223 # built. Otherwise, we can use the cpp just built.
224 if [ "x$md_cppflags" != x ]
227 (if [ x$host = x$build ] ; then
228 echo "MD_DEPS = $(md_file) cpp" ; echo "MD_CPP = ./cpp"
230 echo "MD_DEPS = md.pre-cpp" ; echo "MD_CPP = \$(HOST_CC) -x c -E"
232 echo "MD_CPPFLAGS = $md_cppflags") | \
233 cat - Makefile.tem | sed -e "s|^MD_FILE[ ]*=.*|MD_FILE = md|" > Makefile.xx
235 mv Makefile.xx Makefile.tem
238 # If using -program-transform-name, override the installation names.
239 if [ "x${program_transform_set}" = "xyes" ] ; then
240 sed -e "s/^program_transform_name[ ]*=.*$/program_transform_name =
241 $program_transform_name/" \
242 -e "s/^program_transform_cross_name[
243 ]*=.*$/program_transform_cross_name = $program_transform_name/" \
244 Makefile.tem > Makefile.xx
246 mv Makefile.xx Makefile.tem
249 # Conditionalize the makefile for this target machine.
250 rm -f Makefile.xx Makefile.ll
252 for f in .. ${tmake_file}
254 if [ -f ${mainsrcdir}/config/$f ]
256 cat ${mainsrcdir}/config/$f >> Makefile.ll
257 if [ x"${merged_frags}" != x ]
259 merged_frags="${merged_frags} and "
261 merged_frags="${merged_frags}$f"
264 if [ x"${merged_frags}" != x ]
266 sed -e "/####target/ r Makefile.ll" Makefile.tem > Makefile.xx
267 echo "Merged ${merged_frags}."
269 mv Makefile.xx Makefile.tem
273 # If this is the top level Makefile, add the language fragments.
274 # Languages are added via two mechanisms. Some information must be
275 # recorded in makefile variables, these are defined in config-lang.in.
276 # We accumulate them and plug them into the main Makefile.
277 # The other mechanism is a set of hooks for each of the main targets
278 # like `clean', `install', etc.
281 rm -f Makefile.xx Makefile.ll
283 sed -e "/####language fragments/ r Makefile.ll" Makefile.tem > Makefile.xx
285 mv Makefile.xx Makefile.tem
286 subdirs=`echo $subdirs`
287 sed -e "s|^SUBDIRS[ ]*=.*$|SUBDIRS = $subdirs|" \
288 -e "s|^LANGUAGES[ ]*=[ ]*\(.*\)$|LANGUAGES = \1 $all_languages|" \
289 -e "s|^BOOT_LANGUAGES[ ]*=[ ]*\(.*\)$|BOOT_LANGUAGES = \1 $all_boot_languages|" \
290 -e "s|^COMPILERS[ ]*=[ ]*\(.*\)$|COMPILERS = \1 $all_compilers|" \
291 -e "s|^LANG_MAKEFILES[ ]*=.*$|LANG_MAKEFILES = $all_lang_makefiles|" \
292 -e "s|^LANG_STAGESTUFF[ ]*=.*$|LANG_STAGESTUFF = $all_stagestuff|" \
293 -e "s|^LANG_DIFF_EXCLUDES[ ]*=.*$|LANG_DIFF_EXCLUDES = $all_diff_excludes|" \
294 -e "s|^LANG_EXTRA_HEADERS[ ]*=.*$|LANG_EXTRA_HEADERS = $all_headers|" \
295 -e "s|^LANG_LIB2FUNCS[ ]*=.*$|LANG_LIB2FUNCS = $all_lib2funcs|" \
296 Makefile.tem > Makefile.xx
298 mv Makefile.xx Makefile.tem
300 # Since we can't use `::' targets, we link each language in
301 # with a set of hooks, reached indirectly via lang.${target}.
303 for t in $target_list
306 for l in .. $all_languages
308 if [ $l != ".." ]; then
312 echo "lang.$t: $x" >> Makefile.ll
314 sed -e "/####language hooks/ r Makefile.ll" Makefile.tem > Makefile.xx
316 mv Makefile.xx Makefile.tem
319 # If the host doesn't support symlinks, modify CC in
320 # FLAGS_TO_PASS so CC="stage1/xgcc -Bstage1/" works.
321 # Otherwise, we can use "CC=$(CC)".
323 if $symbolic_link symtest1.tem symtest.tem 2>/dev/null
325 sed -e 's,CC=set-by-configure,CC=$(CC),' \
326 Makefile.tem > Makefile.xx
327 sed -e 's,STAGE_PREFIX=set-by-configure,STAGE_PREFIX=$(STAGE_PREFIX),' \
328 Makefile.xx > Makefile.yy
330 sed -e "s,CC=set-by-configure,CC=\`case '\$(CC)' in *stage*) echo '\$(CC)' | sed -e 's|stage|../stage|g';; *) echo '\$(CC)';; esac\`," \
331 Makefile.tem > Makefile.xx
332 sed -e "s,STAGE_PREFIX=set-by-configure,STAGE_PREFIX=\`case '\$(STAGE_PREFIX)' in stage*) echo '\$(STAGE_PREFIX)' | sed -e 's|stage|../stage|g';; *) echo '\$(STAGE_PREFIX)';; esac\`," \
333 Makefile.xx > Makefile.yy
335 rm -f Makefile.tem Makefile.xx
336 mv Makefile.yy Makefile.tem
339 if [ "x$all_languages" != x ]
341 # Missing space after `Merged' is intentional.
342 echo "Merged$all_languages fragment(s)."
345 # Otherwise, this is a language subdirectory. If the host supports
346 # symlinks, point stage[123] at ../stage[123] so bootstrapping and the
347 # installation procedure can still use CC="stage1/xgcc -Bstage1/".
348 # If the host doesn't support symlinks, FLAGS_TO_PASS has been
349 # modified to solve the problem there.
351 for t in stage1 stage2 stage3 stage4 include
354 $symbolic_link ../$t $t 2>/dev/null
358 # Remove all formfeeds, since some Makes get confused by them.
359 # Also arrange to give the variables `target', `host_xmake_file',
360 # `tmake_file', `prefix', `local_prefix', `exec_prefix', `FIXINCLUDES'
361 # `out_file', `out_object', `md_file', `lang_specs_files',
362 # `lang_options_files', `INSTALL_HEADERS_DIR', and `CROSS_FLOAT_H'
363 # values in the Makefile from the values they have in this script.
365 rm -f aux-output.c aux-output.o md
366 # Create an empty Makefile.sed first, to work around a Nextstep 3.3 bug.
367 echo 's|
\f||' > Makefile.sed
369 echo 's|
\f||' > Makefile.sed
370 echo "s|^target=.*$|target=${target}|" >> Makefile.sed
371 echo "s|^target_alias=.*$|target_alias=${target}|" >> Makefile.sed
372 echo "s|^xmake_file=.*$|xmake_file=${dep_host_xmake_file}|" >> Makefile.sed
373 echo "s|^tmake_file=.*$|tmake_file=${dep_tmake_file}|" >> Makefile.sed
374 echo "s|^version=.*$|version=${version}|" >> Makefile.sed
375 echo "s|^version=.*$|version=${version}|" >> Makefile.sed
376 echo "s|^out_file=.*$|out_file=${srcdir}/config/${out_file}|" >> Makefile.sed
377 echo "s|^out_object_file=.*$|out_object_file=${out_object_file}|" >> Makefile.sed
378 echo "s|^md_file=.*$|md_file=${md_file}|" >> Makefile.sed
379 echo "s|^tm_file=.*$|tm_file=${tm_file_sub}|" >> Makefile.sed
380 echo "s|^host_xm_file=.*$|host_xm_file=${host_xm_file_sub}|" >> Makefile.sed
381 echo "s|^build_xm_file=.*$|build_xm_file=${build_xm_file_sub}|" >> Makefile.sed
382 echo "s|^lang_specs_files=.*$|lang_specs_files=${lang_specs_files}|" >> Makefile.sed
383 echo "s|^lang_options_files=.*$|lang_options_files=${lang_options_files}|" >> Makefile.sed
384 echo "s|^GCC_THREAD_FILE=.*$|GCC_THREAD_FILE=${thread_file}|" >> Makefile.sed
385 echo "s|^prefix[ ]*=.*|prefix = $prefix|" >> Makefile.sed
386 echo "s|^local_prefix[ ]*=.*|local_prefix = $local_prefix|" >> Makefile.sed
387 echo "s|^exec_prefix[ ]*=.*|exec_prefix = $exec_prefix|" >> Makefile.sed
388 echo "s|^FIXINCLUDES[ ]*=.*|FIXINCLUDES = $fixincludes|" >> Makefile.sed
389 echo "s|^INSTALL_HEADERS_DIR[ ]*=.*$|INSTALL_HEADERS_DIR = ${build_install_headers_dir}|" >> Makefile.sed
390 echo "s|^exeext[ ]*=.*$|exeext = ${build_exeext}|" >> Makefile.sed
391 echo "s|^CROSS_FLOAT_H[ ]*=.*|CROSS_FLOAT_H=\$(srcdir)/config/float-${float_format}.h|" >> Makefile.sed
392 sed -f Makefile.sed Makefile.tem > Makefile.xx
393 rm -f Makefile.tem Makefile.sed
394 mv Makefile.xx Makefile.tem
396 # Install Makefile for real, after making final changes.
397 # Define macro CROSS_COMPILE in compilation
398 # if this is a cross-compiler.
399 # Also use all.cross instead of all.internal
400 # and add cross-make to Makefile.
401 if [ x$host != x$target ]
404 echo "CROSS=-DCROSS_COMPILE" > Makefile.xx
405 sed -e "/####cross/ r ${mainsrcdir}/cross-make" Makefile.tem >> Makefile.xx
407 mv Makefile.xx Makefile.tem
410 # When building gcc with a cross-compiler, we need to fix a few things.
411 # This must come after cross-make as we want all.build to override
413 if [ x$build != x$host ]
416 echo "build= $build" > Makefile.xx
417 echo "host= $host" >> Makefile.xx
418 sed -e "s|objc-runtime$||" \
419 -e "/####build/ r ${mainsrcdir}/build-make" Makefile.tem >> Makefile.xx
421 mv Makefile.xx Makefile.tem
427 mv Makefile.tem Makefile
428 echo "Created \`$subdir/Makefile'."
434 done # end of current-dir SUBDIRS loop