[3157] | 1 | #! @SHELL@
|
---|
| 2 | # ifnames - print the identifiers used in C preprocessor conditionals
|
---|
| 3 | # Copyright (C) 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA
|
---|
| 18 | # 02111-1307, USA.
|
---|
| 19 |
|
---|
| 20 | # Reads from stdin if no files are given.
|
---|
| 21 | # Writes to stdout.
|
---|
| 22 |
|
---|
| 23 | # Written by David MacKenzie <djm@gnu.ai.mit.edu>
|
---|
| 24 | # and Paul Eggert <eggert@twinsun.com>.
|
---|
| 25 |
|
---|
| 26 | usage="\
|
---|
| 27 | Usage: ifnames [-h] [--help] [-m dir] [--macrodir=dir] [--version] [file...]"
|
---|
| 28 | show_version=no
|
---|
| 29 |
|
---|
[3159] | 30 | # OS/2 additions
|
---|
| 31 | if test -z "${AC_MACRODIR}"; then
|
---|
| 32 | if test -d "${UNIXROOT}@datadir@"; then
|
---|
| 33 | AC_MACRODIR=${UNIXROOT}@datadir@
|
---|
| 34 | else
|
---|
| 35 | AC_MACRODIR=@datadir@
|
---|
| 36 | fi
|
---|
| 37 | fi
|
---|
[3157] | 38 |
|
---|
| 39 | while test $# -gt 0; do
|
---|
| 40 | case "$1" in
|
---|
| 41 | -h | --help | --h* )
|
---|
| 42 | echo "$usage"; exit 0 ;;
|
---|
| 43 | --macrodir=* | --m*=* )
|
---|
| 44 | AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
|
---|
| 45 | shift ;;
|
---|
| 46 | -m | --macrodir | --m* )
|
---|
| 47 | shift
|
---|
| 48 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
|
---|
| 49 | AC_MACRODIR="$1"
|
---|
| 50 | shift ;;
|
---|
| 51 | --version | --versio | --versi | --vers)
|
---|
| 52 | show_version=yes; shift ;;
|
---|
| 53 | --) # Stop option processing.
|
---|
| 54 | shift; break ;;
|
---|
| 55 | -*) echo "$usage" 1>&2; exit 1 ;;
|
---|
| 56 | *) break ;;
|
---|
| 57 | esac
|
---|
| 58 | done
|
---|
| 59 |
|
---|
| 60 | if test $show_version = yes; then
|
---|
| 61 | version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \
|
---|
| 62 | $AC_MACRODIR/acgeneral.m4`
|
---|
| 63 | echo "Autoconf version $version"
|
---|
| 64 | exit 0
|
---|
| 65 | fi
|
---|
| 66 |
|
---|
| 67 | @AWK@ '
|
---|
| 68 | # Record that sym was found in FILENAME.
|
---|
| 69 | function file_sym(sym, i, fs) {
|
---|
| 70 | if (sym ~ /^[A-Za-z_]/) {
|
---|
| 71 | if (!found[sym,FILENAME]) {
|
---|
| 72 | found[sym,FILENAME] = 1
|
---|
| 73 |
|
---|
| 74 | # Insert FILENAME into files[sym], keeping the list sorted.
|
---|
| 75 | i = 1
|
---|
| 76 | fs = files[sym]
|
---|
| 77 | while (match(substr(fs, i), /^ [^ ]*/) \
|
---|
| 78 | && substr(fs, i + 1, RLENGTH - 1) < FILENAME) {
|
---|
| 79 | i += RLENGTH
|
---|
| 80 | }
|
---|
| 81 | files[sym] = substr(fs, 1, i - 1) " " FILENAME substr(fs, i)
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | /^[\t ]*#/ {
|
---|
| 87 | if (sub(/^[\t ]*#[\t ]*ifn?def[\t ]+/, "", $0)) {
|
---|
| 88 | sub(/[^A-Za-z_0-9].*/, "", $0)
|
---|
| 89 | file_sym($0)
|
---|
| 90 | }
|
---|
| 91 | if (sub(/^[\t ]*#[\t ]*(el)?if[\t ]+/, "", $0)) {
|
---|
| 92 | # Remove comments. Not perfect, but close enough.
|
---|
| 93 | gsub(/\/\*[^\/]*(\*\/)?/, "", $0)
|
---|
| 94 |
|
---|
| 95 | for (i = split($0, field, /[^A-Za-z_0-9]+/); 1 <= i; i--) {
|
---|
| 96 | if (field[i] != "defined") {
|
---|
| 97 | file_sym(field[i])
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | END {
|
---|
| 104 | for (sym in files) {
|
---|
| 105 | print sym files[sym]
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 | ' ${1+"$@"} | sort
|
---|