?RCS: $Id: Findhdr.U 167 2013-05-08 17:58:00Z rmanfredi $ ?RCS: ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi ?RCS: ?RCS: You may redistribute only under the terms of the Artistic License, ?RCS: as specified in the README file that comes with the distribution. ?RCS: You may reuse parts of this distribution only within the terms of ?RCS: that same Artistic License; a copy of which may be found at the root ?RCS: of the source tree for dist 4.0. ?RCS: ?RCS: Original Author: Thomas Neumann ?RCS: ?RCS: $Log: Findhdr.U,v $ ?RCS: Revision 3.0.1.2 1994/10/29 15:53:08 ram ?RCS: patch36: added ?F: line for metalint file checking ?RCS: ?RCS: Revision 3.0.1.1 1994/05/06 14:03:56 ram ?RCS: patch23: cppminus must be after other cppflags, not before ?RCS: ?RCS: Revision 3.0 1993/08/18 12:04:54 ram ?RCS: Baseline for dist 3.0 netwide release. ?RCS: ?X: ?X: This unit produces a findhdr script which is used to locate the header ?X: files in $usrinc or other stranger places using cpp capabilities. The ?X: script is given an include file base name, like 'stdio.h' or 'sys/file.h' ?X: and it returns the full path of the include file and a zero status or an ?X: empty string with an error status if the file could not be located. ?X: ?MAKE:Findhdr: grep tr rm +usrinc awk cat startsh \ cppstdin cppminus +cppflags eunicefix fieldn cppfilter ?MAKE: -pick add $@ %< ?F:./findhdr ?T:cline wanted name awkprg status usrincdir ?X: To locate a header file, we cannot simply check for $usrinc/file.h, since ?X: some machine have the headers in weird places and our only hope is that ?X: the C pre-processor will know how to find those headers. Thank you NexT! : locate header file $cat >findhdr <" > foo\$\$.c $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \ $cppfilter $grep "^[ ]*#.*\$wanted" | \ while read cline; do name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\` case "\$name" in *[/\\\\]\$wanted) echo "\$name"; exit 1;; *[\\\\/]\$wanted) echo "\$name"; exit 1;; *) exit 2;; esac done ?X: status = 0: grep returned 0 lines, case statement not executed ?X: status = 1: headerfile found ?X: status = 2: while loop executed, no headerfile found status=\$? $rm -f foo\$\$.c if test \$status -eq 1; then exit 0 fi exit 1 EOF chmod +x findhdr $eunicefix findhdr