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
88 .Va PROG Ns / Ns Oo Va SH Oc Ns Va LIB Ns / Ns Va SCRIPTS
98 .Oo Va NO_ Oc Ns Va MAN
105 and there is a single source file named the same as the
112 and the manual page is named the same as the
116 All variable assignments are spelled
118 i.e., no space between the variable name and the
120 Keep values sorted alphabetically, if possible.
122 Variables are expanded with
131 to set variables that are only set once
132 (or to set variables for the first time).
134 Do not use vertical whitespace in simple makefiles,
135 but do use it to group locally related things in more complex/longer ones.
147 so it does not get lost in a sea of
151 is an important thing.
156 so that it may be overridden on the command line or in
159 .Dq Li "NO_WERROR= yes"
161 it defeats the purpose of
163 It should only be used on the command line and in special circumstances.
175 is preferred for alphabetical ordering and to make
180 often affect conditional compilation,
183 tend to be quite long.
191 Do not use GCCisms (such as
198 Typically, there is one
202 and the value in order to start the value in column 9.
205 space is allowed for variable names that extend beyond column 9.
206 A lack of whitespace is also allowed for very long variable names.
208 .Ic .include In bsd.*.mk
211 Do not use anachronisms like
224 part of the base system,
230 To optionally build something in the base system,
237 The latter are reserved for the
241 For variables that are only checked with
243 do not provide any fake value.
246 The desire to express a logical grouping often means not obeying some of the
252 .Bd -literal -offset indent
257 \&.include <bsd.prog.mk>
263 .Bd -literal -offset indent
271 \&.include <bsd.lib.mk>
278 This manual page is inspired from the same source as
283 There are few hard and fast style rules here.
284 The style of many things is too dependent on the context of the whole makefile,
285 or the lines surrounding it.