home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / configure < prev    next >
Encoding:
Text File  |  1994-12-30  |  8.7 KB  |  304 lines

  1. #! /bin/sh
  2. # Usage: configure [options] [dirname [cc]]
  3. # Examples:
  4. #   configure make.gcc gcc
  5. #   configure make.cc cc
  6. #   configure obj
  7.  
  8. info_help () {
  9. cat << \EOP
  10. Usage: configure [options] [dirname]
  11. dirname: Name of directory in which to build CLISP. This allows you to build
  12.          CLISP with different compilers on the same machine or for different
  13.          architectures in the same filesystem, sharing the same source.
  14.          Default is `src'.
  15. options: The following options are recognized:
  16.          --help                print this message and exit
  17.          --version             print the CLISP version and exit
  18.          --config              unix/INSTALL step 3: configuration only
  19.          --build               unix/INSTALL steps 3-7: configure, build, check
  20.          --install             unix/INSTALL step 8: install
  21.          The following options are passed to subordinate `configure' scripts:
  22.          --quiet, --silent     do not print `checking...' messages
  23.          --prefix=PREFIX       base directory for files to be installed
  24.          --exec-prefix=PREFIX  base directory for architecture-dependent
  25.                                files to be installed
  26.          --with-PACKAGE        use PACKAGE
  27.          --without-PACKAGE     do not use PACKAGE
  28. Example:
  29.          configure --build built-with-gcc
  30.          su bin
  31.          configure --install built-with-gcc
  32.          exit
  33. Specifying the C compiler:
  34.          If you wish to specify the C compiler that will get used to build
  35.          CLISP, set the environment variables CC, CFLAGS, LIBS. Put compiler
  36.          flags that have to be passed to the preprocessor into the CC
  37.          variable, not the CFLAGS variable. For example, if you want to use
  38.          gcc in ANSI C mode, execute the following before calling `configure':
  39.                setenv CC "gcc -ansi"                 if using csh
  40.                export CC="gcc -ansi"                 if using bash or ksh
  41.                CC="gcc -ansi"; export CC             if using sh
  42. EOP
  43. }
  44.  
  45. # Abort in case something fails.
  46. set -e
  47.  
  48. subdir_configure_args=''
  49. makemake_args=''
  50. do_config=''
  51. do_build=''
  52. do_install=''
  53. argcount=0
  54.  
  55. prev=''
  56. passnext=''
  57. for arg # in "$@"
  58. do
  59.   # If the previous option needs an argument, assign it.
  60.   if test -n "$prev"; then
  61.     # If the previous option needs an argument for subdir_configure_args, pass it.
  62.     if test -n "$passnext"; then
  63.       subdir_configure_args="$subdir_configure_args $arg"
  64.       passnext=''
  65.     else
  66.       eval "$prev=\$arg"
  67.     fi
  68.     prev=''
  69.   else
  70.  
  71.     case "$arg" in
  72.  
  73.       --build | --buil | --bui | --bu | --b)
  74.         do_config=1
  75.         do_build=1 ;;
  76.  
  77.       --config | --confi | --conf | --con | --co | --c)
  78.         do_config=1 ;;
  79.  
  80.       --help | --hel | --he | --h)
  81.         info_help
  82.         exit 0 ;;
  83.  
  84.       --install | --instal | --insta | --inst | --ins | --in | --i)
  85.         do_install=1 ;;
  86.  
  87.       --version | --versio | --versi | --vers | --ver | --ve | --v)
  88.         version="CLISP version "`cat src/VERSION`
  89.         echo $version
  90.         exit 0 ;;
  91.  
  92.       --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | -exec=* | --exe=* | --ex=* | --e=* | \
  93.       --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=* | \
  94.       --quiet | --quie | --qui | --qu | --q | \
  95.       --silent | --silen | --sile | --sil | --si | --s)
  96.         subdir_configure_args="$subdir_configure_args $arg" ;;
  97.  
  98.       --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | -exec | --exe | --ex | --e | \
  99.       --prefix | --prefi | --pref | --pre | --pr | --p)
  100.         subdir_configure_args="$subdir_configure_args $arg"
  101.         prev="$arg"
  102.         passnext=yes ;;
  103.  
  104.       --with-* | --without-*)
  105.         subdir_configure_args="$subdir_configure_args $arg"
  106.         makemake_args="$makemake_args $arg" ;;
  107.  
  108.       --*)
  109.         echo "$0: invalid argument $arg" 1>&2
  110.         echo "$0: Try \`$0 --help'" 1>&2
  111.         exit 1 ;;
  112.  
  113.       *) # Everything else counts as a positional argument
  114.         argcount=`expr $argcount + 1`
  115.         eval "POSARG$argcount=\$arg" ;;
  116.  
  117.     esac
  118.  
  119.   fi
  120. done
  121. if test -n "$prev"; then
  122.   echo "$0: missing argument to $prev" 1>&2
  123.   echo "$0: Try \`$0 --help'" 1>&2
  124.   exit 1
  125. fi
  126.  
  127. DIRNAME=$POSARG1
  128. COMPILER=$POSARG2 # deprecated
  129.  
  130. if test -z "$do_config" -a -z "$do_build" -a -z "$do_install"; then
  131.   # Default is --config
  132.   do_config=1
  133. fi
  134.  
  135. if test -n "$do_config"; then
  136.  
  137.   if test -f /coherent; then
  138.     # The old configure files are needed for Coherent.
  139.     v='.old'
  140.     vcache=''
  141.   else
  142.     v=''
  143.     vcache='--cache-file=../config.cache'
  144.   fi
  145.   subdir_configure_args="$subdir_configure_args $vcache"
  146.  
  147.   if [ "$COMPILER" != "" ] ; then
  148.     CC="$COMPILER"
  149.     export CC
  150.   fi
  151.   if [ "$DIRNAME" = "" -o "$DIRNAME" = src ] ; then
  152.     DIRNAME=src
  153.     chmod a+x $DIRNAME/configure$v
  154.     if test -d $DIRNAME/readline; then
  155.       chmod a+x $DIRNAME/readline/configure$v
  156.     fi
  157.     if test -d $DIRNAME/newreadline; then
  158.       chmod a+x $DIRNAME/newreadline/configure$v
  159.     fi
  160.     if test -d $DIRNAME/stdwin; then
  161.       chmod a+x $DIRNAME/stdwin/configure$v
  162.     fi
  163.     echo "executing $DIRNAME/configure$v ..."
  164.     cd $DIRNAME
  165.     ${CONFIG_SHELL-/bin/sh} configure$v
  166.     if test -d readline; then
  167.       echo "executing $DIRNAME/readline/configure$v ..."
  168.       cd readline
  169.       ${CONFIG_SHELL-/bin/sh} configure$v $subdir_configure_args
  170.       cd ..
  171.     fi
  172.     if test -d newreadline; then
  173.       echo "executing $DIRNAME/newreadline/configure$v ..."
  174.       cd newreadline
  175.       ${CONFIG_SHELL-/bin/sh} configure$v $subdir_configure_args
  176.       cd ..
  177.     fi
  178.     if test -d stdwin; then
  179.       echo "executing $DIRNAME/stdwin/configure$v ..."
  180.       cd stdwin
  181.       ${CONFIG_SHELL-/bin/sh} configure$v --with-x11 $subdir_configure_args
  182.       cd ..
  183.     fi
  184.   else
  185.  
  186.     # checking how to copy files
  187.     echo "blabla" > conftest.x
  188.     err=`/bin/sh -c "cp -p conftest.x conftest.y 2>&1"`
  189.     if test -z "$err"; then
  190.       CP='cp -p'
  191.     else
  192.       CP='cp'
  193.     fi
  194.     rm -f conftest*
  195.  
  196.     if [ ! -d $DIRNAME ] ; then
  197.       mkdir $DIRNAME
  198.     fi
  199.     for f in readline newreadline
  200.     do
  201.       if [ -d src/$f ] ; then
  202.         if [ ! -d $DIRNAME/$f ] ; then
  203.           mkdir $DIRNAME/$f
  204.         fi
  205.       fi
  206.     done
  207.     for f in readline/doc readline/examples \
  208.              stdwin stdwin/H stdwin/Gen stdwin/Tools stdwin/Ports \
  209.              stdwin/Ports/alfa stdwin/Ports/msdos stdwin/Ports/vtrm \
  210.              stdwin/Ports/x11 stdwin/Packs stdwin/Packs/textedit stdwin/Packs/vt \
  211.              queens
  212.     do
  213.       if [ -d src/$f ] ; then
  214.         if [ ! -d $DIRNAME/$f ] ; then
  215.           mkdir $DIRNAME/$f
  216.         fi
  217.         ( cd src
  218.           for g in $f/* ; do
  219.             if [ -f $g ] ; then
  220.               if [ "$g" = readline/Makefile ] ; then
  221.                 $CP -i $g ../$DIRNAME/$g
  222.               else
  223.                 rm -f ../$DIRNAME/$g
  224.                 ln $g ../$DIRNAME/$g || $CP -f $g ../$DIRNAME/$g
  225.               fi
  226.             fi
  227.           done
  228.         )
  229.       fi
  230.     done
  231.     for f in configure$v unixconf.h.in makemake.in \
  232.              readline/configure$v readline/config.h.in readline/Makefile.in \
  233.              newreadline/configure$v
  234.     do
  235.       if [ -f src/$f ] ; then
  236.         rm -f $DIRNAME/$f
  237.         ln src/$f $DIRNAME/$f || $CP -f src/$f $DIRNAME/$f
  238.       fi
  239.     done
  240.     chmod a+x $DIRNAME/configure$v
  241.     if test -d $DIRNAME/readline; then
  242.       chmod a+x $DIRNAME/readline/configure$v
  243.     fi
  244.     if test -d $DIRNAME/newreadline; then
  245.       chmod a+x $DIRNAME/newreadline/configure$v
  246.     fi
  247.     if test -d $DIRNAME/stdwin; then
  248.       chmod a+x $DIRNAME/stdwin/configure$v
  249.     fi
  250.     echo "executing $DIRNAME/configure$v ..."
  251.     cd $DIRNAME
  252.     ${CONFIG_SHELL-/bin/sh} configure$v --srcdir=../src
  253.     if test -d readline; then
  254.       echo "executing $DIRNAME/readline/configure$v ..."
  255.       cd readline
  256.       ${CONFIG_SHELL-/bin/sh} configure$v --srcdir=../../src/readline $subdir_configure_args
  257.       cd ..
  258.     fi
  259.     if test -d newreadline; then
  260.       echo "executing $DIRNAME/newreadline/configure$v ..."
  261.       cd newreadline
  262.       ${CONFIG_SHELL-/bin/sh} configure$v --srcdir=../../src/newreadline $subdir_configure_args
  263.       cd ..
  264.     fi
  265.     if test -d stdwin; then
  266.       echo "executing $DIRNAME/stdwin/configure$v ..."
  267.       cd stdwin
  268.       ${CONFIG_SHELL-/bin/sh} configure$v --srcdir=../../src/stdwin --with-x11 $subdir_configure_args
  269.       cd ..
  270.     fi
  271.   fi
  272.   cd ..
  273.  
  274. fi
  275.  
  276. if test -n "$do_build"; then
  277.  
  278.   if test -d src/readline; then
  279.     makemake_args="$makemake_args --with-readline"
  280.   else
  281.     if test -d src/newreadline; then
  282.       makemake_args="$makemake_args --with-newreadline"
  283.     else
  284.       makemake_args="$makemake_args --with-noreadline"
  285.     fi
  286.   fi
  287.  
  288.   cd $DIRNAME
  289.   ./makemake $makemake_args > makefile
  290.   make
  291.   make check
  292.   cd ..
  293.  
  294. fi
  295.  
  296. if test -n "$do_install"; then
  297.  
  298.   cd $DIRNAME
  299.   make install
  300.   cd ..
  301.  
  302. fi
  303.  
  304.