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.
122 to set variables that are only set once
123 (or to set variables for the first time).
125 Do not use vertical whitespace in simple makefiles,
126 but do use it to group locally related things in more complex/longer ones.
138 so it does not get lost in a sea of
142 is an important thing.
147 so that it may be overridden on the command line or in
150 .Dq Li "NO_WERROR= yes"
152 it defeats the purpose of
154 It should only be used on the command line and in special circumstances.
166 is preferred for alphabetical ordering and to make
171 often affect conditional compilation,
174 tend to be quite long.
182 Do not use GCCisms (such as
189 Typically, there is one
193 and the value in order to start the value in column 9.
196 space is allowed for variable names that extend beyond column 9.
197 A lack of whitespace is also allowed for very long variable names.
199 .Ic .include In bsd.*.mk
202 Do not use anachronisms like
215 part of the base system,
221 To optionally build something in the base system,
228 The latter are reserved for the
232 For variables that are only checked with
234 do not provide any fake value.
237 The desire to express a logical grouping often means not obeying some of the
243 .Bd -literal -offset indent
248 \&.include <bsd.prog.mk>
254 .Bd -literal -offset indent
262 \&.include <bsd.lib.mk>
269 This manual page is inspired from the same source as
274 There are few hard and fast style rules here.
275 The style of many things is too dependent on the context of the whole makefile,
276 or the lines surrounding it.