File: configure

package info (click to toggle)
clisp 1997-12-06-1
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 20,744 kB
  • ctags: 8,390
  • sloc: ansic: 37,808; lisp: 37,255; asm: 6,393; sh: 3,077; objc: 2,481; makefile: 1,174; sed: 96; perl: 14
file content (497 lines) | stat: -rwxr-xr-x 15,288 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
#! /bin/sh
# Usage: configure [options] [dirname [cc]]
# Examples:
#   configure obj
#   CC=gcc configure make.gcc
#   CC=cc configure make.cc
#   configure make.gcc gcc     (deprecated)
#   configure make.cc cc       (deprecated)

info_help () {
cat << \EOP
Usage: configure [options] [dirname]
dirname: Name of directory in which to build CLISP. This allows you to build
         CLISP with different compilers on the same machine or for different
         architectures in the same filesystem, sharing the same source.
         Default is `src'.
options: The following options are recognized:
         --help                print this message and exit
         --version             print the CLISP version and exit
         --config              unix/INSTALL step 3: configuration only
         --build               unix/INSTALL steps 3-7: configure, build, check
         --install             unix/INSTALL step 8: install
         The following options set installation parameters:
         --srcdir=SRCDIR       sets the source directory to SRCDIR
         The following options are passed to subordinate `configure' scripts:
         --quiet, --silent     do not print `checking...' messages
         --prefix=PREFIX       base directory for files to be installed
         --exec-prefix=PREFIX  base directory for architecture-dependent
                               files to be installed
         --fsstnd=STYLE        specify file system standard for installation
         --host=HOST           specify host in CPU-VENDOR-OS format (just
                               in case config.guess guesses wrong)
         --with-PACKAGE        use PACKAGE
         --without-PACKAGE     do not use PACKAGE
Example:
         configure --build built-with-gcc
         su bin
         configure --install built-with-gcc
         exit
Specifying the C compiler:
         If you wish to specify the C compiler that will get used to build
         CLISP, set the environment variables CC, CFLAGS, LIBS. Put compiler
         flags that have to be passed to the preprocessor into the CC
         variable, not the CFLAGS variable. For example, if you want to use
         gcc in ANSI C mode, execute the following before calling `configure':
               setenv CC "gcc -ansi"                 if using csh
               export CC="gcc -ansi"                 if using bash or ksh
               CC="gcc -ansi"; export CC             if using sh
EOP
}

# Abort in case something fails.
set -e

srcdir=''
subdir_configure_args=''
makemake_args=''
do_config=''
do_build=''
do_install=''
argcount=0

prev=''
passnext=''
passnextm=''
for arg # in "$@"
do
  # If the previous option needs an argument, assign it.
  if test -n "$prev"; then
    # If the previous option needs an argument for subdir_configure_args, pass it.
    if test -n "$passnext"; then
      subdir_configure_args="$subdir_configure_args $arg"
      passnext=''
      # If the previous option needs an argument for makemake_args, pass it as well.
      if test -n "$passnextm"; then
        makemake_args="$makemake_args$arg"
        passnextm=''
      fi
    else
      eval "$prev=\$arg"
    fi
    prev=''
  else

    case "$arg" in

      --build | --buil | --bui | --bu | --b)
        do_config=1
        do_build=1 ;;

      --config | --confi | --conf | --con | --co | --c)
        do_config=1 ;;

      --help | --hel | --he | --h)
        info_help
        exit 0 ;;

      --install | --instal | --insta | --inst | --ins | --in | --i)
        do_install=1 ;;

      --version | --versio | --versi | --vers | --ver | --ve | --v)
        version="CLISP version "`cat src/VERSION`
        echo $version
        exit 0 ;;

      --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
        srcdir=`echo "$arg" | sed 's,^[-_a-zA-Z0-9]*=,,'` ;;

      --srcdir | --srcdi | --srcd | --src | --sr)
        prev=srcdir
        passnext=yes ;;

      --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
        subdir_configure_args="$subdir_configure_args $arg"
        makemake_args="$makemake_args --prefix="`echo "$arg" | sed 's,^[-_a-zA-Z0-9]*=,,'` ;;

      --prefix | --prefi | --pref | --pre | --pr | --p)
        subdir_configure_args="$subdir_configure_args $arg"
        makemake_args="$makemake_args --prefix="
        prev=prefix
        passnext=yes
        passnextm=yes ;;

      --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | -exec=* | --exe=* | --ex=* | --e=*)
        subdir_configure_args="$subdir_configure_args $arg"
        makemake_args="$makemake_args --exec-prefix="`echo "$arg" | sed 's,^[-_a-zA-Z0-9]*=,,'` ;;

      --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | -exec | --exe | --ex | --e)
        subdir_configure_args="$subdir_configure_args $arg"
        makemake_args="$makemake_args --exec-prefix="
        prev=exec_prefix
        passnext=yes
        passnextm=yes ;;

      --fsstnd=* | --fsstn=* | --fsst=* | --fss=* | --fs=* | --f=*)
        subdir_configure_args="$subdir_configure_args $arg"
        makemake_args="$makemake_args --fsstnd="`echo "$arg" | sed 's,^[-_a-zA-Z0-9]*=,,'` ;;

      --host=* | --hos=* | --ho=* | --h=* | \
      --quiet | --quie | --qui | --qu | --q | \
      --silent | --silen | --sile | --sil | --si)
        subdir_configure_args="$subdir_configure_args $arg" ;;

      --host | --hos | --ho | --h)
        subdir_configure_args="$subdir_configure_args $arg"
        prev=host
        passnext=yes ;;

      --with-* | --without-*)
        subdir_configure_args="$subdir_configure_args $arg"
        makemake_args="$makemake_args $arg" ;;

      --*)
        echo "$0: invalid argument $arg" 1>&2
        echo "$0: Try \`$0 --help'" 1>&2
        exit 1 ;;

      *) # Everything else counts as a positional argument
        argcount=`expr $argcount + 1`
        eval "POSARG$argcount=\$arg" ;;

    esac

  fi
