Saving FreeBSD Ports Make Flags

Ever tried to save FreeBSD port flags? You probably used /usr/local/etc/pkgtools.conf, that works most of the time. You have to always use portupgrade to install ports though, if you just go to the port dir and type make the port settings in this file are ignored.

An alternative method is to use a Makefile.local with your settings. This will work with both make and portupgrade, the downside is that your settings are imported only if the Makefile of the port you want to install has .include <bsd.port.pre.mk> in it. If it doesn't have that you're out of luck. No settings will take effect.

The best method I've found so far is to use make.conf for your port settings. Actually I use a separate file named /etc/ports.conf that is included if make detects that the current directory includes /usr/ports. So how it works:

Add this to your /etc/make.conf file:

.if ${.CURDIR:M*/usr/ports*}
.include "/etc/ports.conf"
.endif

Then for every port you want to customize a block like the following one in /etc/ports.conf:

.if ${.CURDIR:M*/www/apache*}
WITH_OPENSSL_BASE=1
APACHE_BUFFERED_LOGS=1
.endif

This will effectively add -DWITH_OPENSSL_BASE -DAPACHE_BUFFERED_LOGS when make is called under the apache port dir.

Comments

Nice overview of a couple of the possibilities :)

Just a quick question: are you aware that there are actually quite a few other ways to do this? I mentioned some of them in my OpenFest/BSDCon 2004 presentation at http://openfest.org/presentations/2004/BSDCon/Peter_Pentchev/bsdcon-roam...

G'luck,
Peter

I wasn't aware of the OPTIONS method to customize ports, but you say that's not reliable yet. The other options I haven't heard is penv, that looks nice although you still need to do things in a different way. If I customize make.conf for ports I can just run portupgrade -arR and it will build every port with the specified environment, the format for setting that environment is a bit ugly I admit.

[...] We are neither affiliated with the authors of this page nor responsible for its content. Saving FreeBSD Ports Make Flags How to efficiently save FreeBSD ports' flags so a port upgrade will preserve the make flags used [...]