autoconf
Upload User: yingmei828
Upload Date: 2007-01-01
Package Size: 1646k
Code Size: 5k
Development Platform:

Unix_Linux

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