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