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
46 comes next if needed, and is spelled
55 Special variables (i.e.,
56 .Va LIB , SRCS , MLINKS ,
57 etc.) are listed in order of
59 then building and installing a binary.
60 Special variables may also be listed in
62 order: i.e., ones for the primary program (or library) first.
66 .Va PROG Ns / Ns Oo Va SH Oc Ns Va LIB Ns / Ns Va SCRIPTS
69 .Oo Va NO_ Oc Ns Va MAN
81 .Va PROG Ns / Ns Oo Va SH Oc Ns Va LIB Ns / Ns Va SCRIPTS
91 .Oo Va NO_ Oc Ns Va MAN
98 and there is a single source file named the same as the
105 and the manual page is named the same as the
109 All variable assignments are spelled
111 i.e., no space between the variable name and the
113 Keep values sorted alphabetically, if possible.
115 Variables are expanded with
124 to set variables that are only set once
125 (or to set variables for the first time).
127 Do not use vertical whitespace in simple makefiles,
128 but do use it to group locally related things in more complex/longer ones.
140 so it does not get lost in a sea of
144 is an important thing.
149 so that it may be overridden on the command line or in
152 .Dq Li "MK_WERROR=no"
154 it defeats the purpose of
156 It should only be used on the command line and in special circumstances.
168 is preferred for alphabetical ordering and to make
173 often affect conditional compilation,
176 tend to be quite long.
184 Do not use GCCisms (such as
191 Typically, there is one
195 and the value in order to start the value in column 9.
198 space is allowed for variable names that extend beyond column 9.
199 A lack of whitespace is also allowed for very long variable names.
201 .Ic .include In bsd.*.mk
204 Do not use anachronisms like
217 part of the base system,
223 To optionally build something in the base system,
230 The latter are reserved for the
234 For variables that are only checked with
236 do not provide any fake value.
239 The desire to express a logical grouping often means not obeying some of the
245 .Bd -literal -offset indent
250 \&.include <bsd.prog.mk>
256 .Bd -literal -offset indent
264 \&.include <bsd.lib.mk>
271 This manual page is inspired from the same source as
276 There are few hard and fast style rules here.
277 The style of many things is too dependent on the context of the whole makefile,
278 or the lines surrounding it.