Optional Patches

Matthew Seaman m.seaman at infracaninophile.co.uk
Wed May 18 22:10:50 UTC 2011

On 18/05/2011 22:29, Matthew Pounsett wrote:
> I've added a new option (call it 'FOO') to the OPTIONS definition,
> and I'm attempting to add something like this directly below MASTER_SITES
> near the top of the Makefile:
> .if defined(FOO)
> PATCH_SITES=      http://location.site.com/path/
> PATCHFILES=       port-${PORTVERSION}.patch
> .endif
> The option shows up when the config target is run, but ports doesn't
> do anything with the patch info.  If I remove or comment-out the .if
> and .endif surrounding the above block, then ports finds and applies
> the patch perfectly, so I know the patching info itself is correct.

For an option FOO you want to test 'WITH_FOO' and/or 'WITHOUT_FOO' in
your Makefile.

Basically the structure is like this:

OPTIONS=	FOO	"Frob the foo-ness"  no \
		BAR	"Enable order round" yes

.include <bsd.port.options.mk>

# Testing both WITH_ and WITHOUT_ is a good idea...
.if defined(WITH_FOO) && !defined(WITHOUT_FOO)
{ do foo related stuff }
{ do non-foo stuff }

# ... but just testing WITH_ is very common too.
.if defined(WITH_BAR)
ORDER+=	"Two pints of lager and a packet of crisps"

The important thing is to only test OPTION settings *after* including
<bsd.port.options.mk> (or <bsd.port.pre.mk> which is an older style of
doing options stuff.)



Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew at infracaninophile.co.uk               Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20110518/ab507ec1/signature.pgp

More information about the freebsd-ports mailing list