4 # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc.
6 #This file is part of GNU.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 # Shell script to create proper links to machine-dependent files in
26 # preparation for compilation.
28 # If configure succeeds, it leaves its status in config.status.
29 # If configure fails after disturbing the status quo,
30 # config.status is removed.
42 #symbolic_link="echo ln -s"
46 # clear some things potentially inherited from environment.
54 Makefile_in
=Makefile.
in
67 #if [ "$0" != "./configure" ] ; then
71 #if [ ! -f ./config.sub ] ; then
72 # echo '***' Can not find config.sub.
83 -destdir=* |
+destdir
=* |
+destdi
=* |
+destd
=* |
+dest
=* |
+des
=* |
+de
=* |
+d
=*)
84 destdir
=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
86 -languages=* |
+languages
=* |
+language
=* |
+languag
=* \
87 |
+langua
=* |
+langu
=* |
+lang
=* |
+lan
=* |
+la
=* \
89 languages
="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
103 -recurring |
+recurring |
+recurrin |
+recurri |
+recurr |
+recur |
+recu |
+rec |
+re
)
109 # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
110 # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
112 -subdirs |
+f
* |
+su
*)
115 -target=* |
+target
=* |
+targe
=* |
+targ
=* |
+tar=* |
+ta
=*)
116 if [ -n "${targets}" ] ; then
120 newtargets
="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
121 targets
="${newtargets}"
128 echo "Unrecognized option: \"${arg}\"".
;
133 if [ -n "${hosts}" ] ; then
137 newhosts
="${hosts} ${arg}"
143 if [ -n "${verbose}" ] ; then
144 echo `pwd`/configure $
*
147 # process host and target only if not removing.
148 if [ -z "${removing}" -a -z "${fatal}" ] ; then
149 # Complain if an arg is missing
150 if [ -z "${hosts}" ] ; then
152 echo "configure: No HOST specified." ;
158 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
159 (echo "Usage: configure HOST" ;
161 echo "Options: [defaults in brackets]" ;
162 echo " +ansi configure w/ANSI library. [no ansi lib]" ;
163 echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ;
164 echo " +subdirs configure in subdirectories. [in source directories]" ;
165 echo " +lang=LANG configure to build LANG. [gcc]" ;
166 echo " +help print this message. [normal config]" ;
167 echo " +gas configure the compilers for use with gas. [native as]" ;
168 echo " +nfp configure the compilers default to soft floating point. [hard float]" ;
169 echo " +norecursion configure this directory only. [recurse]" ;
170 echo " +rm remove this configuration. [build a configuration]" ;
171 echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ;
173 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
174 echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ;
175 echo "options given will apply to all targets.") 1>&2
177 if [ -r config.status
] ; then
184 ### break up configure.in.
185 if [ -r configure.
in ] ; then
186 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
187 echo '***' `pwd`/configure.
in has no
"per-host:" line.
1>&2
191 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
192 echo '***' `pwd`/configure.
in has no
"per-target:" line.
1>&2
196 # split configure.in into common, per-host, per-target,
197 # and post-target parts. Post-target is optional.
198 sed -e '/^# per\-host:/,$d' configure.
in > configure.com
199 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.
in > configure.hst
200 if grep -s '^# post-target:' configure.
in ; then
201 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.
in > configure.tgt
202 sed -e '1,/^# post\-target:/d' configure.
in > configure.pos
204 sed -e '1,/^# per\-target:/d' configure.
in > configure.tgt
209 echo '***' No configure.
in in `pwd`
213 ### do common part of configure.in
217 # some sanity checks on configure.in
218 if [ -z "${srctrigger}" ] ; then
219 echo '***' srctrigger not
set in `pwd`/configure.
in.
223 for host in ${hosts} ; do
225 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
232 result
=`/bin/sh ./config.sub ${host}`
233 host_cpu
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
234 host_vendor
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
235 host_os
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
236 host=${host_cpu}-${host_vendor}-${host_os}
237 host_makefile_frag
=config
/hmake-
${host}
241 for target
in ${targets} ; do
243 target_alias
=${target}
244 result
=`/bin/sh ./config.sub ${target}`
245 target_cpu
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
246 target_vendor
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
247 target_os
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
248 target
=${target_cpu}-${target_vendor}-${target_os}
249 target_makefile_frag
=config
/tmake-
${target}
253 # Temporarily, we support only direct subdir builds.
254 hostsubdir
=H-
${host_alias}
255 targetsubdir
=T-
${target_alias}
257 if [ -n "${removing}" ] ; then
258 if [ -n "${subdirs}" ] ; then
259 if [ -d "${hostsubdir}" ] ; then
260 rm -rf ${hostsubdir}/${targetsubdir}
262 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep T- | grep -v T-independent`" ] ; then
266 echo Warning
: no
`pwd`/${hostsubdir} to remove.
269 rm -f ${Makefile} config.status
${links}
272 if [ -n "${subdirs}" ] ; then
273 # check for existing status before allowing forced subdirs.
274 if [ -f ${Makefile} ] ; then
275 echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2
279 if [ ! -d ${hostsubdir} ] ; then mkdir
${hostsubdir} ; fi
282 if [ ! -d ${targetsubdir} ] ; then
283 if [ -z "${commontargets}" ] ; then
284 mkdir
${targetsubdir}
286 if [ ! -d T-independent
] ; then
290 ${symbolic_link} T-independent
${targetsubdir}
291 fi # if target independent
292 fi # if no target dir yet
298 # if not subdir builds, then make sure none exist.
299 if [ -n "`(ls .) 2>&1 | (grep H- ; true)`" ] ; then
300 echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2
307 # Find the source files, if location was not specified.
308 if [ -z "${srcdir}" ] ; then
311 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
316 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
317 if [ -z "${srcdirdefaulted}" ] ; then
318 echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
320 echo '***' "${progname}: Can
't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
323 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
327 # Set up the list of links to be made.
328 # ${links} is the list of link names, and ${files} is the list of names to link to.
331 while [ -n "${files}" ] ; do
332 # set file to car of files, files to cdr of files
333 set ${files}; file=$1; shift; files=$*
334 set ${links}; link=$1; shift; links=$*
336 if [ ! -r ${srcdir}/${file} ] ; then
337 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
338 echo '***' "since the file \"${file}\" does not exist." 1>&2
344 # Make a symlink if possible, otherwise try a hard link
345 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
347 if [ ! -r ${link} ] ; then
348 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
352 if [ -n "${verbose}" ] ; then
353 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
357 # Create a .gdbinit file which runs the one in srcdir
358 # and tells GDB to look there for source files.
364 echo "dir ." > .gdbinit
365 echo "dir ${srcdir}" >> .gdbinit
366 echo "source ${srcdir}/.gdbinit" >> .gdbinit
370 # Install a makefile, and make it set VPATH
371 # if necessary so that the sources are found.
372 # Also change its value of srcdir.
374 # FIXME-someday: This business of always writing to .tem and mv back
375 # is so that I don't screw things up
while developing. Once this
376 # template is stable, these should be optimized. xoxorich.
378 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
379 if [ "${host}" != "${target}" ] ; then
380 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
381 echo "ALL=start.encap" >> ${Makefile}
383 echo "ALL=all.internal" > ${Makefile}
386 # set target, host, VPATH
387 echo "host_alias = ${host_alias}" >> ${Makefile}
388 echo "host_cpu = ${host_cpu}" >> ${Makefile}
389 echo "host_vendor = ${host_vendor}" >> ${Makefile}
390 echo "host_os = ${host_os}" >> ${Makefile}
392 echo "target_alias = ${target_alias}" >> ${Makefile}
393 echo "target_cpu = ${target_cpu}" >> ${Makefile}
394 echo "target_vendor = ${target_vendor}" >> ${Makefile}
395 echo "target_os = ${target_os}" >> ${Makefile}
397 if [ -n "${subdirs}" ] ; then
398 echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile}
400 echo "subdir
=" >> ${Makefile}
403 # echo "workdir
= `pwd`" >> ${Makefile}
404 echo "VPATH
= ${srcdir}" >> ${Makefile}
406 # add "Makefile.
in" (or whatever it's called)
407 cat ${srcdir}/${Makefile_in} >> ${Makefile}
409 # Conditionalize the makefile for this host.
410 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
411 (echo "host_makefile_frag
= ${srcdir}/${host_makefile_frag}" ;
412 sed -e "/^
####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
413 mv Makefile.tem
${Makefile}
416 # Conditionalize the makefile for this target.
417 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
418 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
419 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
420 mv Makefile.tem ${Makefile}
424 sed "s@^srcdir
= \.@srcdir
= ${srcdir}@
" ${Makefile} > Makefile.tem
425 mv Makefile.tem ${Makefile}
428 if [ -n "${destdir}" ] ; then
429 sed "s
:^destdir
=.
*$
:destdir
= ${destdir}:" ${Makefile} > Makefile.tem
430 mv Makefile.tem ${Makefile}
434 sed "s
:^SUBDIRS
=.
*$
:SUBDIRS
= ${configdirs}:" ${Makefile} > Makefile.tem
435 mv Makefile.tem ${Makefile}
438 sed "s
:^NONSUBDIRS
=.
*$
:NONSUBDIRS
= ${noconfigdirs}:" ${Makefile} > Makefile.tem
439 mv Makefile.tem ${Makefile}
442 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
443 using=" using
\"${host_makefile_frag}\""
446 # remove any form feeds.
447 sed -e "s
/\f//" ${Makefile} > Makefile.tem
448 mv Makefile.tem ${Makefile}
450 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
451 if [ -z "${using}" ] ; then
452 andusing=" using
\"${target_makefile_frag}\""
454 andusing="${using} and
\"${target_makefile_frag}\""
460 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
461 echo "Created
\"${Makefile}\"" in `pwd`${andusing}.
464 if [ -f ./configure.pos ] ; then
468 # describe the chosen configuration in config.status.
469 # Make that file a shellscript which will reestablish
470 # the same configuration. Used in Makefiles to rebuild
474 # ${srcname} was configured as follows:
475 ${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status
476 chmod a+x config.status
482 # If there are subdirectories, then recurse.
483 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
484 for configdir in ${configdirs} ; do
485 if [ -n "${verbose}" ] ; then
486 echo Configuring ${configdir}...
489 if [ -d ${configdir} ] ; then
491 configure +recurring ${host_alias} +target=${target_alias} \
492 ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \
495 if [ -n "${verbose}" ] ; then
496 echo Warning: directory \"${configdir}\" is missing.
501 done # for each target
503 # Now build a Makefile for this host.
504 if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
506 cat > GNUmakefile << E!O!F
507 # Makefile generated by configure for host ${host_alias}.
509 ALL := $(shell ls -d T-*)
512 $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
522 rm -f configure.com configure.tgt configure.hst configure.pos