Date: Fri, 18 Mar 2005 03:11:37 +0000 From: Jonathon McKitrick <jcm@FreeBSD-uk.eu.org> To: freebsd-questions@freebsd.org Subject: How to include header files in makefiles Message-ID: <20050318031137.GA99419@dogma.freebsd-uk.eu.org>
next in thread | raw e-mail | index | archive | help
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
--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050318031137.GA99419>
