]> Git Repo - binutils.git/blob - bfd/configure
Fixed a problem with host dependent parts.
[binutils.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 compilation.
32 #
33 # If configure succeeds, it leaves its status in config.status.
34 # If configure fails after disturbing the status quo, 
35 #       config.status is removed.
36 #
37
38 remove=rm
39 hard_link=ln
40 symbolic_link='ln -s'
41
42 #for Test
43 #remove="echo rm"
44 #hard_link="echo ln"
45 #symbolic_link="echo ln -s"
46
47 # clear some things potentially inherited from environment.
48 ansi=
49 defaulttargets=
50 destdir=
51 fatal=
52 hostsubdir=
53 norecurse=
54 removing=
55 srcdir=
56 srctrigger=
57 target=
58 targets=
59 targetsubdir=
60 template=
61 verbose=
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 | +forcesubdirs | +f)
73                 forcesubdirs=${arg}
74                 ;;
75         -languages=* | +languages=* | +language=* | +languag=* \
76                 | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
77                 | +l=*)
78                 languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
79                 ;;
80         -gas | +gas | +ga | +g)
81                 gas=yes
82                 ;;
83         -help | +h | +help)
84                 fatal=true
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         -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=* | +t=*)
99                 if [ -n "${targets}" ] ; then
100                         forcesubdirs="+forcesubdirs"
101                 fi
102
103                 newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
104                 targets="${newtargets}"
105                 ;;
106         -template=* | +template=*)
107                 template=`echo ${arg} | sed 's/[+-]template=//'`
108                 ;;
109         +verbose | +verbos | +verbo | +verb | +ver | +ve | +v)
110                 verbose=${arg}
111                 ;;
112         -* | +*)
113                 (echo ;
114                 echo "Unrecognized option: \"${arg}\"". ;
115                 echo) 1>&2
116                 fatal=true
117                 ;;
118         *)
119                 if [ -n "${hosts}" ] ; then
120                         forcesubdirs="+forcesubdirs"
121                 fi
122
123                 newhosts="${hosts} ${arg}"
124                 hosts=${newhosts}
125                 ;;
126         esac
127 done
128
129 if [ -n "${verbose}" ] ; then
130         echo `pwd`/configure $*
131         echo targets=\"${targets}\"
132 fi
133
134 # process host and target only if not rebuilding configure itself or removing.
135 if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then
136         # Complain if an arg is missing
137         if [ -z "${hosts}" ] ; then
138                 (echo ;
139                 echo "configure: No HOST specified." ;
140                 echo) 2>&1
141                 fatal=true
142         fi
143 fi
144
145 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
146         (echo "Usage: configure HOST" ;
147         echo ;
148         echo "Options: [defaults in brackets]" ;
149         echo " +ansi            configure w/ANSI library. [no ansi lib]" ;
150         echo " +destdir=MYDIR   configure for installation into MYDIR. [/usr/local]" ;
151         echo " +forcesubdirs    configure in subdirectories.  [in source directories]" ;
152         echo " +lang=LANG       configure to build LANG. [gcc]" ;
153         echo " +help            print this message. [normal config]" ;
154         echo " +gas             configure the compilers for use with gas. [native as]" ;
155         echo " +nfp             configure the compilers default to soft floating point. [hard float]" ;
156         echo " +norecurse       configure this directory only. [recurse]" ;
157         echo " +rm              remove this configuration. [build a configuration]" ;
158         echo " +target=TARGET   configure for TARGET.  [TARGET = HOST]" ;
159         echo " +template=TEM    rebuild configure using TEM. [normal config]" ;
160         echo ;
161         echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
162         echo "Asking for more than one \"+target\" implies \"+forcesubdirs\".  Any other" ;
163         echo "options given will apply to all targets.") 1>&2
164
165         if [ -r config.status ] ; then
166                 cat config.status
167         fi
168
169         exit 1
170 fi
171
172 #### configure.in common parts come in here.
173 # This file is a shell script that supplies the information necessary
174 # to tailor a template configure script into the configure script
175 # appropriate for this directory.  For more information, check any
176 # existing configure script.
177
178 srctrigger=libbfd.c
179 srcname="bfd"
180
181 ## end of common part
182
183 # are we rebuilding config itself?
184 if [ -n "${template}" ] ; then
185         if [ ! -r ${template} ] ; then
186                 echo "Can't find template ${template}."
187                 exit 1
188         fi
189
190         mv configure configure.old
191         echo "#!/bin/sh" > configure
192         echo "# Please do not edit this file.  It is generated automatically from" >> configure
193         echo "# configure.in and a configure template." >> configure
194         echo "configdirs=" >> configure
195         echo >> configure
196
197         if [ -r configure.in ] ; then
198                 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
199                         echo `pwd`/configure.in has no "per-host:" line.
200                         exit 1
201                 fi
202
203                 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
204                         echo `pwd`/configure.in has no "per-target:" line.
205                         exit 1
206                 fi
207
208                 # split configure.in into common, per-host, and per-target parts
209                 sed -e '/^# per\-host:/,$d' configure.in > configure.com
210                 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst
211                 sed -e '1,/^# per\-target:/d' configure.in > configure.tgt
212
213                 # and insert them
214                 sed -e '/^#### configure.in common part/  r configure.com' \
215                         -e '/^#### configure.in per\-host part/  r configure.hst' \
216                         -e '/^#### configure.in per\-target part/  r configure.tgt' \
217                         ${template} >> configure
218
219                 rm -f configure.com configure.tgt configure.hst
220         else
221                 echo Warning: no configure.in in `pwd`
222                 cat ${template} >> configure
223         fi
224
225         chmod a+x configure
226         rm configure.old
227         echo Rebuilt configure in `pwd`
228
229         if [ -z "${norecurse}" ] ; then
230                 while [ -n "${configdirs}" ] ; do
231                         # set configdir to car of configdirs, configdirs to cdr of configdirs
232                         set ${configdirs}; configdir=$1; shift; configdirs=$*
233
234                         if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
235                                 targetspecificdirs=${configdir}.*
236                         else
237                                 targetspecificdirs=
238                         fi
239
240                         for i in ${configdir} ${targetspecificdirs} ; do
241                                 if [ -r $i/configure ] ; then
242                                         (cd $i ;
243                                                 ./configure +template=${template} ${verbose})
244                                 else
245                                         echo No configure script in `pwd`/$i
246                                 fi
247                         done
248                 done
249         fi
250
251         exit 0
252 fi
253
254 # some sanity checks on configure.in
255 if [ -z "${srctrigger}" ] ; then
256         echo srctrigger not set in configure.in. `pwd` not configured.
257         exit 1
258 fi
259
260 for host in ${hosts} ; do
261         # Default other arg
262         if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
263                 targets=${host}
264                 defaulttargets=true
265         fi
266
267 #### configure.in per-host parts come in here.
268
269 ## end of per-target part
270
271
272         for target in ${targets} ; do
273
274                 if [ -n "${verbose}" ] ; then
275                         echo "  "target=\"${target}\"
276                 fi
277
278 #### configure.in per-target parts come in here.
279
280 files=
281 links=
282 ## end of per-target part
283
284                 # Temporarily, we support only direct subdir builds.
285                 hostsubdir=Host-${host}
286                 targetsubdir=Target-${target}
287
288                 if [ -n "${removing}" ] ; then
289                         if [ -d "${hostsubdir}/${targetsubdir}" ] ; then
290                                 rm -rf ${hostsubdir}/${targetsubdir}
291
292                                 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ] ; then
293                                         rm -rf ${hostsubdir}
294                                 fi
295                         else
296                                 rm -f Makefile config.status ${links}
297                         fi
298                 else
299                         if [ -n "${forcesubdirs}" ] ; then
300                                 # check for existing status before allowing forced subdirs.
301                                 if [ -f Makefile ] ; then
302                                         echo "Makefile already exists in source directory.  `pwd` not configured."
303                                         exit 1
304                                 fi
305
306                                 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
307                                 cd ${hostsubdir}
308
309                                 if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi
310                                 cd ${targetsubdir}
311
312                                 srcdir=../..
313                         else
314                                 # if not subdir builds, then make sure none exist.
315                                 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
316                                         echo "Configured subdirs exist.  `pwd` not configured."
317                                         exit 1
318                                 fi
319                         fi
320
321                         # Find the source files, if location was not specified.
322                         if [ -z "${srcdir}" ] ; then
323                                 srcdirdefaulted=1
324                                 srcdir=.
325                                 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
326                                         srcdir=..
327                                 fi
328                         fi
329
330                         if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
331                                 if [ -z "${srcdirdefaulted}" ] ; then
332                                   echo "${progname}: Can't find ${srcname} sources in \`${srcdir}'." 1>&2
333                                 else
334                                   echo "${progname}: Can't find ${srcname} sources in \`.' or \`..'." 1>&2
335                                 fi
336
337                                 exit 1
338                         fi
339
340                         # Set up the list of links to be made.
341                         # ${links} is the list of link names, and ${files} is the list of names to link to.
342
343                         # Make the links.
344                         while [ -n "${files}" ] ; do
345                                 # set file to car of files, files to cdr of files
346                                 set ${files}; file=$1; shift; files=$*
347                                 set ${links}; link=$1; shift; links=$*
348
349                                 if [ ! -r ${srcdir}/${file} ] ; then
350                                         echo "${progname}: cannot create a link \"${link}\"," 1>&2
351                                         echo "since the file \"${file}\" does not exist." 1>&2
352                                         exit 1
353                                 fi
354
355                                 ${remove} -f ${link}
356                                 rm -f config.status
357                                 # Make a symlink if possible, otherwise try a hard link
358                                 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
359
360                                 if [ ! -r ${link} ] ; then
361                                         echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
362                                         exit 1
363                                 fi
364                                 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
365                         done
366
367                         # Create a .gdbinit file which runs the one in srcdir
368                         # and tells GDB to look there for source files.
369
370                         case ${srcdir} in
371                         .)
372                                 ;;
373                         *)
374                                 echo "dir ." > .gdbinit
375                                 echo "dir ${srcdir}" >> .gdbinit
376                                 echo "source ${srcdir}/.gdbinit" >> .gdbinit
377                                 ;;
378                         esac
379
380                         # Install a makefile, and make it set VPATH
381                         # if necessary so that the sources are found.
382                         # Also change its value of srcdir.
383
384                 # FIXME-someday: This business of always writing to .tem and mv back
385                 # is so that I don't screw things up while developing.  Once this
386                 # template is stable, these should be optimized. xoxorich.
387
388                         # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
389                         if [ "${host}" != "${target}" ] ; then
390                                 echo "CROSS=-DCROSS_COMPILE" > Makefile
391                                 echo "ALL=start.encap" >> Makefile
392                         else
393                                 echo "ALL=all.internal" > Makefile
394                         fi
395
396                         # set target, host, VPATH
397                         echo "host = ${host}" >> Makefile
398                         echo "target = ${target}" >> Makefile
399
400                         if [ -n "${forcesubdirs}" ] ; then
401                                 echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile
402                         else
403                                 echo "subdir =" >> Makefile
404                         fi
405
406                 #       echo "workdir = `pwd`" >> Makefile
407                         echo "VPATH = ${srcdir}" >> Makefile
408
409                         # add Makefile.in
410                         cat ${srcdir}/Makefile.in >> Makefile
411
412                         # and shake thoroughly.
413                         host_var_file=hmake-${host}
414                         target_var_file=tmake-${target}
415
416                         # Conditionalize the makefile for this host.
417                         if [ -f ${srcdir}/config/${host_var_file} ] ; then
418                                 sed -e "/^####/  r ${srcdir}/config/${host_var_file}" Makefile > Makefile.tem
419                                 mv Makefile.tem Makefile
420                         fi
421
422                         # Conditionalize the makefile for this target.
423                         if [ -f ${srcdir}/config/${target_var_file} ] ; then
424                                 sed -e "/^####/  r ${srcdir}/config/${target_var_file}" Makefile > Makefile.tem
425                                 mv Makefile.tem Makefile
426                         fi
427
428                         # set srcdir
429                         sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem
430                         mv Makefile.tem Makefile
431
432                         # set destdir
433                         if [ -n "${destdir}" ] ; then
434                                 sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem
435                                 mv Makefile.tem Makefile
436                         fi
437
438                         # Remove all formfeeds, since some Makes get confused by them.
439                         sed "s/\f//" Makefile >> Makefile.tem
440                         mv Makefile.tem Makefile
441
442                         # reset SUBDIRS
443                         sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem
444                         mv Makefile.tem Makefile
445
446                         # reset NONSUBDIRS
447                         sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem
448                         mv Makefile.tem Makefile
449
450                         using=
451                         if [ -f ${srcdir}/config/${host_var_file} ] ; then
452                                 using=" using \"${host_var_file}\""
453                         fi
454
455                         if [ -f ${srcdir}/config/${target_var_file} ] ; then
456                                 if [ -z "${using}" ] ; then
457                                         andusing=" using \"${target_var_file}\""
458                                 else
459                                         andusing="${using} and \"${target_var_file}\""
460                                 fi
461                         else
462                                 andusing=${using}
463                         fi
464
465                         echo "Created \"Makefile\"" in `pwd`${andusing}.
466
467                         if [ "${host}" = "${target}" ] ; then
468                                 echo "Links are now set up for use with a ${target}." \
469                                         > config.status
470                 #                       | tee ${srcdir}/config.status
471                         else
472                                 echo "Links are now set up for host ${host} and target ${target}." \
473                                         > config.status
474                 #                       | tee ${srcdir}/config.status
475                         fi
476
477                         originaldir=`pwd`
478                         cd ${srcdir}
479                 fi
480         done
481 done
482
483 # If there are subdirectories, then recurse. 
484
485 if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi
486
487 # configdirs is not null
488 for configdir in ${configdirs} ; do
489         echo Configuring ${configdir}...
490         specifics=
491         commons=
492
493         if [ -n "${defaulttargets}" ] ; then
494                 for host in ${hosts} ; do
495                         if [ -d ${configdir}.${host} ] ; then
496                                 newspecifics="${specifics} ${host}"
497                                 specifics=${newspecifics}
498                         else
499                                 newcommons="${commons} ${host}"
500                                 commons=${newcommons}
501                         fi # if target specific
502                 done # for each host
503
504                 if [ -n "${commons}" ] ; then
505                         (cd ${configdir} ;
506                                 ./configure ${commons} ${verbose} ${forcesubdirs} ${removing}) \
507                                 | sed 's/^/     /'
508                 fi # if any common hosts
509
510                 if [ -n "${specifics}" ] ; then
511                         for host in ${specifics} ; do
512                                 echo Configuring target specific directory ${configdir}.${host}...
513                                 (cd ${configdir}.${host} ;
514                                         ./configure ${host} ${verbose} ${forcesubdirs} ${removing}) \
515                                         | sed 's/^/     /'
516                         done # for host in specifics
517                 fi # if there are any specifics
518         else
519
520                 for target in ${targets} ; do
521                         if [ -d ${configdir}.${target} ] ; then
522                                 newspecifics="${specifics} ${target}"
523                                 specifics=${newspecifics}
524                         else
525                                 newcommons="${commons} +target=${target}"
526                                 commons=${newcommons}
527                         fi
528
529                 done # check for target specific dir override
530
531                 if [ -n "${verbose}" ] ; then
532                         echo "  "commons=\"${commons}\"
533                         echo "  "specifics=\"${specifics}\"
534                 fi # if verbose
535
536                 if [ -n "${commons}" ] ; then
537                         (cd ${configdir} ;
538                                 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons}) \
539                                 | sed 's/^/     /'
540                 fi # if any commons
541
542                 if [ -n "${specifics}" ] ; then
543                         for target in ${specifics} ; do
544                                 echo Configuring target specific directory ${configdir}.${target}...
545                                 (cd ${configdir}.${target} ;
546                                         ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \
547                                         | sed 's/^/     /'
548                         done
549                 fi # if any specifics
550         fi # not default targets
551 done
552
553 exit 0
554
555 #
556 # $Log$
557 # Revision 1.7  1991/04/17 01:41:18  rich
558 # Fixed a problem with host dependent parts.
559 #
560 # Revision 1.6  1991/04/16  00:18:44  rich
561 # Now handles multiple hosts and targets.
562 #
563 # Revision 1.5  1991/04/15  23:43:44  rich
564 # Now handles multiple hosts and targets.
565 #
566 # Revision 1.4  1991/04/13  02:11:03  rich
567 # Config cut 3.  We now almost install a29k.
568 #
569 # Revision 1.3  1991/04/11  02:41:54  rich
570 # Cut 2 config.  Subdirs.
571 #
572 #
573 #
574
575 #
576 # Local Variables:
577 # fill-column: 131
578 # End:
579 #
580
581 # end of configure.template
This page took 0.05993 seconds and 4 git commands to generate.