How to include header files in makefiles
Jonathon McKitrick
jcm at FreeBSD-uk.eu.org
Thu Mar 17 19:11:40 PST 2005
Hi all,
I'm setting up a build system for a small project and I want to use included
makefiles. I have a base.mk that looks like this:
.PATH.h : ../ ../include
.INCLUDES : .h
CFLAGS = -O -pipe -Wall -g
CFLAGS += $(.INCLUDES)
OBJS = ${SRCS:R:S/$/.o/g}
and a bin.mk that looks like this:
include ../include/mk/base.mk
all: ${BIN}
${BIN}: ${OBJS}
${CC} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
so that a makefile for a specific program looks like this:
BIN = app
SRCS = app.c
LDFLAGS += -pthread
include ../include/mk/bin.mk
But I'm having a problem figuring out how to handle header files. I have
some that are local to this binary, but others are in the project include
directory.
How can I include the .h files so the .c files are recompiled when the
header files they require are changed? GNU make has 'make depend' but I'd
like a better, BSDmake-centric way, if possible.
Thanks for your help,
jm
--
More information about the freebsd-questions
mailing list