]>
Commit | Line | Data |
---|---|---|
fecd2382 | 1 | #!/bin/sh |
fecd2382 | 2 | |
5a168a17 | 3 | # Configuration script |
fecd2382 RP |
4 | # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. |
5 | ||
6 | #This file is part of GNU. | |
7 | ||
b81fa6a2 RP |
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. */ | |
fecd2382 | 21 | |
74cc5508 RP |
22 | # $Id$ |
23 | ||
fecd2382 RP |
24 | # |
25 | # Shell script to create proper links to machine-dependent files in | |
3d6f0983 | 26 | # preparation for compilation. |
fecd2382 RP |
27 | # |
28 | # If configure succeeds, it leaves its status in config.status. | |
29 | # If configure fails after disturbing the status quo, | |
30 | # config.status is removed. | |
31 | # | |
32 | ||
fecd2382 RP |
33 | remove=rm |
34 | hard_link=ln | |
35 | symbolic_link='ln -s' | |
36 | ||
37 | #for Test | |
38 | #remove="echo rm" | |
39 | #hard_link="echo ln" | |
40 | #symbolic_link="echo ln -s" | |
41 | ||
c4220303 RP |
42 | progname=$0 |
43 | ||
fecd2382 | 44 | # clear some things potentially inherited from environment. |
fecd2382 | 45 | ansi= |
5a168a17 | 46 | arguments=$* |
3d6f0983 | 47 | defaulttargets= |
ec342d7d | 48 | destdir= |
3d6f0983 | 49 | fatal= |
61907f51 | 50 | hostsubdir= |
b81fa6a2 RP |
51 | Makefile=Makefile |
52 | Makefile_in=Makefile.in | |
5a168a17 RP |
53 | norecursion= |
54 | recurring= | |
61907f51 | 55 | removing= |
74cc5508 | 56 | srcdir= |
ec342d7d | 57 | srctrigger= |
61907f51 | 58 | target= |
3d6f0983 | 59 | targets= |
1ca5c46c | 60 | commontargets= |
5a168a17 | 61 | configdirs= |
61907f51 RP |
62 | targetsubdir= |
63 | template= | |
3d6f0983 | 64 | verbose= |
fecd2382 RP |
65 | |
66 | for arg in $*; | |
67 | do | |
ec342d7d | 68 | case ${arg} in |
353deb84 | 69 | -ansi | +a*) |
fecd2382 | 70 | ansi=true |
1ca5c46c | 71 | clib=clib |
fecd2382 | 72 | ;; |
ec342d7d RP |
73 | -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) |
74 | destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` | |
75 | ;; | |
74cc5508 RP |
76 | -languages=* | +languages=* | +language=* | +languag=* \ |
77 | | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ | |
78 | | +l=*) | |
ec342d7d | 79 | languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" |
fecd2382 | 80 | ;; |
353deb84 | 81 | -gas | +g*) |
fecd2382 RP |
82 | gas=yes |
83 | ;; | |
353deb84 | 84 | -help | +h*) |
3d6f0983 RP |
85 | fatal=true |
86 | ;; | |
353deb84 | 87 | -nfp | +nf*) |
fecd2382 RP |
88 | nfp=yes |
89 | ;; | |
5a168a17 RP |
90 | -norecursion | +no*) |
91 | norecursion=true | |
61907f51 | 92 | ;; |
5a168a17 RP |
93 | -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) |
94 | recurring=true | |
1ca5c46c | 95 | ;; |
5a168a17 | 96 | -rm | +rm) |
ec342d7d | 97 | removing=${arg} |
61907f51 | 98 | ;; |
3d6f0983 RP |
99 | # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) |
100 | # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` | |
101 | # ;; | |
353deb84 RP |
102 | -subdirs | +f* | +su*) |
103 | subdirs=${arg} | |
104 | ;; | |
105 | -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) | |
3d6f0983 | 106 | if [ -n "${targets}" ] ; then |
353deb84 | 107 | subdirs="+subdirs" |
3d6f0983 RP |
108 | fi |
109 | ||
110 | newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" | |
111 | targets="${newtargets}" | |
61907f51 | 112 | ;; |
353deb84 | 113 | -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) |
ec342d7d | 114 | template=`echo ${arg} | sed 's/[+-]template=//'` |
61907f51 | 115 | ;; |
1ca5c46c | 116 | -v | -verbose | +v*) |
3d6f0983 RP |
117 | verbose=${arg} |
118 | ;; | |
119 | -* | +*) | |
120 | (echo ; | |
121 | echo "Unrecognized option: \"${arg}\"". ; | |
122 | echo) 1>&2 | |
123 | fatal=true | |
124 | ;; | |
fecd2382 | 125 | *) |
3d6f0983 | 126 | if [ -n "${hosts}" ] ; then |
353deb84 | 127 | subdirs="+subdirs" |
3d6f0983 RP |
128 | fi |
129 | ||
130 | newhosts="${hosts} ${arg}" | |
131 | hosts=${newhosts} | |
fecd2382 RP |
132 | ;; |
133 | esac | |
134 | done | |
135 | ||
3d6f0983 RP |
136 | if [ -n "${verbose}" ] ; then |
137 | echo `pwd`/configure $* | |
3d6f0983 RP |
138 | fi |
139 | ||
61907f51 | 140 | # process host and target only if not rebuilding configure itself or removing. |
3d6f0983 | 141 | if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then |
fecd2382 | 142 | # Complain if an arg is missing |
3d6f0983 RP |
143 | if [ -z "${hosts}" ] ; then |
144 | (echo ; | |
145 | echo "configure: No HOST specified." ; | |
1ca5c46c | 146 | echo) 1>&2 |
3d6f0983 | 147 | fatal=true |
fecd2382 | 148 | fi |
61907f51 | 149 | fi |
fecd2382 | 150 | |
3d6f0983 RP |
151 | if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then |
152 | (echo "Usage: configure HOST" ; | |
153 | echo ; | |
154 | echo "Options: [defaults in brackets]" ; | |
155 | echo " +ansi configure w/ANSI library. [no ansi lib]" ; | |
156 | echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; | |
353deb84 | 157 | echo " +subdirs configure in subdirectories. [in source directories]" ; |
3d6f0983 RP |
158 | echo " +lang=LANG configure to build LANG. [gcc]" ; |
159 | echo " +help print this message. [normal config]" ; | |
160 | echo " +gas configure the compilers for use with gas. [native as]" ; | |
161 | echo " +nfp configure the compilers default to soft floating point. [hard float]" ; | |
5a168a17 | 162 | echo " +norecursion configure this directory only. [recurse]" ; |
3d6f0983 RP |
163 | echo " +rm remove this configuration. [build a configuration]" ; |
164 | echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; | |
165 | echo " +template=TEM rebuild configure using TEM. [normal config]" ; | |
166 | echo ; | |
167 | echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; | |
353deb84 | 168 | echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; |
3d6f0983 RP |
169 | echo "options given will apply to all targets.") 1>&2 |
170 | ||
171 | if [ -r config.status ] ; then | |
172 | cat config.status | |
173 | fi | |
174 | ||
175 | exit 1 | |
fecd2382 RP |
176 | fi |
177 | ||
3d6f0983 | 178 | #### configure.in common parts come in here. |
fecd2382 RP |
179 | # This file is a shell script that supplies the information necessary |
180 | # to tailor a template configure script into the configure script | |
181 | # appropriate for this directory. For more information, check any | |
182 | # existing configure script. | |
183 | ||
184 | srctrigger=as.c | |
185 | srcname="gas" | |
353deb84 | 186 | targetdependent=true |
fecd2382 | 187 | |
c4220303 | 188 | ## end of common part. |
fecd2382 RP |
189 | |
190 | # are we rebuilding config itself? | |
3d6f0983 RP |
191 | if [ -n "${template}" ] ; then |
192 | if [ ! -r ${template} ] ; then | |
1ca5c46c | 193 | echo '***' "Can't find template ${template}." 1>&2 |
fecd2382 RP |
194 | exit 1 |
195 | fi | |
196 | ||
c4220303 RP |
197 | # prep the template |
198 | sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\ | |
199 | #### configure.in common parts come in here.\ | |
200 | ## end of common part.' \ | |
201 | -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\ | |
202 | #### configure.in per-host parts come in here.\ | |
203 | ## end of per-host part.' \ | |
204 | -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ | |
205 | #### configure.in per-target parts come in here.\ | |
206 | ## end of per-target part.' \ | |
b81fa6a2 RP |
207 | -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\ |
208 | #### configure.in post-target parts come in here.\ | |
209 | ## end of post-target part.' \ | |
c4220303 | 210 | < ${template} > template.new |
fecd2382 | 211 | |
3d6f0983 RP |
212 | if [ -r configure.in ] ; then |
213 | if [ -z "`grep '^# per\-host:' configure.in`" ] ; then | |
1ca5c46c | 214 | echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 |
3d6f0983 RP |
215 | exit 1 |
216 | fi | |
217 | ||
218 | if [ -z "`grep '^# per\-target:' configure.in`" ] ; then | |
1ca5c46c | 219 | echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 |
3d6f0983 RP |
220 | exit 1 |
221 | fi | |
222 | ||
b81fa6a2 RP |
223 | # split configure.in into common, per-host, per-target, |
224 | # and post-target parts. Post-target is optional. | |
04dc1a62 RP |
225 | sed -e '/^# per\-host:/,$d' configure.in > configure.com |
226 | sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst | |
b81fa6a2 RP |
227 | if grep -s '^# post-target:' configure.in ; then |
228 | sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt | |
229 | sed -e '1,/^# post\-target:/d' configure.in > configure.pos | |
230 | else | |
231 | sed -e '1,/^# per\-target:/d' configure.in > configure.tgt | |
232 | echo >configure.pos | |
233 | fi | |
3d6f0983 | 234 | |
04dc1a62 | 235 | # and insert them |
c4220303 RP |
236 | sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ |
237 | -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ | |
238 | -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ | |
b81fa6a2 | 239 | -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ |
c4220303 | 240 | template.new > configure.new |
3d6f0983 | 241 | |
b81fa6a2 | 242 | rm -f configure.com configure.tgt configure.hst configure.pos |
fecd2382 | 243 | else |
ec342d7d RP |
244 | echo Warning: no configure.in in `pwd` |
245 | cat ${template} >> configure | |
fecd2382 RP |
246 | fi |
247 | ||
c4220303 RP |
248 | chmod a+x configure.new |
249 | rm template.new | |
250 | # mv configure configure.old | |
251 | mv configure.new configure | |
1ca5c46c RP |
252 | |
253 | if [ -n "${verbose}" ] ; then | |
254 | echo Rebuilt configure in `pwd` | |
255 | fi | |
256 | ||
257 | # Now update config.sub from the template directory. | |
258 | if echo "$template" | grep -s 'configure$' ; then | |
259 | cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new | |
260 | # mv config.sub config.sub.old | |
261 | mv config.sub.new config.sub | |
262 | ||
263 | if [ -n "${verbose}" ] ; then | |
264 | echo Rebuilt config.sub in `pwd` | |
265 | fi | |
266 | fi | |
fecd2382 | 267 | |
5a168a17 RP |
268 | if [ -z "${norecursion}" ] ; then |
269 | # If template is relative path, make it absolute for recurring. | |
b81fa6a2 RP |
270 | if echo "${template}" | grep -s '^/' ; then |
271 | true | |
272 | else | |
273 | template=`pwd`/${template} | |
274 | fi | |
275 | ||
3d6f0983 | 276 | while [ -n "${configdirs}" ] ; do |
fecd2382 | 277 | # set configdir to car of configdirs, configdirs to cdr of configdirs |
ec342d7d | 278 | set ${configdirs}; configdir=$1; shift; configdirs=$* |
fecd2382 | 279 | |
3d6f0983 | 280 | if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then |
fecd2382 RP |
281 | targetspecificdirs=${configdir}.* |
282 | else | |
283 | targetspecificdirs= | |
284 | fi | |
285 | ||
3d6f0983 | 286 | for i in ${configdir} ${targetspecificdirs} ; do |
9d1e053b RP |
287 | if [ -d $i ] ; then |
288 | if [ -r $i/configure ] ; then | |
289 | (cd $i ; | |
290 | ./configure +template=${template} ${verbose}) | |
291 | else | |
1ca5c46c | 292 | echo Warning: No configure script in `pwd`/$i |
9d1e053b | 293 | fi |
fecd2382 | 294 | else |
1ca5c46c RP |
295 | if [ -n "${verbose}" ] ; then |
296 | echo Warning: directory $i is missing. | |
297 | fi | |
fecd2382 RP |
298 | fi |
299 | done | |
300 | done | |
301 | fi | |
302 | ||
303 | exit 0 | |
304 | fi | |
305 | ||
ec342d7d | 306 | # some sanity checks on configure.in |
3d6f0983 | 307 | if [ -z "${srctrigger}" ] ; then |
1ca5c46c | 308 | echo Warning: srctrigger not set in configure.in. `pwd` not configured. |
ec342d7d RP |
309 | exit 1 |
310 | fi | |
311 | ||
3d6f0983 RP |
312 | for host in ${hosts} ; do |
313 | # Default other arg | |
314 | if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then | |
315 | targets=${host} | |
316 | defaulttargets=true | |
317 | fi | |
fecd2382 | 318 | |
5a168a17 RP |
319 | host_alias=${host} |
320 | ||
1ca5c46c RP |
321 | result=`/bin/sh ./config.sub ${host}` |
322 | host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` | |
323 | host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` | |
324 | host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` | |
325 | host=${host_cpu}-${host_vendor}-${host_os} | |
6c18e393 RP |
326 | host_makefile_frag=config/hmake-${host} |
327 | ||
3d6f0983 | 328 | #### configure.in per-host parts come in here. |
fecd2382 | 329 | |
1ca5c46c RP |
330 | gas_host=generic |
331 | ||
332 | case "${host_cpu}" in | |
333 | a29k | rs6000 | vax) gas_host=${host_cpu} ;; | |
334 | mips) | |
335 | case "${host_os}" in | |
336 | ultrix) gas_host=decstation ;; | |
337 | esac | |
338 | ;; | |
339 | *) | |
340 | case "${host_os}" in | |
341 | ansi | ultrix | hpux | sysv*) gas_host=${host_os} ;; | |
342 | *) | |
343 | case "${host_vendor}" in | |
344 | sun) | |
345 | case "${host_cpu}" in | |
346 | m68k) gas_host=sun3 ;; | |
347 | i386) gas_host=sun386 ;; | |
348 | sparc) gas_host=sun4 ;; | |
349 | esac | |
350 | ;; | |
351 | esac | |
352 | ;; | |
353 | esac | |
354 | ;; | |
355 | esac | |
3d6f0983 | 356 | |
1ca5c46c | 357 | ## end of per-host part. |
3d6f0983 RP |
358 | |
359 | for target in ${targets} ; do | |
360 | ||
5a168a17 | 361 | target_alias=${target} |
1ca5c46c RP |
362 | result=`/bin/sh ./config.sub ${target}` |
363 | target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` | |
364 | target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` | |
365 | target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` | |
366 | target=${target_cpu}-${target_vendor}-${target_os} | |
6c18e393 RP |
367 | target_makefile_frag=config/tmake-${target} |
368 | ||
3d6f0983 RP |
369 | #### configure.in per-target parts come in here. |
370 | ||
371 | # assign cpu type | |
353deb84 RP |
372 | emulation=generic |
373 | ||
1ca5c46c | 374 | cpu_type=${target_cpu} |
3d6f0983 RP |
375 | |
376 | # assign object format | |
1ca5c46c | 377 | case ${target_os} in |
b678740d | 378 | sysv* | -coff*) |
3d6f0983 RP |
379 | obj_format=coff |
380 | ;; | |
b678740d | 381 | bout*) |
3d6f0983 RP |
382 | obj_format=bout |
383 | ;; | |
b678740d | 384 | bsd* | sunos* | *) |
1ca5c46c RP |
385 | obj_format=aout |
386 | ;; | |
3d6f0983 RP |
387 | generic) |
388 | obj_format=generic | |
389 | ;; | |
3d6f0983 RP |
390 | esac |
391 | ||
392 | # assign floating point type | |
1ca5c46c | 393 | case ${target_cpu} in |
3d6f0983 RP |
394 | vax) |
395 | atof=vax | |
396 | ;; | |
397 | *) | |
398 | atof=ieee | |
399 | ;; | |
400 | esac | |
401 | ||
5a168a17 RP |
402 | # and target makefile frag |
403 | ||
404 | target_makefile_frag=config/tmake-${target_cpu} | |
405 | ||
1ca5c46c | 406 | files="config/ho-${gas_host}.h config/tc-${cpu_type}.c \ |
353deb84 | 407 | config/tc-${cpu_type}.h config/te-${emulation}.h \ |
3d6f0983 RP |
408 | config/obj-${obj_format}.h config/obj-${obj_format}.c \ |
409 | config/atof-${atof}.c" | |
410 | ||
411 | links="host.h targ-cpu.c targ-cpu.h targ-env.h obj-format.h obj-format.c atof-targ.c" | |
c4220303 | 412 | ## end of per-target part. |
3d6f0983 RP |
413 | |
414 | # Temporarily, we support only direct subdir builds. | |
5a168a17 RP |
415 | hostsubdir=H-${host_alias} |
416 | targetsubdir=T-${target_alias} | |
3d6f0983 RP |
417 | |
418 | if [ -n "${removing}" ] ; then | |
353deb84 | 419 | if [ -n "${subdirs}" ] ; then |
c4220303 RP |
420 | if [ -d "${hostsubdir}" ] ; then |
421 | rm -rf ${hostsubdir}/${targetsubdir} | |
3d6f0983 | 422 | |
1ca5c46c | 423 | if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then |
c4220303 RP |
424 | rm -rf ${hostsubdir} |
425 | fi | |
426 | else | |
427 | echo Warning: no `pwd`/${hostsubdir} to remove. | |
3d6f0983 RP |
428 | fi |
429 | else | |
b81fa6a2 | 430 | rm -f ${Makefile} config.status ${links} |
3d6f0983 | 431 | fi |
74cc5508 | 432 | else |
353deb84 | 433 | if [ -n "${subdirs}" ] ; then |
3d6f0983 | 434 | # check for existing status before allowing forced subdirs. |
b81fa6a2 | 435 | if [ -f ${Makefile} ] ; then |
1ca5c46c | 436 | echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 |
3d6f0983 RP |
437 | exit 1 |
438 | fi | |
fecd2382 | 439 | |
3d6f0983 RP |
440 | if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi |
441 | cd ${hostsubdir} | |
fecd2382 | 442 | |
1ca5c46c RP |
443 | if [ ! -d ${targetsubdir} ] ; then |
444 | if [ -z "${commontargets}" ] ; then | |
445 | mkdir ${targetsubdir} | |
446 | else | |
447 | if [ ! -d Target-independent ] ; then | |
448 | mkdir Target-independent | |
449 | fi | |
450 | ||
451 | ${symbolic_link} Target-independent ${targetsubdir} | |
452 | fi # if target independent | |
453 | fi # if no target dir yet | |
454 | ||
3d6f0983 | 455 | cd ${targetsubdir} |
fecd2382 | 456 | |
3d6f0983 RP |
457 | srcdir=../.. |
458 | else | |
459 | # if not subdir builds, then make sure none exist. | |
460 | if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then | |
1ca5c46c | 461 | echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 |
3d6f0983 RP |
462 | exit 1 |
463 | fi | |
464 | fi | |
fecd2382 | 465 | |
3d6f0983 RP |
466 | # Find the source files, if location was not specified. |
467 | if [ -z "${srcdir}" ] ; then | |
468 | srcdirdefaulted=1 | |
469 | srcdir=. | |
470 | if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then | |
471 | srcdir=.. | |
472 | fi | |
473 | fi | |
fecd2382 | 474 | |
3d6f0983 RP |
475 | if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then |
476 | if [ -z "${srcdirdefaulted}" ] ; then | |
1ca5c46c | 477 | echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 |
3d6f0983 | 478 | else |
1ca5c46c | 479 | echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 |
3d6f0983 RP |
480 | fi |
481 | ||
1ca5c46c | 482 | echo '***' \(At least ${srctrigger} is missing.\) 1>&2 |
3d6f0983 RP |
483 | exit 1 |
484 | fi | |
fecd2382 | 485 | |
3d6f0983 RP |
486 | # Set up the list of links to be made. |
487 | # ${links} is the list of link names, and ${files} is the list of names to link to. | |
61907f51 | 488 | |
3d6f0983 RP |
489 | # Make the links. |
490 | while [ -n "${files}" ] ; do | |
491 | # set file to car of files, files to cdr of files | |
492 | set ${files}; file=$1; shift; files=$* | |
493 | set ${links}; link=$1; shift; links=$* | |
fecd2382 | 494 | |
3d6f0983 | 495 | if [ ! -r ${srcdir}/${file} ] ; then |
1ca5c46c RP |
496 | echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 |
497 | echo '***' "since the file \"${file}\" does not exist." 1>&2 | |
3d6f0983 RP |
498 | exit 1 |
499 | fi | |
61907f51 | 500 | |
3d6f0983 RP |
501 | ${remove} -f ${link} |
502 | rm -f config.status | |
503 | # Make a symlink if possible, otherwise try a hard link | |
504 | ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} | |
61907f51 | 505 | |
3d6f0983 | 506 | if [ ! -r ${link} ] ; then |
1ca5c46c | 507 | echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 |
3d6f0983 RP |
508 | exit 1 |
509 | fi | |
1ca5c46c RP |
510 | |
511 | if [ -n "${verbose}" ] ; then | |
512 | echo "Linked \"${link}\" to \"${srcdir}/${file}\"." | |
513 | fi | |
3d6f0983 | 514 | done |
61907f51 | 515 | |
3d6f0983 RP |
516 | # Create a .gdbinit file which runs the one in srcdir |
517 | # and tells GDB to look there for source files. | |
518 | ||
519 | case ${srcdir} in | |
520 | .) | |
521 | ;; | |
522 | *) | |
523 | echo "dir ." > .gdbinit | |
524 | echo "dir ${srcdir}" >> .gdbinit | |
525 | echo "source ${srcdir}/.gdbinit" >> .gdbinit | |
526 | ;; | |
527 | esac | |
528 | ||
529 | # Install a makefile, and make it set VPATH | |
530 | # if necessary so that the sources are found. | |
531 | # Also change its value of srcdir. | |
532 | ||
533 | # FIXME-someday: This business of always writing to .tem and mv back | |
534 | # is so that I don't screw things up while developing. Once this | |
535 | # template is stable, these should be optimized. xoxorich. | |
536 | ||
537 | # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. | |
538 | if [ "${host}" != "${target}" ] ; then | |
b81fa6a2 RP |
539 | echo "CROSS=-DCROSS_COMPILE" > ${Makefile} |
540 | echo "ALL=start.encap" >> ${Makefile} | |
3d6f0983 | 541 | else |
b81fa6a2 | 542 | echo "ALL=all.internal" > ${Makefile} |
3d6f0983 | 543 | fi |
61907f51 | 544 | |
3d6f0983 | 545 | # set target, host, VPATH |
5a168a17 RP |
546 | echo "host_alias = ${host_alias}" >> ${Makefile} |
547 | echo "host_cpu = ${host_cpu}" >> ${Makefile} | |
548 | echo "host_vendor = ${host_vendor}" >> ${Makefile} | |
549 | echo "host_os = ${host_os}" >> ${Makefile} | |
550 | ||
551 | echo "target_alias = ${target_alias}" >> ${Makefile} | |
552 | echo "target_cpu = ${target_cpu}" >> ${Makefile} | |
553 | echo "target_vendor = ${target_vendor}" >> ${Makefile} | |
554 | echo "target_os = ${target_os}" >> ${Makefile} | |
61907f51 | 555 | |
353deb84 | 556 | if [ -n "${subdirs}" ] ; then |
b81fa6a2 | 557 | echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} |
3d6f0983 | 558 | else |
b81fa6a2 | 559 | echo "subdir =" >> ${Makefile} |
3d6f0983 | 560 | fi |
61907f51 | 561 | |
b81fa6a2 RP |
562 | # echo "workdir = `pwd`" >> ${Makefile} |
563 | echo "VPATH = ${srcdir}" >> ${Makefile} | |
61907f51 | 564 | |
b81fa6a2 RP |
565 | # add "Makefile.in" (or whatever it's called) |
566 | cat ${srcdir}/${Makefile_in} >> ${Makefile} | |
fecd2382 | 567 | |
3d6f0983 | 568 | # Conditionalize the makefile for this host. |
9d1e053b | 569 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then |
5a168a17 RP |
570 | (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; |
571 | sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem | |
b81fa6a2 | 572 | mv Makefile.tem ${Makefile} |
3d6f0983 | 573 | fi |
fecd2382 | 574 | |
3d6f0983 | 575 | # Conditionalize the makefile for this target. |
9d1e053b | 576 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then |
5a168a17 RP |
577 | (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; |
578 | sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem | |
b81fa6a2 | 579 | mv Makefile.tem ${Makefile} |
3d6f0983 | 580 | fi |
61907f51 | 581 | |
3d6f0983 | 582 | # set srcdir |
b81fa6a2 RP |
583 | sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem |
584 | mv Makefile.tem ${Makefile} | |
ec342d7d | 585 | |
3d6f0983 RP |
586 | # set destdir |
587 | if [ -n "${destdir}" ] ; then | |
b81fa6a2 RP |
588 | sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem |
589 | mv Makefile.tem ${Makefile} | |
3d6f0983 | 590 | fi |
fecd2382 | 591 | |
3d6f0983 | 592 | # reset SUBDIRS |
b81fa6a2 RP |
593 | sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem |
594 | mv Makefile.tem ${Makefile} | |
fecd2382 | 595 | |
3d6f0983 | 596 | # reset NONSUBDIRS |
b81fa6a2 RP |
597 | sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem |
598 | mv Makefile.tem ${Makefile} | |
fecd2382 | 599 | |
3d6f0983 | 600 | using= |
9d1e053b RP |
601 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then |
602 | using=" using \"${host_makefile_frag}\"" | |
3d6f0983 | 603 | fi |
fecd2382 | 604 | |
5a168a17 RP |
605 | # remove any form feeds. |
606 | sed -e "s/\f//" ${Makefile} > Makefile.tem | |
607 | mv Makefile.tem ${Makefile} | |
608 | ||
9d1e053b | 609 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then |
3d6f0983 | 610 | if [ -z "${using}" ] ; then |
9d1e053b | 611 | andusing=" using \"${target_makefile_frag}\"" |
3d6f0983 | 612 | else |
9d1e053b | 613 | andusing="${using} and \"${target_makefile_frag}\"" |
3d6f0983 RP |
614 | fi |
615 | else | |
616 | andusing=${using} | |
617 | fi | |
fecd2382 | 618 | |
5a168a17 | 619 | if [ -n "${verbose}" -o -z "${recurring}" ] ; then |
1ca5c46c RP |
620 | echo "Created \"${Makefile}\"" in `pwd`${andusing}. |
621 | fi | |
b81fa6a2 RP |
622 | |
623 | #### configure.in post-target parts come in here. | |
624 | ||
625 | ## end of post-target part. | |
fecd2382 | 626 | |
5a168a17 RP |
627 | # describe the chosen configuration in config.status. |
628 | # Make that file a shellscript which will reestablish | |
629 | # the same configuration. Used in Makefiles to rebuild | |
630 | # Makefiles. | |
631 | ||
632 | echo "#!/bin/sh | |
633 | # ${srcname} was configured as follows: | |
634 | ${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status | |
635 | chmod a+x config.status | |
3d6f0983 RP |
636 | |
637 | originaldir=`pwd` | |
638 | cd ${srcdir} | |
639 | fi | |
b678740d RP |
640 | |
641 | # If there are subdirectories, then recurse. | |
5a168a17 | 642 | if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then |
b678740d RP |
643 | for configdir in ${configdirs} ; do |
644 | if [ -n "${verbose}" ] ; then | |
645 | echo Configuring ${configdir}... | |
646 | fi | |
647 | ||
648 | if [ -d ${configdir} ] ; then | |
649 | (cd ${configdir} ; | |
5a168a17 | 650 | ./configure +recurring ${host_alias} +target=${target_alias} \ |
b678740d RP |
651 | ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ |
652 | | sed 's/^/ /' | |
653 | else | |
654 | if [ -n "${verbose}" ] ; then | |
655 | echo Warning: directory \"${configdir}\" is missing. | |
656 | fi | |
657 | fi | |
658 | done | |
659 | fi | |
c4220303 RP |
660 | done # for each target |
661 | ||
b81fa6a2 | 662 | # Now build a Makefile for this host. |
353deb84 | 663 | if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then |
b81fa6a2 RP |
664 | cd ${hostsubdir} |
665 | cat > GNUmakefile << E!O!F | |
5a168a17 | 666 | # Makefile generated by configure for host ${host_alias}. |
b81fa6a2 RP |
667 | |
668 | ALL := $(shell ls -d Target-*) | |
669 | ||
670 | %: | |
671 | $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true | |
672 | ||
673 | all: | |
674 | E!O!F | |
675 | cd .. | |
676 | fi | |
c4220303 | 677 | done # for each host |
fecd2382 | 678 | |
fecd2382 | 679 | exit 0 |
74cc5508 | 680 | |
3d6f0983 RP |
681 | # |
682 | # Local Variables: | |
683 | # fill-column: 131 | |
684 | # End: | |
685 | # | |
74cc5508 | 686 | |
5a168a17 | 687 | # end of configure |