1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
# configure.lang for GNU CC
# This script is run by configure for configuration of language
# subdirectories which conform to the old GCC configure mechansim
# for such subdirectories.
# Copyright (C) 1997 Free Software Foundation, Inc.
#This file is part of GNU CC.
#GNU CC is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2, or (at your option)
#any later version.
#GNU CC is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with GNU CC; see the file COPYING. If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330,
#Boston, MA 02111-1307, USA.
savesrcdir=$srcdir
for subdir in . $subdirs
do
oldsrcdir=$savesrcdir
# Re-adjust the path
case $oldsrcdir in
/*)
case $subdir in
.)
srcdir=$oldsrcdir
;;
*)
srcdir=$oldsrcdir/$subdir
;;
esac
;;
*)
case $subdir in
.)
;;
*)
oldsrcdir=../${oldsrcdir}
srcdir=$oldsrcdir/$subdir
;;
esac
;;
esac
mainsrcdir=$oldsrcdir
STARTDIR=`pwd`
test -d $subdir || mkdir $subdir
cd $subdir
# Create Makefile.tem from Makefile.in.
# Make it set VPATH if necessary so that the sources are found.
# Also change its value of srcdir.
# Also create a .gdbinit file which runs the one in srcdir
# and tells GDB to look there for source files.
case $srcdir in
. | ./$subdir | .././$subdir)
rm -f Makefile.tem
cp Makefile.in Makefile.tem
chmod +w Makefile.tem
;;
*)
rm -f Makefile.tem
echo "VPATH = ${srcdir}" \
| cat - ${srcdir}/Makefile.in \
| sed "s@^srcdir = \.@srcdir = ${srcdir}@" > Makefile.tem
rm -f .gdbinit
echo "dir ." > .gdbinit
echo "dir ${srcdir}" >> .gdbinit
if [ x$gdb_needs_out_file_path = xyes ]
then
echo "dir ${srcdir}/config/"`dirname ${out_file}` >> .gdbinit
fi
if [ "x$subdirs" != x ]; then
for s in $subdirs
do
echo "dir ${srcdir}/$s" >> .gdbinit
done
fi
echo "source ${srcdir}/.gdbinit" >> .gdbinit
;;
esac
# Conditionalize the makefile for this host machine.
rm -f Makefile.xx Makefile.ll
merged_frags=
for f in .. ${host_xmake_file}
do
if [ -f ${mainsrcdir}/config/$f ]
then
cat ${mainsrcdir}/config/$f >> Makefile.ll
if [ x"${merged_frags}" != x ]
then
merged_frags="${merged_frags} and "
fi
merged_frags="${merged_frags}${f}"
fi
done
if [ x"${merged_frags}" != x ]
then
sed -e "/####host/ r Makefile.ll" Makefile.tem > Makefile.xx
echo "Merged ${merged_frags}."
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
rm -f Makefile.ll
fi
# Add a definition for MAKE if system wants one.
case "$SET_MAKE" in
?*)
rm -f Makefile.xx
(echo "$SET_MAKE"; cat Makefile.tem) >Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
esac
# Add a definition for INSTALL if system wants one.
# This substitutes for lots of x-* files.
if [ x$build_broken_install = x ]
then true
else
rm -f Makefile.xx
abssrcdir=`cd ${srcdir}; pwd`
sed "s|^INSTALL = .*|INSTALL = ${abssrcdir}/install.sh -c|" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Some of the following don't make sense in the language makefiles,
# but rather than introduce another level of nesting, we leave them
# as is.
# Set EXTRA_HEADERS according to extra_headers.
# This substitutes for lots of t-* files.
extra_headers_list=
if [ "x$extra_headers" = x ]
then true
else
rm -f Makefile.xx
sed "s|^EXTRA_HEADERS =|EXTRA_HEADERS = ${extra_headers_list}|" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Set EXTRA_PASSES according to extra_passes.
# This substitutes for lots of t-* files.
if [ "x$extra_passes" = x ]
then true
else
rm -f Makefile.xx
sed "s/^EXTRA_PASSES =/EXTRA_PASSES = $extra_passes/" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Set EXTRA_PARTS according to extra_parts.
# This substitutes for lots of t-* files.
if [ "x$extra_parts" = x ]
then true
else
rm -f Makefile.xx
sed "s/^EXTRA_PARTS =/EXTRA_PARTS = $extra_parts/" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Set EXTRA_PROGRAMS according to extra_programs.
if [ "x$extra_programs" = x ]
then true
else
rm -f Makefile.xx
sed "s/^EXTRA_PROGRAMS =/EXTRA_PROGRAMS = $extra_programs/" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Set EXTRA_OBJS according to extra_objs.
# This substitutes for lots of t-* files.
if [ "x$extra_objs" = x ]
then true
else
rm -f Makefile.xx
sed "s|^EXTRA_OBJS =|EXTRA_OBJS = $extra_objs|" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Set EXTRA_GCC_OBJS according to host_extra_gcc_objs.
# This substitutes for lots of x-* files.
if [ "x$host_extra_gcc_objs" = x ]
then true
else
rm -f Makefile.xx
sed "s|^EXTRA_GCC_OBJS =|EXTRA_GCC_OBJS = $host_extra_gcc_objs|"
Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Add a definition of USE_COLLECT2 if system wants one.
# Also tell toplev.c what to do.
# This substitutes for lots of t-* files.
if [ x$use_collect2 != x ]
then
rm -f Makefile.xx
(echo "USE_COLLECT2 = ld"; echo "MAYBE_USE_COLLECT2 = -DUSE_COLLECT2")\
| cat - Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Set MD_DEPS if the real md file is in md.pre-cpp.
# Set MD_CPP to the cpp to pass the md file through. Md files use ';'
# for line oriented comments, so we must always use a GNU cpp. If
# building gcc with a cross compiler, use the cross compiler just
# built. Otherwise, we can use the cpp just built.
if [ "x$md_cppflags" != x ]
then
rm -f Makefile.xx
(if [ x$host = x$build ] ; then
echo "MD_DEPS = $(md_file) cpp" ; echo "MD_CPP = ./cpp"
else
echo "MD_DEPS = md.pre-cpp" ; echo "MD_CPP = \$(HOST_CC) -x c -E"
fi
echo "MD_CPPFLAGS = $md_cppflags") | \
cat - Makefile.tem | sed -e "s|^MD_FILE[ ]*=.*|MD_FILE = md|" > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# If using -program-transform-name, override the installation names.
if [ "x${program_transform_set}" = "xyes" ] ; then
sed -e "s/^program_transform_name[ ]*=.*$/program_transform_name =
$program_transform_name/" \
-e "s/^program_transform_cross_name[
]*=.*$/program_transform_cross_name = $program_transform_name/" \
Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# Conditionalize the makefile for this target machine.
rm -f Makefile.xx Makefile.ll
merged_frags=
for f in .. ${tmake_file}
do
if [ -f ${mainsrcdir}/config/$f ]
then
cat ${mainsrcdir}/config/$f >> Makefile.ll
if [ x"${merged_frags}" != x ]
then
merged_frags="${merged_frags} and "
fi
merged_frags="${merged_frags}$f"
fi
done
if [ x"${merged_frags}" != x ]
then
sed -e "/####target/ r Makefile.ll" Makefile.tem > Makefile.xx
echo "Merged ${merged_frags}."
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
rm -f Makefile.ll
fi
# If this is the top level Makefile, add the language fragments.
# Languages are added via two mechanisms. Some information must be
# recorded in makefile variables, these are defined in config-lang.in.
# We accumulate them and plug them into the main Makefile.
# The other mechanism is a set of hooks for each of the main targets
# like `clean', `install', etc.
if [ $subdir = . ]
then
rm -f Makefile.xx Makefile.ll
touch Makefile.ll
sed -e "/####language fragments/ r Makefile.ll" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
subdirs=`echo $subdirs`
sed -e "s|^SUBDIRS[ ]*=.*$|SUBDIRS = $subdirs|" \
-e "s|^LANGUAGES[ ]*=[ ]*\(.*\)$|LANGUAGES = \1 $all_languages|" \
-e "s|^BOOT_LANGUAGES[ ]*=[ ]*\(.*\)$|BOOT_LANGUAGES = \1 $all_boot_languages|" \
-e "s|^COMPILERS[ ]*=[ ]*\(.*\)$|COMPILERS = \1 $all_compilers|" \
-e "s|^LANG_MAKEFILES[ ]*=.*$|LANG_MAKEFILES = $all_lang_makefiles|" \
-e "s|^LANG_STAGESTUFF[ ]*=.*$|LANG_STAGESTUFF = $all_stagestuff|" \
-e "s|^LANG_DIFF_EXCLUDES[ ]*=.*$|LANG_DIFF_EXCLUDES = $all_diff_excludes|" \
-e "s|^LANG_EXTRA_HEADERS[ ]*=.*$|LANG_EXTRA_HEADERS = $all_headers|" \
-e "s|^LANG_LIB2FUNCS[ ]*=.*$|LANG_LIB2FUNCS = $all_lib2funcs|" \
Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
# Since we can't use `::' targets, we link each language in
# with a set of hooks, reached indirectly via lang.${target}.
rm -f Makefile.ll
for t in $target_list
do
x=
for l in .. $all_languages
do
if [ $l != ".." ]; then
x="$x $l.$t"
fi
done
echo "lang.$t: $x" >> Makefile.ll
done
sed -e "/####language hooks/ r Makefile.ll" Makefile.tem > Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
rm -f Makefile.ll
# If the host doesn't support symlinks, modify CC in
# FLAGS_TO_PASS so CC="stage1/xgcc -Bstage1/" works.
# Otherwise, we can use "CC=$(CC)".
rm -f symtest.tem
if $symbolic_link symtest1.tem symtest.tem 2>/dev/null
then
sed -e 's,CC=set-by-configure,CC=$(CC),' \
Makefile.tem > Makefile.xx
sed -e 's,STAGE_PREFIX=set-by-configure,STAGE_PREFIX=$(STAGE_PREFIX),' \
Makefile.xx > Makefile.yy
else
sed -e "s,CC=set-by-configure,CC=\`case '\$(CC)' in *stage*) echo '\$(CC)' | sed -e 's|stage|../stage|g';; *) echo '\$(CC)';; esac\`," \
Makefile.tem > Makefile.xx
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\`," \
Makefile.xx > Makefile.yy
fi
rm -f Makefile.tem Makefile.xx
mv Makefile.yy Makefile.tem
rm -f symtest.tem
if [ "x$all_languages" != x ]
then
# Missing space after `Merged' is intentional.
echo "Merged$all_languages fragment(s)."
fi
# Otherwise, this is a language subdirectory. If the host supports
# symlinks, point stage[123] at ../stage[123] so bootstrapping and the
# installation procedure can still use CC="stage1/xgcc -Bstage1/".
# If the host doesn't support symlinks, FLAGS_TO_PASS has been
# modified to solve the problem there.
else
for t in stage1 stage2 stage3 stage4 include
do
rm -f $t
$symbolic_link ../$t $t 2>/dev/null
done
fi
# Remove all formfeeds, since some Makes get confused by them.
# Also arrange to give the variables `target', `host_xmake_file',
# `tmake_file', `prefix', `local_prefix', `exec_prefix', `FIXINCLUDES'
# `out_file', `out_object', `md_file', `lang_specs_files',
# `lang_options_files', `INSTALL_HEADERS_DIR', and `CROSS_FLOAT_H'
# values in the Makefile from the values they have in this script.
rm -f Makefile.xx
rm -f aux-output.c aux-output.o md
# Create an empty Makefile.sed first, to work around a Nextstep 3.3 bug.
echo 's|||' > Makefile.sed
rm Makefile.sed
echo 's|||' > Makefile.sed
echo "s|^target=.*$|target=${target}|" >> Makefile.sed
echo "s|^target_alias=.*$|target_alias=${target}|" >> Makefile.sed
echo "s|^xmake_file=.*$|xmake_file=${dep_host_xmake_file}|" >> Makefile.sed
echo "s|^tmake_file=.*$|tmake_file=${dep_tmake_file}|" >> Makefile.sed
echo "s|^version=.*$|version=${version}|" >> Makefile.sed
echo "s|^version=.*$|version=${version}|" >> Makefile.sed
echo "s|^out_file=.*$|out_file=${srcdir}/config/${out_file}|" >> Makefile.sed
echo "s|^out_object_file=.*$|out_object_file=${out_object_file}|" >> Makefile.sed
echo "s|^md_file=.*$|md_file=${md_file}|" >> Makefile.sed
echo "s|^tm_file=.*$|tm_file=${tm_file_sub}|" >> Makefile.sed
echo "s|^host_xm_file=.*$|host_xm_file=${host_xm_file_sub}|" >> Makefile.sed
echo "s|^build_xm_file=.*$|build_xm_file=${build_xm_file_sub}|" >> Makefile.sed
echo "s|^lang_specs_files=.*$|lang_specs_files=${lang_specs_files}|" >> Makefile.sed
echo "s|^lang_options_files=.*$|lang_options_files=${lang_options_files}|" >> Makefile.sed
echo "s|^OBJC_THREAD_FILE=.*$|OBJC_THREAD_FILE=thr-${objc_thread_file}|" >> Makefile.sed
echo "s|^prefix[ ]*=.*|prefix = $prefix|" >> Makefile.sed
echo "s|^local_prefix[ ]*=.*|local_prefix = $local_prefix|" >> Makefile.sed
echo "s|^exec_prefix[ ]*=.*|exec_prefix = $exec_prefix|" >> Makefile.sed
echo "s|^FIXINCLUDES[ ]*=.*|FIXINCLUDES = $fixincludes|" >> Makefile.sed
echo "s|^INSTALL_HEADERS_DIR[ ]*=.*$|INSTALL_HEADERS_DIR = ${build_install_headers_dir}|" >> Makefile.sed
echo "s|^exeext[ ]*=.*$|exeext = ${build_exeext}|" >> Makefile.sed
echo "s|^CROSS_FLOAT_H[ ]*=.*|CROSS_FLOAT_H=\$(srcdir)/config/float-${float_format}.h|" >> Makefile.sed
sed -f Makefile.sed Makefile.tem > Makefile.xx
rm -f Makefile.tem Makefile.sed
mv Makefile.xx Makefile.tem
# Install Makefile for real, after making final changes.
# Define macro CROSS_COMPILE in compilation
# if this is a cross-compiler.
# Also use all.cross instead of all.internal
# and add cross-make to Makefile.
if [ x$host != x$target ]
then
rm -f Makefile.xx
echo "CROSS=-DCROSS_COMPILE" > Makefile.xx
sed -e "/####cross/ r ${mainsrcdir}/cross-make" Makefile.tem >> Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
# When building gcc with a cross-compiler, we need to fix a few things.
# This must come after cross-make as we want all.build to override
# all.cross.
if [ x$build != x$host ]
then
rm -f Makefile.xx
echo "build= $build" > Makefile.xx
echo "host= $host" >> Makefile.xx
sed -e "s|objc-runtime$||" \
-e "/####build/ r ${mainsrcdir}/build-make" Makefile.tem >> Makefile.xx
rm -f Makefile.tem
mv Makefile.xx Makefile.tem
fi
if [ $subdir != . ]
then
rm -f Makefile
mv Makefile.tem Makefile
echo "Created \`$subdir/Makefile'."
else
rm -f Makefile.tem
fi
cd $STARTDIR
done # end of current-dir SUBDIRS loop
srcdir=$savesrcdir
|