HAVE_GNOME vs. bsd.ports.options.mk

Chris Rees crees at FreeBSD.org
Wed Oct 10 19:36:14 UTC 2012

On 10 October 2012 16:52, Michael Gmelin <freebsd at grem.de> wrote:
> On Wed, 10 Oct 2012 16:40:39 +0100
> Chris Rees <utisoft at gmail.com> wrote:
>> On 10 Oct 2012 11:19, "Michael Gmelin" <freebsd at grem.de> wrote:
>> >
>> > Hi
>> >
>> > I noticed that HAVE_GNOME doesn't work properly with
>> > bsd.ports.options.mk yet, so
>> >
>> > .include <bsd.port.options.mk>
>> > .if ${HAVE_GNOME:Mgnomelibs}!=""
>> > # ...
>> > .endif
>> > .include <bsd.port.mk>
>> >
>> > won't work, while this
>> >
>> > .include <bsd.port.pre.mk>
>> > .if ${HAVE_GNOME:Mgnomelibs}!=""
>> > # ...
>> > .endif
>> > .include <bsd.port.post.mk>
>> >
>> > does.
>> >
>> > AFAIK bsd.port.pre.mk/bsd.port.post.mk should be replaced by
>> > bsd.port.options.mk/bsd.port.mk in the long term, so having this
>> > work or documenting a workaround would help port maintainers who are
>> > in the process of updating the port structure.
>> No. They are two separate methods with two different reasons for
>> using them.
>> You have discovered a case of pre.mk being the correct one to use,
>> which is unusual :)
>> Chris
>> _______________________________________________
>> freebsd-ports at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-ports
>> To unsubscribe, send any mail to
>> "freebsd-ports-unsubscribe at freebsd.org"
> In which case the Porter's Handbook gives little to no advice what the
> actual differences are.
> The only time bsd.port.options.mk is mentioned is in the context of
> OptionsNG ( where it says:
> "OPTIONS definitions must appear before the inclusion of
> bsd.port.options.mk. The PORT_OPTIONS variable can only be tested after
> the inclusion of bsd.port.options.mk. Inclusion of bsd.port.pre.mk can
> be used instead, too, and is still widely used in ports written before
> the introduction of bsd.port.options.mk. But be aware that some
> variables will not work as expected after the inclusion of
> bsd.port.pre.mk, typically some USE_* flags."
> Which sounds to me like: "Yes, you can still use bsd.port.pre.mk, but
> it's the old way of doing things and expect bad things to happen."
> It would probably make sense to refine that section in the Porter's
> Handbook - I know that this is a moving target right now, but since it
> is it either needs to be adapted or at least fact that this is the case
> should be stated somewhere (potentially with a link to the wiki).
> I would be willing to propose a refined version of this section in the
> Porter's Handbook - might take me a while though since I'm pretty busy
> at the moment. But if nobody else has the resources I would do it myself
> for the sake of making things easier for maintainers.

I'm afraid this archive is full of "This should be in the Porter's
Handbook" suggestions-- you're absolutely right, but Someone (tm)
needs to write that section-- it's very kind of you to volunteer :)

There are always going to be weird subtleties.

In a nutshell;

bsd.port.pre.mk USED to be used for:

- Defining ARCH, PREFIX, etc for testing
- Defining WITH_/WITHOUT_ etc for testing from OPTIONS.

bsd.port.options.mk now performs these stages.

The use for bsd.port.pre.mk is for testing variables defined in
Mk/bsd.*.mk if a USE_ variable has been defined.


.include <bsd.port.pre.mk>

.if ${EMACS_VER} > 20.6
# do something

I can't think of any other circumstances where pre.mk is required--
anyone is free to correct me.

The upshot is that bsd.port.pre.mk is rarely required nowadays, since
bsd.port.options.mk defines most things and has fewer nasty side
effects.  However, there are still unusual cases such as the one I
just mentioned; both need to be kept. I have a nice rant about the
craziness there at [1], but bear in mind there are lots of rough edges
and it needs reworking if any of it needs implementing.


[1] http://wiki.freebsd.org/SimplifyingMkIncludes

More information about the freebsd-ports mailing list