]>
Commit | Line | Data |
---|---|---|
3f86071f RP |
1 | #!/bin/sh |
2 | ||
5a168a17 | 3 | # Configuration script |
3f86071f RP |
4 | # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. |
5 | ||
6 | #This file is part of GNU. | |
7 | ||
c65cca22 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. */ | |
3f86071f RP |
21 | |
22 | # $Id$ | |
23 | ||
24 | # | |
25 | # Shell script to create proper links to machine-dependent files in | |
26 | # preparation for compilation. | |
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 | ||
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 | ||
42 | progname=$0 | |
43 | ||
44 | # clear some things potentially inherited from environment. | |
45 | ansi= | |
5a168a17 | 46 | arguments=$* |
3f86071f RP |
47 | defaulttargets= |
48 | destdir= | |
49 | fatal= | |
50 | hostsubdir= | |
c65cca22 JG |
51 | Makefile=Makefile |
52 | Makefile_in=Makefile.in | |
5a168a17 RP |
53 | norecursion= |
54 | recurring= | |
3f86071f RP |
55 | removing= |
56 | srcdir= | |
57 | srctrigger= | |
58 | target= | |
59 | targets= | |
f0b9c976 | 60 | commontargets= |
5a168a17 | 61 | configdirs= |
3f86071f RP |
62 | targetsubdir= |
63 | template= | |
64 | verbose= | |
65 | ||
66 | for arg in $*; | |
67 | do | |
68 | case ${arg} in | |
f0b9c976 | 69 | -ansi | +a*) |
3f86071f | 70 | ansi=true |
f0b9c976 | 71 | clib=clib |
3f86071f RP |
72 | ;; |
73 | -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) | |
74 | destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` | |
75 | ;; | |
3f86071f RP |
76 | -languages=* | +languages=* | +language=* | +languag=* \ |
77 | | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ | |
78 | | +l=*) | |
79 | languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" | |
80 | ;; | |
f0b9c976 | 81 | -gas | +g*) |
3f86071f RP |
82 | gas=yes |
83 | ;; | |
f0b9c976 | 84 | -help | +h*) |
3f86071f RP |
85 | fatal=true |
86 | ;; | |
f0b9c976 | 87 | -nfp | +nf*) |
3f86071f RP |
88 | nfp=yes |
89 | ;; | |
5a168a17 RP |
90 | -norecursion | +no*) |
91 | norecursion=true | |
3f86071f | 92 | ;; |
5a168a17 RP |
93 | -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) |
94 | recurring=true | |
9f267380 | 95 | ;; |
5a168a17 | 96 | -rm | +rm) |
3f86071f RP |
97 | removing=${arg} |
98 | ;; | |
99 | # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) | |
100 | # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` | |
101 | # ;; | |
f0b9c976 RP |
102 | -subdirs | +f* | +su*) |
103 | subdirs=${arg} | |
104 | ;; | |
105 | -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) | |
3f86071f | 106 | if [ -n "${targets}" ] ; then |
f0b9c976 | 107 | subdirs="+subdirs" |
3f86071f RP |
108 | fi |
109 | ||
110 | newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" | |
111 | targets="${newtargets}" | |
112 | ;; | |
f0b9c976 | 113 | -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) |
3f86071f RP |
114 | template=`echo ${arg} | sed 's/[+-]template=//'` |
115 | ;; | |
f0b9c976 | 116 | -v | -verbose | +v*) |
3f86071f RP |
117 | verbose=${arg} |
118 | ;; | |
119 | -* | +*) | |
120 | (echo ; | |
121 | echo "Unrecognized option: \"${arg}\"". ; | |
9f267380 | 122 | echo) 1>&2 |
3f86071f RP |
123 | fatal=true |
124 | ;; | |
125 | *) | |
126 | if [ -n "${hosts}" ] ; then | |
f0b9c976 | 127 | subdirs="+subdirs" |
3f86071f RP |
128 | fi |
129 | ||
130 | newhosts="${hosts} ${arg}" | |
131 | hosts=${newhosts} | |
132 | ;; | |
133 | esac | |
134 | done | |
135 | ||
136 | if [ -n "${verbose}" ] ; then | |
137 | echo `pwd`/configure $* | |
3f86071f RP |
138 | fi |
139 | ||
140 | # process host and target only if not rebuilding configure itself or removing. | |
141 | if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then | |
142 | # Complain if an arg is missing | |
143 | if [ -z "${hosts}" ] ; then | |
144 | (echo ; | |
145 | echo "configure: No HOST specified." ; | |
9f267380 | 146 | echo) 1>&2 |
3f86071f RP |
147 | fatal=true |
148 | fi | |
149 | fi | |
150 | ||
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]" ; | |
f0b9c976 | 157 | echo " +subdirs configure in subdirectories. [in source directories]" ; |
3f86071f 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]" ; |
3f86071f 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." ; | |
f0b9c976 | 168 | echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; |
9f267380 | 169 | echo "options given will apply to all targets.") 1>&2 |
3f86071f RP |
170 | |
171 | if [ -r config.status ] ; then | |
172 | cat config.status | |
173 | fi | |
174 | ||
175 | exit 1 | |
176 | fi | |
177 | ||
178 | #### configure.in common parts come in here. | |
179 | # This file is a shell script fragment that supplies the information | |
180 | # necessary to tailor a template configure script into the configure | |
181 | # script appropriate for this directory. For more information, check | |
182 | # any existing configure script. | |
183 | ||
184 | configdirs= | |
185 | srctrigger=readline.c | |
186 | srcname="the readline library" | |
187 | ||
188 | ## end of common part. | |
189 | ||
190 | # are we rebuilding config itself? | |
191 | if [ -n "${template}" ] ; then | |
192 | if [ ! -r ${template} ] ; then | |
9f267380 | 193 | echo '***' "Can't find template ${template}." 1>&2 |
3f86071f RP |
194 | exit 1 |
195 | fi | |
196 | ||
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.' \ | |
c65cca22 JG |
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.' \ | |
3f86071f RP |
210 | < ${template} > template.new |
211 | ||
212 | if [ -r configure.in ] ; then | |
213 | if [ -z "`grep '^# per\-host:' configure.in`" ] ; then | |
9f267380 | 214 | echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 |
3f86071f RP |
215 | exit 1 |
216 | fi | |
217 | ||
218 | if [ -z "`grep '^# per\-target:' configure.in`" ] ; then | |
9f267380 | 219 | echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 |
3f86071f RP |
220 | exit 1 |
221 | fi | |
222 | ||
c65cca22 JG |
223 | # split configure.in into common, per-host, per-target, |
224 | # and post-target parts. Post-target is optional. | |
3f86071f 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 | |
c65cca22 JG |
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 | |
3f86071f RP |
234 | |
235 | # and insert them | |
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' \ | |
c65cca22 | 239 | -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ |
3f86071f RP |
240 | template.new > configure.new |
241 | ||
c65cca22 | 242 | rm -f configure.com configure.tgt configure.hst configure.pos |
3f86071f RP |
243 | else |
244 | echo Warning: no configure.in in `pwd` | |
245 | cat ${template} >> configure | |
246 | fi | |
247 | ||
248 | chmod a+x configure.new | |
249 | rm template.new | |
250 | # mv configure configure.old | |
251 | mv configure.new configure | |
f0b9c976 RP |
252 | |
253 | if [ -n "${verbose}" ] ; then | |
254 | echo Rebuilt configure in `pwd` | |
255 | fi | |
3f86071f | 256 | |
9f267380 SG |
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 | |
267 | ||
5a168a17 RP |
268 | if [ -z "${norecursion}" ] ; then |
269 | # If template is relative path, make it absolute for recurring. | |
c65cca22 JG |
270 | if echo "${template}" | grep -s '^/' ; then |
271 | true | |
272 | else | |
273 | template=`pwd`/${template} | |
274 | fi | |
275 | ||
3f86071f RP |
276 | while [ -n "${configdirs}" ] ; do |
277 | # set configdir to car of configdirs, configdirs to cdr of configdirs | |
278 | set ${configdirs}; configdir=$1; shift; configdirs=$* | |
279 | ||
280 | if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then | |
281 | targetspecificdirs=${configdir}.* | |
282 | else | |
283 | targetspecificdirs= | |
284 | fi | |
285 | ||
286 | for i in ${configdir} ${targetspecificdirs} ; do | |
287 | if [ -d $i ] ; then | |
288 | if [ -r $i/configure ] ; then | |
289 | (cd $i ; | |
290 | ./configure +template=${template} ${verbose}) | |
291 | else | |
f0b9c976 | 292 | echo Warning: No configure script in `pwd`/$i |
3f86071f RP |
293 | fi |
294 | else | |
9f267380 SG |
295 | if [ -n "${verbose}" ] ; then |
296 | echo Warning: directory $i is missing. | |
297 | fi | |
3f86071f RP |
298 | fi |
299 | done | |
300 | done | |
301 | fi | |
302 | ||
303 | exit 0 | |
304 | fi | |
305 | ||
306 | # some sanity checks on configure.in | |
307 | if [ -z "${srctrigger}" ] ; then | |
f0b9c976 | 308 | echo Warning: srctrigger not set in configure.in. `pwd` not configured. |
3f86071f RP |
309 | exit 1 |
310 | fi | |
311 | ||
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 | |
318 | ||
5a168a17 RP |
319 | host_alias=${host} |
320 | ||
9f267380 SG |
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 | ||
3f86071f RP |
328 | #### configure.in per-host parts come in here. |
329 | ||
9f267380 SG |
330 | case "${host_os}" in |
331 | sysv* | irix*) host_makefile_frag=config/hmake-sysv ;; | |
332 | esac | |
333 | ||
3f86071f RP |
334 | ## end of per-host part. |
335 | ||
3f86071f RP |
336 | for target in ${targets} ; do |
337 | ||
5a168a17 | 338 | target_alias=${target} |
9f267380 SG |
339 | result=`/bin/sh ./config.sub ${target}` |
340 | target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` | |
341 | target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` | |
342 | target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` | |
343 | target=${target_cpu}-${target_vendor}-${target_os} | |
6c18e393 RP |
344 | target_makefile_frag=config/tmake-${target} |
345 | ||
3f86071f RP |
346 | #### configure.in per-target parts come in here. |
347 | ||
348 | ## end of per-target part. | |
349 | ||
350 | # Temporarily, we support only direct subdir builds. | |
5a168a17 RP |
351 | hostsubdir=H-${host_alias} |
352 | targetsubdir=T-${target_alias} | |
3f86071f RP |
353 | |
354 | if [ -n "${removing}" ] ; then | |
f0b9c976 | 355 | if [ -n "${subdirs}" ] ; then |
3f86071f RP |
356 | if [ -d "${hostsubdir}" ] ; then |
357 | rm -rf ${hostsubdir}/${targetsubdir} | |
358 | ||
f0b9c976 | 359 | if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then |
3f86071f RP |
360 | rm -rf ${hostsubdir} |
361 | fi | |
362 | else | |
363 | echo Warning: no `pwd`/${hostsubdir} to remove. | |
364 | fi | |
365 | else | |
c65cca22 | 366 | rm -f ${Makefile} config.status ${links} |
3f86071f RP |
367 | fi |
368 | else | |
f0b9c976 | 369 | if [ -n "${subdirs}" ] ; then |
3f86071f | 370 | # check for existing status before allowing forced subdirs. |
c65cca22 | 371 | if [ -f ${Makefile} ] ; then |
9f267380 | 372 | echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 |
3f86071f RP |
373 | exit 1 |
374 | fi | |
375 | ||
376 | if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi | |
377 | cd ${hostsubdir} | |
378 | ||
f0b9c976 RP |
379 | if [ ! -d ${targetsubdir} ] ; then |
380 | if [ -z "${commontargets}" ] ; then | |
381 | mkdir ${targetsubdir} | |
382 | else | |
383 | if [ ! -d Target-independent ] ; then | |
384 | mkdir Target-independent | |
385 | fi | |
386 | ||
387 | ${symbolic_link} Target-independent ${targetsubdir} | |
388 | fi # if target independent | |
389 | fi # if no target dir yet | |
390 | ||
3f86071f RP |
391 | cd ${targetsubdir} |
392 | ||
393 | srcdir=../.. | |
394 | else | |
395 | # if not subdir builds, then make sure none exist. | |
396 | if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then | |
9f267380 | 397 | echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 |
3f86071f RP |
398 | exit 1 |
399 | fi | |
400 | fi | |
401 | ||
402 | # Find the source files, if location was not specified. | |
403 | if [ -z "${srcdir}" ] ; then | |
404 | srcdirdefaulted=1 | |
405 | srcdir=. | |
406 | if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then | |
407 | srcdir=.. | |
408 | fi | |
409 | fi | |
410 | ||
411 | if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then | |
412 | if [ -z "${srcdirdefaulted}" ] ; then | |
9f267380 | 413 | echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 |
3f86071f | 414 | else |
9f267380 | 415 | echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 |
3f86071f RP |
416 | fi |
417 | ||
9f267380 | 418 | echo '***' \(At least ${srctrigger} is missing.\) 1>&2 |
3f86071f RP |
419 | exit 1 |
420 | fi | |
421 | ||
422 | # Set up the list of links to be made. | |
423 | # ${links} is the list of link names, and ${files} is the list of names to link to. | |
424 | ||
425 | # Make the links. | |
426 | while [ -n "${files}" ] ; do | |
427 | # set file to car of files, files to cdr of files | |
428 | set ${files}; file=$1; shift; files=$* | |
429 | set ${links}; link=$1; shift; links=$* | |
430 | ||
431 | if [ ! -r ${srcdir}/${file} ] ; then | |
9f267380 SG |
432 | echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 |
433 | echo '***' "since the file \"${file}\" does not exist." 1>&2 | |
3f86071f RP |
434 | exit 1 |
435 | fi | |
436 | ||
437 | ${remove} -f ${link} | |
438 | rm -f config.status | |
439 | # Make a symlink if possible, otherwise try a hard link | |
440 | ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} | |
441 | ||
442 | if [ ! -r ${link} ] ; then | |
9f267380 | 443 | echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 |
3f86071f RP |
444 | exit 1 |
445 | fi | |
f0b9c976 RP |
446 | |
447 | if [ -n "${verbose}" ] ; then | |
448 | echo "Linked \"${link}\" to \"${srcdir}/${file}\"." | |
449 | fi | |
3f86071f RP |
450 | done |
451 | ||
452 | # Create a .gdbinit file which runs the one in srcdir | |
453 | # and tells GDB to look there for source files. | |
454 | ||
455 | case ${srcdir} in | |
456 | .) | |
457 | ;; | |
458 | *) | |
459 | echo "dir ." > .gdbinit | |
460 | echo "dir ${srcdir}" >> .gdbinit | |
461 | echo "source ${srcdir}/.gdbinit" >> .gdbinit | |
462 | ;; | |
463 | esac | |
464 | ||
465 | # Install a makefile, and make it set VPATH | |
466 | # if necessary so that the sources are found. | |
467 | # Also change its value of srcdir. | |
468 | ||
469 | # FIXME-someday: This business of always writing to .tem and mv back | |
470 | # is so that I don't screw things up while developing. Once this | |
471 | # template is stable, these should be optimized. xoxorich. | |
472 | ||
473 | # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. | |
474 | if [ "${host}" != "${target}" ] ; then | |
c65cca22 JG |
475 | echo "CROSS=-DCROSS_COMPILE" > ${Makefile} |
476 | echo "ALL=start.encap" >> ${Makefile} | |
3f86071f | 477 | else |
c65cca22 | 478 | echo "ALL=all.internal" > ${Makefile} |
3f86071f RP |
479 | fi |
480 | ||
481 | # set target, host, VPATH | |
5a168a17 RP |
482 | echo "host_alias = ${host_alias}" >> ${Makefile} |
483 | echo "host_cpu = ${host_cpu}" >> ${Makefile} | |
484 | echo "host_vendor = ${host_vendor}" >> ${Makefile} | |
485 | echo "host_os = ${host_os}" >> ${Makefile} | |
486 | ||
487 | echo "target_alias = ${target_alias}" >> ${Makefile} | |
488 | echo "target_cpu = ${target_cpu}" >> ${Makefile} | |
489 | echo "target_vendor = ${target_vendor}" >> ${Makefile} | |
490 | echo "target_os = ${target_os}" >> ${Makefile} | |
3f86071f | 491 | |
f0b9c976 | 492 | if [ -n "${subdirs}" ] ; then |
c65cca22 | 493 | echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} |
3f86071f | 494 | else |
c65cca22 | 495 | echo "subdir =" >> ${Makefile} |
3f86071f RP |
496 | fi |
497 | ||
c65cca22 JG |
498 | # echo "workdir = `pwd`" >> ${Makefile} |
499 | echo "VPATH = ${srcdir}" >> ${Makefile} | |
3f86071f | 500 | |
c65cca22 JG |
501 | # add "Makefile.in" (or whatever it's called) |
502 | cat ${srcdir}/${Makefile_in} >> ${Makefile} | |
3f86071f | 503 | |
3f86071f RP |
504 | # Conditionalize the makefile for this host. |
505 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then | |
5a168a17 RP |
506 | (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; |
507 | sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem | |
c65cca22 | 508 | mv Makefile.tem ${Makefile} |
3f86071f RP |
509 | fi |
510 | ||
511 | # Conditionalize the makefile for this target. | |
512 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then | |
5a168a17 RP |
513 | (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; |
514 | sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem | |
c65cca22 | 515 | mv Makefile.tem ${Makefile} |
3f86071f RP |
516 | fi |
517 | ||
518 | # set srcdir | |
c65cca22 JG |
519 | sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem |
520 | mv Makefile.tem ${Makefile} | |
3f86071f RP |
521 | |
522 | # set destdir | |
523 | if [ -n "${destdir}" ] ; then | |
c65cca22 JG |
524 | sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem |
525 | mv Makefile.tem ${Makefile} | |
3f86071f RP |
526 | fi |
527 | ||
3f86071f | 528 | # reset SUBDIRS |
c65cca22 JG |
529 | sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem |
530 | mv Makefile.tem ${Makefile} | |
3f86071f RP |
531 | |
532 | # reset NONSUBDIRS | |
c65cca22 JG |
533 | sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem |
534 | mv Makefile.tem ${Makefile} | |
3f86071f RP |
535 | |
536 | using= | |
537 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then | |
538 | using=" using \"${host_makefile_frag}\"" | |
539 | fi | |
540 | ||
5a168a17 RP |
541 | # remove any form feeds. |
542 | sed -e "s/\f//" ${Makefile} > Makefile.tem | |
543 | mv Makefile.tem ${Makefile} | |
544 | ||
3f86071f RP |
545 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then |
546 | if [ -z "${using}" ] ; then | |
547 | andusing=" using \"${target_makefile_frag}\"" | |
548 | else | |
549 | andusing="${using} and \"${target_makefile_frag}\"" | |
550 | fi | |
551 | else | |
552 | andusing=${using} | |
553 | fi | |
554 | ||
5a168a17 | 555 | if [ -n "${verbose}" -o -z "${recurring}" ] ; then |
f0b9c976 RP |
556 | echo "Created \"${Makefile}\"" in `pwd`${andusing}. |
557 | fi | |
c65cca22 JG |
558 | |
559 | #### configure.in post-target parts come in here. | |
560 | ||
561 | ## end of post-target part. | |
3f86071f | 562 | |
5a168a17 RP |
563 | # describe the chosen configuration in config.status. |
564 | # Make that file a shellscript which will reestablish | |
565 | # the same configuration. Used in Makefiles to rebuild | |
566 | # Makefiles. | |
567 | ||
568 | echo "#!/bin/sh | |
569 | # ${srcname} was configured as follows: | |
570 | ${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status | |
571 | chmod a+x config.status | |
3f86071f RP |
572 | |
573 | originaldir=`pwd` | |
574 | cd ${srcdir} | |
575 | fi | |
9f267380 SG |
576 | |
577 | # If there are subdirectories, then recurse. | |
5a168a17 | 578 | if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then |
9f267380 SG |
579 | for configdir in ${configdirs} ; do |
580 | if [ -n "${verbose}" ] ; then | |
581 | echo Configuring ${configdir}... | |
582 | fi | |
583 | ||
584 | if [ -d ${configdir} ] ; then | |
585 | (cd ${configdir} ; | |
5a168a17 | 586 | ./configure +recurring ${host_alias} +target=${target_alias} \ |
9f267380 SG |
587 | ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ |
588 | | sed 's/^/ /' | |
589 | else | |
590 | if [ -n "${verbose}" ] ; then | |
591 | echo Warning: directory \"${configdir}\" is missing. | |
592 | fi | |
593 | fi | |
594 | done | |
595 | fi | |
3f86071f RP |
596 | done # for each target |
597 | ||
4101d868 | 598 | # Now build a Makefile for this host. |
f0b9c976 | 599 | if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then |
4101d868 RP |
600 | cd ${hostsubdir} |
601 | cat > GNUmakefile << E!O!F | |
5a168a17 | 602 | # Makefile generated by configure for host ${host_alias}. |
4101d868 RP |
603 | |
604 | ALL := $(shell ls -d Target-*) | |
605 | ||
606 | %: | |
607 | $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true | |
608 | ||
609 | all: | |
610 | E!O!F | |
611 | cd .. | |
612 | fi | |
3f86071f RP |
613 | done # for each host |
614 | ||
3f86071f RP |
615 | exit 0 |
616 | ||
3f86071f RP |
617 | # |
618 | # Local Variables: | |
619 | # fill-column: 131 | |
620 | # End: | |
621 | # | |
622 | ||
5a168a17 | 623 | # end of configure |