done
if test -n "$prev"; then
  echo "$0: missing argument to $prev" 1>&2
  echo "$0: Try \`$0 --help'" 1>&2
  exit 1
fi

DIRNAME=$POSARG1
COMPILER=$POSARG2 # deprecated

if test -z "$do_config" -a -z "$do_build" -a -z "$do_install"; then
  # Default is --config
  do_config=1
fi

# checking how to copy files
echo "blabla" > conftest.x
err=`/bin/sh -c "cp -p conftest.x conftest.y 2>&1 ; exit 0"`
if test -z "$err"; then
  CP='cp -p'
else
  CP='cp'
fi
rm -f conftest*

# link FILE1 FILE2  is like `ln', but chooses the cheapest alternative:
# hard link if FILE1 and FILE2 on the same disk, else symbolic link if the
# system supports that, else file copy.
link () {
# Note: With some versions of "ln" this does not work if FILE2 is a symlink.
if ln "$1" "$2" 2>/dev/null; then
  :
else
  srcfile_dirname=`echo "$1" | sed -e 's,/[^/]*$,,'`
  test -n "$srcfile_dirname" || srcfile_dirname='/'
  srcfile_basename=`echo "$1" | sed -e 's,^.*/,,'`
  srcfile_absdirname=`cd "$srcfile_dirname"; pwd`
  if ln -s "$srcfile_absdirname/$srcfile_basename" "$2" 2>/dev/null; then
    :
  else
    $CP "$1" "$2"
  fi
fi
}

# Note that we would need to call `/bin/pwd` if we wanted to compare two
# directories for equality. But he we only need to get _some_ absolute
# pathnames, hence `pwd` is enough.
# Note also that /bin/pwd doesn't exist on Cygwin32.

if test -f /bin/pwd ; then
  ABSPATHPWD=/bin/pwd
else
  ABSPATHPWD=pwd
fi

INPLACE=''
if test -n "$srcdir" ; then
  if test ! -d "$srcdir" ; then
    echo "$0: srcdir: ($srcdir) nonexistent" 1>&2
    exit 1
  fi
  ABS_SRCDIR=`cd "$srcdir"; pwd`
  if [ "$DIRNAME" = "" ] ; then
    DIRNAME='.'
  fi
  if [ ! -d $DIRNAME ] ; then
    mkdir $DIRNAME
  fi
  REL_SRCDIR="$ABS_SRCDIR"
else
  if test -f ./ANNOUNCE -a -f ./SUMMARY; then
    srcdir='.'
    ABS_SRCDIR=`cd "$srcdir"; pwd`
    if [ "$DIRNAME" = "" ] ; then
      DIRNAME=src
    fi
  else
    if test -f ../ANNOUNCE -a -f ../SUMMARY; then
      srcdir='..'
      ABS_SRCDIR=`cd "$srcdir"; pwd`
      if [ "$DIRNAME" = "" ] ; then
        DIRNAME='.'
      fi
    else
      echo "$0: source directory not found, use --srcdir option" 1>&2
      exit 1
    fi
  fi
  if [ ! -d $DIRNAME ] ; then
    mkdir $DIRNAME
  fi
  if test `cd "$DIRNAME"/..; $ABSPATHPWD` = `cd "$srcdir"; $ABSPATHPWD` ; then
    REL_SRCDIR='..'
  else
    REL_SRCDIR="$ABS_SRCDIR"
  fi
