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