diff options
author | 1994-10-27 17:52:11 +0000 | |
---|---|---|
committer | 1994-10-27 17:52:11 +0000 | |
commit | 3f7ae2a57c457566cb035a15d701a3ef33a4f6d0 (patch) | |
tree | 41df2676e87c3897a1bd608e698df1739ab3d96b /util | |
parent | 29f84717e9d1ac7aebd90d553ca9d0d6e89a2222 (diff) |
Initial revision
Diffstat (limited to 'util')
-rwxr-xr-x | util/autoconf/autoconf | 152 | ||||
-rwxr-xr-x | util/autoconf/autoheader | 250 | ||||
-rwxr-xr-x | util/autoconf/autoreconf | 127 | ||||
-rwxr-xr-x | util/autoconf/autoscan | 393 | ||||
-rwxr-xr-x | util/autoconf/autoupdate | 112 | ||||
-rwxr-xr-x | util/autoconf/ifnames | 93 |
6 files changed, 1127 insertions, 0 deletions
diff --git a/util/autoconf/autoconf b/util/autoconf/autoconf new file mode 100755 index 0000000..5358738 --- /dev/null +++ b/util/autoconf/autoconf @@ -0,0 +1,152 @@ +#!/bin/sh +# autoconf -- create `configure' using m4 macros +# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# If given no args, create `configure' from template file `configure.in'. +# With one arg, create a configure script on standard output from +# the given template file. + +usage="\ +Usage: autoconf [-h] [--help] [-m dir] [--macrodir=dir] + [-l dir] [--localdir=dir] [--version] [template-file]" + +# NLS nuisances. +# Only set `LANG' and `LC_ALL' to "C" if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + +test -z "${AC_MACRODIR}" && AC_MACRODIR=/usr/local/share/autoconf +test -z "${M4}" && M4=/mit/gnu/rsaixbin/gm4 +case "${M4}" in +/*) # Handle the case that m4 has moved since we were configured. + # It may have been found originally in a build directory. + test -f "${M4}" || M4=m4 ;; +esac + +tmpout=/tmp/acout.$$ +localdir= +show_version=no + +while test $# -gt 0 ; do + case "${1}" in + -h | --help | --h* ) + echo "${usage}" 1>&2; exit 0 ;; + --localdir=* | --l*=* ) + localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`" + shift ;; + -l | --localdir | --l*) + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + localdir="${1}" + shift ;; + --macrodir=* | --m*=* ) + AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`" + shift ;; + -m | --macrodir | --m* ) + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + AC_MACRODIR="${1}" + shift ;; + --version | --v* ) + show_version=yes; shift ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "${usage}" 1>&2; exit 1 ;; + * ) + break ;; + esac +done + +if test $show_version = yes; then + version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \ + $AC_MACRODIR/acgeneral.m4` + echo "Autoconf version $version" + exit 0 +fi + +case $# in + 0) infile=configure.in ;; + 1) infile="$1" ;; + *) echo "$usage" >&2; exit 1 ;; +esac + +trap 'rm -f $tmpin $tmpout; exit 1' 1 2 15 + +tmpin=/tmp/acin.$$ # Always set this, to avoid bogus errors from some rm's. +if test z$infile = z-; then + infile=$tmpin + cat > $infile +elif test ! -r "$infile"; then + echo "autoconf: ${infile}: No such file or directory" >&2 + exit 1 +fi + +if test -n "$localdir"; then + use_localdir="-I$localdir -DAC_LOCALDIR=$localdir" +else + use_localdir= +fi + +# Use the frozen version of Autoconf if available. +r= f= +# Some non-GNU m4's don't reject the --help option, so give them /dev/null. +case `$M4 --help < /dev/null 2>&1` in +*reload-state*) test -r $AC_MACRODIR/autoconf.m4f && { r=--reload f=f; } ;; +*traditional*) ;; +*) echo Autoconf requires GNU m4 1.1 or later >&2; rm -f $tmpin; exit 1 ;; +esac + +$M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f $infile > $tmpout || + { rm -f $tmpin $tmpout; exit 2; } + +# You could add your own prefixes to pattern if you wanted to check for +# them too, e.g. pattern="AC_\|ILT_", except that UNIX sed doesn't do +# alternation. +pattern="AC_" + +status=0 +if grep "${pattern}" $tmpout > /dev/null 2>&1; then + echo "autoconf: Undefined macros:" >&2 + grep "${pattern}" $tmpout | sed "s/.*\(${pattern}[_A-Z0-9]*\).*/\1/" | + while read name; do + grep -n $name $infile /dev/null + done | sort -u >&2 + status=1 +fi + +if test $# -eq 0; then + exec 4> configure; chmod +x configure +else + exec 4>&1 +fi + +# Put the real line numbers into configure to make config.log more helpful. +awk ' +/__oline__/ { printf "%d:", NR + 1 } + { print } +' $tmpout | sed ' +/__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__\(.*\)$/\2\1\3/ +' >&4 + +rm -f $tmpout + +exit $status diff --git a/util/autoconf/autoheader b/util/autoconf/autoheader new file mode 100755 index 0000000..54b68d9 --- /dev/null +++ b/util/autoconf/autoheader @@ -0,0 +1,250 @@ +#!/bin/sh +# autoheader -- create `config.h.in' from `configure.in' +# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Written by Roland McGrath. + +# If given no args, create `config.h.in' from template file `configure.in'. +# With one arg, create a header file on standard output from +# the given template file. + +usage="\ +Usage: autoheader [-h] [--help] [-m dir] [--macrodir=dir] + [-l dir] [--localdir=dir] [--version] [template-file]" + +# NLS nuisances. +# Only set `LANG' and `LC_ALL' to "C" if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + +test -z "${AC_MACRODIR}" && AC_MACRODIR=/usr/local/share/autoconf +test -z "${M4}" && M4=/mit/gnu/rsaixbin/gm4 +case "${M4}" in +/*) # Handle the case that m4 has moved since we were configured. + # It may have been found originally in a build directory. + test -f "${M4}" || M4=m4 ;; +esac + +localdir=. +show_version=no + +while test $# -gt 0 ; do + case "${1}" in + -h | --help | --h* ) + echo "${usage}"; exit 0 ;; + --localdir=* | --l*=* ) + localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`" + shift ;; + -l | --localdir | --l*) + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + localdir="${1}" + shift ;; + --macrodir=* | --m*=* ) + AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`" + shift ;; + -m | --macrodir | --m* ) + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + AC_MACRODIR="${1}" + shift ;; + --version | --v* ) + show_version=yes; shift ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "${usage}" 1>&2; exit 1 ;; + * ) + break ;; + esac +done + +if test $show_version = yes; then + version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \ + $AC_MACRODIR/acgeneral.m4` + echo "Autoconf version $version" + exit 0 +fi + +TEMPLATES="${AC_MACRODIR}/acconfig.h" +test -r $localdir/acconfig.h && TEMPLATES="${TEMPLATES} $localdir/acconfig.h" + +case $# in + 0) infile=configure.in ;; + 1) infile=$1 ;; + *) echo "$usage" >&2; exit 1 ;; +esac + +config_h=config.h +syms= +types= +funcs= +headers= +libs= + +if test "$localdir" != .; then + use_localdir="-I$localdir -DAC_LOCALDIR=$localdir" +else + use_localdir= +fi + +# Use the frozen version of Autoconf if available. +r= f= +# Some non-GNU m4's don't reject the --help option, so give them /dev/null. +case `$M4 --help < /dev/null 2>&1` in +*reload-state*) test -r $AC_MACRODIR/autoheader.m4f && { r=--reload f=f; } ;; +*traditional*) ;; +*) echo Autoconf requires GNU m4 1.1 or later >&2; exit 1 ;; +esac + +# Extract assignments of SYMS, TYPES, FUNCS, HEADERS, and LIBS from the +# modified autoconf processing of the input file. The sed hair is +# necessary to win for multi-line macro invocations. +eval "`$M4 -I$AC_MACRODIR $use_localdir $r autoheader.m4$f $infile | + sed -n -e ' + : again + /^@@@.*@@@$/s/^@@@\(.*\)@@@$/\1/p + /^@@@/{ + s/^@@@//p + n + s/^/@@@/ + b again + }'`" + +# Make SYMS newline-separated rather than blank-separated, and remove dups. +# Start each symbol with a blank (to match the blank after "#undef") +# to reduce the possibility of mistakenly matching another symbol that +# is a substring of it. +syms="`for sym in $syms; do echo $sym; done | sort | uniq | sed 's@^@ @'`" + +if test $# -eq 0; then + tmpout=autoh$$ + trap "rm -f $tmpout; exit 1" 1 2 15 + exec > $tmpout +fi + +# Support "outfile[:infile]", defaulting infile="outfile.in". +case "$config_h" in +*:*) config_h_in=`echo "$config_h"|sed 's%.*:%%'` + config_h=`echo "$config_h"|sed 's%:.*%%'` ;; +*) config_h_in="${config_h}.in" ;; +esac + +# Don't write "do not edit" -- it will get copied into the +# config.h, which it's ok to edit. +echo "/* ${config_h_in}. Generated automatically from $infile by autoheader. */" + +test -r ${config_h}.top && cat ${config_h}.top +test -r $localdir/acconfig.h && + grep @TOP@ $localdir/acconfig.h >/dev/null && + sed '/@TOP@/,$d' $localdir/acconfig.h + +# This puts each template paragraph on its own line, separated by @s. +if test -n "$syms"; then + # Make sure the boundary of template files is also the boundary + # of the paragraph. Extra newlines don't hurt since they will + # be removed. + for t in $TEMPLATES; do cat $t; echo; echo; done | + # The sed script is suboptimal because it has to take care of + # some broken seds (e.g. AIX) that remove '\n' from the + # pattern/hold space if the line is empty. (junio@twinsun.com). + sed -n -e ' + /^[ ]*$/{ + x + s/\n/@/g + p + s/.*/@/ + x + } + H' | sed -e 's/@@*/@/g' | + # Select each paragraph that refers to a symbol we picked out above. + fgrep "$syms" | + tr @ \\012 +fi + +echo "$types" | tr , \\012 | sort | uniq | while read ctype; do + test -z "$ctype" && continue + # Solaris 2.3 tr rejects noncontiguous characters in character classes. + sym="`echo "${ctype}" | tr '[a-z] *' '[A-Z]_P'`" + echo " +/* The number of bytes in a ${ctype}. */ +#undef SIZEOF_${sym}" +done + +# /bin/sh on the Alpha gives `for' a random value if $funcs is empty. +if test -n "$funcs"; then + for func in `for x in $funcs; do echo $x; done | sort | uniq`; do + sym="`echo ${func} | sed 's/[^a-zA-Z0-9_]/_/g' | tr '[a-z]' '[A-Z]'`" + echo " +/* Define if you have the ${func} function. */ +#undef HAVE_${sym}" + done +fi + +if test -n "$headers"; then + for header in `for x in $headers; do echo $x; done | sort | uniq`; do + sym="`echo ${header} | sed 's/[^a-zA-Z0-9_]/_/g' | tr '[a-z]' '[A-Z]'`" + echo " +/* Define if you have the <${header}> header file. */ +#undef HAVE_${sym}" + done +fi + +if test -n "$libs"; then + for lib in `for x in $libs; do echo $x; done | sort | uniq`; do + sym="`echo ${lib} | sed 's/[^a-zA-Z0-9_]/_/g' | tr '[a-z]' '[A-Z]'`" + echo " +/* Define if you have the ${lib} library (-l${lib}). */ +#undef HAVE_LIB${sym}" + done +fi + +test -r $localdir/acconfig.h && + grep @BOTTOM@ $localdir/acconfig.h >/dev/null && + sed '1,/@BOTTOM@/d' $localdir/acconfig.h +test -f ${config_h}.bot && cat ${config_h}.bot + +status=0 + +if test -n "$syms"; then + for sym in $syms; do + if fgrep $sym $TEMPLATES >/dev/null; then + : # All is well. + else + echo "$0: Symbol \`${sym}' is not covered by $TEMPLATES" >&2 + status=1 + fi + done +fi + +if test $# -eq 0; then + if test $status -eq 0; then + if cmp -s $tmpout ${config_h_in}; then + rm -f $tmpout + else + mv -f $tmpout ${config_h_in} + fi + else + rm -f $tmpout + fi +fi + +exit $status diff --git a/util/autoconf/autoreconf b/util/autoconf/autoreconf new file mode 100755 index 0000000..bc2d61b --- /dev/null +++ b/util/autoconf/autoreconf @@ -0,0 +1,127 @@ +#!/bin/sh +# autoreconf - remake all Autoconf configure scripts in a directory tree +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +usage="\ +Usage: autoreconf [-h] [--help] [-m dir] [--macrodir=dir] + [-l dir] [--localdir=dir] [--verbose] [--version]" + +localdir= +verbose=no +show_version=no + +test -z "$AC_MACRODIR" && AC_MACRODIR=/usr/local/share/autoconf + +while test $# -gt 0; do + case "$1" in + -h | --help | --h*) + echo "$usage"; exit 0 ;; + --localdir=* | --l*=* ) + localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`" + shift ;; + -l | --localdir | --l*) + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + localdir="${1}" + shift ;; + --macrodir=* | --m*=* ) + AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`" + shift ;; + -m | --macrodir | --m*) + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + AC_MACRODIR="$1" + shift ;; + --verbose | --verb*) + verbose=yes; shift ;; + --version | --vers*) + show_version=yes; shift ;; + --) # Stop option processing. + shift; break ;; + -*) echo "$usage" 1>&2; exit 1 ;; + *) break ;; + esac +done + +if test $show_version = yes; then + version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \ + $AC_MACRODIR/acgeneral.m4` + echo "Autoconf version $version" + exit 0 +fi + +if test $# -ne 0; then + echo "$usage" 1>&2; exit 1 +fi + +top_autoconf=`echo $0|sed s%autoreconf%autoconf%` +top_autoheader=`echo $0|sed s%autoreconf%autoheader%` + +# The xargs grep filters out Cygnus configure.in files. +find . -name configure.in -print | +xargs grep -l AC_OUTPUT | +sed 's%/configure\.in$%%; s%^./%%' | +while read dir; do + ( + cd $dir || continue + + case "$dir" in + .) dots= ;; + *) # A "../" for each directory in /$dir. + dots=`echo /$dir|sed 's%/[^/]*%../%g'` ;; + esac + + case "$0" in + /*) autoconf=$top_autoconf; autoheader=$top_autoheader ;; + */*) autoconf=$dots$top_autoconf; autoheader=$dots$top_autoheader ;; + *) autoconf=$top_autoconf; autoheader=$top_autoheader ;; + esac + + case "$AC_MACRODIR" in + /*) macrodir_opt="--macrodir=$AC_MACRODIR" ;; + *) macrodir_opt="--macrodir=$dots$AC_MACRODIR" ;; + esac + + case "$localdir" in + "") localdir_opt= ;; + /*) localdir_opt="--localdir=$localdir" ;; + *) localdir_opt="--localdir=$dots$localdir" ;; + esac + + test $verbose = yes && echo running autoconf in $dir + $autoconf $macrodir_opt $localdir_opt + + if grep AC_CONFIG_HEADER configure.in >/dev/null; then + template=`sed -n '/AC_CONFIG_HEADER/{ +s%[^#]*AC_CONFIG_HEADER(\([^)]*\).*%\1% +t here +: here +s%.*:%% +t colon +s%$%.in% +: colon +p +q +}' configure.in` + if test ! -f $template || grep autoheader $template >/dev/null; then + test $verbose = yes && echo running autoheader in $dir + $autoheader $macrodir_opt $localdir_opt + fi + fi + ) +done + diff --git a/util/autoconf/autoscan b/util/autoconf/autoscan new file mode 100755 index 0000000..74debe5 --- /dev/null +++ b/util/autoconf/autoscan @@ -0,0 +1,393 @@ +#!/usr/athena/bin/perl +# autoscan - Create configure.scan (a preliminary configure.in) for a package. +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Written by David MacKenzie <djm@gnu.ai.mit.edu>. + +require "find.pl"; + +$datadir = $ENV{"AC_MACRODIR"} || "/usr/local/share/autoconf"; +$verbose = 0; +# Reference these variables to pacify perl -w. +undef %identifiers_macros; +undef %makevars_macros; +undef %programs_macros; + +&parse_args; +&init_tables; +&find('.'); +&scan_files; +&output; + +exit 0; + +# Process any command line arguments. +sub parse_args +{ + local ($usage) = + "Usage: autoscan [--macrodir=dir] [--help] [--verbose] [--version] [srcdir]\n"; + + foreach $_ (@ARGV) { + if (/^--m[a-z]*=(.*)/) { + $datadir = $1; + } elsif (/^--h/) { + print "$usage"; + exit 0; + } elsif (/^--verb/) { + $verbose = 1; + } elsif (/^--vers/) { + &version; + } elsif (/^[^-]/) { + die "$usage" if defined($srcdir); + # Top level directory of the package being autoscanned. + $srcdir = $_; + } else { + die "$usage"; + } + } + + $srcdir="." if !defined($srcdir); + + print "srcdir=$srcdir\n" if $verbose; + chdir $srcdir || die "$0: cannot cd to $srcdir: $!\n"; + + open(CONF, ">configure.scan") || + die "$0: cannot create configure.scan: $!\n"; +} + +# Print the version number and exit. +sub version +{ + open(ACG, "<$datadir/acgeneral.m4") || + die "$0: cannot open $datadir/acgeneral.m4: $!\n"; + while (<ACG>) { + if (/define.AC_ACVERSION.\s*([0-9.]+)/) { + print "Autoconf version $1\n"; + exit 0; + } + } + die "Autoconf version unknown\n"; +} + +# Put values in the tables of what to do with each token. +sub init_tables +{ + local($kind, $word, $macro); + + # Initialize a table of C keywords (to ignore). + # Taken from K&R 1st edition p. 180. + # ANSI C, GNU C, and C++ keywords can introduce portability problems, + # so don't ignore them. + foreach $word ('int', 'char', 'float', 'double', 'struct', 'union', + 'long', 'short', 'unsigned', 'auto', 'extern', 'register', + 'typedef', 'static', 'goto', 'return', 'sizeof', 'break', + 'continue', 'if', 'else', 'for', 'do', 'while', 'switch', + 'case', 'default') { + $c_keywords{$word} = 0; + } + + # The data file format supports only one line of macros per function. + # If more than that is required for a common portability problem, + # a new Autoconf macro should probably be written for that case, + # instead of duplicating the code in lots of configure.in files. + + foreach $kind ('functions', 'headers', 'identifiers', 'programs', + 'makevars') { + open(TABLE, "<$datadir/ac$kind") || + die "$0: cannot open $datadir/ac$kind: $!\n"; + while (<TABLE>) { + next if /^\s*$/ || /^\s*#/; # Ignore blank lines and comments. + ($word, $macro) = split; + eval "\$$kind" . "_macros{\$word} = \$macro"; + } + close(TABLE); + } +} + +# Collect names of various kinds of files in the package. +# Called by &find on each file. +sub wanted +{ + if (/^.*\.[chlymC]$/ || /^.*\.cc$/) { + $name =~ s?^\./??; push(@cfiles, $name); + } + elsif (/^[Mm]akefile$/ || /^[Mm]akefile\.in$/ || /^GNUmakefile$/) { + $name =~ s?^\./??; push(@makefiles, $name); + } + elsif (/^.*\.sh$/) { + $name =~ s?^\./??; push(@shfiles, $name); + } +} + +# Read through the files and collect lists of tokens in them +# that might create nonportabilities. +sub scan_files +{ + $initfile = $cfiles[0]; # Pick one at random. + + if ($verbose) { + print "cfiles:", join(" ", @cfiles), "\n"; + print "makefiles:", join(" ", @makefiles), "\n"; + print "shfiles:", join(" ", @shfiles), "\n"; + } + + foreach $file (@cfiles) { + &scan_c_file($file); + } + + foreach $file (@makefiles) { + &scan_makefile($file); + } + + foreach $file (@shfiles) { + &scan_sh_file($file); + } +} + +sub scan_c_file +{ + local($file) = @_; + local($in_comment) = 0; # Nonzero if in a multiline comment. + + open(CFILE, "<$file") || die "$0: cannot open $file: $!\n"; + while (<CFILE>) { + # Strip out comments, approximately. + # Ending on this line. + if ($in_comment && m,\*/,) { + s,.*\*/,,; + $in_comment = 0; + } + # All on one line. + s,/\*.*\*/,,g; + # Starting on this line. + if (m,/\*,) { + $in_comment = 1; + } + # Continuing on this line. + next if $in_comment; + + # Preprocessor directives. + if (/^\s*#\s*include\s*<([^>]*)>/) { + $headers{$1}++; + } + # Ignore other preprocessor directives. + next if /^\s*#/; + + # Remove string and character constants. + s,\"[^\"]*\",,g; + s,\'[^\']*\',,g; + + # Tokens in the code. + # Maybe we should ignore function definitions (in column 0)? + while (s/\W([a-zA-Z_]\w*)\s*\(/ /) { + $functions{$1}++ if !defined($c_keywords{$1}); + } + while (s/\W([a-zA-Z_]\w*)\W/ /) { + $identifiers{$1}++ if !defined($c_keywords{$1}); + } + } + close(CFILE); + + if ($verbose) { + local($word); + + print "\n$file functions:\n"; + foreach $word (sort keys %functions) { + print "$word $functions{$word}\n"; + } + + print "\n$file identifiers:\n"; + foreach $word (sort keys %identifiers) { + print "$word $identifiers{$word}\n"; + } + + print "\n$file headers:\n"; + foreach $word (sort keys %headers) { + print "$word $headers{$word}\n"; + } + } +} + +sub scan_makefile +{ + local($file) = @_; + + open(MFILE, "<$file") || die "$0: cannot open $file: $!\n"; + while (<MFILE>) { + # Strip out comments and variable references. + s/#.*//; + s/\$\([^\)]*\)//g; + s/\${[^\}]*}//g; + s/@[^@]*@//g; + + # Variable assignments. + while (s/\W([a-zA-Z_]\w*)\s*=/ /) { + $makevars{$1}++; + } + # Libraries. + while (s/\W-l([a-zA-Z_]\w*)\W/ /) { + $libraries{$1}++; + } + # Tokens in the code. + while (s/\W([a-zA-Z_]\w*)\W/ /) { + $programs{$1}++; + } + } + close(MFILE); + + if ($verbose) { + local($word); + + print "\n$file makevars:\n"; + foreach $word (sort keys %makevars) { + print "$word $makevars{$word}\n"; + } + + print "\n$file libraries:\n"; + foreach $word (sort keys %libraries) { + print "$word $libraries{$word}\n"; + } + + print "\n$file programs:\n"; + foreach $word (sort keys %programs) { + print "$word $programs{$word}\n"; + } + } +} + +sub scan_sh_file +{ + local($file) = @_; + + open(MFILE, "<$file") || die "$0: cannot open $file: $!\n"; + while (<MFILE>) { + # Strip out comments and variable references. + s/#.*//; + s/\${[^\}]*}//g; + s/@[^@]*@//g; + + # Tokens in the code. + while (s/\W([a-zA-Z_]\w*)\W/ /) { + $programs{$1}++; + } + } + close(MFILE); + + if ($verbose) { + local($word); + + print "\n$file programs:\n"; + foreach $word (sort keys %programs) { + print "$word $programs{$word}\n"; + } + } +} + +# Print a configure.in. +sub output +{ + local (%unique_makefiles); + + print CONF "dnl Process this file with autoconf to produce a configure script.\n"; + print CONF "AC_INIT($initfile)\n"; + + &output_programs; + &output_headers; + &output_identifiers; + &output_functions; + + # Change DIR/Makefile.in to DIR/Makefile. + foreach $_ (@makefiles) { + s/\.in$//; + $unique_makefiles{$_}++; + } + print CONF "\nAC_OUTPUT(", join(" ", keys(%unique_makefiles)), ")\n"; + + close CONF; +} + +# Print Autoconf macro $1 if it's not undef and hasn't been printed already. +sub print_unique +{ + local($macro) = @_; + + if (defined($macro) && !defined($printed{$macro})) { + print CONF "$macro\n"; + $printed{$macro} = 1; + } +} + +sub output_programs +{ + local ($word); + + print CONF "\ndnl Checks for programs.\n"; + foreach $word (sort keys %programs) { + &print_unique($programs_macros{$word}); + } + foreach $word (sort keys %makevars) { + &print_unique($makevars_macros{$word}); + } + print CONF "\ndnl Checks for libraries.\n"; + foreach $word (sort keys %libraries) { + print CONF "AC_HAVE_LIBRARY($word)\n"; + } +} + +sub output_headers +{ + local ($word); + + print CONF "\ndnl Checks for header files.\n"; + foreach $word (sort keys %headers) { + if (defined($headers_macros{$word}) && + $headers_macros{$word} eq 'AC_CHECK_HEADERS') { + push(@have_headers, $word); + } else { + &print_unique($headers_macros{$word}); + } + } + print CONF "AC_CHECK_HEADERS(" . join(' ', sort(@have_headers)) . ")\n" + if defined(@have_headers); +} + +sub output_identifiers +{ + local ($word); + + print CONF "\ndnl Checks for typedefs, structures, and compiler characteristics.\n"; + foreach $word (sort keys %identifiers) { + &print_unique($identifiers_macros{$word}); + } +} + +sub output_functions +{ + local ($word); + + print CONF "\ndnl Checks for library functions.\n"; + foreach $word (sort keys %functions) { + if (defined($functions_macros{$word}) && + $functions_macros{$word} eq 'AC_CHECK_FUNCS') { + push(@have_funcs, $word); + } else { + &print_unique($functions_macros{$word}); + } + } + print CONF "AC_CHECK_FUNCS(" . join(' ', sort(@have_funcs)) . ")\n" + if defined(@have_funcs); +} diff --git a/util/autoconf/autoupdate b/util/autoconf/autoupdate new file mode 100755 index 0000000..b69f61b --- /dev/null +++ b/util/autoconf/autoupdate @@ -0,0 +1,112 @@ +#!/bin/sh +# autoupdate - modernize a configure.in +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# If given no args, update `configure.in'; +# With one arg, write on the standard output from the given template file. +# +# Written by David MacKenzie <djm@gnu.ai.mit.edu> + +usage="\ +Usage: autoupdate [-h] [--help] [-m dir] [--macrodir=dir] + [--version] [template-file]" + +sedtmp=/tmp/acups.$$ +# For debugging. +#sedtmp=/tmp/acups +show_version=no +test -z "${AC_MACRODIR}" && AC_MACRODIR=/usr/local/share/autoconf + +while test $# -gt 0 ; do + case "${1}" in + -h | --help | --h* ) + echo "${usage}" 1>&2; exit 0 ;; + --macrodir=* | --m*=* ) + AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`" + shift ;; + -m | --macrodir | --m* ) + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + AC_MACRODIR="${1}" + shift ;; + --version | --versio | --versi | --vers) + show_version=yes; shift ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "${usage}" 1>&2; exit 1 ;; + * ) + break ;; + esac +done + +if test $show_version = yes; then + version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \ + $AC_MACRODIR/acgeneral.m4` + echo "Autoconf version $version" + exit 0 +fi + +: ${SIMPLE_BACKUP_SUFFIX='~'} + +tmpout=acupo.$$ +trap 'rm -f $sedtmp $tmpout; exit 1' 1 2 15 +case $# in + 0) infile=configure.in; out="> $tmpout" + # Make sure $infile can be read, and $tmpout has the same permissions. + cp $infile $tmpout || exit + + # Make sure $infile can be written. + if test ! -w $infile; then + rm -f $tmpout + echo "$0: $infile: cannot write" >&2 + exit 1 + fi + ;; + 1) infile="$1"; out= ;; + *) echo "$usage" >&2; exit 1 ;; +esac + +# Turn the m4 macro file into a sed script. +# For each old macro name, make one substitution command to replace it +# at the end of a line, and one when followed by ( or whitespace. +# That is easier than splitting the macros up into those that take +# arguments and those that don't. +sed -n -e ' +/^AC_DEFUN(/ { + s//s%/ + s/, *\[indir(\[/$%/ + s/\].*/%/ + p + s/\$// + s/%/^/ + s/%/\\([( ]\\)^/ + s/%/\\1^/ + s/\^/%/g + p +}' ${AC_MACRODIR}/acoldnames.m4 > $sedtmp +eval sed -f $sedtmp $infile $out + +case $# in + 0) mv configure.in configure.in${SIMPLE_BACKUP_SUFFIX} && + mv $tmpout configure.in ;; +esac + +rm -f $sedtmp $tmpout +exit 0 diff --git a/util/autoconf/ifnames b/util/autoconf/ifnames new file mode 100755 index 0000000..67f4da1 --- /dev/null +++ b/util/autoconf/ifnames @@ -0,0 +1,93 @@ +#!/bin/sh +# ifnames - print the identifiers used in C preprocessor conditionals +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Reads from stdin if no files are given. +# Writes to stdout. + +# Written by David MacKenzie <djm@gnu.ai.mit.edu> + +usage="\ +Usage: ifnames [-h] [--help] [-m dir] [--macrodir=dir] [--version] [file...]" +show_version=no + +test -z "$AC_MACRODIR" && AC_MACRODIR=/usr/local/share/autoconf + +while test $# -gt 0; do + case "$1" in + -h | --help | --h* ) + echo "$usage"; exit 0 ;; + --macrodir=* | --m*=* ) + AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`" + shift ;; + -m | --macrodir | --m* ) + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + AC_MACRODIR="$1" + shift ;; + --version | --versio | --versi | --vers) + show_version=yes; shift ;; + --) # Stop option processing. + shift; break ;; + -*) echo "$usage" 1>&2; exit 1 ;; + *) break ;; + esac +done + +if test $show_version = yes; then + version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \ + $AC_MACRODIR/acgeneral.m4` + echo "Autoconf version $version" + exit 0 +fi + +if test $# -eq 0; then + cat > stdin + set stdin + trap 'rm -f stdin' 0 + trap 'rm -f stdin; exit 1' 1 3 15 +fi + +for arg +do +# The first two substitutions remove comments. Not perfect, but close enough. +# The second is for comments that end on a later line. The others do: +# Enclose identifiers in @ and a space. +# Handle "#if 0" -- there are no @s to trigger removal. +# Remove non-identifiers. +# Remove any spaces at the end. +# Translate any other spaces to newlines. +sed -n ' +s%/\*[^/]*\*/%%g +s%/\*[^/]*%%g +/^[ ]*#[ ]*ifn*def[ ][ ]*\([A-Za-z0-9_]*\).*/s//\1/p +/^[ ]*#[ ]*e*l*if[ ]/{ + s/// + s/@//g + s/\([A-Za-z_][A-Za-z_0-9]*\)/@\1 /g + s/$/@ / + s/@defined //g + s/[^@]*@\([^ ]* \)[^@]*/\1/g + s/ *$// + s/ /\ +/g + p +} +' $arg | sort -u | sed 's%$% '$arg'%' +done | awk ' +{ files[$1] = files[$1] " " $2 } +END { for (sym in files) print sym files[sym] }' | sort |