makefilefreebsdbsdmake

How to properly link libraries with FreeBSD bmake?


Background

I'd like to compile a small program with some libraries and headers which live in /usr/local/lib and /usr/local/include (I installed them from ports).

I'm using the default FreeBSD make(1) (which happens to be bmake(1) underneath).

Makefile

So far my Makefile looks like this:

PROG_CXX=   client
MAN=
LDADD=  -lhip -lhop -lpthread
SRCS=   client.cc

CFLAGS+=    -I/usr/local/include -L/usr/local/lib

.include <bsd.prog.mk>

Question

Is there a better way to do it? I'm sure that CFLAGS+= -I/usr/local/include -L/usr/local/lib is already automated by some bsd.*.mk but I couldn't find it. I've tried including <bsd.lib.mk> but to no avail.

References


Solution

  • I reached out to the community and I was told that what I'm doing with CFLAGS is actually right:

    The base system purposely excludes /usr/local/* from build stuff so your CFLAGS to include them, are the right thing.