Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / libuafs / make_h_tree
CommitLineData
805e021f
CE
1#!/bin/sh -e
2
3# make_h_tree
4# Generate an h tree that includes the appropriate sys headers
5#
6# Usage: make_h_tree ${SRC} ...
7#
8# The source files in the specified directories will be scanned for include
9# directives. The h directory will be created under the current directory and
10# populated with stubs that include the actual header file for every header
11# included by any source file in the ${SRC} directories. Since this script is
12# for userspace only, this effectively just makes a file called h/foo.h that
13# contains:
14# #include <sys/foo.h>
15# For every include directive that is found that looks like #include <h/foo.h>
16# This is an ugly hack to work around the naming of header files using h
17# instead of their proper names elsewhere in the code.
18
19mkdir h
20
21for dir in "$@" ; do
22 for hsrc in `cat "$dir"/*.c | \
23 sed -n -e 's|^[ ]*#[ ]*include[ ]*[<"]h/\([^>"/]*\)[>"].*$|\1|p' | \
24 sort | uniq` ; do
25
26 echo "#include <sys/$hsrc>" > h/"$hsrc"
27 done
28done