1994-07-19 22:37:37 +08:00
|
|
|
#!/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>
|
|
|
|
|
1994-09-16 02:34:35 +08:00
|
|
|
usage="\
|
|
|
|
Usage: ifnames [-h] [--help] [-m dir] [--macrodir=dir] [--version] [file...]"
|
1994-07-19 22:37:37 +08:00
|
|
|
show_version=no
|
|
|
|
|
|
|
|
test -z "$AC_MACRODIR" && AC_MACRODIR=@datadir@
|
|
|
|
|
|
|
|
while test $# -gt 0; do
|
|
|
|
case "$1" in
|
1994-09-16 02:34:35 +08:00
|
|
|
-h | --help | --h* )
|
1994-07-19 22:37:37 +08:00
|
|
|
echo "$usage"; exit 0 ;;
|
|
|
|
--macrodir=* | --m*=* )
|
|
|
|
AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
|
|
|
|
shift ;;
|
1994-09-16 02:34:35 +08:00
|
|
|
-m | --macrodir | --m* )
|
1994-07-19 22:37:37 +08:00
|
|
|
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
|
1994-10-19 13:41:52 +08:00
|
|
|
# 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.
|
1994-07-19 22:37:37 +08:00
|
|
|
sed -n '
|
1994-09-18 02:05:24 +08:00
|
|
|
s%/\*[^/]*\*/%%g
|
|
|
|
s%/\*[^/]*%%g
|
1994-07-19 22:37:37 +08:00
|
|
|
/^[ ]*#[ ]*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
|
|
|
|
}
|
1994-09-18 02:05:24 +08:00
|
|
|
' $arg | sort -u | sed 's%$% '$arg'%'
|
1994-07-19 22:37:37 +08:00
|
|
|
done | awk '
|
|
|
|
{ files[$1] = files[$1] " " $2 }
|
1994-08-23 14:01:14 +08:00
|
|
|
END { for (sym in files) print sym files[sym] }' | sort
|