Check-in [d11b73831a]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Document options helpers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d11b73831a323ffe0ffbdb2520290e13d04185be
User & Date: bapt 2013-07-29 16:39:23
Context
2013-07-29
16:46
Document new libdepends way check-in: c60d5d2fe2 user: bapt tags: trunk
16:39
Document options helpers check-in: d11b73831a user: bapt tags: trunk
15:41
USE_DISPLAY is now USES=display check-in: 89dd423fcb user: bapt tags: trunk
Changes

Added options-helpers.patch.

























































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
Index: book.xml
===================================================================
diff --git a/head/en_US.ISO8859-1/books/porters-handbook/book.xml b/head/en_US.ISO8859-1/books/porters-handbook/book.xml
--- a/head/en_US.ISO8859-1/books/porters-handbook/book.xml	(revision 42469)
+++ b/head/en_US.ISO8859-1/books/porters-handbook/book.xml	(working copy)
@@ -4645,6 +4645,246 @@
 .if ${VARIABLE:MVALUE}</programlisting>
 	</note>
       </sect2>
+      <sect2>
+	<title>Options helpers</title>
+
+	<para>A couple of helpers exists to simplify handling actions
+	  based on the value of an option.</para>
+
+	<para>If <makevar>OPTIONS_SUB</makevar> is set to
+	  <literal>yes</literal> then all <makevar>PLIST_SUB<makevar>
+	  will be populated automatically for each options defined in
+	  <makevar>OPTIONS_DEFINE</makevar>, for example:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPTIONS_SUB=	yes</programlisting>
+
+	<para> is equivalent of:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.if ${PORT_OPTIONS:MOPT1}
+PLIST_SUB+=	OPT1=""
+.else
+PLIST_SUB+=	OPT1="@comment "
+.endif</programlisting>
+
+	<para>If <makevar>X_CONFIGURE_ENABLE</makevar> is set then it
+	  will add <literal>--enable-${X_CONFIGURE_ENABLE}</literal>
+	  or <literal>--disable-${X_CONFIGURE_ENABLE}</literal> to
+	  <makevar>CONFIGURE_ARGS</makevar depending the value of the
+	  option<makevar>X</makevar>, for example:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_CONFIGURE_ENABLE=	test</programlisting>
+
+	<para>is equivalent of:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.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 it
+	  will add <literal>--with-${X_CONFIGURE_WITH}</literal>
+	  or <literal>--without-${X_CONFIGURE_WITH}</literal> to
+	  <makevar>CONFIGURE_ARGS</makevar depending the value of the
+	  option<makevar>X</makevar>, for example:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_CONFIGURE_WITH=	test</programlisting>
+
+	<para>is equivalent of:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.if ${PORT_OPTIONS:MOPT1}
+CONFIGURE_ARGS+=	--with-test
+.else
+CONFIGURE_ARGS+=	--without-test
+.endif</programlisting>
+
+	<para>If <makevar>X_CONFIGURE_ON<makevar> is then its value
+	  will be appended to <makevar>CONFIGURE_ARGS</makevar> if
+	  the options <makevar>X</makevar> is activated, for example:
+	</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_CONFIGURE_ON=	--add-test</programlisting>
+
+	<para>is equivalent of</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.if ${PORT_OPTIONS:MOPT1}
+CONFIGURE_ARGS+=	--add-test
+.endif</programlisting>
+
+	<para>If <makevar>X_CONFIGURE_OFF<makevar> is then its value
+	  will be appended to <makevar>CONFIGURE_ARGS</makevar> if
+	  the options <makevar>X</makevar> is deactivated, for example:
+	</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_CONFIGURE_OFF=	--no-test</programlisting>
+
+	<para>is equivalent of</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+.include &ls;bsd.port.options.mk&gt;
+.if ! ${PORT_OPTIONS:MOPT1}
+CONFIGURE_ARGS+=	--no-test
+.endif</programlisting>
+
+	<para>If <makevar>X_CMAKE_ON<makevar> is then its value
+	  will be appended to <makevar>CMAKE_ARGS</makevar> if
+	  the options <makevar>X</makevar> is activated, for example:
+	</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_CMAKE_ON=	-DTEST:BOOL=true</programlisting>
+
+	<para>is equivalent of</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.if ${PORT_OPTIONS:MOPT1}
+CMAKE_ARGS+=	-DTEST:BOOL=true
+.endif</programlisting>
+
+	<para>If <makevar>X_CMAKE_OFF<makevar> is then its value
+	  will be appended to <makevar>CMAKE_ARGS</makevar> if
+	  the options <makevar>X</makevar> is deactivated, for example:
+	</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_CMAKE_OFF=	-DTEST:BOOL=false</programlisting>
+
+	<para>is equivalent of</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.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> if <makevar>X</makevar>
+	  is activated, for example:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_USES=	gmake
+OPT1_CFLAGS=	-DTEST</programlisting>
+
+	<para>is equivalent of:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.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> if <makevar>X</makevar>
+	  is activated, for example:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+OPT1_LIB_DEPENDS=	liba.so:${PORTSDIR}/devel/a</programlisting>
+
+	<para>is equivalent of:</para>
+
+	<programlisting>OPTIONS_DEFINE=	OPT1
+
+.include &ls;bsd.port.options.mk&gt;
+
+.if ${PORT_OPTIONS:MOPT1}
+LIB_DEPENDS+=	liba.so:${PORTSDIR}/devel/a
+.endif</programlisting>
+      </sect2>
     </sect1>
 
     <sect1 id="makefile-wrkdir">