Commit | Line | Data |
---|---|---|
eb02fd64 | 1 | #!/bin/sh |
eb02fd64 | 2 | |
46f3c7cd | 3 | # Configuration script |
eb02fd64 RP |
4 | # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. |
5 | ||
6 | #This file is part of GNU. | |
7 | ||
063efd10 JG |
8 | # This program is free software; you can redistribute it and/or modify |
9 | # it under the terms of the GNU General Public License as published by | |
10 | # the Free Software Foundation; either version 2 of the License, or | |
11 | # (at your option) any later version. | |
12 | # | |
13 | # This program is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with this program; if not, write to the Free Software | |
20 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
eb02fd64 | 21 | |
74cc5508 RP |
22 | # $Id$ |
23 | ||
49b10446 RP |
24 | # Please email any bugs, comments, and/or additions to this file to: |
25 | # configure@cygnus.com | |
26 | ||
eb02fd64 RP |
27 | # |
28 | # Shell script to create proper links to machine-dependent files in | |
0df06ca0 | 29 | # preparation for compilation. |
eb02fd64 RP |
30 | # |
31 | # If configure succeeds, it leaves its status in config.status. | |
32 | # If configure fails after disturbing the status quo, | |
33 | # config.status is removed. | |
34 | # | |
35 | ||
4d714963 RP |
36 | # NOTE: This script contains support for a Cygnus experimental feature, called |
37 | # +subdirs, which is currently, tentatively, de-supported. | |
c5ae5678 | 38 | |
4d714963 | 39 | export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$) |
c297d71e | 40 | |
eb02fd64 RP |
41 | remove=rm |
42 | hard_link=ln | |
43 | symbolic_link='ln -s' | |
44 | ||
45 | #for Test | |
46 | #remove="echo rm" | |
47 | #hard_link="echo ln" | |
48 | #symbolic_link="echo ln -s" | |
49 | ||
50 | # clear some things potentially inherited from environment. | |
6f8ac2d9 RP |
51 | |
52 | Makefile=Makefile | |
53 | Makefile_in=Makefile.in | |
eb02fd64 | 54 | ansi= |
b8f8fddc | 55 | arguments=$* |
6f8ac2d9 RP |
56 | commontargets= |
57 | configdirs= | |
4d714963 RP |
58 | datadir= |
59 | datadiroption= | |
0df06ca0 | 60 | defaulttargets= |
0df06ca0 | 61 | fatal= |
4d714963 RP |
62 | floating_point=default |
63 | gas=default | |
64 | hosts= | |
65 | #hostsubdir= | |
66 | #namesubdir= | |
67 | next_prefix= | |
68 | next_host= | |
69 | #next_namesubdir= | |
70 | #next_objdir= | |
3509822c | 71 | next_site= |
4d714963 | 72 | next_srcdir= |
3509822c RP |
73 | next_target= |
74 | next_tmpdir= | |
46766962 | 75 | norecursion= |
4d714963 RP |
76 | #objdir= |
77 | #objdiroption= | |
78 | prefix=/usr/local | |
49b10446 | 79 | progname= |
46766962 | 80 | recurring= |
131a3881 | 81 | removing= |
74cc5508 | 82 | srcdir= |
ec342d7d | 83 | srctrigger= |
131a3881 | 84 | target= |
0df06ca0 | 85 | targets= |
4d714963 RP |
86 | #targetsubdir= |
87 | undefinedargs= | |
0df06ca0 | 88 | verbose= |
4d714963 RP |
89 | x11=default |
90 | ||
7785cbdd | 91 | # or maybe grab from gcc/version.c |
4d714963 RP |
92 | version_path= |
93 | next_version_path= | |
94 | ||
95 | NO_EDIT="This file was generated automatically by configure. Do not edit." | |
96 | ||
97 | ## this is a little touchy and won't always work, but... | |
98 | ## | |
99 | ## if the argv[0] starts with a slash then it is an absolute name that can be | |
100 | ## used as is. | |
101 | ## | |
102 | ## otherwise, if argv[0] has no slash in it, we can assume that it is on the | |
103 | ## path. Since PATH might include "." we also add `pwd` to the end of PATH. | |
104 | ## | |
105 | ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute | |
106 | ## path. | |
107 | ## | |
108 | ||
109 | PWD=`pwd` | |
110 | ||
111 | if (echo $0 | grep '^/' > /dev/null) ; then | |
112 | progname=$0 | |
113 | elif (echo $0 | grep '/' > /dev/null) ; then | |
114 | progname=${PWD}/$0 | |
115 | else | |
116 | progname=$0 | |
117 | PATH=$PATH:${PWD} ; export PATH | |
118 | fi | |
119 | ||
120 | configsub=`echo ${progname} | sed 's/configure$/config.sub/'` | |
121 | ||
122 | if ${configsub} none >/dev/null 2>&1 ; then | |
123 | true | |
124 | else | |
125 | echo '***' cannot find config.sub. | |
126 | echo 1 | |
127 | fi | |
128 | ||
eb02fd64 RP |
129 | for arg in $*; |
130 | do | |
3509822c | 131 | # handle things that might have args following as separate words |
4d714963 RP |
132 | if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix= |
133 | elif [ -n "${next_datadir}" ] ; then datadir=${arg} ; datadiroption="-datadir=${datadir}" ; next_datadir= | |
134 | # elif [ -n "${next_namesubdir}" ] ; then \ | |
135 | # namesubdir=${arg} ; namesubdiroption="--namesubdir=${namesubdir}" ; next_namesubdir= | |
136 | # elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; objdiroption="--objdir=${objdir}" ; next_objdir= | |
137 | elif [ -n "${next_version_path}" ] ; then version_path=${arg} ; next_version_path= | |
3509822c | 138 | elif [ -n "${next_site}" ] ; then site=${arg} ; next_site= |
4d714963 | 139 | elif [ -n "${next_srcdir}" ] ; then srcdir=${arg} ; next_srcdir= |
3509822c RP |
140 | elif [ -n "${next_target}" ] ; then |
141 | next_target= | |
4d714963 RP |
142 | if [ -z "${targets}" ] ; then |
143 | newtargets="${targets} ${arg}" | |
144 | targets="${newtargets}" | |
145 | else | |
146 | echo '***' Can only configure for one target at a time. | |
147 | fatal=yes | |
0df06ca0 | 148 | fi |
3509822c RP |
149 | elif [ -n "${next_tmpdir}" ] ; then |
150 | next_tmpdir= | |
4d714963 | 151 | tmpdiroption="--tmpdir=${arg}" |
3509822c RP |
152 | TMPDIR=${arg} |
153 | ||
154 | else | |
155 | case ${arg} in | |
4d714963 | 156 | -ansi | --a*) |
3509822c RP |
157 | ansi=true |
158 | clib=clib | |
159 | ;; | |
4d714963 | 160 | -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* | --da=* | --d=*) |
0e0643c7 | 161 | datadir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
4d714963 | 162 | datadiroption=${arg} |
3509822c | 163 | ;; |
4d714963 RP |
164 | -datadir | --datadir | --datadi | --datad | --data | --dat | --da | --d) |
165 | next_datadir=yes | |
3509822c | 166 | ;; |
4d714963 | 167 | -gas | --g*) |
3509822c RP |
168 | gas=yes |
169 | ;; | |
4d714963 | 170 | -help | --he*) |
3509822c RP |
171 | fatal=true |
172 | ;; | |
4d714963 RP |
173 | -host=* | --host=* | --hos=* | --ho=*) |
174 | # if [ -n "${hosts}" ] ; then | |
175 | # subdirs="--subdirs" | |
176 | # fi | |
177 | ||
178 | if [ -z "${hosts}" ] ; then | |
0e0643c7 | 179 | newhosts="${hosts} `echo ${arg} | sed 's/^[-a-z]*=//'`" |
4d714963 RP |
180 | hosts="${newhosts}" |
181 | else | |
182 | echo '***' Can only configure for one host at a time. | |
183 | fatal=yes | |
184 | fi | |
3509822c | 185 | ;; |
4d714963 RP |
186 | -languages=* | --languages=* | --language=* | --languag=* \ |
187 | | --langua=* | --langu=* | --lang=* | --lan=* | --la=* \ | |
188 | | --l=*) | |
0e0643c7 | 189 | languages="${languages} `echo ${arg} | sed 's/^[-a-z]*=//'`" |
3509822c | 190 | ;; |
4d714963 RP |
191 | # -namesubdir | --namesubdir | --namesubdi | --namesubd | --namesub | --namesu | --names | --name | --nam | --na) |
192 | # next_namesubdir=yes | |
193 | # ;; | |
194 | # -namesubdir=* | --namesubdir=* | --namesubdi=* | --namesubd=* | --namesub=* | --namesu=* | --names=* | --name=* | --nam=* | --na=*) | |
0e0643c7 | 195 | # namesubdir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
4d714963 RP |
196 | # namesubdiroption=${arg} |
197 | # ;; | |
198 | -nfp | --nf*) | |
199 | floating_point=no | |
3509822c | 200 | ;; |
4d714963 | 201 | -norecursion | --no*) |
3509822c RP |
202 | norecursion=true |
203 | ;; | |
4d714963 RP |
204 | # -objdir=* | --objdir=* | --objdi=* | --objd=* | --obj=* | --ob=* | --o=*) |
205 | # objdiroption=${arg} | |
0e0643c7 | 206 | # objdir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
4d714963 RP |
207 | # ;; |
208 | # -objdir | --objdir | --objdi | --objd | --obj | --ob | --o) | |
209 | # next_objdir=yes | |
210 | # ;; | |
211 | -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) | |
0e0643c7 | 212 | prefix=`echo ${arg} | sed 's/^[-a-z]*=//'` |
4d714963 | 213 | prefixoption=${arg} |
3509822c | 214 | ;; |
4d714963 RP |
215 | -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) |
216 | next_prefix=yes | |
3509822c | 217 | ;; |
4d714963 | 218 | -recurring | --recurring | --recurrin | --recurri | --recurr | --recur | --recu | --rec | --re) |
3509822c RP |
219 | recurring=true |
220 | arguments=`echo ${arguments} | sed "s:${arg}::"` | |
221 | ;; | |
4d714963 | 222 | -rm | --rm) |
3509822c RP |
223 | removing=${arg} |
224 | ;; | |
4d714963 | 225 | -site=* | --site=* | --sit=* | --si=*) |
0e0643c7 | 226 | site=`echo ${arg} | sed 's/^[-a-z]*=//'` |
3509822c | 227 | ;; |
4d714963 | 228 | -site | --site | --sit | --si) |
3509822c RP |
229 | next_site=yes |
230 | ;; | |
4d714963 | 231 | -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) |
0e0643c7 | 232 | srcdir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
4d714963 RP |
233 | ;; |
234 | -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) | |
235 | next_srcdir=yes | |
3509822c | 236 | ;; |
4d714963 RP |
237 | # -subdirs | --su*) |
238 | # subdirs=${arg} | |
239 | # ;; | |
240 | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*) | |
241 | # if [ -n "${targets}" ] ; then | |
242 | # subdirs="--subdirs" | |
243 | # fi | |
244 | ||
245 | if [ -z "${targets}" ] ; then | |
0e0643c7 | 246 | newtargets="${targets} `echo ${arg} | sed 's/^[-a-z]*=//'`" |
4d714963 RP |
247 | targets="${newtargets}" |
248 | else | |
249 | echo '***' Can only configure for one target at a time. | |
250 | fatal=yes | |
3509822c | 251 | fi |
3509822c | 252 | ;; |
4d714963 | 253 | -target | --target | --targe | --targ | --tar | --ta) |
3509822c RP |
254 | next_target=yes |
255 | ;; | |
4d714963 | 256 | -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*) |
3509822c | 257 | tmpdiroption=${arg} |
0e0643c7 | 258 | TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'` |
3509822c | 259 | ;; |
4d714963 | 260 | -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm) |
3509822c RP |
261 | next_tmpdir=yes |
262 | ;; | |
4d714963 | 263 | -v | -verbose | --v) |
3509822c RP |
264 | verbose=${arg} |
265 | ;; | |
4d714963 RP |
266 | -x | --x) ;; |
267 | -* | --*) | |
3509822c RP |
268 | (echo ; |
269 | echo "Unrecognized option: \"${arg}\"". ; | |
270 | echo) 1>&2 | |
271 | fatal=true | |
272 | ;; | |
273 | *) | |
4d714963 RP |
274 | # if [ -n "${hosts}" ] ; then |
275 | # subdirs="--subdirs" | |
276 | # fi | |
3509822c | 277 | |
4d714963 RP |
278 | if [ -z "${undefs}" ] ; then |
279 | newundefs="${undefs} ${arg}" | |
280 | undefs=${newundefs} | |
281 | else | |
282 | echo '***' Can only configure for one host and one target at a time. | |
283 | fatal=yes | |
284 | fi | |
3509822c RP |
285 | ;; |
286 | esac | |
287 | fi | |
eb02fd64 RP |
288 | done |
289 | ||
0df06ca0 | 290 | if [ -n "${verbose}" ] ; then |
49b10446 | 291 | echo $0 $* |
0df06ca0 RP |
292 | fi |
293 | ||
4d714963 RP |
294 | # process host and target |
295 | if [ -z "${fatal}" ] ; then | |
296 | # # Complain if an arg is missing | |
297 | # if [ -z "${hosts}" ] ; then | |
298 | # (echo ; | |
299 | # echo "configure: No HOST specified." ; | |
300 | # echo) 1>&2 | |
301 | # fatal=true | |
302 | # fi | |
303 | ||
304 | ### This is a bit twisted. | |
305 | ### * if all three are specified, this is an error. | |
306 | ### * if we have neither hosts, nor unadorned args, this is an error. | |
307 | ### * if no hosts are specified, then the unadorned args are hosts, but if | |
308 | ### there were none, this is an error. | |
309 | ### * if no targets are specified, then the unadorned args are targets, but if | |
310 | ### there were no unadorned args, then the hosts are also targets. | |
311 | ||
312 | if [ -n "${hosts}" -a -n "${targets}" -a -n "${undefs}" ] ; then | |
313 | echo '***' Can only configure for one host and one target at a time. | |
314 | fatal=yes | |
315 | elif [ -z "${hosts}" -a -z "${undefs}" ] ; then | |
316 | echo '***' You must tell me for which host you want to configure. | |
317 | fatal=yes | |
49b10446 | 318 | else |
4d714963 RP |
319 | if [ -z "${hosts}" ] ; then |
320 | hosts=${undefs} | |
321 | fi | |
49b10446 | 322 | |
4d714963 RP |
323 | if [ -z "${targets}" ] ; then |
324 | if [ -n "${undefs}" ] ; then | |
325 | targets=${undefs} | |
326 | else | |
327 | targets=${hosts} | |
328 | fi | |
329 | fi | |
eb02fd64 | 330 | fi |
131a3881 | 331 | fi |
eb02fd64 | 332 | |
0df06ca0 RP |
333 | if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then |
334 | (echo "Usage: configure HOST" ; | |
335 | echo ; | |
336 | echo "Options: [defaults in brackets]" ; | |
4d714963 RP |
337 | echo " -ansi configure w/ANSI library. [no ansi lib]" ; |
338 | echo " -datadir=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ; | |
339 | echo " -gas configure the compilers for use with gas. [native as]" ; | |
340 | echo " -help print this message. [normal config]" ; | |
341 | echo " -lang=LANG configure to build LANG. [gcc]" ; | |
342 | echo " -nfp configure the compilers default to soft floating point. [hard float]" ; | |
343 | echo " -norecursion configure this directory only. [recurse]" ; | |
344 | # echo " -objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ; | |
345 | echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ; | |
346 | echo " -rm remove this configuration. [build a configuration]" ; | |
347 | echo " -site configure with site specific makefile" ; | |
348 | echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ; | |
639665de | 349 | # This is correctly aligned in the output, even though it isn't here. |
4d714963 RP |
350 | # echo " -subdirs configure in subdirectories. [in source directories]" ; |
351 | echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ; | |
352 | echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ; | |
0df06ca0 RP |
353 | echo ; |
354 | echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; | |
4d714963 RP |
355 | # echo "Asking for more than one \"--target\" implies \"--subdirs\". Any other" ; |
356 | # echo "options given will apply to all targets." | |
357 | ) 1>&2 | |
0df06ca0 RP |
358 | |
359 | if [ -r config.status ] ; then | |
360 | cat config.status | |
361 | fi | |
362 | ||
363 | exit 1 | |
eb02fd64 RP |
364 | fi |
365 | ||
4d714963 RP |
366 | if [ -z "${srcdir}" ] ; then |
367 | if [ -r configure.in ] ; then | |
368 | srcdir=. | |
369 | elif [ -r ../configure.in ] ; then | |
370 | srcdir=.. | |
371 | else | |
372 | echo '***' "Can't find configure.in. Try using -srcdir=some_dir" | |
eb02fd64 RP |
373 | exit 1 |
374 | fi | |
4d714963 | 375 | fi |
eb02fd64 | 376 | |
bc58b41d | 377 | |
4d714963 RP |
378 | ### break up ${srcdir}/configure.in. |
379 | if [ -z "`grep '^# per\-host:' ${srcdir}/configure.in`" ] ; then | |
380 | echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2 | |
381 | exit 1 | |
382 | fi | |
49b10446 | 383 | |
4d714963 RP |
384 | if [ -z "`grep '^# per\-target:' ${srcdir}/configure.in`" ] ; then |
385 | echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2 | |
386 | exit 1 | |
387 | fi | |
c5ae5678 | 388 | |
4d714963 RP |
389 | if [ -z "${TMPDIR}" ] ; then |
390 | TMPDIR=/tmp ; export TMPDIR | |
391 | fi | |
eb02fd64 | 392 | |
4d714963 RP |
393 | # keep this filename short for &%*%$*# 14 char file names |
394 | tmpfile=${TMPDIR}/cONf$$ | |
395 | trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0 | |
396 | ||
397 | # split ${srcdir}/configure.in into common, per-host, per-target, | |
398 | # and post-target parts. Post-target is optional. | |
399 | sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com | |
400 | sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst | |
401 | if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then | |
402 | sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt | |
403 | sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos | |
c297d71e | 404 | else |
4d714963 RP |
405 | sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt |
406 | echo >${tmpfile}.pos | |
c297d71e | 407 | fi |
eb02fd64 | 408 | |
c297d71e | 409 | ### do common part of configure.in |
eb02fd64 | 410 | |
c5ae5678 | 411 | . ${tmpfile}.com |
eb02fd64 | 412 | |
ec342d7d | 413 | # some sanity checks on configure.in |
0df06ca0 | 414 | if [ -z "${srctrigger}" ] ; then |
4d714963 | 415 | echo '***' srctrigger not set in ${PWD}/configure.in. |
ec342d7d RP |
416 | exit 1 |
417 | fi | |
418 | ||
0df06ca0 RP |
419 | for host in ${hosts} ; do |
420 | # Default other arg | |
421 | if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then | |
422 | targets=${host} | |
423 | defaulttargets=true | |
424 | fi | |
eb02fd64 | 425 | |
b8f8fddc RP |
426 | host_alias=${host} |
427 | ||
50ac10c1 | 428 | result=`${configsub} ${host}` |
bc58b41d RP |
429 | host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` |
430 | host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` | |
431 | host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` | |
432 | host=${host_cpu}-${host_vendor}-${host_os} | |
ee8f0bd7 | 433 | host_makefile_frag=config/mh-${host} |
ba04ec6e HS |
434 | if [ ! -f ${host_makefile_frag} ] |
435 | then | |
ee8f0bd7 | 436 | host_makefile_frag=config/mh-${host_alias} |
ba04ec6e | 437 | fi |
6c18e393 | 438 | |
c5ae5678 | 439 | . ${tmpfile}.hst |
eb02fd64 | 440 | |
0df06ca0 | 441 | for target in ${targets} ; do |
eb02fd64 | 442 | |
b8f8fddc | 443 | target_alias=${target} |
50ac10c1 | 444 | result=`${configsub} ${target}` |
bc58b41d RP |
445 | target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` |
446 | target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` | |
447 | target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` | |
448 | target=${target_cpu}-${target_vendor}-${target_os} | |
ee8f0bd7 | 449 | target_makefile_frag=config/mt-${target} |
ba04ec6e HS |
450 | if [ ! -f ${target_makefile_frag} ] |
451 | then | |
ee8f0bd7 | 452 | target_makefile_frag=config/mt-${target_alias} |
ba04ec6e | 453 | fi |
6408afba | 454 | |
c5ae5678 | 455 | . ${tmpfile}.tgt |
0df06ca0 | 456 | |
4d714963 RP |
457 | if [ "${host_alias}" = "${target_alias}" ] ; then |
458 | subdirname=H-${host_alias} | |
459 | else | |
460 | subdirname=X-${host_alias}-${target_alias} | |
461 | fi | |
49b10446 | 462 | |
4d714963 RP |
463 | if [ -n "${namesubdir}" ] ; then |
464 | subdirname=${namesubdir} | |
465 | fi | |
0df06ca0 | 466 | |
4d714963 RP |
467 | if [ -n "${removing}" ] ; then |
468 | # if [ -n "${objdir}" ] ; then | |
469 | # echo '***' --rm not supported for --objdir. Just \"rm -rf ${objdir}\" by hand. | |
470 | # exit 1 | |
471 | # fi | |
472 | ||
473 | # if [ -n "${subdirs}" ] ; then | |
474 | # if [ -d "${subdirname}" ] ; then | |
475 | # rm -rf ${hostsubdir} | |
476 | # else | |
477 | # echo Warning: no ${PWD}/${hostsubdir} to remove. | |
478 | # fi | |
479 | # else | |
063efd10 | 480 | rm -f ${Makefile} config.status ${links} |
4d714963 | 481 | # fi |
74cc5508 | 482 | else |
4d714963 RP |
483 | # if [ -n "${objdir}" ]; then |
484 | # srcdir=${PWD} | |
485 | # cd ${objdir} | |
486 | # fi | |
487 | ||
488 | # if [ -n "${subdirs}" ] ; then | |
489 | # # check for existing status before allowing forced subdirs. | |
490 | # if [ -f ${Makefile} ] ; then | |
491 | # echo '***' "${Makefile} already exists in source directory. ${PWD} not configured." 1>&2 | |
492 | # exit 1 | |
493 | # fi | |
494 | # | |
495 | # # use a subdir common to all targets for this host iff: this is a cross AND | |
496 | # # this tool does not claim to be target dependent AND we have not been asked to name the subdir. | |
497 | # if [ ${host_alias} != ${target_alias} -a -z "${target_dependent}" -a -z "${namesubdiroption}" ] | |
498 | # then | |
499 | # if [ ! -d H-${host_alias} ] ; then mkdir H-${host_alias} ; fi | |
500 | # | |
501 | # if (${symbolic_link} ${subdirname} H-${host_alias} 2> /dev/null) ; then | |
502 | # true | |
503 | # else # just give up. they lose. | |
504 | # rmdir H-${host_alias} | |
505 | # if [ ! -d ${subdirname} ] ; then mkdir ${subdirname} ; fi | |
506 | # fi | |
507 | # elif [ ! -d ${subdirname} ] ; then | |
508 | # mkdir ${subdirname} | |
509 | # fi | |
510 | # | |
511 | # cd ${subdirname} | |
512 | # | |
513 | # if [ -z "${srcdir}" ] ; then | |
514 | # srcdir=.. | |
515 | # fi | |
516 | # elif [ "`echo H-*`" != "H-*" -a "`echo X-*`" != "X-*" ] ; then | |
517 | # # if not subdir builds, then make sure none exist. | |
518 | # # We might miss if there are explicitly named subdirs. | |
519 | # echo '***' "Configured subdirs exist. ${PWD} not configured." 1>&2 | |
520 | # exit 1 | |
521 | # else | |
522 | # true | |
523 | # fi | |
eb02fd64 | 524 | |
0df06ca0 RP |
525 | # Find the source files, if location was not specified. |
526 | if [ -z "${srcdir}" ] ; then | |
527 | srcdirdefaulted=1 | |
528 | srcdir=. | |
4d714963 | 529 | if [ ! -r ${srctrigger} ] ; then |
0df06ca0 RP |
530 | srcdir=.. |
531 | fi | |
532 | fi | |
eb02fd64 | 533 | |
4d714963 | 534 | if [ ! -r ${srcdir}/${srctrigger} ] ; then |
0df06ca0 | 535 | if [ -z "${srcdirdefaulted}" ] ; then |
4d714963 | 536 | echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2 |
0df06ca0 | 537 | else |
4d714963 | 538 | echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2 |
0df06ca0 | 539 | fi |
eb02fd64 | 540 | |
bc58b41d | 541 | echo '***' \(At least ${srctrigger} is missing.\) 1>&2 |
0df06ca0 RP |
542 | exit 1 |
543 | fi | |
131a3881 | 544 | |
0df06ca0 RP |
545 | # Set up the list of links to be made. |
546 | # ${links} is the list of link names, and ${files} is the list of names to link to. | |
eb02fd64 | 547 | |
0df06ca0 RP |
548 | # Make the links. |
549 | while [ -n "${files}" ] ; do | |
550 | # set file to car of files, files to cdr of files | |
551 | set ${files}; file=$1; shift; files=$* | |
552 | set ${links}; link=$1; shift; links=$* | |
131a3881 | 553 | |
0df06ca0 | 554 | if [ ! -r ${srcdir}/${file} ] ; then |
bc58b41d RP |
555 | echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 |
556 | echo '***' "since the file \"${file}\" does not exist." 1>&2 | |
0df06ca0 RP |
557 | exit 1 |
558 | fi | |
131a3881 | 559 | |
0df06ca0 RP |
560 | ${remove} -f ${link} |
561 | rm -f config.status | |
562 | # Make a symlink if possible, otherwise try a hard link | |
563 | ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} | |
131a3881 | 564 | |
0df06ca0 | 565 | if [ ! -r ${link} ] ; then |
bc58b41d | 566 | echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 |
0df06ca0 RP |
567 | exit 1 |
568 | fi | |
bc58b41d RP |
569 | |
570 | if [ -n "${verbose}" ] ; then | |
571 | echo "Linked \"${link}\" to \"${srcdir}/${file}\"." | |
572 | fi | |
0df06ca0 | 573 | done |
131a3881 | 574 | |
0df06ca0 RP |
575 | # Create a .gdbinit file which runs the one in srcdir |
576 | # and tells GDB to look there for source files. | |
577 | ||
4d714963 RP |
578 | if [ -r ${srcdir}/.gdbinit ] ; then |
579 | case ${srcdir} in | |
580 | .) | |
581 | ;; | |
582 | *) | |
583 | echo "# "${NO_EDIT} > .gdbinit | |
584 | echo "dir ." >> .gdbinit | |
585 | echo "dir ${srcdir}" >> .gdbinit | |
586 | echo "source ${srcdir}/.gdbinit" >> .gdbinit | |
587 | ;; | |
588 | esac | |
589 | fi | |
0df06ca0 RP |
590 | |
591 | # Install a makefile, and make it set VPATH | |
592 | # if necessary so that the sources are found. | |
593 | # Also change its value of srcdir. | |
594 | ||
595 | # FIXME-someday: This business of always writing to .tem and mv back | |
596 | # is so that I don't screw things up while developing. Once this | |
597 | # template is stable, these should be optimized. xoxorich. | |
598 | ||
599 | # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. | |
600 | if [ "${host}" != "${target}" ] ; then | |
063efd10 JG |
601 | echo "CROSS=-DCROSS_COMPILE" > ${Makefile} |
602 | echo "ALL=start.encap" >> ${Makefile} | |
0df06ca0 | 603 | else |
063efd10 | 604 | echo "ALL=all.internal" > ${Makefile} |
0df06ca0 | 605 | fi |
131a3881 | 606 | |
0df06ca0 | 607 | # set target, host, VPATH |
b8f8fddc RP |
608 | echo "host_alias = ${host_alias}" >> ${Makefile} |
609 | echo "host_cpu = ${host_cpu}" >> ${Makefile} | |
610 | echo "host_vendor = ${host_vendor}" >> ${Makefile} | |
611 | echo "host_os = ${host_os}" >> ${Makefile} | |
7785cbdd | 612 | echo "version_path = ${version_path}" >> ${Makefile} |
b8f8fddc RP |
613 | echo "target_alias = ${target_alias}" >> ${Makefile} |
614 | echo "target_cpu = ${target_cpu}" >> ${Makefile} | |
615 | echo "target_vendor = ${target_vendor}" >> ${Makefile} | |
616 | echo "target_os = ${target_os}" >> ${Makefile} | |
131a3881 | 617 | |
4d714963 RP |
618 | # if [ -n "${subdirs}" ] ; then |
619 | # (echo "subdir = /${subdirname}" ; | |
620 | # echo "unsubdir = ..") >> ${Makefile} | |
621 | # else | |
49b10446 RP |
622 | (echo "subdir =" ; |
623 | echo "unsubdir = .") >> ${Makefile} | |
4d714963 | 624 | # fi |
131a3881 | 625 | |
4d714963 | 626 | # echo "workdir = ${PWD}" >> ${Makefile} |
063efd10 | 627 | echo "VPATH = ${srcdir}" >> ${Makefile} |
eb02fd64 | 628 | |
063efd10 JG |
629 | # add "Makefile.in" (or whatever it's called) |
630 | cat ${srcdir}/${Makefile_in} >> ${Makefile} | |
eb02fd64 | 631 | |
28f3b094 RP |
632 | # Conditionalize the makefile for this site. |
633 | if [ -n "${site}" ] ; then | |
634 | site_makefile_frag=config/ms-${site} | |
635 | ||
636 | if [ -f ${srcdir}/${site_makefile_frag} ] ; then | |
637 | (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ; | |
638 | sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem | |
639 | else | |
640 | (echo "site_makefile_frag =" ; | |
641 | cat ${Makefile}) > Makefile.tem | |
642 | fi | |
643 | mv Makefile.tem ${Makefile} | |
644 | fi | |
645 | ||
0df06ca0 | 646 | # Conditionalize the makefile for this host. |
ee8f0bd7 SC |
647 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then |
648 | (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; | |
649 | sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem | |
650 | else | |
651 | (echo "host_makefile_frag =" ; | |
652 | cat ${Makefile}) > Makefile.tem | |
653 | fi | |
c5ae5678 | 654 | mv Makefile.tem ${Makefile} |
131a3881 | 655 | |
0df06ca0 | 656 | # Conditionalize the makefile for this target. |
ee8f0bd7 SC |
657 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then |
658 | (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; | |
659 | sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem | |
660 | else | |
661 | (echo "target_makefile_frag =" ; | |
662 | cat ${Makefile}) > Makefile.tem | |
663 | fi | |
c5ae5678 | 664 | mv Makefile.tem ${Makefile} |
ec342d7d | 665 | |
0df06ca0 | 666 | # set srcdir |
063efd10 JG |
667 | sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem |
668 | mv Makefile.tem ${Makefile} | |
eb02fd64 | 669 | |
4d714963 RP |
670 | # set prefix |
671 | if [ -n "${prefix}" ] ; then | |
672 | sed "s:^prefix =.*$:prefix = ${prefix}:" ${Makefile} > Makefile.tem | |
28f3b094 RP |
673 | mv Makefile.tem ${Makefile} |
674 | fi | |
675 | ||
4d714963 RP |
676 | # set datadir |
677 | if [ -n "${datadir}" ] ; then | |
678 | sed "s:^datadir =.*$:datadir = ${datadir}:" ${Makefile} > Makefile.tem | |
063efd10 | 679 | mv Makefile.tem ${Makefile} |
0df06ca0 | 680 | fi |
eb02fd64 | 681 | |
0df06ca0 | 682 | # reset SUBDIRS |
063efd10 JG |
683 | sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem |
684 | mv Makefile.tem ${Makefile} | |
eb02fd64 | 685 | |
0df06ca0 | 686 | # reset NONSUBDIRS |
063efd10 JG |
687 | sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem |
688 | mv Makefile.tem ${Makefile} | |
eb02fd64 | 689 | |
7875b07f RP |
690 | # remove any form feeds. |
691 | sed -e "s/\f//" ${Makefile} > Makefile.tem | |
692 | mv Makefile.tem ${Makefile} | |
693 | ||
4d714963 RP |
694 | # prepend warning about editting. |
695 | echo "# "${NO_EDIT} > ${Makefile}.tem | |
696 | cat ${Makefile} >> ${Makefile}.tem | |
697 | mv Makefile.tem ${Makefile} | |
698 | ||
0df06ca0 | 699 | using= |
9d1e053b | 700 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then |
c5ae5678 | 701 | using="${using} and \"${host_makefile_frag}\"" |
0df06ca0 | 702 | fi |
9d1e053b | 703 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then |
c5ae5678 | 704 | using="${using} and \"${target_makefile_frag}\"" |
0df06ca0 | 705 | fi |
c5ae5678 RP |
706 | if [ -n "${site}" -a \ |
707 | -f ${srcdir}/${site_makefile_frag} ] ; then | |
708 | using="${using} and \"${site_makefile_frag}\"" | |
7875b07f | 709 | fi |
c5ae5678 | 710 | using=`echo "${using}" | sed 's/and/using/'` |
4d714963 | 711 | using="Created \"${Makefile}\" in ${PWD}${using}." |
7875b07f | 712 | |
46766962 | 713 | if [ -n "${verbose}" -o -z "${recurring}" ] ; then |
c5ae5678 | 714 | echo ${using} |
bc58b41d | 715 | fi |
063efd10 | 716 | |
c5ae5678 | 717 | . ${tmpfile}.pos |
eb02fd64 | 718 | |
b8f8fddc RP |
719 | # describe the chosen configuration in config.status. |
720 | # Make that file a shellscript which will reestablish | |
721 | # the same configuration. Used in Makefiles to rebuild | |
722 | # Makefiles. | |
723 | ||
4d714963 RP |
724 | if [ -z "${norecursion}" ] ; then |
725 | arguments="${arguments} -norecursion" | |
726 | fi | |
727 | ||
b8f8fddc | 728 | echo "#!/bin/sh |
4d714963 RP |
729 | # ${NO_EDIT} |
730 | # ${PWD} was configured as follows: | |
731 | ${progname}" ${arguments} " | |
c5ae5678 | 732 | # ${using}" > config.status |
b8f8fddc | 733 | chmod a+x config.status |
0df06ca0 | 734 | |
4d714963 RP |
735 | # originaldir=${PWD} |
736 | # cd ${srcdir} | |
0df06ca0 | 737 | fi |
bc58b41d | 738 | |
4d714963 | 739 | # If there are subdirectories, then recur. |
46766962 | 740 | if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then |
bc58b41d RP |
741 | for configdir in ${configdirs} ; do |
742 | if [ -n "${verbose}" ] ; then | |
743 | echo Configuring ${configdir}... | |
744 | fi | |
745 | ||
4d714963 RP |
746 | if [ -d ${srcdir}/${configdir} ] ; then |
747 | if [ "${srcdir}" != "." ] ; then | |
748 | if [ ! -d ./${configdir} ] ; then | |
749 | mkdir ./${configdir} | |
49b10446 RP |
750 | fi |
751 | fi | |
752 | ||
4d714963 | 753 | POPDIR=${PWD} |
5420feaa RP |
754 | cd ${configdir} |
755 | ||
4d714963 RP |
756 | ### figure out what to do with srcdir |
757 | case "${srcdir}" in | |
758 | ".") ;; # do nothing. We're building in place. | |
759 | "..") srcdiroption="-srcdir=../../${configdir}" ;; | |
760 | *) srcdiroption="-srcdir=${srcdir}/${configdir}" ;; | |
761 | esac | |
762 | ||
763 | ### The recursion line is here. | |
764 | if (${progname} -recurring ${host_alias} -target=${target_alias} \ | |
765 | ${verbose} ${subdirs} ${removing} ${prefixoption} \ | |
766 | ${tmpdiroption} ${namesubdiroption} ${datadiroption} \ | |
767 | ${srcdiroption}) ; then | |
c5ae5678 RP |
768 | true |
769 | else | |
770 | exit 1 | |
771 | fi | |
5420feaa RP |
772 | |
773 | cd ${POPDIR} | |
4d714963 RP |
774 | elif [ -n "${verbose}" ] ; then |
775 | echo Warning: source directory \"${srcdir}/${configdir}\" is missing. | |
bc58b41d RP |
776 | fi |
777 | done | |
778 | fi | |
67ca110d RP |
779 | done # for each target |
780 | ||
4101d868 | 781 | # Now build a Makefile for this host. |
4d714963 RP |
782 | # if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then |
783 | # push=${PWD} | |
784 | # | |
785 | # if [ -n "${objdir}" ] ; then | |
786 | # cd ${objdir} | |
787 | # fi | |
788 | # | |
789 | # cd ${hostsubdir} | |
790 | # cat > GNUmakefile << 'E!O!F' | |
791 | ## Makefile generated by configure for host ${host_alias}. | |
792 | # | |
793 | #ALL := $(shell ls -d T-*) | |
794 | # | |
795 | #%: | |
796 | # $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true | |
797 | # | |
798 | #all: | |
799 | #E!O!F | |
800 | # cd ${push} | |
801 | # fi | |
67ca110d | 802 | done # for each host |
eb02fd64 | 803 | |
c297d71e RP |
804 | ### clean up. |
805 | ||
4d714963 RP |
806 | # trap cmd above handles this now: |
807 | #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos | |
c297d71e | 808 | |
eb02fd64 | 809 | exit 0 |
74cc5508 | 810 | |
0df06ca0 RP |
811 | # |
812 | # Local Variables: | |
813 | # fill-column: 131 | |
814 | # End: | |
815 | # | |
74cc5508 | 816 | |
46f3c7cd | 817 | # end of configure |