Date: Fri, 2 Aug 2013 16:08:38 +0000 (UTC) From: Brad Davis <brd@FreeBSD.org> To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r42487 - head/en_US.ISO8859-1/books/porters-handbook Message-ID: <201308021608.r72G8cbM084392@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: brd Date: Fri Aug 2 16:08:38 2013 New Revision: 42487 URL: http://svnweb.freebsd.org/changeset/doc/42487 Log: - Add a new section for Options Helpers from bapt@ Submitted by: bapt@ Reviewed by: Ken Reed <kreed002@gmail.com> Modified: head/en_US.ISO8859-1/books/porters-handbook/book.xml Modified: head/en_US.ISO8859-1/books/porters-handbook/book.xml ============================================================================== --- head/en_US.ISO8859-1/books/porters-handbook/book.xml Fri Aug 2 06:01:58 2013 (r42486) +++ head/en_US.ISO8859-1/books/porters-handbook/book.xml Fri Aug 2 16:08:38 2013 (r42487) @@ -4629,6 +4629,247 @@ CONFIGURE_ARGS+= --disable-foo .if ${VARIABLE:MVALUE}</programlisting> </note> </sect2> + <sect2> + <title>Options Helpers</title> + + <para>There are some macros to help simplify conditional + values which differ based on the options set.</para> + + <para>If <makevar>OPTIONS_SUB</makevar> is set to + <literal>yes</literal> then each of the options added + to <makevar>OPTIONS_DEFINE</makevar> will be added to + <makevar>PLIST_SUB</makevar>, for example:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPTIONS_SUB= yes</programlisting> + + <para> is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MOPT1} +PLIST_SUB+= OPT1="" +.else +PLIST_SUB+= OPT1="@comment " +.endif</programlisting> + + <para>If <makevar>X_CONFIGURE_ENABLE</makevar> is set then + <literal>--enable-${X_CONFIGURE_ENABLE}</literal> + or <literal>--disable-${X_CONFIGURE_ENABLE}</literal> will + be added to <makevar>CONFIGURE_ARGS</makevar> depending on + the value of the option<makevar>X</makevar>, for example:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_CONFIGURE_ENABLE= test</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MOPT1} +CONFIGURE_ARGS+= --enable-test +.else +CONFIGURE_ARGS+= --disable-test +.endif</programlisting> + + <para>If <makevar>X_CONFIGURE_WITH</makevar> is set then + <literal>--with-${X_CONFIGURE_WITH}</literal> + or <literal>--without-${X_CONFIGURE_WITH}</literal> will + be added to <makevar>CONFIGURE_ARGS</makevar> depending + on the status of the option <makevar>X</makevar>, + for example:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_CONFIGURE_WITH= test</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MOPT1} +CONFIGURE_ARGS+= --with-test +.else +CONFIGURE_ARGS+= --without-test +.endif</programlisting> + + <para>If <makevar>X_CONFIGURE_ON</makevar> is set then its value + will be appended to <makevar>CONFIGURE_ARGS</makevar> depending + on the status of the option <makevar>X</makevar>, for example: + </para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_CONFIGURE_ON= --add-test</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MOPT1} +CONFIGURE_ARGS+= --add-test +.endif</programlisting> + + <para>If <makevar>X_CONFIGURE_OFF</makevar> is set then its value + will be appended to <makevar>CONFIGURE_ARGS</makevar> depending + on the status of the option <makevar>X</makevar>, for example: + </para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_CONFIGURE_OFF= --no-test</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 +.include <bsd.port.options.mk> +.if ! ${PORT_OPTIONS:MOPT1} +CONFIGURE_ARGS+= --no-test +.endif</programlisting> + + <para>If <makevar>X_CMAKE_ON</makevar> is set then its value + will be appended to <makevar>CMAKE_ARGS</makevar> depending + on the status of the option <makevar>X</makevar>, for example: + </para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_CMAKE_ON= -DTEST:BOOL=true</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MOPT1} +CMAKE_ARGS+= -DTEST:BOOL=true +.endif</programlisting> + + <para>If <makevar>X_CMAKE_OFF</makevar> is set then its value + will be appended to <makevar>CMAKE_ARGS</makevar> depending + on the status of the option <makevar>X</makevar>, for example: + </para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_CMAKE_OFF= -DTEST:BOOL=false</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ! ${PORT_OPTIONS:MOPT1} +CMAKE_ARGS+= -DTEST:BOOL=false +.endif</programlisting> + + <para>For any of the following variables:</para> + + <itemizedlist> + <listitem> + <para><makevar>CFLAGS</makevar></para> + </listitem> + + <listitem> + <para><makevar>CXXFLAGS</makevar></para> + </listitem> + + <listitem> + <para><makevar>LDLAGS</makevar></para> + </listitem> + + <listitem> + <para><makevar>CONFIGURE_ENV</makevar></para> + </listitem> + + <listitem> + <para><makevar>MAKE_ENV</makevar></para> + </listitem> + + <listitem> + <para><makevar>USES</makevar></para> + </listitem> + + <listitem> + <para><makevar>DISTFILES</makevar></para> + </listitem> + </itemizedlist> + + <para>If <makevar>X_ABOVEVARIABLE</makevar> is defined then + its value will be appended to + <makevar>ABOVEVARIABLE</makevar> depending on the status of + the option <makevar>X</makevar>, for example:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_USES= gmake +OPT1_CFLAGS= -DTEST</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MOPT1} +USES+= gmake +CFLAGS+= -DTEST +.endif</programlisting> + + <para>For any of the following dependency type:</para> + + <itemizedlist> + <listitem> + <para><makevar>PKG_DEPENDS</makevar></para> + </listitem> + + <listitem> + <para><makevar>EXTRACT_DEPENDS</makevar></para> + </listitem> + + <listitem> + <para><makevar>PATCH_DEPENDS</makevar></para> + </listitem> + + <listitem> + <para><makevar>FETCH_DEPENDS</makevar></para> + </listitem> + + <listitem> + <para><makevar>BUILD_DEPENDS</makevar></para> + </listitem> + + <listitem> + <para><makevar>LIB_DEPENDS</makevar></para> + </listitem> + + <listitem> + <para><makevar>RUN_DEPENDS</makevar></para> + </listitem> + </itemizedlist> + + <para>If <makevar>X_ABOVEVARIABLE</makevar> is defined then + its value will be appended to + <makevar>ABOVEVARIABLE</makevar> depending on the status + of the option <makevar>X</makevar>, for example:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 +OPT1_LIB_DEPENDS= liba.so:${PORTSDIR}/devel/a</programlisting> + + <para>is equivalent to:</para> + + <programlisting>OPTIONS_DEFINE= OPT1 + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MOPT1} +LIB_DEPENDS+= liba.so:${PORTSDIR}/devel/a +.endif</programlisting> + </sect2> </sect1> <sect1 id="makefile-wrkdir">
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308021608.r72G8cbM084392>