mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-22 23:50:07 +08:00
5b80666b99
2000-05-25 Benjamin Kosnik <bkoz@milou.soma.redhat.com> * inclosure: Change to... * mkinclosure: This. Fix paths to bash. * mkcshadow: Fix paths to bash. * src/Makefile.am: Tweaks. Do cshadow header trickery at build time. * src/Makefile.in: Regnerate. * acinclude.m4 (GLIBCPP_COMPILER_VERSION): Fix typo. (GLIBCPP_ENABLE_SHADOW): Do a less gross hack. * aclocal.m4: Regenerate. * configure.in: Enable long long by default. * configure: Regenerate. * mkcheck.in (LIB_PATH): Revert. From-SVN: r34166
103 lines
2.6 KiB
Bash
Executable File
103 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# usage: inclosure [ -I dir ] ... [ -G header-name ] ... header-name ...
|
|
#
|
|
# Locates each standard header and argument header-name in the
|
|
# specified "-I" include path (default is /usr/include) and parses
|
|
# any header names out of its #include directives. These names are
|
|
# treated recursively to identify a _transitive_closure_ of standard
|
|
# header names, which is sorted and sent to standard output. Headers
|
|
# not specified with -G, and included somewhere but not located are
|
|
# reported.
|
|
#
|
|
# Each header reported by this program must be "shadowed" by a
|
|
# file of the same name in a C++ header. See
|
|
# http://www.cantrip.org/cheaders.html
|
|
#
|
|
# BUGS:
|
|
# - Cannot cope with header file names that contain spaces
|
|
# - Ignores comment-block delimiters
|
|
# - Ignores sub-includes under #include_next headers.
|
|
|
|
OLDH=/tmp/old$$
|
|
echo "this-compensates-for-a-stupid-bug-in-GNU-fgrep." >$OLDH
|
|
HDRS=/tmp/hdrs$$
|
|
>$HDRS
|
|
NEW=/tmp/new$$
|
|
>$NEW
|
|
IGNORES=/tmp/ignores$$
|
|
echo "this-compensates-for-a-stupid-bug-in-GNU-fgrep.">$IGNORES
|
|
|
|
trap "rm -f $NEW $HDRS $OLDH $IGNORES" 0
|
|
|
|
# process arguments
|
|
unset INCPATH
|
|
while [ $# != 0 -a "$1" != "${1#-}" ]; do
|
|
FLAG="${1%%${1##-?}}"
|
|
case "$FLAG" in -I|-G)
|
|
ARG="${1##${FLAG}}"
|
|
if [ "$ARG" = "" ]; then
|
|
if [ $# != 0 ]; then
|
|
shift;
|
|
ARG="$1"
|
|
else
|
|
echo "$0: $FLAG needs an argument."
|
|
exit
|
|
fi
|
|
fi ;;
|
|
esac
|
|
shift
|
|
case "$FLAG" in
|
|
-I) INCPATH="$INCPATH $ARG" ;;
|
|
-G) echo " $ARG " >>$IGNORES ;;
|
|
esac
|
|
done
|
|
INCPATH=${INCPATH-"/usr/include"}
|
|
|
|
# identify headers
|
|
|
|
STDHDRS="assert.h ctype.h errno.h float.h limits.h \
|
|
locale.h math.h setjmp.h signal.h stdarg.h stddef.h \
|
|
stdio.h stdlib.h string.h time.h wchar.h wctype.h "
|
|
OTHERS="$*"
|
|
|
|
for file in $STDHDRS $OTHERS; do
|
|
echo "$file"
|
|
done >$HDRS
|
|
|
|
until cmp -s $OLDH $HDRS; do # (until no new headers found)
|
|
|
|
fgrep -v -f $OLDH $HDRS \
|
|
| while read file; do
|
|
found=no
|
|
for dir in $INCPATH; do
|
|
name="$dir/$file"
|
|
if [ -f "$name" ]; then
|
|
cat "$name"
|
|
found=yes
|
|
break;
|
|
fi
|
|
done
|
|
if [ "$found" = no ]; then # && echo " $file " | fgrep -v -q -f $IGNORES
|
|
echo "$0: warning: header $file not found in include path." $1>&2
|
|
fi
|
|
done \
|
|
| sed -n -e \
|
|
'/^[ ]*#[ ]*include[ ]*<[^>]*>/s/^[^<]*<\([^>]*\)>.*/\1/p' \
|
|
| while read file; do
|
|
drop=no
|
|
for ignore in `cat $IGNORES`; do
|
|
if [ "$ignore" == "$file" ]; then drop=yes; fi
|
|
done
|
|
case "$file" in /*) drop=yes;; esac # no absolute paths
|
|
case $drop in no) echo "$file";; esac
|
|
done >$NEW
|
|
mv $HDRS $OLDH
|
|
cat $OLDH $NEW | sort -u -o $HDRS
|
|
|
|
done
|
|
cat $HDRS
|
|
|
|
|
|
|