home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-2.LHA / CLISP960530-ki.lha / ffcall / autoconf / autoconf < prev    next >
Encoding:
Text File  |  1996-04-15  |  4.4 KB  |  154 lines

  1. #! /bin/sh
  2. # autoconf -- create `configure' using m4 macros
  3. # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
  4.  
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9.  
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. # If given no args, create `configure' from template file `configure.in'.
  20. # With one arg, create a configure script on standard output from
  21. # the given template file.
  22.  
  23. usage="\
  24. Usage: autoconf [-h] [--help] [-m dir] [--macrodir=dir] 
  25.        [-l dir] [--localdir=dir] [--version] [template-file]" 
  26.  
  27. # NLS nuisances.
  28. # Only set `LANG' and `LC_ALL' to "C" if already set.
  29. # These must not be set unconditionally because not all systems understand
  30. # e.g. LANG=C (notably SCO).
  31. if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
  32. if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
  33.  
  34. : ${AC_MACRODIR=/usr/local/share/autoconf}
  35. : ${M4=/disk/karle/marcus/bin/gm4}
  36. case "${M4}" in
  37. /*) # Handle the case that m4 has moved since we were configured.
  38.     # It may have been found originally in a build directory.
  39.     test -f "${M4}" || M4=m4 ;;
  40. esac
  41.  
  42. : ${TMPDIR=/tmp}
  43. tmpout=${TMPDIR}/acout.$$
  44. localdir=
  45. show_version=no
  46.  
  47. while test $# -gt 0 ; do
  48.    case "${1}" in 
  49.       -h | --help | --h* )
  50.          echo "${usage}" 1>&2; exit 0 ;;
  51.       --localdir=* | --l*=* )
  52.          localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
  53.          shift ;;
  54.       -l | --localdir | --l*)
  55.          shift
  56.          test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
  57.          localdir="${1}"
  58.          shift ;;
  59.       --macrodir=* | --m*=* )
  60.          AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
  61.          shift ;;
  62.       -m | --macrodir | --m* ) 
  63.          shift
  64.          test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
  65.          AC_MACRODIR="${1}"
  66.          shift ;;
  67.       --version | --v* )
  68.          show_version=yes; shift ;;
  69.       -- )     # Stop option processing
  70.         shift; break ;;
  71.       - )    # Use stdin as input.
  72.         break ;;
  73.       -* )
  74.         echo "${usage}" 1>&2; exit 1 ;;
  75.       * )
  76.         break ;;
  77.    esac
  78. done
  79.  
  80. if test $show_version = yes; then
  81.   version=`sed -n 's/define.AC_ACVERSION.[     ]*\([0-9.]*\).*/\1/p' \
  82.     $AC_MACRODIR/acgeneral.m4`
  83.   echo "Autoconf version $version"
  84.   exit 0
  85. fi
  86.  
  87. case $# in
  88.   0) infile=configure.in ;;
  89.   1) infile="$1" ;;
  90.   *) echo "$usage" >&2; exit 1 ;;
  91. esac
  92.  
  93. trap 'rm -f $tmpin $tmpout; exit 1' 1 2 15
  94.  
  95. tmpin=${TMPDIR}/acin.$$ # Always set this, to avoid bogus errors from some rm's.
  96. if test z$infile = z-; then
  97.   infile=$tmpin
  98.   cat > $infile
  99. elif test ! -r "$infile"; then
  100.   echo "autoconf: ${infile}: No such file or directory" >&2
  101.   exit 1
  102. fi
  103.  
  104. if test -n "$localdir"; then
  105.   use_localdir="-I$localdir -DAC_LOCALDIR=$localdir"
  106. else
  107.   use_localdir=
  108. fi
  109.  
  110. # Use the frozen version of Autoconf if available.
  111. r= f=
  112. # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
  113. case `$M4 --help < /dev/null 2>&1` in
  114. *reload-state*) test -r $AC_MACRODIR/autoconf.m4f && { r=--reload f=f; } ;;
  115. *traditional*) ;;
  116. *) echo Autoconf requires GNU m4 1.1 or later >&2; rm -f $tmpin; exit 1 ;;
  117. esac
  118.  
  119. $M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f $infile > $tmpout ||
  120.   { rm -f $tmpin $tmpout; exit 2; }
  121.  
  122. # You could add your own prefixes to pattern if you wanted to check for
  123. # them too, e.g. pattern="AC_\|ILT_", except that UNIX sed doesn't do
  124. # alternation.
  125. pattern="AC_"
  126.  
  127. status=0
  128. if grep "${pattern}" $tmpout > /dev/null 2>&1; then
  129.   echo "autoconf: Undefined macros:" >&2
  130.   grep "${pattern}" $tmpout | sed "s/.*\(${pattern}[_A-Za-z0-9]*\).*/\1/" |
  131.     while read name; do
  132.       grep -n $name $infile /dev/null
  133.     done | sort -u >&2
  134.   status=1
  135. fi
  136.  
  137. if test $# -eq 0; then
  138.   exec 4> configure; chmod +x configure
  139. else
  140.   exec 4>&1
  141. fi
  142.  
  143. # Put the real line numbers into configure to make config.log more helpful.
  144. awk '
  145. /__oline__/ { printf "%d:", NR + 1 }
  146.            { print }
  147. ' $tmpout | sed '
  148. /__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__\(.*\)$/\2\1\3/
  149. ' >&4
  150.  
  151. rm -f $tmpout
  152.  
  153. exit $status
  154.