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