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