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