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