1 .\" Copyright (c) 2002-2003 David O'Brien <obrien@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the author nor the names of any contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL DAVID O'BRIEN OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 This file specifies the preferred style for makefiles in the
45 All makefiles should have an SCM ID at the start of the file,
46 followed by a blank line.
53 comes next if needed, and is spelled
62 Special variables (i.e.,
63 .Va LIB , SRCS , MLINKS ,
64 etc.) are listed in order of
66 then building and installing a binary.
67 Special variables may also be listed in
69 order: i.e., ones for the primary program (or library) first.
73 .Va PROG Ns / Ns Oo Va SH Oc Ns Va LIB Ns / Ns Va SCRIPTS
76 .Oo Va NO_ Oc Ns Va MAN
87 .Va PROG Ns / Ns Oo Va SH Oc Ns Va LIB Ns / Ns Va SCRIPTS
96 .Oo Va NO_ Oc Ns Va MAN
103 and there is a single source file named the same as the
110 and the manual page is named the same as the
114 All variable assignments are spelled
116 i.e., no space between the variable name and the
118 Keep values sorted alphabetically, if possible.
120 Variables are expanded with
129 to set variables that are only set once
130 (or to set variables for the first time).
132 Do not use vertical whitespace in simple makefiles,
133 but do use it to group locally related things in more complex/longer ones.
145 so it does not get lost in a sea of
149 is an important thing.
154 so that it may be overridden on the command line or in
157 .Dq Li "NO_WERROR= yes"
159 it defeats the purpose of
161 It should only be used on the command line and in special circumstances.
173 is preferred for alphabetical ordering and to make
178 often affect conditional compilation,
181 tend to be quite long.
189 Do not use GCCisms (such as
196 Typically, there is one
200 and the value in order to start the value in column 9.
203 space is allowed for variable names that extend beyond column 9.
204 A lack of whitespace is also allowed for very long variable names.
206 .Ic .include In bsd.*.mk
209 Do not use anachronisms like
222 part of the base system,
228 To optionally build something in the base system,
235 The latter are reserved for the
239 For variables that are only checked with
241 do not provide any fake value.
244 The desire to express a logical grouping often means not obeying some of the
250 .Bd -literal -offset indent
255 \&.include <bsd.prog.mk>
261 .Bd -literal -offset indent
269 \&.include <bsd.lib.mk>
276 This manual page is inspired from the same source as
281 There are few hard and fast style rules here.
282 The style of many things is too dependent on the context of the whole makefile,
283 or the lines surrounding it.