Subject: automatically rebuilding headers using make
To: None <netbsd-help@netbsd.org>
From: Brook Milligan <brook@biology.nmsu.edu>
List: netbsd-help
Date: 12/12/2001 09:40:25
I am have trouble getting a Makefile based on the definitions in
bsd.lib.mk to work.  I am trying to use it to make a small library.
One of the header files (units-defs.h) needs to be rebuilt from a
template (units-defs.h.in) prior to compiling the library.  My attempt
to include an explicit rule in the Makefile is illustrated below.

     # Makefile

     SRCDIR=		..

     LIB=		units

     SRCS+=		${SRCDIR}/lib/units.c

     CPPFLAGS+=	-O0 -g -I/usr/pkg/include/pgsql
     CPICFLAGS=	-fpic -DPIC
     CPPPICFLAGS=	-DPIC

     MKLINT=		no
     NOPROFILE=	no profile library

     install:	# needed only for build

     units-defs.h: units-defs.h.in ../bin/units-defs
	     ../bin/units-defs < ${.TARGET}.in > ${.TARGET}
     units.o: units-defs.h

     .include <bsd.lib.mk>

Unfortunately, this doesn't work.  Even though units-defs.h is out of
date with respect to units-defs.h.in, the appropriate rule is never
used.

An examination of the debugging output from make seems to indicate
that it considers units-defs.h to be a source file, and therefore is
never out of date.

What are the proper incantations to make this happen?  Are there any
examples in the NetBSD source code of rebuilding a header file prior
to compilation?

Thanks for your help.

Cheers,
Brook