home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / autoconf-2.10-src.tgz / tar.out / fsf / autoconf / autoconf.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1996-09-24  |  5KB  |  156 lines

  1. #! /bin/sh
  2. # autoconf -- create `configure' using m4 macros
  3. # Copyright (C) 1992, 1993, 1994, 1996 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=@datadir@}
  35. : ${M4=@M4@}
  36. : ${AWK=@AWK@}
  37. case "${M4}" in
  38. /*) # Handle the case that m4 has moved since we were configured.
  39.     # It may have been found originally in a build directory.
  40.     test -f "${M4}" || M4=m4 ;;
  41. esac
  42.  
  43. : ${TMPDIR=/tmp}
  44. tmpout=${TMPDIR}/acout.$$
  45. localdir=
  46. show_version=no
  47.  
  48. while test $# -gt 0 ; do
  49.    case "${1}" in
  50.       -h | --help | --h* )
  51.          echo "${usage}" 1>&2; exit 0 ;;
  52.       --localdir=* | --l*=* )
  53.          localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
  54.          shift ;;
  55.       -l | --localdir | --l*)
  56.          shift
  57.          test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
  58.          localdir="${1}"
  59.          shift ;;
  60.       --macrodir=* | --m*=* )
  61.          AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
  62.          shift ;;
  63.       -m | --macrodir | --m* )
  64.          shift
  65.          test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
  66.          AC_MACRODIR="${1}"
  67.          shift ;;
  68.       --version | --v* )
  69.          show_version=yes; shift ;;
  70.       -- )     # Stop option processing
  71.         shift; break ;;
  72.       - )    # Use stdin as input.
  73.         break ;;
  74.       -* )
  75.         echo "${usage}" 1>&2; exit 1 ;;
  76.       * )
  77.         break ;;
  78.    esac
  79. done
  80.  
  81. if test $show_version = yes; then
  82.   version=`sed -n 's/define.AC_ACVERSION.[     ]*\([0-9.]*\).*/\1/p' \
  83.     $AC_MACRODIR/acgeneral.m4`
  84.   echo "Autoconf version $version"
  85.   exit 0
  86. fi
  87.  
  88. case $# in
  89.   0) infile=configure.in ;;
  90.   1) infile="$1" ;;
  91.   *) echo "$usage" >&2; exit 1 ;;
  92. esac
  93.  
  94. trap 'rm -f $tmpin $tmpout; exit 1' 1 2 15
  95.  
  96. tmpin=${TMPDIR}/acin.$$ # Always set this, to avoid bogus errors from some rm's.
  97. if test z$infile = z-; then
  98.   infile=$tmpin
  99.   cat > $infile
  100. elif test ! -r "$infile"; then
  101.   echo "autoconf: ${infile}: No such file or directory" >&2
  102.   exit 1
  103. fi
  104.  
  105. if test -n "$localdir"; then
  106.   use_localdir="-I$localdir -DAC_LOCALDIR=$localdir"
  107. else
  108.   use_localdir=
  109. fi
  110.  
  111. # Use the frozen version of Autoconf if available.
  112. r= f=
  113. # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
  114. case `$M4 --help < /dev/null 2>&1` in
  115. *reload-state*) test -r $AC_MACRODIR/autoconf.m4f && { r=--reload f=f; } ;;
  116. *traditional*) ;;
  117. *) echo Autoconf requires GNU m4 1.1 or later >&2; rm -f $tmpin; exit 1 ;;
  118. esac
  119.  
  120. $M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f $infile > $tmpout ||
  121.   { rm -f $tmpin $tmpout; exit 2; }
  122.  
  123. # You could add your own prefixes to pattern if you wanted to check for
  124. # them too, e.g. pattern="AC_\|ILT_", except that UNIX sed doesn't do
  125. # alternation.
  126. pattern="AC_"
  127.  
  128. status=0
  129. if grep "^[^#]*${pattern}" $tmpout > /dev/null 2>&1; then
  130.   echo "autoconf: Undefined macros:" >&2
  131.   sed -n "s/^[^#]*\\(${pattern}[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
  132.     while read macro; do
  133.       grep -n "^[^#]*$macro" $infile /dev/null
  134.       test $? -eq 1 && echo >&2 "***BUG in Autoconf--please report*** $macro"
  135.     done | sort -u >&2
  136.   status=1
  137. fi
  138.  
  139. if test $# -eq 0; then
  140.   exec 4> configure #; chmod +x configure (AmigaOS hack -fnf)
  141. else
  142.   exec 4>&1
  143. fi
  144.  
  145. # Put the real line numbers into configure to make config.log more helpful.
  146. $AWK '
  147. /__oline__/ { printf "%d:", NR + 1 }
  148.            { print }
  149. ' $tmpout | sed '
  150. /__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
  151. ' >&4
  152.  
  153. rm -f $tmpout
  154.  
  155. exit $status
  156.