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