aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/porters-handbook/order/chapter.xml
blob: 4761a9228006d2a2e5f15f731cea947738dd25fa (plain) (blame)
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
     The FreeBSD Documentation Project

     $FreeBSD$
-->

<chapter xmlns="http://docbook.org/ns/docbook"
  xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
  xml:id="porting-order">

  <title>Order of Variables in Port Makefiles</title>

  <para>The first sections of the <filename>Makefile</filename>
    must always come in the same order.  This standard makes it so
    everyone can easily read any port without having to search for
    variables in a random order.</para>

  <para>The first line of a <filename>Makefile</filename> is always
    a comment containing the <application>Subversion</application>
    version control ID, followed by an empty line.  In new ports, it
    looks like this:</para>

  <programlisting># &dollar;FreeBSD&dollar;
&nbsp;</programlisting>

  <para>In existing ports, <application>Subversion</application>
    has expanded it to look like this:</para>

  <programlisting># &dollar;FreeBSD: head/ports-mgmt/pkg/Makefile 437007 2017-03-26 21:25:47Z bapt &dollar;
&nbsp;</programlisting>

  <note>
    <para>The sections and variables described here are mandatory in
      a ordinary port.  In a slave port, many sections variables and
      can be skipped.</para>
  </note>

  <important>
    <para>Each following block must be separated from the previous
      block by a single blank line.</para>

    <para>In the following blocks, only set the variables that are
      required by the port.  Define these variables in the order
      they are shown here.</para>
  </important>

  <sect1 xml:id="porting-order-portname">
    <title><varname>PORTNAME</varname> Block</title>

    <para>This block is the most important.  It defines the port
      name, version, distribution file location, and category.  The
      variables must be in this order:</para>

    <itemizedlist>
      <listitem>
	<para><link
	    linkend="makefile-portname"><varname>PORTNAME</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-versions"><varname>PORTVERSION</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-versions"><varname>DISTVERSIONPREFIX</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-versions"><varname>DISTVERSION</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-versions"><varname>DISTVERSIONSUFFIX</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-portrevision"><varname>PORTREVISION</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-portepoch"><varname>PORTEPOCH</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-categories"><varname>CATEGORIES</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-master_sites"><varname>MASTER_SITES</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-master_sites-shorthand"><varname>MASTER_SITE_SUBDIR</varname></link>
	  (deprecated)</para>
      </listitem>

      <listitem>
	<para><link
	    linkend="porting-pkgnameprefix-suffix"><varname>PKGNAMEPREFIX</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="porting-pkgnameprefix-suffix"><varname>PKGNAMESUFFIX</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-distname"><varname>DISTNAME</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-extract_sufx"><varname>EXTRACT_SUFX</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-distfiles-definition"><varname>DISTFILES</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-dist_subdir"><varname>DIST_SUBDIR</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-extract_only"><varname>EXTRACT_ONLY</varname></link></para>
      </listitem>
    </itemizedlist>

    <important>
      <para>Only one of <varname>PORTVERSION</varname> and
	<varname>DISTVERSION</varname> can be used.</para>
    </important>
  </sect1>

  <sect1 xml:id="porting-order-patch">
    <title><varname>PATCHFILES</varname> Block</title>

    <para>This block is optional.  The variables are:</para>

    <itemizedlist>
      <listitem>
	<para><link
	    linkend="porting-patchfiles"><varname>PATCH_SITES</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="porting-patchfiles"><varname>PATCHFILES</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="porting-patchfiles"><varname>PATCH_DIST_STRIP</varname></link></para>
      </listitem>
    </itemizedlist>
  </sect1>

  <sect1 xml:id="porting-order-maintainer">
    <title><varname>MAINTAINER</varname> Block</title>

    <para>This block is mandatory.  The variables are:</para>

    <itemizedlist>
      <listitem>
	<para><link
	    linkend="makefile-maintainer"><varname>MAINTAINER</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-comment"><varname>COMMENT</varname></link></para>
      </listitem>
    </itemizedlist>
  </sect1>

  <sect1 xml:id="porting-order-license">
    <title><varname>LICENSE</varname> Block</title>

    <para>This block is optional, although it is highly recommended.
      The variables are:</para>

    <itemizedlist>
      <listitem>
	<para><link
	    linkend="licenses-license"><varname>LICENSE</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="licenses-license_comb"><varname>LICENSE_COMB</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="licenses-license_groups"><varname>LICENSE_GROUPS</varname></link>
	  or
	  <varname>LICENSE_GROUPS_<replaceable>NAME</replaceable></varname></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="licenses-license_name"><varname>LICENSE_NAME</varname></link>
	  or
	  <varname>LICENSE_NAME_<replaceable>NAME</replaceable></varname></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="licenses-license_text"><varname>LICENSE_TEXT</varname></link>
	  or
	  <varname>LICENSE_TEXT_<replaceable>NAME</replaceable></varname></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="licenses-license_file"><varname>LICENSE_FILE</varname></link>
	  or
	  <varname>LICENSE_FILE_<replaceable>NAME</replaceable></varname></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="licenses-license_perms"><varname>LICENSE_PERMS</varname></link>
	  or
	  <varname>LICENSE_PERMS_<replaceable>NAME</replaceable></varname></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="licenses-license_distfiles"><varname>LICENSE_DISTFILES</varname></link>
	  or
	  <varname>LICENSE_DISTFILES_<replaceable>NAME</replaceable></varname></para>
      </listitem>
    </itemizedlist>

    <para>If there are multiple licenses, sort the different
      LICENSE_<replaceable>VAR</replaceable>_<replaceable>NAME</replaceable>
      variables by license name.</para>
  </sect1>

  <sect1 xml:id="porting-order-broken">
    <title>Generic
      <varname>BROKEN</varname>/<varname>IGNORE</varname>/<varname>DEPRECATED</varname>
      Messages</title>

    <para>This block is optional.  The variables are:</para>

    <itemizedlist>
      <listitem>
	<para><link
	    linkend="dads-deprecated"><varname>DEPRECATED</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-deprecated"><varname>EXPIRATION_DATE</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>FORBIDDEN</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>BROKEN</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>BROKEN_<replaceable>*</replaceable></varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>IGNORE</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>IGNORE_<replaceable>*</replaceable></varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>ONLY_FOR_ARCHS</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>ONLY_FOR_ARCHS_REASON<replaceable>*</replaceable></varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>NOT_FOR_ARCHS</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="dads-noinstall"><varname>NOT_FOR_ARCHS_REASON<replaceable>*</replaceable></varname></link></para>
      </listitem>
    </itemizedlist>

    <note>
      <para><varname>BROKEN_<replaceable>*</replaceable></varname>
	and <varname>IGNORE_<replaceable>*</replaceable></varname>
	can be any generic variables, for example,
	<varname>IGNORE_amd64</varname>,
	<varname>BROKEN_FreeBSD_10</varname>, etc.  With the exception
	of variables that depend on a <link
	  linkend="uses"><varname>USES</varname></link>, place those
	in <xref linkend="porting-order-uses"/>.  For instance,
	<varname>IGNORE_WITH_PHP</varname> only works if
	<link linkend="uses-php"><literal>USES=php</literal></link> is
	set, and <varname>BROKEN_SSL</varname> only if <link
	  linkend="uses-ssl"><literal>USES=ssl</literal></link> is
	set.</para>

      <para>If the port is marked BROKEN when some conditions are
	met, and such conditions can only be tested after including
	<filename>bsd.port.options.mk</filename> or
	<filename>bsd.port.pre.mk</filename>, then those variables
	should be set later, in <xref
	  linkend="porting-order-rest"/>.</para>
    </note>
  </sect1>

  <sect1 xml:id="porting-order-depends">
    <title>The Dependencies Block</title>

    <para>This block is optional.  The variables are:</para>

    <itemizedlist>
      <listitem>
	<para><link
	    linkend="makefile-fetch_depends"><varname>FETCH_DEPENDS</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-extract_depends"><varname>EXTRACT_DEPENDS</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-patch_depends"><varname>PATCH_DEPENDS</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-build_depends"><varname>BUILD_DEPENDS</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-lib_depends"><varname>LIB_DEPENDS</varname></link></para>
      </listitem>

      <listitem>
	<para><link
	    linkend="makefile-run_depends"><varname>RUN_DEPENDS</varname></link></para>
      </listitem>

      <listitem>
	<!-- FIXME: write a section about tests -->
	<para><varname>TEST_DEPENDS</varname></para>
      </listitem>
    </itemizedlist>
  </sect1>

  <sect1 xml:id="porting-order-flavors">
    <title>Flavors</title>

    <para>This block is optional.</para>

    <para>Start this section with defining <varname>FLAVORS</varname>.
      Continue with the possible Flavors helpers.  See <xref
	linkend="flavors-using"/> for more Information.</para>

    <para>Constructs setting variables not available as helpers using
      <literal>.if ${FLAVOR:U} == foo</literal> should go in their
      respective sections below.</para>
  </sect1>

  <sect1 xml:id="porting-order-uses">
    <title><varname>USES</varname> and
      <varname>USE_<replaceable>x</replaceable></varname></title>

    <para>Start this section with defining <varname>USES</varname>,
      and then possible
      <varname>USE_<replaceable>x</replaceable></varname>.</para>

    <para>Keep related variables close together.  For example, if
      using <link
	linkend="makefile-master_sites-github"><varname>USE_GITHUB</varname></link>,
      always put the
      <varname>GH_<replaceable>*</replaceable></varname> variables
      right after it.</para>
  </sect1>

  <sect1 xml:id="porting-order-variables">
    <title>Standard <filename>bsd.port.mk</filename> Variables</title>

    <para>This section block is for variables that can be defined in
      <filename>bsd.port.mk</filename> that do not belong in any
      of the previous section blocks.</para>

    <para>Order is not important, however try to keep similar
      variables together.  For example uid and gid variables
      <varname>USERS</varname> and <varname>GROUPS</varname>.
      Configuration variables
      <varname>CONFIGURE_<replaceable>*</replaceable></varname> and
      <varname><replaceable>*</replaceable>_CONFIGURE</varname>.  List
      of files, and directories <varname>PORTDOCS</varname> and
      <varname>PORTEXAMPLES</varname>.</para>
  </sect1>

  <sect1 xml:id="porting-order-options">
    <title>Options and Helpers</title>

    <para>If the port uses the <link
	linkend="makefile-options">options framework</link>, define
      <varname>OPTIONS_DEFINE</varname> and
      <varname>OPTIONS_DEFAULT</varname> first, then the other
      <varname>OPTIONS_<replaceable>*</replaceable></varname>
      variables first, then the
      <varname><replaceable>*</replaceable>_DESC</varname>
      descriptions, then the options helpers.  Try and sort all of
      those alphabetically.</para>

    <example xml:id="porting-order-options-ex1">
      <title>Options Variables Order Example</title>

      <para>The <literal>FOO</literal> and <literal>BAR</literal>
	options do not have a standard description, so one need to
	be written.  The other options already have one in
	<filename>Mk/bsd.options.desc.mk</filename> so writing one
	is not needed.  The <literal>DOCS</literal> and
	<literal>EXAMPLES</literal> use target helpers to install
	their files, they are shown here for completeness, though
	they belong in <xref linkend="porting-order-targets"/>, so
	other variables and targets could be inserted before
	them.</para>

      <programlisting>OPTIONS_DEFINE=	DOCS EXAMPLES FOO BAR
