| 1 | #!/bin/sh |
| 2 | |
| 3 | # Configuration script |
| 4 | # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. |
| 5 | |
| 6 | #This file is part of GNU. |
| 7 | |
| 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. |
| 12 | # |
| 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. |
| 17 | # |
| 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. */ |
| 21 | |
| 22 | # $Id$ |
| 23 | |
| 24 | # Please email any bugs, comments, and/or additions to this file to: |
| 25 | # configure@cygnus.com |
| 26 | |
| 27 | # |
| 28 | # Shell script to create proper links to machine-dependent files in |
| 29 | # preparation for compilation. |
| 30 | # |
| 31 | # If configure succeeds, it leaves its status in config.status. |
| 32 | # If configure fails after disturbing the status quo, |
| 33 | # config.status is removed. |
| 34 | # |
| 35 | |
| 36 | # NOTE: This script contains support for a Cygnus experimental feature, called |
| 37 | # +subdirs, which is currently, tentatively, de-supported. |
| 38 | |
| 39 | export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$) |
| 40 | |
| 41 | remove=rm |
| 42 | hard_link=ln |
| 43 | symbolic_link='ln -s' |
| 44 | |
| 45 | #for Test |
| 46 | #remove="echo rm" |
| 47 | #hard_link="echo ln" |
| 48 | #symbolic_link="echo ln -s" |
| 49 | |
| 50 | # clear some things potentially inherited from environment. |
| 51 | |
| 52 | Makefile=Makefile |
| 53 | Makefile_in=Makefile.in |
| 54 | arguments=$* |
| 55 | commontargets= |
| 56 | configdirs= |
| 57 | datadir= |
| 58 | datadiroption= |
| 59 | defaulttargets= |
| 60 | fatal= |
| 61 | floating_point=default |
| 62 | gas=default |
| 63 | hosts= |
| 64 | #hostsubdir= |
| 65 | #namesubdir= |
| 66 | next_prefix= |
| 67 | next_host= |
| 68 | #next_namesubdir= |
| 69 | #next_objdir= |
| 70 | next_site= |
| 71 | next_srcdir= |
| 72 | next_target= |
| 73 | next_tmpdir= |
| 74 | norecursion= |
| 75 | #objdir= |
| 76 | #objdiroption= |
| 77 | prefix=/usr/local |
| 78 | progname= |
| 79 | recurring= |
| 80 | removing= |
| 81 | srcdir= |
| 82 | srctrigger= |
| 83 | target= |
| 84 | targets= |
| 85 | #targetsubdir= |
| 86 | undefinedargs= |
| 87 | verbose= |
| 88 | version="$Revision$" |
| 89 | x11=default |
| 90 | |
| 91 | NO_EDIT="This file was generated automatically by configure. Do not edit." |
| 92 | |
| 93 | ## this is a little touchy and won't always work, but... |
| 94 | ## |
| 95 | ## if the argv[0] starts with a slash then it is an absolute name that can be |
| 96 | ## used as is. |
| 97 | ## |
| 98 | ## otherwise, if argv[0] has no slash in it, we can assume that it is on the |
| 99 | ## path. Since PATH might include "." we also add `pwd` to the end of PATH. |
| 100 | ## |
| 101 | ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute |
| 102 | ## path. |
| 103 | ## |
| 104 | |
| 105 | PWD=`pwd` |
| 106 | |
| 107 | if (echo $0 | grep '^/' > /dev/null) ; then |
| 108 | progname=$0 |
| 109 | elif (echo $0 | grep '/' > /dev/null) ; then |
| 110 | progname=${PWD}/$0 |
| 111 | else |
| 112 | progname=$0 |
| 113 | PATH=$PATH:${PWD} ; export PATH |
| 114 | fi |
| 115 | |
| 116 | for arg in $*; |
| 117 | do |
| 118 | # handle things that might have args following as separate words |
| 119 | if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix= |
| 120 | elif [ -n "${next_datadir}" ] ; then datadir=${arg} ; datadiroption="-datadir=${datadir}" ; next_datadir= |
| 121 | # elif [ -n "${next_namesubdir}" ] ; then \ |
| 122 | # namesubdir=${arg} ; namesubdiroption="--namesubdir=${namesubdir}" ; next_namesubdir= |
| 123 | # elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; objdiroption="--objdir=${objdir}" ; next_objdir= |
| 124 | elif [ -n "${next_site}" ] ; then site=${arg} ; next_site= |
| 125 | elif [ -n "${next_srcdir}" ] ; then srcdir=${arg} ; next_srcdir= |
| 126 | elif [ -n "${next_target}" ] ; then |
| 127 | next_target= |
| 128 | if [ -z "${targets}" ] ; then |
| 129 | newtargets="${targets} ${arg}" |
| 130 | targets="${newtargets}" |
| 131 | else |
| 132 | echo '***' Can only configure for one target at a time. |
| 133 | fatal=yes |
| 134 | fi |
| 135 | elif [ -n "${next_tmpdir}" ] ; then |
| 136 | next_tmpdir= |
| 137 | tmpdiroption="--tmpdir=${arg}" |
| 138 | TMPDIR=${arg} |
| 139 | |
| 140 | else |
| 141 | case ${arg} in |
| 142 | -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* | --da=* | --d=*) |
| 143 | datadir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
| 144 | datadiroption=${arg} |
| 145 | ;; |
| 146 | -datadir | --datadir | --datadi | --datad | --data | --dat | --da | --d) |
| 147 | next_datadir=yes |
| 148 | ;; |
| 149 | -gas | --g*) |
| 150 | gas=yes |
| 151 | ;; |
| 152 | -help | --he*) |
| 153 | fatal=true |
| 154 | ;; |
| 155 | -host=* | --host=* | --hos=* | --ho=*) |
| 156 | # if [ -n "${hosts}" ] ; then |
| 157 | # subdirs="--subdirs" |
| 158 | # fi |
| 159 | |
| 160 | if [ -z "${hosts}" ] ; then |
| 161 | newhosts="${hosts} `echo ${arg} | sed 's/^[-a-z]*=//'`" |
| 162 | hosts="${newhosts}" |
| 163 | else |
| 164 | echo '***' Can only configure for one host at a time. |
| 165 | fatal=yes |
| 166 | fi |
| 167 | ;; |
| 168 | # -namesubdir | --namesubdir | --namesubdi | --namesubd | --namesub | --namesu | --names | --name | --nam | --na) |
| 169 | # next_namesubdir=yes |
| 170 | # ;; |
| 171 | # -namesubdir=* | --namesubdir=* | --namesubdi=* | --namesubd=* | --namesub=* | --namesu=* | --names=* | --name=* | --nam=* | --na=*) |
| 172 | # namesubdir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
| 173 | # namesubdiroption=${arg} |
| 174 | # ;; |
| 175 | -nfp | --nf*) |
| 176 | floating_point=no |
| 177 | ;; |
| 178 | -norecursion | --no*) |
| 179 | norecursion=true |
| 180 | ;; |
| 181 | # -objdir=* | --objdir=* | --objdi=* | --objd=* | --obj=* | --ob=* | --o=*) |
| 182 | # objdiroption=${arg} |
| 183 | # objdir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
| 184 | # ;; |
| 185 | # -objdir | --objdir | --objdi | --objd | --obj | --ob | --o) |
| 186 | # next_objdir=yes |
| 187 | # ;; |
| 188 | -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) |
| 189 | prefix=`echo ${arg} | sed 's/^[-a-z]*=//'` |
| 190 | prefixoption=${arg} |
| 191 | ;; |
| 192 | -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) |
| 193 | next_prefix=yes |
| 194 | ;; |
| 195 | -recurring | --recurring | --recurrin | --recurri | --recurr | --recur | --recu | --rec | --re) |
| 196 | recurring=true |
| 197 | arguments=`echo ${arguments} | sed "s:${arg}::"` |
| 198 | ;; |
| 199 | -rm | --rm) |
| 200 | removing=${arg} |
| 201 | ;; |
| 202 | -site=* | --site=* | --sit=* | --si=*) |
| 203 | site=`echo ${arg} | sed 's/^[-a-z]*=//'` |
| 204 | ;; |
| 205 | -site | --site | --sit | --si) |
| 206 | next_site=yes |
| 207 | ;; |
| 208 | -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) |
| 209 | srcdir=`echo ${arg} | sed 's/^[-a-z]*=//'` |
| 210 | ;; |
| 211 | -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) |
| 212 | next_srcdir=yes |
| 213 | ;; |
| 214 | # -subdirs | --su*) |
| 215 | # subdirs=${arg} |
| 216 | # ;; |
| 217 | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*) |
| 218 | # if [ -n "${targets}" ] ; then |
| 219 | # subdirs="--subdirs" |
| 220 | # fi |
| 221 | |
| 222 | if [ -z "${targets}" ] ; then |
| 223 | newtargets="${targets} `echo ${arg} | sed 's/^[-a-z]*=//'`" |
| 224 | targets="${newtargets}" |
| 225 | else |
| 226 | echo '***' Can only configure for one target at a time. |
| 227 | fatal=yes |
| 228 | fi |
| 229 | ;; |
| 230 | -target | --target | --targe | --targ | --tar | --ta) |
| 231 | next_target=yes |
| 232 | ;; |
| 233 | -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*) |
| 234 | tmpdiroption=${arg} |
| 235 | TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'` |
| 236 | ;; |
| 237 | -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm) |
| 238 | next_tmpdir=yes |
| 239 | ;; |
| 240 | -v | -verbose | --v) |
| 241 | verbose=${arg} |
| 242 | ;; |
| 243 | -version | -V | --version | --V) |
| 244 | echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'` |
| 245 | exit 0 |
| 246 | ;; |
| 247 | -x | --x) ;; |
| 248 | -* | --*) |
| 249 | (echo ; |
| 250 | echo "Unrecognized option: \"${arg}\"". ; |
| 251 | echo) 1>&2 |
| 252 | fatal=true |
| 253 | ;; |
| 254 | *) |
| 255 | # if [ -n "${hosts}" ] ; then |
| 256 | # subdirs="--subdirs" |
| 257 | # fi |
| 258 | |
| 259 | if [ -z "${undefs}" ] ; then |
| 260 | newundefs="${undefs} ${arg}" |
| 261 | undefs=${newundefs} |
| 262 | else |
| 263 | echo '***' Can only configure for one host and one target at a time. |
| 264 | fatal=yes |
| 265 | fi |
| 266 | ;; |
| 267 | esac |
| 268 | fi |
| 269 | done |
| 270 | |
| 271 | # process host and target |
| 272 | if [ -z "${fatal}" ] ; then |
| 273 | # # Complain if an arg is missing |
| 274 | # if [ -z "${hosts}" ] ; then |
| 275 | # (echo ; |
| 276 | # echo "configure: No HOST specified." ; |
| 277 | # echo) 1>&2 |
| 278 | # fatal=true |
| 279 | # fi |
| 280 | |
| 281 | ### This is a bit twisted. |
| 282 | ### * if all three are specified, this is an error. |
| 283 | ### * if we have neither hosts, nor unadorned args, this is an error. |
| 284 | ### * if no hosts are specified, then the unadorned args are hosts, but if |
| 285 | ### there were none, this is an error. |
| 286 | ### * if no targets are specified, then the unadorned args are targets, but if |
| 287 | ### there were no unadorned args, then the hosts are also targets. |
| 288 | |
| 289 | if [ -n "${hosts}" -a -n "${targets}" -a -n "${undefs}" ] ; then |
| 290 | echo '***' Can only configure for one host and one target at a time. |
| 291 | fatal=yes |
| 292 | elif [ -z "${hosts}" -a -z "${undefs}" ] ; then |
| 293 | echo '***' You must tell me for which host you want to configure. |
| 294 | fatal=yes |
| 295 | else |
| 296 | if [ -z "${hosts}" ] ; then |
| 297 | hosts=${undefs} |
| 298 | fi |
| 299 | |
| 300 | if [ -z "${targets}" ] ; then |
| 301 | if [ -n "${undefs}" ] ; then |
| 302 | targets=${undefs} |
| 303 | else |
| 304 | targets=${hosts} |
| 305 | fi |
| 306 | fi |
| 307 | fi |
| 308 | fi |
| 309 | |
| 310 | if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then |
| 311 | (echo "Usage: configure HOST" ; |
| 312 | echo ; |
| 313 | echo "Options: [defaults in brackets]" ; |
| 314 | echo " -datadir=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ; |
| 315 | echo " -gas configure the compilers for use with gas. [native as]" ; |
| 316 | echo " -help print this message. [normal config]" ; |
| 317 | echo " -lang=LANG configure to build LANG. [gcc]" ; |
| 318 | echo " -nfp configure the compilers default to soft floating point. [hard float]" ; |
| 319 | echo " -norecursion configure this directory only. [recurse]" ; |
| 320 | # echo " -objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ; |
| 321 | echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ; |
| 322 | echo " -rm remove this configuration. [build a configuration]" ; |
| 323 | echo " -site configure with site specific makefile" ; |
| 324 | echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ; |
| 325 | # This is correctly aligned in the output, even though it isn't here. |
| 326 | # echo " -subdirs configure in subdirectories. [in source directories]" ; |
| 327 | echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ; |
| 328 | echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ; |
| 329 | echo ; |
| 330 | echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; |
| 331 | # echo "Asking for more than one \"--target\" implies \"--subdirs\". Any other" ; |
| 332 | # echo "options given will apply to all targets." |
| 333 | ) 1>&2 |
| 334 | |
| 335 | if [ -r config.status ] ; then |
| 336 | cat config.status |
| 337 | fi |
| 338 | |
| 339 | exit 1 |
| 340 | fi |
| 341 | |
| 342 | configsub=`echo ${progname} | sed 's/configure$/config.sub/'` |
| 343 | |
| 344 | if (${configsub} `echo ${hosts} | sed -e 's/ .*//'`) >/dev/null 2>&1 ; then |
| 345 | true |
| 346 | else |
| 347 | echo '***' cannot find config.sub. |
| 348 | exit 1 |
| 349 | fi |
| 350 | |
| 351 | if [ -z "${srcdir}" ] ; then |
| 352 | if [ -r configure.in ] ; then |
| 353 | srcdir=. |
| 354 | else |
| 355 | echo '***' "Can't find configure.in. Try using -srcdir=some_dir" |
| 356 | exit 1 |
| 357 | fi |
| 358 | fi |
| 359 | |
| 360 | |
| 361 | ### break up ${srcdir}/configure.in. |
| 362 | if [ -z "`grep '^# per\-host:' ${srcdir}/configure.in`" ] ; then |
| 363 | echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2 |
| 364 | exit 1 |
| 365 | fi |
| 366 | |
| 367 | if [ -z "`grep '^# per\-target:' ${srcdir}/configure.in`" ] ; then |
| 368 | echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2 |
| 369 | exit 1 |
| 370 | fi |
| 371 | |
| 372 | if [ -z "${TMPDIR}" ] ; then |
| 373 | TMPDIR=/tmp ; export TMPDIR |
| 374 | fi |
| 375 | |
| 376 | # keep this filename short for &%*%$*# 14 char file names |
| 377 | tmpfile=${TMPDIR}/cONf$$ |
| 378 | trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0 |
| 379 | |
| 380 | # split ${srcdir}/configure.in into common, per-host, per-target, |
| 381 | # and post-target parts. Post-target is optional. |
| 382 | sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com |
| 383 | sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst |
| 384 | if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then |
| 385 | sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt |
| 386 | sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos |
| 387 | else |
| 388 | sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt |
| 389 | echo >${tmpfile}.pos |
| 390 | fi |
| 391 | |
| 392 | ### do common part of configure.in |
| 393 | |
| 394 | . ${tmpfile}.com |
| 395 | |
| 396 | # some sanity checks on configure.in |
| 397 | if [ -z "${srctrigger}" ] ; then |
| 398 | echo '***' srctrigger not set in ${PWD}/configure.in. |
| 399 | exit 1 |
| 400 | fi |
| 401 | |
| 402 | for host in ${hosts} ; do |
| 403 | # Default other arg |
| 404 | if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then |
| 405 | targets=${host} |
| 406 | defaulttargets=true |
| 407 | fi |
| 408 | |
| 409 | host_alias=${host} |
| 410 | |
| 411 | result=`${configsub} ${host}` |
| 412 | host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` |
| 413 | host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` |
| 414 | host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` |
| 415 | host=${host_cpu}-${host_vendor}-${host_os} |
| 416 | host_makefile_frag=config/mh-${host} |
| 417 | if [ ! -f ${host_makefile_frag} ] |
| 418 | then |
| 419 | host_makefile_frag=config/mh-${host_alias} |
| 420 | fi |
| 421 | |
| 422 | . ${tmpfile}.hst |
| 423 | |
| 424 | for target in ${targets} ; do |
| 425 | |
| 426 | target_alias=${target} |
| 427 | result=`${configsub} ${target}` |
| 428 | target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` |
| 429 | target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` |
| 430 | target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` |
| 431 | target=${target_cpu}-${target_vendor}-${target_os} |
| 432 | target_makefile_frag=config/mt-${target} |
| 433 | if [ ! -f ${target_makefile_frag} ] |
| 434 | then |
| 435 | target_makefile_frag=config/mt-${target_alias} |
| 436 | fi |
| 437 | |
| 438 | . ${tmpfile}.tgt |
| 439 | |
| 440 | if [ "${host_alias}" = "${target_alias}" ] ; then |
| 441 | subdirname=H-${host_alias} |
| 442 | else |
| 443 | subdirname=X-${host_alias}-${target_alias} |
| 444 | fi |
| 445 | |
| 446 | if [ -n "${namesubdir}" ] ; then |
| 447 | subdirname=${namesubdir} |
| 448 | fi |
| 449 | |
| 450 | if [ -n "${removing}" ] ; then |
| 451 | # if [ -n "${objdir}" ] ; then |
| 452 | # echo '***' --rm not supported for --objdir. Just \"rm -rf ${objdir}\" by hand. |
| 453 | # exit 1 |
| 454 | # fi |
| 455 | |
| 456 | # if [ -n "${subdirs}" ] ; then |
| 457 | # if [ -d "${subdirname}" ] ; then |
| 458 | # rm -rf ${hostsubdir} |
| 459 | # else |
| 460 | # echo Warning: no ${PWD}/${hostsubdir} to remove. |
| 461 | # fi |
| 462 | # else |
| 463 | rm -f ${Makefile} config.status ${links} |
| 464 | # fi |
| 465 | else |
| 466 | # if [ -n "${objdir}" ]; then |
| 467 | # srcdir=${PWD} |
| 468 | # cd ${objdir} |
| 469 | # fi |
| 470 | |
| 471 | # if [ -n "${subdirs}" ] ; then |
| 472 | # # check for existing status before allowing forced subdirs. |
| 473 | # if [ -f ${Makefile} ] ; then |
| 474 | # echo '***' "${Makefile} already exists in source directory. ${PWD} not configured." 1>&2 |
| 475 | # exit 1 |
| 476 | # fi |
| 477 | # |
| 478 | # # use a subdir common to all targets for this host iff: this is a cross AND |
| 479 | # # this tool does not claim to be target dependent AND we have not been asked to name the subdir. |
| 480 | # if [ ${host_alias} != ${target_alias} -a -z "${target_dependent}" -a -z "${namesubdiroption}" ] |
| 481 | # then |
| 482 | # if [ ! -d H-${host_alias} ] ; then mkdir H-${host_alias} ; fi |
| 483 | # |
| 484 | # if (${symbolic_link} ${subdirname} H-${host_alias} 2> /dev/null) ; then |
| 485 | # true |
| 486 | # else # just give up. they lose. |
| 487 | # rmdir H-${host_alias} |
| 488 | # if [ ! -d ${subdirname} ] ; then mkdir ${subdirname} ; fi |
| 489 | # fi |
| 490 | # elif [ ! -d ${subdirname} ] ; then |
| 491 | # mkdir ${subdirname} |
| 492 | # fi |
| 493 | # |
| 494 | # cd ${subdirname} |
| 495 | # |
| 496 | # if [ -z "${srcdir}" ] ; then |
| 497 | # srcdir=.. |
| 498 | # fi |
| 499 | # elif [ "`echo H-*`" != "H-*" -a "`echo X-*`" != "X-*" ] ; then |
| 500 | # # if not subdir builds, then make sure none exist. |
| 501 | # # We might miss if there are explicitly named subdirs. |
| 502 | # echo '***' "Configured subdirs exist. ${PWD} not configured." 1>&2 |
| 503 | # exit 1 |
| 504 | # else |
| 505 | # true |
| 506 | # fi |
| 507 | |
| 508 | # Find the source files, if location was not specified. |
| 509 | if [ -z "${srcdir}" ] ; then |
| 510 | srcdirdefaulted=1 |
| 511 | srcdir=. |
| 512 | if [ ! -r ${srctrigger} ] ; then |
| 513 | srcdir=.. |
| 514 | fi |
| 515 | fi |
| 516 | |
| 517 | if [ ! -r ${srcdir}/${srctrigger} ] ; then |
| 518 | if [ -z "${srcdirdefaulted}" ] ; then |
| 519 | echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2 |
| 520 | else |
| 521 | echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2 |
| 522 | fi |
| 523 | |
| 524 | echo '***' \(At least ${srctrigger} is missing.\) 1>&2 |
| 525 | exit 1 |
| 526 | fi |
| 527 | |
| 528 | # Set up the list of links to be made. |
| 529 | # ${links} is the list of link names, and ${files} is the list of names to link to. |
| 530 | |
| 531 | # Make the links. |
| 532 | while [ -n "${files}" ] ; do |
| 533 | # set file to car of files, files to cdr of files |
| 534 | set ${files}; file=$1; shift; files=$* |
| 535 | set ${links}; link=$1; shift; links=$* |
| 536 | |
| 537 | if [ ! -r ${srcdir}/${file} ] ; then |
| 538 | echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 |
| 539 | echo '***' "since the file \"${file}\" does not exist." 1>&2 |
| 540 | exit 1 |
| 541 | fi |
| 542 | |
| 543 | ${remove} -f ${link} |
| 544 | rm -f config.status |
| 545 | # Make a symlink if possible, otherwise try a hard link |
| 546 | ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} |
| 547 | |
| 548 | if [ ! -r ${link} ] ; then |
| 549 | echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 |
| 550 | exit 1 |
| 551 | fi |
| 552 | |
| 553 | if [ -n "${verbose}" ] ; then |
| 554 | echo "Linked \"${link}\" to \"${srcdir}/${file}\"." |
| 555 | fi |
| 556 | done |
| 557 | |
| 558 | # Create a .gdbinit file which runs the one in srcdir |
| 559 | # and tells GDB to look there for source files. |
| 560 | |
| 561 | if [ -r ${srcdir}/.gdbinit ] ; then |
| 562 | case ${srcdir} in |
| 563 | .) |
| 564 | ;; |
| 565 | *) |
| 566 | echo "# "${NO_EDIT} > .gdbinit |
| 567 | echo "dir ." >> .gdbinit |
| 568 | echo "dir ${srcdir}" >> .gdbinit |
| 569 | echo "source ${srcdir}/.gdbinit" >> .gdbinit |
| 570 | ;; |
| 571 | esac |
| 572 | fi |
| 573 | |
| 574 | # Install a makefile, and make it set VPATH |
| 575 | # if necessary so that the sources are found. |
| 576 | # Also change its value of srcdir. |
| 577 | |
| 578 | # FIXME-someday: This business of always writing to .tem and mv back |
| 579 | # is so that I don't screw things up while developing. Once this |
| 580 | # template is stable, these should be optimized. xoxorich. |
| 581 | |
| 582 | # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. |
| 583 | if [ "${host}" != "${target}" ] ; then |
| 584 | echo "CROSS=-DCROSS_COMPILE" > ${Makefile} |
| 585 | echo "ALL=all.cross" >> ${Makefile} |
| 586 | else |
| 587 | echo "ALL=all.internal" > ${Makefile} |
| 588 | fi |
| 589 | |
| 590 | # set target, host, VPATH |
| 591 | echo "host_alias = ${host_alias}" >> ${Makefile} |
| 592 | echo "host_cpu = ${host_cpu}" >> ${Makefile} |
| 593 | echo "host_vendor = ${host_vendor}" >> ${Makefile} |
| 594 | echo "host_os = ${host_os}" >> ${Makefile} |
| 595 | |
| 596 | echo "target_alias = ${target_alias}" >> ${Makefile} |
| 597 | echo "target_cpu = ${target_cpu}" >> ${Makefile} |
| 598 | echo "target_vendor = ${target_vendor}" >> ${Makefile} |
| 599 | echo "target_os = ${target_os}" >> ${Makefile} |
| 600 | |
| 601 | # if [ -n "${subdirs}" ] ; then |
| 602 | # (echo "subdir = /${subdirname}" ; |
| 603 | # echo "unsubdir = ..") >> ${Makefile} |
| 604 | # else |
| 605 | (echo "subdir =" ; |
| 606 | echo "unsubdir = .") >> ${Makefile} |
| 607 | # fi |
| 608 | |
| 609 | # echo "workdir = ${PWD}" >> ${Makefile} |
| 610 | echo "VPATH = ${srcdir}" >> ${Makefile} |
| 611 | |
| 612 | # add "Makefile.in" (or whatever it's called) |
| 613 | cat ${srcdir}/${Makefile_in} >> ${Makefile} |
| 614 | |
| 615 | # Conditionalize the makefile for this site. |
| 616 | if [ -n "${site}" ] ; then |
| 617 | site_makefile_frag=config/ms-${site} |
| 618 | |
| 619 | if [ -f ${srcdir}/${site_makefile_frag} ] ; then |
| 620 | (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ; |
| 621 | sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem |
| 622 | else |
| 623 | (echo "site_makefile_frag =" ; |
| 624 | cat ${Makefile}) > Makefile.tem |
| 625 | fi |
| 626 | mv Makefile.tem ${Makefile} |
| 627 | fi |
| 628 | |
| 629 | # Conditionalize the makefile for this host. |
| 630 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then |
| 631 | (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; |
| 632 | sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem |
| 633 | else |
| 634 | (echo "host_makefile_frag =" ; |
| 635 | cat ${Makefile}) > Makefile.tem |
| 636 | fi |
| 637 | mv Makefile.tem ${Makefile} |
| 638 | |
| 639 | # Conditionalize the makefile for this target. |
| 640 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then |
| 641 | (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; |
| 642 | sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem |
| 643 | else |
| 644 | (echo "target_makefile_frag =" ; |
| 645 | cat ${Makefile}) > Makefile.tem |
| 646 | fi |
| 647 | mv Makefile.tem ${Makefile} |
| 648 | |
| 649 | # set srcdir |
| 650 | sed "s:^srcdir[ ]*=.*$:srcdir = ${srcdir}:" ${Makefile} > Makefile.tem |
| 651 | mv Makefile.tem ${Makefile} |
| 652 | |
| 653 | # set prefix |
| 654 | if [ -n "${prefix}" ] ; then |
| 655 | sed "s:^prefix[ ]*=.*$:prefix = ${prefix}:" ${Makefile} > Makefile.tem |
| 656 | mv Makefile.tem ${Makefile} |
| 657 | fi |
| 658 | |
| 659 | # set datadir |
| 660 | if [ -n "${datadir}" ] ; then |
| 661 | sed "s:^datadir[ ]*=.*$:datadir = ${datadir}:" ${Makefile} > Makefile.tem |
| 662 | mv Makefile.tem ${Makefile} |
| 663 | fi |
| 664 | |
| 665 | # reset SUBDIRS |
| 666 | sed "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem |
| 667 | mv Makefile.tem ${Makefile} |
| 668 | |
| 669 | # reset NONSUBDIRS |
| 670 | sed "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem |
| 671 | mv Makefile.tem ${Makefile} |
| 672 | |
| 673 | # remove any form feeds. |
| 674 | sed -e "s/\f//" ${Makefile} > Makefile.tem |
| 675 | mv Makefile.tem ${Makefile} |
| 676 | |
| 677 | # prepend warning about editting. |
| 678 | echo "# "${NO_EDIT} > ${Makefile}.tem |
| 679 | cat ${Makefile} >> ${Makefile}.tem |
| 680 | mv Makefile.tem ${Makefile} |
| 681 | |
| 682 | using= |
| 683 | if [ -f ${srcdir}/${host_makefile_frag} ] ; then |
| 684 | using="${using} and \"${host_makefile_frag}\"" |
| 685 | fi |
| 686 | if [ -f ${srcdir}/${target_makefile_frag} ] ; then |
| 687 | using="${using} and \"${target_makefile_frag}\"" |
| 688 | fi |
| 689 | if [ -n "${site}" -a \ |
| 690 | -f ${srcdir}/${site_makefile_frag} ] ; then |
| 691 | using="${using} and \"${site_makefile_frag}\"" |
| 692 | fi |
| 693 | using=`echo "${using}" | sed 's/and/using/'` |
| 694 | using="Created \"${Makefile}\" in ${PWD}${using}." |
| 695 | |
| 696 | if [ -n "${verbose}" -o -z "${recurring}" ] ; then |
| 697 | echo ${using} |
| 698 | fi |
| 699 | |
| 700 | . ${tmpfile}.pos |
| 701 | |
| 702 | # describe the chosen configuration in config.status. |
| 703 | # Make that file a shellscript which will reestablish |
| 704 | # the same configuration. Used in Makefiles to rebuild |
| 705 | # Makefiles. |
| 706 | |
| 707 | if [ -z "${norecursion}" ] ; then |
| 708 | arguments="${arguments} -norecursion" |
| 709 | fi |
| 710 | |
| 711 | echo "#!/bin/sh |
| 712 | # ${NO_EDIT} |
| 713 | # ${PWD} was configured as follows: |
| 714 | ${progname}" ${arguments} " |
| 715 | # ${using}" > config.status |
| 716 | chmod a+x config.status |
| 717 | |
| 718 | # originaldir=${PWD} |
| 719 | # cd ${srcdir} |
| 720 | fi |
| 721 | |
| 722 | # If there are subdirectories, then recur. |
| 723 | if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then |
| 724 | for configdir in ${configdirs} ; do |
| 725 | if [ -n "${verbose}" ] ; then |
| 726 | echo Configuring ${configdir}... |
| 727 | fi |
| 728 | |
| 729 | if [ -d ${srcdir}/${configdir} ] ; then |
| 730 | if [ "${srcdir}" != "." ] ; then |
| 731 | if [ ! -d ./${configdir} ] ; then |
| 732 | mkdir ./${configdir} |
| 733 | fi |
| 734 | fi |
| 735 | |
| 736 | POPDIR=${PWD} |
| 737 | cd ${configdir} |
| 738 | |
| 739 | ### figure out what to do with srcdir |
| 740 | case "${srcdir}" in |
| 741 | ".") ;; # do nothing. We're building in place. |
| 742 | /*) srcdiroption="-srcdir=${srcdir}/${configdir}" ;; # absolute path |
| 743 | *) srcdiroption="-srcdir=../${srcdir}/${configdir}" ;; # otherwise relative |
| 744 | esac |
| 745 | |
| 746 | ### The recursion line is here. |
| 747 | if [ -x configure ] ; then |
| 748 | recprog=`pwd`/configure |
| 749 | else |
| 750 | recprog=${progname} |
| 751 | fi |
| 752 | |
| 753 | if (${recprog} -recurring ${host_alias} -target=${target_alias} \ |
| 754 | ${verbose} ${subdirs} ${removing} ${prefixoption} \ |
| 755 | ${tmpdiroption} ${namesubdiroption} ${datadiroption} \ |
| 756 | ${srcdiroption}) ; then |
| 757 | true |
| 758 | else |
| 759 | exit 1 |
| 760 | fi |
| 761 | |
| 762 | cd ${POPDIR} |
| 763 | elif [ -n "${verbose}" ] ; then |
| 764 | echo Warning: source directory \"${srcdir}/${configdir}\" is missing. |
| 765 | fi |
| 766 | done |
| 767 | fi |
| 768 | done # for each target |
| 769 | |
| 770 | # Now build a Makefile for this host. |
| 771 | # if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then |
| 772 | # push=${PWD} |
| 773 | # |
| 774 | # if [ -n "${objdir}" ] ; then |
| 775 | # cd ${objdir} |
| 776 | # fi |
| 777 | # |
| 778 | # cd ${hostsubdir} |
| 779 | # cat > GNUmakefile << 'E!O!F' |
| 780 | ## Makefile generated by configure for host ${host_alias}. |
| 781 | # |
| 782 | #ALL := $(shell ls -d T-*) |
| 783 | # |
| 784 | #%: |
| 785 | # $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true |
| 786 | # |
| 787 | #all: |
| 788 | #E!O!F |
| 789 | # cd ${push} |
| 790 | # fi |
| 791 | done # for each host |
| 792 | |
| 793 | ### clean up. |
| 794 | |
| 795 | # trap cmd above handles this now: |
| 796 | #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos |
| 797 | |
| 798 | exit 0 |
| 799 | |
| 800 | # |
| 801 | # Local Variables: |
| 802 | # fill-column: 131 |
| 803 | # End: |
| 804 | # |
| 805 | |
| 806 | # end of configure |