diff --git a/src/libuafs/Makefile.common.in b/src/libuafs/Makefile.common.in index 5779c54db1..e6a382fe23 100644 --- a/src/libuafs/Makefile.common.in +++ b/src/libuafs/Makefile.common.in @@ -2039,8 +2039,8 @@ $(PERLUAFS)/ukernel.so: $(PERLUAFS)/ukernel_swig_perl.o UAFS.pic/libuafs_pic.a clean: -$(RM) -rf UAFS* JUAFS* AFSWEB* PERLUAFS nsapi afsd afs afsint config rx - -$(RM) -f h net netinet rpc ufs machine inet nfs sys linktest $(AFS_OS_CLEAN) - + -$(RM) -rf h + -$(RM) linktest $(AFS_OS_CLEAN) install: UAFS/$(LIBUAFS) JUAFS/$(LIBJUAFS) UAFS.pic/libuafs_pic.a \ @LIBUAFS_BUILD_PERL@ @@ -2102,15 +2102,10 @@ AFSWEB: mkdir -p $@ setup_common: - -$(RM) -f h net netinet rpc ufs nfs machine sys inet nsapi afsd - -ln -s ${ISYSROOT}/usr/include/sys h - -ln -s ${ISYSROOT}/usr/include/net net - -ln -s ${ISYSROOT}/usr/include/netinet netinet - -ln -s ${ISYSROOT}/usr/include/rpc rpc - -ln -s ${ISYSROOT}/usr/include/sys sys - -ln -s ${ISYSROOT}/usr/include/nfs nfs - -ln -s ${ISYSROOT}/usr/include/inet inet - -ln -s ${ISYSROOT}/usr/include/ufs ufs + -$(RM) -f nsapi afsd + -$(RM) -rf h + @TOP_SRCDIR@/libuafs/make_h_tree.pl $(TOP_SRC_AFS) $(TOP_SRC_VNOPS) \ + $(TOP_SRC_RX) -ln -s $(TOP_SRCDIR)/afsd afsd -ln -s $(NS_INCL) nsapi diff --git a/src/libuafs/make_h_tree.pl b/src/libuafs/make_h_tree.pl new file mode 100755 index 0000000000..d877be04a2 --- /dev/null +++ b/src/libuafs/make_h_tree.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# make_h_tree.pl +# Generate an h tree that includes the appropriate sys headers +# +# Usage: make_h_tree.pl ${SRC} ... +# +# The specified makefiles will be scanned for variable values. The h +# directory will be created under the current directory and populated with +# stubs that include the actual header file for every header included by any +# source file in the ${SRC} directories. This is an ugly hack to work around +# the naming of header files using h instead of their proper names elsewhere +# in the code. + +use IO::File; + +if (@ARGV < 1) { + die "Usage: $0 SRC ...\n"; +} + +%remap = ('h' => 'sys'); +foreach $src (keys %remap) { + mkdir($src, 0777) or die "$src: $!\n"; +%seen = (); +@q = map { glob ("$_/*.[Sc]") } @ARGV; + while (@q) { + $src = shift @q; + $content = new IO::File($src, O_RDONLY) or die "$src: $!\n"; + LINE: + while (<$content>) { + chomp; + if (/^\s*\#\s*include\s*[<\"](?:\.\.\/)?([^\/>\"]*)(.*?)[>\"]/) { + $inc = "$1$2"; + if (exists $seen{$inc}) { + next; + } elsif (exists $remap{$1} && $2 !~ /.\//) { + $H = new IO::File("$inc", O_WRONLY|O_CREAT|O_TRUNC, 0666) + or die "$inc: $!\n"; + print $H "#include \n"; + $H->close() or die "$inc: $!\n"; + $seen{$inc} = 1; + } + } + } + } +}