OPTIONS_DEFAULT=	FOO
OPTIONS_RADIO=	SSL
OPTIONS_RADIO_SSL=    OPENSSL GNUTLS
OPTIONS_SUB=	yes

BAR_DESC=		Enable bar support
FOO_DESC=		Enable foo support

BAR_CONFIGURE_WITH=	bar=${LOCALBASE}
FOO_CONFIGURE_ENABLE=	foo
GNUTLS_CONFIGURE_ON=	--with-ssl=gnutls
OPENSSL_CONFIGURE_ON=	--with-ssl=openssl

post-install-DOCS-on:
      ${MKDIR} ${STAGEDIR}${DOCSDIR}
      cd ${WRKSRC}/doc &amp;&amp; ${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR}

post-install-EXAMPLES-on:
      ${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
      cd ${WRKSRC}/ex &amp;&amp; ${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR}</programlisting>
    </example>
  </sect1>

  <sect1 xml:id="porting-order-rest">
    <title>The Rest of the Variables</title>

    <para>And then, the rest of the variables that are not
      mentioned in the previous blocks.</para>
  </sect1>

  <sect1 xml:id="porting-order-targets">
    <title>The Targets</title>

    <para>After all the variables are defined, the optional
      &man.make.1; targets can be defined.  Keep
      <literal>pre-<replaceable>*</replaceable></literal> before
      <literal>post-<replaceable>*</replaceable></literal> and in
      the same order as the different stages run:</para>

    <itemizedlist>
      <listitem>
	<para><varname>fetch</varname></para>
      </listitem>

      <listitem>
	<para><varname>extract</varname></para>
      </listitem>

      <listitem>
	<para><varname>patch</varname></para>
      </listitem>

      <listitem>
	<para><varname>configure</varname></para>
      </listitem>

      <listitem>
	<para><varname>build</varname></para>
      </listitem>

      <listitem>
	<para><varname>install</varname></para>
      </listitem>

      <listitem>
	<para><varname>test</varname></para>
      </listitem>
    </itemizedlist>

    <tip>
      <para>When using options helpers target keep them alphabetically
	sorted, but keep the
	<literal><replaceable>*</replaceable>-on</literal> before the
	<literal><replaceable>*</replaceable>-off</literal>.  When
	also using the main target, keep the main target before the
	optional ones:</para>

      <programlisting>post-install:
	# install generic bits

post-install-DOCS-on:
	# Install documentation

post-install-X11-on:
	# Install X11 related bits

post-install-X11-off:
	# Install bits that should be there if X11 is disabled</programlisting>
    </tip>
  </sect1>
</chapter>