ports makefile stuff (bsd.lib.mk)

Mel fbsd.questions at rachie.is-a-geek.net
Thu Feb 7 20:54:10 UTC 2008


first of all, /usr/share/mk/bsd.lib.mk is part of the FreeBSD system make 
files, not just the ports. So if you change something there, you will almost 
certainly break your buildworld and buildkernel.

On Wednesday 06 February 2008 16:49:46 Jim Stapleton wrote:

> 1) Initially, this library will actually build several sublibraries.
> To keep my code neat, each library has it's own source directory.

So you set SUBDIR.

> However, I also want to make cross linking easier and less prone to
> "oops, I forgot to add the library's directory to the lib path list"
> issues, so under the source directory I made an 'objs' directory,
> where I was manually putting the output. Is there a way to simply have
> the final output files sent to that directory?

Not sure exactly what you want to do, so I'll just explain the "right" way:
The system make, will always look for ${.CURDIR}/../Makefile.inc and include 
that if it's present.
This allows you to centralize common CFLAGS/LDADD/LDFLAGS variables in one 
file, providing your source tree isn't deeper then 2 levels (otherwise, 
simply do .include "${.CURDIR}/../../Makefile.inc" before .include 

Objects are put in OBJDIR. If you have not set MAKEOBJDIRPREFIX in the 
environment, this will default to ${.CURDIR} and give you a warning.

Providing the right libraries to compile /your/ program is /your/ 
responsibility. Here's an example:


SRCS=main.c foo.c

.include <bsd.prog.mk>

Now the only problem you have, is making sure libfoo is built before progfoo, 
SUBDIR=libfoo progfoo

.include <bsd.subdir.mk>


More information about the freebsd-questions mailing list