fi
ABS_DIRNAME=`cd "$DIRNAME"; pwd`
if test `cd "$DIRNAME"; $ABSPATHPWD` = `cd "$srcdir"/src; $ABSPATHPWD` ; then
  INPLACE=yes
fi
case "$REL_SRCDIR" in
  /*) RREL_SRCDIR="$REL_SRCDIR";;
  *)  RREL_SRCDIR="../$REL_SRCDIR";;
esac

# srcdir        top level source directory
#               (i.e. this script is $srcdir/configure)
# ABS_SRCDIR    absolute srcdir
# REL_SRCDIR    srcdir, relative to $DIRNAME
# RREL_SRCDIR   srcdir, relative to $DIRNAME/anysubdir
# DIRNAME       directory in which to build
# ABS_DIRNAME   absolute DIRNAME
# INPLACE       set if DIRNAME is the source directory, hence no links needed

if test -n "$do_config"; then

  cd "$ABS_SRCDIR"

  if [ "$COMPILER" != "" ] ; then
    CC="$COMPILER"
    export CC
  fi
  if test -z "$INPLACE"; then
    # Create subdirectories for: readline newreadline gettext termcap,
    # and fill them.
    # - readline, termcap: Because the Makefile carefully uses $(srcdir), only
    #   a few files need to be linked over.
    # - newreadline, gettext: The Makefiles use VPATH=$(srcdir), which is not
    #   portable, hence all files need to be linked over.
    for subdir in readline newreadline gettext termcap
    do
      if [ -d src/$subdir ] ; then
        if [ ! -d $ABS_DIRNAME/$subdir ] ; then
          mkdir $ABS_DIRNAME/$subdir
        fi
      fi
    done
    for f in readline/doc readline/examples \
             newreadline \
             gettext gettext/intl gettext/po
    do
      if [ -d src/$f ] ; then
        if [ ! -d $ABS_DIRNAME/$f ] ; then
          mkdir $ABS_DIRNAME/$f
        fi
        ( cd src
          for g in $f/* ; do
            if [ -f $g ] ; then
              rm -f $ABS_DIRNAME/$g
              link $g $ABS_DIRNAME/$g
            fi
          done
        )
      fi
    done
    for f in configure unixconf.h.in makemake.in VERSION \
             readline/configure readline/config.h.in readline/Makefile.in \
             termcap/configure termcap/Makefile.in
    do
      if [ -f src/$f ] ; then
        rm -f $ABS_DIRNAME/$f
        link src/$f $ABS_DIRNAME/$f
      fi
    done
  fi
  # Create subdirectories for the modules parts, and fill them.
  # The modules outright assumes that $(srcdir)='.', hence all files need to
  # be linked over.
  #for subdir in `cd modules ; find . -type d -print`
  #do
  #  if [ ! -d $ABS_DIRNAME/$f ] ; then
  #    mkdir $ABS_DIRNAME/$f
  #  fi
  #done
  #for f in `cd modules ; find . '!' -type d -print`
  #do
  #  rm -f $ABS_DIRNAME/$f
  #  link $f $ABS_DIRNAME/$f
  #done
  ( cd modules
    for d in *
    do
      if [ -d "$d" ] ; then
        ../src/lndir "$d" "$ABS_DIRNAME/$d"
      fi
    done
  )
  # Create subdirectories for the ffcall parts, and fill them.
  # The Makefiles carefully use $(srcdir). Need to link over only a few files.
  for subdir in avcall vacall trampoline
  do
    if [ -d ffcall/$subdir ] ; then
      if [ ! -d $ABS_DIRNAME/$subdir ] ; then
        mkdir $ABS_DIRNAME/$subdir
      fi
    fi
  done
  for subdir in avcall vacall trampoline
  do
    f=$subdir/configure
    if [ -f ffcall/$f ] ; then
      rm -f $ABS_DIRNAME/$f
      link ffcall/$f $ABS_DIRNAME/$f
    fi
  done
  # Prepare the configure files.
  chmod a+x $ABS_DIRNAME/configure
  for subdir in readline newreadline stdwin avcall vacall trampoline; do
    if test -d $ABS_DIRNAME/$subdir; then
      chmod a+x $ABS_DIRNAME/$subdir/configure
    fi
  done
  # Start the configurations.
  echo "executing $DIRNAME/configure ..."
  cd $ABS_DIRNAME
  if test -n "$INPLACE"; then
    subdir_srcdir_args=''
  else
    subdir_srcdir_args="--srcdir=$REL_SRCDIR/src"
  fi
  ${CONFIG_SHELL-/bin/sh} configure $subdir_srcdir_args $subdir_configure_args
  subdir_configure_args="$subdir_configure_args --cache-file=../config.cache"
  for subdir in readline newreadline gettext stdwin; do
    if test -d $subdir; then
      echo "executing $DIRNAME/$subdir/configure ..."
      cd $subdir
      if test -n "$INPLACE" -o $subdir = newreadline -o $subdir = gettext -o $subdir = stdwin; then
        subdir_srcdir_args=''
      else
        subdir_srcdir_args="--srcdir=$RREL_SRCDIR/src/$subdir"
      fi
      ${CONFIG_SHELL-/bin/sh} configure $subdir_srcdir_args \
         `if test $subdir = stdwin; then echo "--with-x11"; fi` \
         $subdir_configure_args
    cd ..
    fi
  done
  for subdir in avcall vacall trampoline; do
    if test -d $subdir; then
      echo "executing $DIRNAME/$subdir/configure ..."
      cd $subdir
      ${CONFIG_SHELL-/bin/sh} configure --srcdir="$RREL_SRCDIR/ffcall/$subdir" \
          $subdir_configure_args
    cd ..
    fi
  done
  cd ..

fi

# Determine recommended makemake arguments.
if grep 'cl_cv_prog_cc_cplusplus.*yes' $ABS_DIRNAME/config.cache > /dev/null ; then
  makemake_args="$makemake_args --with-noreadline"
else
  if test -d $ABS_DIRNAME/readline; then
    makemake_args="$makemake_args --with-readline"
  else
    if test -d $ABS_DIRNAME/newreadline; then
      makemake_args="$makemake_args --with-newreadline"
    else
      makemake_args="$makemake_args --with-noreadline"
    fi
  fi
fi
if grep 'cl_cv_prog_cc_cplusplus.*yes' $ABS_DIRNAME/config.cache > /dev/null ; then
  makemake_args="$makemake_args --with-nogettext"
else
  if test -d $ABS_DIRNAME/gettext; then
    makemake_args="$makemake_args --with-gettext"
  else
    makemake_args="$makemake_args --with-nogettext"
  fi
fi
if test -d $ABS_DIRNAME/avcall -a -d $ABS_DIRNAME/vacall -a -d $ABS_DIRNAME/trampoline; then
  (cd $ABS_DIRNAME/avcall && make) &&
  (cd $ABS_DIRNAME/vacall && make) &&
  (cd $ABS_DIRNAME/trampoline && make) &&
  (cd $ABS_DIRNAME/avcall && make check) &&
  (cd $ABS_DIRNAME/vacall && make check) &&
  (cd $ABS_DIRNAME/trampoline && make check) &&
  makemake_args="$makemake_args --with-dynamic-ffi"
fi
if grep 'cl_cv_prog_cc_gcc.*yes' $ABS_DIRNAME/config.cache > /dev/null ; then
  if grep 'cl_cv_c_longlong.*yes' $ABS_DIRNAME/config.cache > /dev/null ; then
    eval `grep '^cl_cv_host=' $ABS_DIRNAME/config.cache`
    case "$cl_cv_host" in
      mips-* | hppa*-* )
        # 32-bit cpu, but gcc-2.7.2 crashes when compiling spvw.d with -DWIDE
        ;;
      m68k-* )
        # 32-bit cpu, but gcc-2.7.2 crashes when compiling foreign.d with -DWIDE
        ;;
      i?86-* | m68k-* | mips-* | sparc-* | hppa*-* | arm-* | rs6000-* | m88k-* | convex*-* )
        # 32-bit cpu
        makemake_args="$makemake_args --with-wide"
        ;;
      alpha-* | mips64-* )
        # 64-bit cpu
        ;;
    esac
  fi
fi

if test -z "$do_build"; then

  echo
  echo "To continue building CLISP, the following commands are recommended"
  echo "(cf. unix/INSTALL step 4):"
  echo "    cd $DIRNAME"
  echo "    ./makemake $makemake_args > Makefile"
  echo "    make"
  echo "    make check"

else

  cd $ABS_DIRNAME
  ./makemake $makemake_args > Makefile
  make
  make check
  cd ..

fi

if test -n "$do_install"; then

  cd $ABS_DIRNAME
  make install
  cd ..

fi