conditional (FreeBSD version specific) OPTIONS definition

Alexander Zhuravlev zaa at ulstu.ru
Sun Mar 19 22:40:53 UTC 2006


Hello,

My port needs to provide option for zlib support inclusion in a php extension.
The thing is that it requires zlib version which is not shipped with
OSVERSION < 500000. Thus I tried to use the following code in Makefile:

OPTIONS=        CURL                    "Enable cURL HTTP requests"     on \
                MAGIC_MIME              "Enable response content type guessing" off

.include <bsd.port.pre.mk>

.if ${OSVERSION} >= 500000
OPTIONS+=       ZLIB_COMPRESSION        "Enable support for encoded message bodies"     on
.endif

.if defined(WITH_ZLIB_COMPRESSION)
CONFIGURE_ARGS+=--with-http-zlib-compression=/usr
.else
CONFIGURE_ARGS+=--without-http-zlib-compression
.endif

.if defined(WITH_CURL)
LIB_DEPENDS+=   curl.3:${PORTSDIR}/ftp/curl
CONFIGURE_ARGS+=--with-http-curl-requests=${LOCALBASE}
.else
CONFIGURE_ARGS+=--without-http-curl-requests
.endif

.if defined(WITH_MAGIC_MIME)
LIB_DEPENDS+=   magic.1:${PORTSDIR}/sysutils/file
CONFIGURE_ARGS+=--with-http-magic-mime=${LOCALBASE}
.else
CONFIGURE_ARGS+=--without-http-magic-mime
.endif

.include <bsd.port.post.mk>

When I run portlint -Aa (portlink version 2.8.7) I got the following
error message:
FATAL: Makefile [34]: OPTIONS is set after including bsd.port.pre.mk.

Why is it declined to define OPTIONS after inclusion of the bsd.port.pre.mk
file? Is it possible to impement dynamic options definition using other means?

For now I overcame the issue by using the following code:

OPTIONS=        CURL                    "Enable cURL HTTP requests"     on \
                MAGIC_MIME              "Enable response content type guessing" off \
                ZLIB_COMPRESSION        "Enable support for encoded message bodies"     off

.include <bsd.port.pre.mk>

.if defined(WITH_CURL)
LIB_DEPENDS+=   curl.3:${PORTSDIR}/ftp/curl
CONFIGURE_ARGS+=--with-http-curl-requests=${LOCALBASE}
.else
CONFIGURE_ARGS+=--without-http-curl-requests
.endif

.if defined(WITH_MAGIC_MIME)
LIB_DEPENDS+=   magic.1:${PORTSDIR}/sysutils/file
CONFIGURE_ARGS+=--with-http-magic-mime=${LOCALBASE}
.else
CONFIGURE_ARGS+=--without-http-magic-mime
.endif

.if defined(WITH_ZLIB_COMPRESSION) && ${OSVERSION} < 500000
CONFIGURE_ARGS+=--with-http-zlib-compression=/usr
.else
CONFIGURE_ARGS+=--without-http-zlib-compression
.endif

.include <bsd.port.post.mk>

But it is not that elegant solution because users of FreeBSD
will be presented with not supported option for their FreeBSD
version.

Thank you.
--
Alexander Zhuravlev


More information about the freebsd-ports mailing list