Config cut 3. We now almost install a29k.
[binutils-gdb.git] / gas / 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 compiling gcc.
32 #
33 # Usage: configure [+srcdir=DIR] [+host=HOST] [+gas] [+nfp] TARGET
34 #
35 # If configure succeeds, it leaves its status in config.status.
36 # If configure fails after disturbing the status quo,
37 # config.status is removed.
38 #
39
40 progname=$0
41
42 remove=rm
43 hard_link=ln
44 symbolic_link='ln -s'
45
46 #for Test
47 #remove="echo rm"
48 #hard_link="echo ln"
49 #symbolic_link="echo ln -s"
50
51 # clear some things potentially inherited from environment.
52 ansi=
53 destdir=
54 hostsubdir=
55 norecurse=
56 removing=
57 srcdir=
58 srctrigger=
59 target=
60 targetsubdir=
61 template=
62
63 for arg in $*;
64 do
65 case ${arg} in
66 -ansi | +ansi)
67 ansi=true
68 ;;
69 -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*)
70 destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
71 ;;
72 -forcesubdirs | +f*)
73 forcesubdirs=${arg}
74 ;;
75 -host=* | +host=* | +hos=* | +ho=* | +h=*)
76 host=`echo ${arg} | sed 's/[+-]h[a-z]*=//'`
77 ;;
78 -languages=* | +languages=* | +language=* | +languag=* \
79 | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
80 | +l=*)
81 languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
82 ;;
83 -gas | +gas | +ga | +g)
84 gas=yes
85 ;;
86 -nfp | +nfp | +nf | +n)
87 nfp=yes
88 ;;
89 -norecurse | +norecurse)
90 norecurse=true
91 ;;
92 -rm | +rm)
93 removing=${arg}
94 ;;
95 -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
96 srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
97 ;;
98 -template=* | +template=*)
99 template=`echo ${arg} | sed 's/[+-]template=//'`
100 ;;
101 *)
102 # Allow configure HOST TARGET
103 if [ -z "${host}" ] ; then host=${target} ; fi
104 target=${arg}
105 ;;
106 esac
107 done
108
109 # process host and target only if not rebuilding configure itself or removing.
110 if [ -z "${template}" -a -z "${removing}" ]
111 then
112 # Complain if an arg is missing
113 if [ -z "${target}" ]
114 then
115 echo "Usage: ${progname} [+srcdir=DIR] [+host=HOST] [+gas] [+nfp] TARGET"
116 echo -n "Where HOST and TARGET are something like "
117 echo "\`vax', \`sun3', \`encore', etc."
118 if [ -r config.status ]
119 then
120 cat config.status
121 fi
122 exit 1
123 fi
124 fi
125
126 # Default other arg
127 if [ -z "${host}" ]
128 then
129 host=${target}
130 fi
131
132 #### configure.in files come in here.
133 # This file is a shell script that supplies the information necessary
134 # to tailor a template configure script into the configure script
135 # appropriate for this directory. For more information, check any
136 # existing configure script.
137
138 srctrigger=as.c
139 srcname="gas"
140
141 # assign cpu type
142 case $target in
143 sun4* | sparc*)
144 cpu_type=sparc
145 ;;
146 sun3*)
147 cpu_type=m68k
148 ;;
149 i386*)
150 cpu_type=i386
151 ;;
152 i960*)
153 cpu_type=i960
154 ;;
155 a29k*)
156 cpu_type=a29k
157 ;;
158 *)
159 cpu_type=generic
160 ;;
161 esac
162
163 # assign object format
164 case $target in
165 *-coff)
166 obj_format=coff
167 ;;
168 *-bout)
169 obj_format=bout
170 ;;
171 generic)
172 obj_format=generic
173 ;;
174 *)
175 obj_format=aout
176 ;;
177 esac
178
179 # assign floating point type
180 case $target in
181 vax)
182 atof=vax
183 ;;
184 *)
185 atof=ieee
186 ;;
187 esac
188
189 files="config/ho-${host}.h config/tc-${cpu_type}.c \
190 config/tc-${cpu_type}.h config/te-generic.h \
191 config/obj-${obj_format}.h config/obj-${obj_format}.c \
192 config/atof-${atof}.c"
193
194 links="host.h targ-cpu.c targ-cpu.h targ-env.h obj-format.h obj-format.c atof-targ.c"
195 ### end of configure.in
196
197 # are we rebuilding config itself?
198 if [ -n "${template}" ]
199 then
200 if [ ! -r ${template} ]
201 then
202 echo "Can't find template ${template}."
203 exit 1
204 fi
205
206 mv configure configure.old
207 echo "#!/bin/sh" > configure
208 echo "# Please do not edit this file. It is generated automatically from" >> configure
209 echo "# configure.in and a configure template." >> configure
210 echo "configdirs=" >> configure
211 echo >> configure
212
213 if [ -r configure.in ]
214 then
215 sed -e "/^####/ r configure.in" ${template} >> configure
216 else
217 echo Warning: no configure.in in `pwd`
218 cat ${template} >> configure
219 fi
220
221 chmod a+x configure
222 rm configure.old
223 echo Rebuilt configure in `pwd`
224
225 if [ -z "${norecurse}" ]
226 then
227 while [ -n "${configdirs}" ]
228 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}.*" ]
233 then
234 targetspecificdirs=${configdir}.*
235 else
236 targetspecificdirs=
237 fi
238
239 for i in ${configdir} ${targetspecificdirs}
240 do
241 if [ -r $i/configure ]
242 then
243 (cd $i ;
244 configure +template=${template})
245 else
246 echo No configure script in `pwd`/$i
247 fi
248 done
249 done
250 fi
251
252 exit 0
253 fi
254
255 # some sanity checks on configure.in
256 if [ -z "${srctrigger}" ]
257 then
258 echo srctrigger not set in configure.in. `pwd` not configured.
259 exit 1
260 fi
261
262 # Temporarily, we support only direct subdir builds.
263 hostsubdir=Host-${host}
264 targetsubdir=Target-${target}
265
266 if [ -n "${removing}" ]
267 then
268 if [ -d "${hostsubdir}/${targetsubdir}" ]
269 then
270 rm -rf ${hostsubdir}/${targetsubdir}
271
272 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ]
273 then
274 rm -rf ${hostsubdir}
275 fi
276 else
277 rm -f .gdbinit Makefile config.status ${links}
278 fi
279 else
280 if [ -n "${forcesubdirs}" ]
281 then
282 # check for existing status before allowing forced subdirs.
283 if [ -f Makefile ]
284 then
285 echo "Makefile already exists in source directory. `pwd` not configured."
286 exit 1
287 fi
288
289 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
290 cd ${hostsubdir}
291
292 if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi
293 cd ${targetsubdir}
294
295 srcdir=../..
296 else
297 # if not subdir builds, then make sure none exist.
298 if [ -n "`(ls .) 2>&1 | grep Host-`" ]
299 then
300 echo "Configured subdirs exist. `pwd` not configured."
301 exit 1
302 fi
303 fi
304
305 # Find the source files, if location was not specified.
306 if [ -z "${srcdir}" ]
307 then
308 srcdirdefaulted=1
309 srcdir=.
310 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ]
311 then
312 srcdir=..
313 fi
314 fi
315
316 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ]
317 then
318 if [ -z "${srcdirdefaulted}" ]
319 then
320 echo "${progname}: Can't find ${srcname} sources in \`${srcdir}'." 1>&2
321 else
322 echo "${progname}: Can't find ${srcname} sources in \`.' or \`..'." 1>&2
323 fi
324 exit 1
325 fi
326
327 # Set up the list of links to be made.
328 # ${links} is the list of link names, and ${files} is the list of names to link to.
329
330 # Make the links.
331 while [ -n "${files}" ]
332 do
333 # set file to car of files, files to cdr of files
334 set ${files}; file=$1; shift; files=$*
335 set ${links}; link=$1; shift; links=$*
336
337 if [ ! -r ${srcdir}/${file} ]
338 then
339 echo "${progname}: cannot create a link \"${link}\"," 1>&2
340 echo "since the file \"${file}\" does not exist." 1>&2
341 exit 1
342 fi
343
344 ${remove} -f ${link}
345 rm -f config.status
346 # Make a symlink if possible, otherwise try a hard link
347 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
348
349 if [ ! -r ${link} ]
350 then
351 echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
352 exit 1
353 fi
354 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
355 done
356
357 # Create a .gdbinit file which runs the one in srcdir
358 # and tells GDB to look there for source files.
359
360 case ${srcdir} in
361 .)
362 ;;
363 *)
364 echo "dir ." > .gdbinit
365 echo "dir ${srcdir}" >> .gdbinit
366 echo "source ${srcdir}/.gdbinit" >> .gdbinit
367 ;;
368 esac
369
370 # Install a makefile, and make it set VPATH
371 # if necessary so that the sources are found.
372 # Also change its value of srcdir.
373
374 # FIXME-someday: This business of always writing to .tem and mv back
375 # is so that I don't screw things up while developing. Once this
376 # template is stable, these should be optimized. xoxorich.
377
378 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
379 if [ "${host}" != "${target}" ]
380 then
381 echo "CROSS=-DCROSS_COMPILE" > Makefile
382 echo "ALL=start.encap" >> Makefile
383 else
384 echo "ALL=all.internal" > Makefile
385 fi
386
387 # set target, host, VPATH
388 echo "host = ${host}" >> Makefile
389 echo "target = ${target}" >> Makefile
390
391 if [ -n "${forcesubdirs}" ]
392 then
393 echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile
394 else
395 echo "subdir =" >> Makefile
396 fi
397
398 # echo "workdir = `pwd`" >> Makefile
399 echo "VPATH = ${srcdir}" >> Makefile
400
401 # add Makefile.in
402 cat ${srcdir}/Makefile.in >> Makefile
403
404 # and shake thoroughly.
405 host_var_file=hmake-${host}
406 target_var_file=tmake-${target}
407
408 # Conditionalize the makefile for this host.
409 if [ -f ${srcdir}/config/${host_var_file} ]
410 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} ]
417 then
418 sed -e "/^####/ r ${srcdir}/config/${target_var_file}" Makefile > Makefile.tem
419 mv Makefile.tem Makefile
420 fi
421
422 # set srcdir
423 sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem
424 mv Makefile.tem Makefile
425
426 # set destdir
427 if [ -n "${destdir}" ]
428 then
429 sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem
430 mv Makefile.tem Makefile
431 fi
432
433 # Remove all formfeeds, since some Makes get confused by them.
434 sed "s/\f//" Makefile >> Makefile.tem
435 mv Makefile.tem Makefile
436
437 # reset SUBDIRS
438 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem
439 mv Makefile.tem Makefile
440
441 # reset NONSUBDIRS
442 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem
443 mv Makefile.tem Makefile
444
445 using=
446 if [ -f ${srcdir}/config/${host_var_file} ]
447 then
448 using=" using \"${host_var_file}\""
449 fi
450
451 if [ -f ${srcdir}/config/${target_var_file} ]
452 then
453 if [ -z "${using}" ]
454 then
455 andusing=" using \"${target_var_file}\""
456 else
457 andusing="${using} and \"${target_var_file}\""
458 fi
459 else
460 andusing=${using}
461 fi
462
463 echo "Created \"Makefile\""${andusing}.
464
465 if [ "${host}" = "${target}" ]
466 then
467 echo "Links are now set up for use with a ${target}." \
468 > config.status
469 # | tee ${srcdir}/config.status
470 else
471 echo "Links are now set up for host ${host} and target ${target}." \
472 > config.status
473 # | tee ${srcdir}/config.status
474 fi
475
476 originaldir=`pwd`
477 cd ${srcdir}
478 fi
479
480 # If there are subdirectories, then recurse.
481
482 if [ -n "${norecurse}" ] ; then exit 0 ; fi
483
484 while [ -n "${configdirs}" ]
485 do
486 # set configdir to car of configdirs, configdirs to cdr of configdirs
487 set ${configdirs}; configdir=$1; shift; configdirs=$*
488
489 # check for target override
490 targetspecificdir=${configdir}.${target}
491 if [ -d ${targetspecificdir} ]
492 then
493 configdir=${targetspecificdir}
494 fi
495
496 echo Configuring ${configdir}...
497 (cd ${configdir} ;
498 ./configure ${forcesubdirs} ${removing} +host=${host} ${target}) \
499 | sed 's/^/ /'
500 done
501
502 exit 0
503
504 #
505 # $Log$
506 # Revision 1.4 1991/04/13 02:10:29 rich
507 # Config cut 3. We now almost install a29k.
508 #
509 # Revision 1.3 1991/04/11 02:41:54 rich
510 # Cut 2 config. Subdirs.
511 #
512 #
513 #
514
515
516 # end of configure.template