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 # Add a definition of USE_COLLECT2 if system wants one.
141 # Also tell toplev.c what to do.
142 # This substitutes for lots of t-* files.
143 if [ x$use_collect2 != x ]
146 (echo "USE_COLLECT2 = ld"; echo "MAYBE_USE_COLLECT2 = -DUSE_COLLECT2")\
147 | cat - Makefile.tem > Makefile.xx
149 mv Makefile.xx Makefile.tem
152 # If using -program-transform-name, override the installation names.
153 if [ "x${program_transform_set}" = "xyes" ] ; then
154 sed -e "s/^program_transform_name[ ]*=.*$/program_transform_name =
155 $program_transform_name/" \
156 -e "s/^program_transform_cross_name[
157 ]*=.*$/program_transform_cross_name = $program_transform_name/" \
158 Makefile.tem > Makefile.xx
160 mv Makefile.xx Makefile.tem
163 # Conditionalize the makefile for this target machine.
164 rm -f Makefile.xx Makefile.ll
166 for f in .. ${tmake_file}
168 if [ -f ${mainsrcdir}/config/$f ]
170 cat ${mainsrcdir}/config/$f >> Makefile.ll
171 if [ x"${merged_frags}" != x ]
173 merged_frags="${merged_frags} and "
175 merged_frags="${merged_frags}$f"
178 if [ x"${merged_frags}" != x ]
180 sed -e "/####target/ r Makefile.ll" Makefile.tem > Makefile.xx
181 echo "Merged ${merged_frags}."
183 mv Makefile.xx Makefile.tem
187 # If this is the top level Makefile, add the language fragments.
188 # Languages are added via two mechanisms. Some information must be
189 # recorded in makefile variables, these are defined in config-lang.in.
190 # We accumulate them and plug them into the main Makefile.
191 # The other mechanism is a set of hooks for each of the main targets
192 # like `clean', `install', etc.
195 rm -f Makefile.xx Makefile.ll
197 sed -e "/####language fragments/ r Makefile.ll" Makefile.tem > Makefile.xx
199 mv Makefile.xx Makefile.tem
200 subdirs=`echo $subdirs`
201 sed -e "s|^SUBDIRS[ ]*=.*$|SUBDIRS = $subdirs|" \
202 -e "s|^LANGUAGES[ ]*=[ ]*\(.*\)$|LANGUAGES = \1 $all_languages|" \
203 -e "s|^BOOT_LANGUAGES[ ]*=[ ]*\(.*\)$|BOOT_LANGUAGES = \1 $all_boot_languages|" \
204 -e "s|^COMPILERS[ ]*=[ ]*\(.*\)$|COMPILERS = \1 $all_compilers|" \
205 -e "s|^LANG_MAKEFILES[ ]*=.*$|LANG_MAKEFILES = $all_lang_makefiles|" \
206 -e "s|^LANG_STAGESTUFF[ ]*=.*$|LANG_STAGESTUFF = $all_stagestuff|" \
207 -e "s|^LANG_DIFF_EXCLUDES[ ]*=.*$|LANG_DIFF_EXCLUDES = $all_diff_excludes|" \
208 -e "s|^LANG_EXTRA_HEADERS[ ]*=.*$|LANG_EXTRA_HEADERS = $all_headers|" \
209 -e "s|^LANG_LIB2FUNCS[ ]*=.*$|LANG_LIB2FUNCS = $all_lib2funcs|" \
210 Makefile.tem > Makefile.xx
212 mv Makefile.xx Makefile.tem
214 # Since we can't use `::' targets, we link each language in
215 # with a set of hooks, reached indirectly via lang.${target}.
217 for t in $target_list
220 for l in .. $all_languages
222 if [ $l != ".." ]; then
226 echo "lang.$t: $x" >> Makefile.ll
228 sed -e "/####language hooks/ r Makefile.ll" Makefile.tem > Makefile.xx
230 mv Makefile.xx Makefile.tem
233 # If the host doesn't support symlinks, modify CC in
234 # FLAGS_TO_PASS so CC="stage1/xgcc -Bstage1/" works.
235 # Otherwise, we can use "CC=$(CC)".
237 if $symbolic_link symtest1.tem symtest.tem 2>/dev/null
239 sed -e 's,CC=set-by-configure,CC=$(CC),' \
240 Makefile.tem > Makefile.xx
241 sed -e 's,STAGE_PREFIX=set-by-configure,STAGE_PREFIX=$(STAGE_PREFIX),' \
242 Makefile.xx > Makefile.yy
244 sed -e "s,CC=set-by-configure,CC=\`case '\$(CC)' in *stage*) echo '\$(CC)' | sed -e 's|stage|../stage|g';; *) echo '\$(CC)';; esac\`," \
245 Makefile.tem > Makefile.xx
246 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\`," \
247 Makefile.xx > Makefile.yy
249 rm -f Makefile.tem Makefile.xx
250 mv Makefile.yy Makefile.tem
253 if [ "x$all_languages" != x ]
255 # Missing space after `Merged' is intentional.
256 echo "Merged$all_languages fragment(s)."
259 # Otherwise, this is a language subdirectory. If the host supports
260 # symlinks, point stage[123] at ../stage[123] so bootstrapping and the
261 # installation procedure can still use CC="stage1/xgcc -Bstage1/".
262 # If the host doesn't support symlinks, FLAGS_TO_PASS has been
263 # modified to solve the problem there.
265 for t in stage1 stage2 stage3 stage4 include
268 $symbolic_link ../$t $t 2>/dev/null
272 # Remove all formfeeds, since some Makes get confused by them.
273 # Also arrange to give the variables `target', `host_xmake_file',
274 # `tmake_file', `prefix', `local_prefix', `exec_prefix', `FIXINCLUDES'
275 # `out_file', `out_object', `md_file', `lang_specs_files',
276 # `lang_options_files', `INSTALL_HEADERS_DIR', and `CROSS_FLOAT_H'
277 # values in the Makefile from the values they have in this script.
279 rm -f aux-output.c aux-output.o md
280 # Create an empty Makefile.sed first, to work around a Nextstep 3.3 bug.
281 echo 's|
\f||' > Makefile.sed
283 echo 's|
\f||' > Makefile.sed
284 echo "s|^target=.*$|target=${target}|" >> Makefile.sed
285 echo "s|^target_alias=.*$|target_alias=${target}|" >> Makefile.sed
286 echo "s|^xmake_file=.*$|xmake_file=${dep_host_xmake_file}|" >> Makefile.sed
287 echo "s|^tmake_file=.*$|tmake_file=${dep_tmake_file}|" >> Makefile.sed
288 echo "s|^version=.*$|version=${version}|" >> Makefile.sed
289 echo "s|^out_file=.*$|out_file=${srcdir}/config/${out_file}|" >> Makefile.sed
290 echo "s|^out_object_file=.*$|out_object_file=${out_object_file}|" >> Makefile.sed
291 echo "s|^md_file=.*$|md_file=${md_file}|" >> Makefile.sed
292 echo "s|^tm_file=.*$|tm_file=${tm_file_sub}|" >> Makefile.sed
293 echo "s|^host_xm_file=.*$|host_xm_file=${host_xm_file_sub}|" >> Makefile.sed
294 echo "s|^build_xm_file=.*$|build_xm_file=${build_xm_file_sub}|" >> Makefile.sed
295 echo "s|^lang_specs_files=.*$|lang_specs_files=${lang_specs_files}|" >> Makefile.sed
296 echo "s|^lang_options_files=.*$|lang_options_files=${lang_options_files}|" >> Makefile.sed
297 echo "s|^GCC_THREAD_FILE=.*$|GCC_THREAD_FILE=${thread_file}|" >> Makefile.sed
298 echo "s|^prefix[ ]*=.*|prefix = $prefix|" >> Makefile.sed
299 echo "s|^local_prefix[ ]*=.*|local_prefix = $local_prefix|" >> Makefile.sed
300 echo "s|^exec_prefix[ ]*=.*|exec_prefix = $exec_prefix|" >> Makefile.sed
301 echo "s|^FIXINCLUDES[ ]*=.*|FIXINCLUDES = $fixincludes|" >> Makefile.sed
302 echo "s|^INSTALL_HEADERS_DIR[ ]*=.*$|INSTALL_HEADERS_DIR = ${build_install_headers_dir}|" >> Makefile.sed
303 echo "s|^exeext[ ]*=.*$|exeext = ${build_exeext}|" >> Makefile.sed
304 echo "s|^CROSS_FLOAT_H[ ]*=.*|CROSS_FLOAT_H=\$(srcdir)/config/float-${float_format}.h|" >> Makefile.sed
305 sed -f Makefile.sed Makefile.tem > Makefile.xx
306 rm -f Makefile.tem Makefile.sed
307 mv Makefile.xx Makefile.tem
309 # Install Makefile for real, after making final changes.
310 # Define macro CROSS_COMPILE in compilation
311 # if this is a cross-compiler.
312 # Also use all.cross instead of all.internal
313 # and add cross-make to Makefile.
314 if [ x$host != x$target ]
317 echo "CROSS=-DCROSS_COMPILE" > Makefile.xx
318 sed -e "/####cross/ r ${mainsrcdir}/cross-make" Makefile.tem >> Makefile.xx
320 mv Makefile.xx Makefile.tem
323 # When building gcc with a cross-compiler, we need to fix a few things.
324 # This must come after cross-make as we want all.build to override
326 if [ x$build != x$host ]
329 echo "build= $build" > Makefile.xx
330 echo "host= $host" >> Makefile.xx
331 sed -e "s|objc-runtime$||" \
332 -e "/####build/ r ${mainsrcdir}/build-make" Makefile.tem >> Makefile.xx
334 mv Makefile.xx Makefile.tem
340 mv Makefile.tem Makefile
341 echo "Created \`$subdir/Makefile'."
347 done # end of current-dir SUBDIRS loop