summaryrefslogtreecommitdiffstats
path: root/gcc/configure.lang
blob: 6932f8fa4f66bdaa89840a114e7d15a9e585370e (plain)
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
# configure.lang for GNU CC
# This script is run by configure for configuration of language
# subdirectories which conform to the old GCC configure mechanism
# 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 . $oldstyle_subdirs
do
	# We only want to do this in language subdirs, but we have to handle
	# the case of $oldstyle_subdirs = "".
	if [ $subdir = . ]
	then
		continue
	fi

	oldsrcdir=$savesrcdir

	# Re-adjust the path
	case $oldsrcdir in
	/*)
		srcdir=$oldsrcdir/$subdir
		;;
	*)
		oldsrcdir=../${oldsrcdir}
		srcdir=$oldsrcdir/$subdir
		;;
	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
		echo "dir ${mainsrcdir}" >> .gdbinit
		if [ x$gdb_needs_out_file_path = xyes ]
		then
			echo "dir ${mainsrcdir}/config/"`dirname ${out_file}` >> .gdbinit
		fi
		echo "source ${mainsrcdir}/.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}|" Makefile.tem > 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 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.
	for t in stage1 stage2 stage3 stage4 include
	do
		rm -f $t
		$symbolic_link ../$t $t 2>/dev/null
	done

	# Remove all formfeeds, since some Makes get confused by them.
	# Also arrange to give the variables `target', `target_alias',
	# `host_xmake_file', `tmake_file', `prefix', `local_prefix',
	# `exec_prefix', `INSTALL_HEADERS_DIR', `exeext'
	# values in the Makefile from the values they have in this script.
	rm -f Makefile.xx
	# 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=${target_alias}|" >> 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|^GCC_THREAD_FILE=.*$|GCC_THREAD_FILE=${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|^INSTALL_HEADERS_DIR[ 	]*=.*$|INSTALL_HEADERS_DIR = ${build_install_headers_dir}|" >> Makefile.sed
	echo "s|^exeext[ 	]*=.*$|exeext = ${build_exeext}|" >> 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

	rm -f Makefile
	mv Makefile.tem Makefile
	echo "Created \`$subdir/Makefile'."

	cd $STARTDIR
done   # end of current-dir SUBDIRS loop

# Restore this, remember we're invoked with `.'.
srcdir=$savesrcdir
OpenPOWER on IntegriCloud