Now handles multiple hosts and targets.
[deliverable/binutils-gdb.git] / gdb / configure
1 #!/bin/sh
2 # Please do not edit this file. It is generated automatically from
3 # configure.in and a configure template.
4 configdirs=
5
6 #!/bin/sh
7
8 # Configuration script template
9 # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc.
10
11 #This file is part of GNU.
12
13 #GNU CC is free software; you can redistribute it and/or modify
14 #it under the terms of the GNU General Public License as published by
15 #the Free Software Foundation; either version 1, or (at your option)
16 #any later version.
17
18 #GNU CC is distributed in the hope that it will be useful,
19 #but WITHOUT ANY WARRANTY; without even the implied warranty of
20 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 #GNU General Public License for more details.
22
23 #You should have received a copy of the GNU General Public License
24 #along with GNU CC; see the file COPYING. If not, write to
25 #the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 # $Id$
28
29 #
30 # Shell script to create proper links to machine-dependent files in
31 # preparation for compilation.
32 #
33 # If configure succeeds, it leaves its status in config.status.
34 # If configure fails after disturbing the status quo,
35 # config.status is removed.
36 #
37
38 remove=rm
39 hard_link=ln
40 symbolic_link='ln -s'
41
42 #for Test
43 #remove="echo rm"
44 #hard_link="echo ln"
45 #symbolic_link="echo ln -s"
46
47 # clear some things potentially inherited from environment.
48 ansi=
49 destdir=
50 fatal=
51 hostsubdir=
52 norecurse=
53 removing=
54 srcdir=
55 srctrigger=
56 target=
57 targets=
58 targetsubdir=
59 template=
60 verbose=
61
62 for arg in $*;
63 do
64 case ${arg} in
65 -ansi | +ansi)
66 ansi=true
67 ;;
68 -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*)
69 destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
70 ;;
71 -forcesubdirs | +forcesubdirs | +f)
72 forcesubdirs=${arg}
73 ;;
74 -languages=* | +languages=* | +language=* | +languag=* \
75 | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
76 | +l=*)
77 languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
78 ;;
79 -gas | +gas | +ga | +g)
80 gas=yes
81 ;;
82 -help | +h | +help)
83 fatal=true
84 ;;
85 -nfp | +nfp | +nf | +n)
86 nfp=yes
87 ;;
88 -norecurse | +norecurse)
89 norecurse=true
90 ;;
91 -rm | +rm)
92 removing=${arg}
93 ;;
94 # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
95 # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
96 # ;;
97 -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=* | +t=*)
98 if [ -n "${targets}" ] ; then
99 forcesubdirs="+forcesubdirs"
100 fi
101
102 newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
103 targets="${newtargets}"
104 ;;
105 -template=* | +template=*)
106 template=`echo ${arg} | sed 's/[+-]template=//'`
107 ;;
108 +verbose | +verbos | +verbo | +verb | +ver | +ve | +v)
109 verbose=${arg}
110 ;;
111 -* | +*)
112 (echo ;
113 echo "Unrecognized option: \"${arg}\"". ;
114 echo) 1>&2
115 fatal=true
116 ;;
117 *)
118 if [ -n "${hosts}" ] ; then
119 forcesubdirs="+forcesubdirs"
120 fi
121
122 newhosts="${hosts} ${arg}"
123 hosts=${newhosts}
124 ;;
125 esac
126 done
127
128 if [ -n "${verbose}" ] ; then
129 echo `pwd`/configure $*
130 echo targets=\"${targets}\"
131 fi
132
133 # process host and target only if not rebuilding configure itself or removing.
134 if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then
135 # Complain if an arg is missing
136 if [ -z "${hosts}" ] ; then
137 (echo ;
138 echo "configure: No HOST specified." ;
139 echo) 2>&1
140 fatal=true
141 fi
142 fi
143
144 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
145 (echo "Usage: configure HOST" ;
146 echo ;
147 echo "Options: [defaults in brackets]" ;
148 echo " +ansi configure w/ANSI library. [no ansi lib]" ;
149 echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ;
150 echo " +forcesubdirs configure in subdirectories. [in source directories]" ;
151 echo " +lang=LANG configure to build LANG. [gcc]" ;
152 echo " +help print this message. [normal config]" ;
153 echo " +gas configure the compilers for use with gas. [native as]" ;
154 echo " +nfp configure the compilers default to soft floating point. [hard float]" ;
155 echo " +norecurse configure this directory only. [recurse]" ;
156 echo " +rm remove this configuration. [build a configuration]" ;
157 echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ;
158 echo " +template=TEM rebuild configure using TEM. [normal config]" ;
159 echo ;
160 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
161 echo "Asking for more than one \"+target\" implies \"+forcesubdirs\". Any other" ;
162 echo "options given will apply to all targets.") 1>&2
163
164 if [ -r config.status ] ; then
165 cat config.status
166 fi
167
168 exit 1
169 fi
170
171 #### configure.in common parts come in here.
172 # This file is a shell script fragment that supplies the information
173 # necessary to tailor a template configure script into the configure
174 # script appropriate for this directory. For more information, check
175 # any existing configure script.
176
177 configdirs="bfd binutils ld gas gnulib gcc clib"
178 srctrigger=README.configure
179 srcname="gnu development package"
180
181 # per-host:
182
183 ## end of common part
184
185 # are we rebuilding config itself?
186 if [ -n "${template}" ] ; then
187 if [ ! -r ${template} ] ; then
188 echo "Can't find template ${template}."
189 exit 1
190 fi
191
192 mv configure configure.old
193 echo "#!/bin/sh" > configure
194 echo "# Please do not edit this file. It is generated automatically from" >> configure
195 echo "# configure.in and a configure template." >> configure
196 echo "configdirs=" >> configure
197 echo >> configure
198
199 if [ -r configure.in ] ; then
200 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
201 echo `pwd`/configure.in has no "per-host:" line.
202 exit 1
203 fi
204
205 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
206 echo `pwd`/configure.in has no "per-target:" line.
207 exit 1
208 fi
209
210 sed -e '/^# per\-target:/,$d' configure.in > configure.com
211 sed -e '1,/^# per\-target:/d' configure.in > configure.tgt
212
213 sed -e '/^#### configure.in common parts/ r configure.com' \
214 -e '/^##### / r configure.tgt' \
215 ${template} >> configure
216
217 rm -f configure.top configure.bot
218 else
219 echo Warning: no configure.in in `pwd`
220 cat ${template} >> configure
221 fi
222
223 chmod a+x configure
224 rm configure.old
225 echo Rebuilt configure in `pwd`
226
227 if [ -z "${norecurse}" ] ; then
228 while [ -n "${configdirs}" ] ; do
229 # set configdir to car of configdirs, configdirs to cdr of configdirs
230 set ${configdirs}; configdir=$1; shift; configdirs=$*
231
232 if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
233 targetspecificdirs=${configdir}.*
234 else
235 targetspecificdirs=
236 fi
237
238 for i in ${configdir} ${targetspecificdirs} ; do
239 if [ -r $i/configure ] ; then
240 (cd $i ;
241 ./configure +template=${template} ${verbose})
242 else
243 echo No configure script in `pwd`/$i
244 fi
245 done
246 done
247 fi
248
249 exit 0
250 fi
251
252 # some sanity checks on configure.in
253 if [ -z "${srctrigger}" ] ; then
254 echo srctrigger not set in configure.in. `pwd` not configured.
255 exit 1
256 fi
257
258 for host in ${hosts} ; do
259 # Default other arg
260 if [ -z "${targets}" ] ; then
261 targets=${host}
262 fi
263
264 #### configure.in per-host parts come in here.
265 ## end of per-target part
266
267
268 for target in ${targets} ; do
269
270 if [ -n "${verbose}" ] ; then
271 echo " "target=\"${target}\"
272 fi
273
274 #### configure.in per-target parts come in here.
275 ## end of per-target part
276
277 # Temporarily, we support only direct subdir builds.
278 hostsubdir=Host-${host}
279 targetsubdir=Target-${target}
280
281 if [ -n "${removing}" ] ; then
282 if [ -d "${hostsubdir}/${targetsubdir}" ] ; then
283 rm -rf ${hostsubdir}/${targetsubdir}
284
285 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ] ; then
286 rm -rf ${hostsubdir}
287 fi
288 else
289 rm -f Makefile config.status ${links}
290 fi
291 else
292 if [ -n "${forcesubdirs}" ] ; then
293 # check for existing status before allowing forced subdirs.
294 if [ -f Makefile ] ; then
295 echo "Makefile already exists in source directory. `pwd` not configured."
296 exit 1
297 fi
298
299 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
300 cd ${hostsubdir}
301
302 if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi
303 cd ${targetsubdir}
304
305 srcdir=../..
306 else
307 # if not subdir builds, then make sure none exist.
308 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
309 echo "Configured subdirs exist. `pwd` not configured."
310 exit 1
311 fi
312 fi
313
314 # Find the source files, if location was not specified.
315 if [ -z "${srcdir}" ] ; then
316 srcdirdefaulted=1
317 srcdir=.
318 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
319 srcdir=..
320 fi
321 fi
322
323 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
324 if [ -z "${srcdirdefaulted}" ] ; then
325 echo "${progname}: Can't find ${srcname} sources in \`${srcdir}'." 1>&2
326 else
327 echo "${progname}: Can't find ${srcname} sources in \`.' or \`..'." 1>&2
328 fi
329
330 exit 1
331 fi
332
333 # Set up the list of links to be made.
334 # ${links} is the list of link names, and ${files} is the list of names to link to.
335
336 # Make the links.
337 while [ -n "${files}" ] ; do
338 # set file to car of files, files to cdr of files
339 set ${files}; file=$1; shift; files=$*
340 set ${links}; link=$1; shift; links=$*
341
342 if [ ! -r ${srcdir}/${file} ] ; then
343 echo "${progname}: cannot create a link \"${link}\"," 1>&2
344 echo "since the file \"${file}\" does not exist." 1>&2
345 exit 1
346 fi
347
348 ${remove} -f ${link}
349 rm -f config.status
350 # Make a symlink if possible, otherwise try a hard link
351 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
352
353 if [ ! -r ${link} ] ; then
354 echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
355 exit 1
356 fi
357 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
358 done
359
360 # Create a .gdbinit file which runs the one in srcdir
361 # and tells GDB to look there for source files.
362
363 case ${srcdir} in
364 .)
365 ;;
366 *)
367 echo "dir ." > .gdbinit
368 echo "dir ${srcdir}" >> .gdbinit
369 echo "source ${srcdir}/.gdbinit" >> .gdbinit
370 ;;
371 esac
372
373 # Install a makefile, and make it set VPATH
374 # if necessary so that the sources are found.
375 # Also change its value of srcdir.
376
377 # FIXME-someday: This business of always writing to .tem and mv back
378 # is so that I don't screw things up while developing. Once this
379 # template is stable, these should be optimized. xoxorich.
380
381 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
382 if [ "${host}" != "${target}" ] ; then
383 echo "CROSS=-DCROSS_COMPILE" > Makefile
384 echo "ALL=start.encap" >> Makefile
385 else
386 echo "ALL=all.internal" > Makefile
387 fi
388
389 # set target, host, VPATH
390 echo "host = ${host}" >> Makefile
391 echo "target = ${target}" >> Makefile
392
393 if [ -n "${forcesubdirs}" ] ; then
394 echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile
395 else
396 echo "subdir =" >> Makefile
397 fi
398
399 # echo "workdir = `pwd`" >> Makefile
400 echo "VPATH = ${srcdir}" >> Makefile
401
402 # add Makefile.in
403 cat ${srcdir}/Makefile.in >> Makefile
404
405 # and shake thoroughly.
406 host_var_file=hmake-${host}
407 target_var_file=tmake-${target}
408
409 # Conditionalize the makefile for this host.
410 if [ -f ${srcdir}/config/${host_var_file} ] ; then
411 sed -e "/^####/ r ${srcdir}/config/${host_var_file}" Makefile > Makefile.tem
412 mv Makefile.tem Makefile
413 fi
414
415 # Conditionalize the makefile for this target.
416 if [ -f ${srcdir}/config/${target_var_file} ] ; then
417 sed -e "/^####/ r ${srcdir}/config/${target_var_file}" Makefile > Makefile.tem
418 mv Makefile.tem Makefile
419 fi
420
421 # set srcdir
422 sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem
423 mv Makefile.tem Makefile
424
425 # set destdir
426 if [ -n "${destdir}" ] ; then
427 sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem
428 mv Makefile.tem Makefile
429 fi
430
431 # Remove all formfeeds, since some Makes get confused by them.
432 sed "s/\f//" Makefile >> Makefile.tem
433 mv Makefile.tem Makefile
434
435 # reset SUBDIRS
436 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem
437 mv Makefile.tem Makefile
438
439 # reset NONSUBDIRS
440 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem
441 mv Makefile.tem Makefile
442
443 using=
444 if [ -f ${srcdir}/config/${host_var_file} ] ; then
445 using=" using \"${host_var_file}\""
446 fi
447
448 if [ -f ${srcdir}/config/${target_var_file} ] ; then
449 if [ -z "${using}" ] ; then
450 andusing=" using \"${target_var_file}\""
451 else
452 andusing="${using} and \"${target_var_file}\""
453 fi
454 else
455 andusing=${using}
456 fi
457
458 echo "Created \"Makefile\"" in `pwd`${andusing}.
459
460 if [ "${host}" = "${target}" ] ; then
461 echo "Links are now set up for use with a ${target}." \
462 > config.status
463 # | tee ${srcdir}/config.status
464 else
465 echo "Links are now set up for host ${host} and target ${target}." \
466 > config.status
467 # | tee ${srcdir}/config.status
468 fi
469
470 originaldir=`pwd`
471 cd ${srcdir}
472 fi
473 done
474 done
475
476 # If there are subdirectories, then recurse.
477
478 if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi
479
480 # configdirs is not null
481 for configdir in ${configdirs} ; do
482 echo Configuring ${configdir}...
483 specifics=
484 commons=
485
486 for target in ${targets} ; do
487 # check for target specific dir override
488 if [ -d ${configdir}.${target} ] ; then
489 newspecifics="${specifics} ${target}"
490 specifics=${newspecifics}
491 else
492 newcommons="${commons} +target=${target}"
493 commons=${newcommons}
494 fi
495
496 done
497
498 if [ -n "${verbose}" ] ; then
499 echo " "commons=\"${commons}\"
500 echo " "specifics=\"${specifics}\"
501 fi
502
503 if [ -n "${commons}" ] ; then
504 (cd ${configdir} ;
505 ./configure ${host} ${verbose} ${forcesubdirs} ${removing} ${commons}) \
506 | sed 's/^/ /'
507 fi
508
509 if [ -n "${specifics}" ] ; then
510 for target in ${specifics} ; do
511 echo Configuring target specific directory ${configdir}.${target}...
512 (cd ${configdir}.${target} ;
513 ./configure ${host} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \
514 | sed 's/^/ /'
515 done
516 fi
517 done
518
519 exit 0
520
521 #
522 # $Log$
523 # Revision 1.2 1991/04/15 23:46:48 rich
524 # Now handles multiple hosts and targets.
525 #
526 # Revision 1.4 1991/04/13 02:11:03 rich
527 # Config cut 3. We now almost install a29k.
528 #
529 # Revision 1.3 1991/04/11 02:41:54 rich
530 # Cut 2 config. Subdirs.
531 #
532 #
533 #
534
535 #
536 # Local Variables:
537 # fill-column: 131
538 # End:
539 #
540
541 # end of configure.template
This page took 0.055408 seconds and 5 git commands to generate.