Check for set Makefile options and compile accordingly

Antoine Brodin antoine at freebsd.org
Tue Sep 9 22:17:26 UTC 2014


On Wed, Sep 10, 2014 at 12:10 AM, Oliver Mahmoudi
<olivermahmoudi at gmail.com> wrote:
> Hello,
>
> I am working on a new port here and have a few questions regarding the new
> style of handling Makefile options.
>
> The program I got, is configured in a non standard way, i.e. there is no
> configure script or the like. Depending on what modules/libraries you want
> to build along with the executable,
>
> pre-build:
>         ${GMAKE} ${MAKE_ARGS} cfg
>
> is run, to configure the program's build system. This can be translated to:
>
> pre-build:
>         ${GMAKE} include_modules="module_1 module_2 ..." cfg
>
> I set up MAKE_ARGS in the following way:
>
> .if !empty (EXTRA_MODULES)
> MAKE_ARGS=      include_modules="${EXTRA_MODULES}"
> .endif
>
> About a year ago, when writing the original Makefile, I handled the
> situation like this:
>
> .if ${PORT_OPTIONS:MMYSQL}
> BUILD_DEPENDS+=
> ${LOCALBASE}/libexec/mysqld:${PORTSDIR}/databases/mysql56-server
> RUN_DEPENDS+:=  ${BUILD_DEPENDS}
> EXTRA_MODULES+= db_mysql
> PLIST_SUB+=     MYSQL=""
> .else
> PLIST_SUB+=     MYSQL="@comment "
> .endif
>
> To get the port out there, folks now want me to change the way I handle the
> Makefile options. Therefore, the above if/else/endif block now now looks
> like this:
>
> OPT_ABOVEVARIABLE=      YES
> OPTIONS_SUB=      YES
>
> MYSQL_BUILD_DEPENDS=
> ${LOCALBASE}/libexec/mysqld:${PORTSDIR}/databases/mysql56-server
>
> #
> # This stuff now hangs loose
> #
> RUN_DEPENDS+:=  ${BUILD_DEPENDS}
> EXTRA_MODULES+= db_mysql
> #
> #
> #
>
> Given the new style of handling Makefile options how do I handle passing my
> EXTRA_MODULES variable - there is more than just the one above - to the
> port's configure stage via MAKE_ARGS and how would I deal with the
> RUN_DEPENDS+:=  ${BUILD_DEPENDS} situation?
>
> None of the situations offered on:
>
> https://www.freebsd.org/doc/en/books/porters-handbook/makefile-options.html
>
> match my given scenario.
>
> Any pointers?


Hi,

If the options helpers do not fit your needs,  you can still use constructs like
.include <bsd.port.options.mk>
.if ${PORT_OPTIONS:MMYSQL}
...

Cheers,

Antoine


More information about the freebsd-ports mailing list