191c8d237SDavid E. O'Brien.\" Copyright (c) 2002-2003 David O'Brien <obrien@FreeBSD.org> 291c8d237SDavid E. O'Brien.\" All rights reserved. 391c8d237SDavid E. O'Brien.\" 491c8d237SDavid E. O'Brien.\" Redistribution and use in source and binary forms, with or without 591c8d237SDavid E. O'Brien.\" modification, are permitted provided that the following conditions 691c8d237SDavid E. O'Brien.\" are met: 791c8d237SDavid E. O'Brien.\" 1. Redistributions of source code must retain the above copyright 891c8d237SDavid E. O'Brien.\" notice, this list of conditions and the following disclaimer. 991c8d237SDavid E. O'Brien.\" 2. Redistributions in binary form must reproduce the above copyright 1091c8d237SDavid E. O'Brien.\" notice, this list of conditions and the following disclaimer in the 1191c8d237SDavid E. O'Brien.\" documentation and/or other materials provided with the distribution. 1291c8d237SDavid E. O'Brien.\" 3. Neither the name of the author nor the names of any contributors 1391c8d237SDavid E. O'Brien.\" may be used to endorse or promote products derived from this software 1491c8d237SDavid E. O'Brien.\" without specific prior written permission. 1591c8d237SDavid E. O'Brien.\" 1691c8d237SDavid E. O'Brien.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1791c8d237SDavid E. O'Brien.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1891c8d237SDavid E. O'Brien.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1991c8d237SDavid E. O'Brien.\" ARE DISCLAIMED. IN NO EVENT SHALL DAVID O'BRIEN OR CONTRIBUTORS BE LIABLE 2091c8d237SDavid E. O'Brien.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2191c8d237SDavid E. O'Brien.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2291c8d237SDavid E. O'Brien.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2391c8d237SDavid E. O'Brien.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2491c8d237SDavid E. O'Brien.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2591c8d237SDavid E. O'Brien.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2691c8d237SDavid E. O'Brien.\" SUCH DAMAGE. 2791c8d237SDavid E. O'Brien.\" 2891c8d237SDavid E. O'Brien.\" $FreeBSD$ 2991c8d237SDavid E. O'Brien.\" 30ef91670aSDavid E. O'Brien.Dd February 28, 2003 3191c8d237SDavid E. O'Brien.Dt STYLE.MAKEFILE 5 3291c8d237SDavid E. O'Brien.Os 3391c8d237SDavid E. O'Brien.Sh NAME 3491c8d237SDavid E. O'Brien.Nm style.Makefile 35ef91670aSDavid E. O'Brien.Nd 36ef91670aSDavid E. O'Brien.Fx 37ef91670aSDavid E. O'Brien.Pa Makefile 38ef91670aSDavid E. O'Brienfile style guide 3991c8d237SDavid E. O'Brien.Sh DESCRIPTION 40ef91670aSDavid E. O'BrienThis file specifies the preferred style for makefiles in the 4191c8d237SDavid E. O'Brien.Fx 4291c8d237SDavid E. O'Briensource tree. 43ef91670aSDavid E. O'Brien.Bl -bullet 4491c8d237SDavid E. O'Brien.It 45ef91670aSDavid E. O'BrienAll makefiles should have an SCM ID at the start of the file, 4691c8d237SDavid E. O'Brienfollowed by a blank line. 4791c8d237SDavid E. O'Brien.Bd -literal 48ef91670aSDavid E. O'Brien# $FreeBSD\&$ 4991c8d237SDavid E. O'Brien 5091c8d237SDavid E. O'Brien.Ed 5191c8d237SDavid E. O'Brien.It 52ef91670aSDavid E. O'Brien.Cm .PATH : 53ef91670aSDavid E. O'Briencomes next if needed, and is spelled 54ef91670aSDavid E. O'Brien.Dq Li ".PATH: " , 55ef91670aSDavid E. O'Brienwith a single 56ef91670aSDavid E. O'Brien.Tn ASCII 57ef91670aSDavid E. O'Brienspace after a colon. 5891c8d237SDavid E. O'Brien.It 59ef91670aSDavid E. O'BrienSpecial variables (i.e., 60ef91670aSDavid E. O'Brien.Va LIB , SRCS , MLINKS , 61ef91670aSDavid E. O'Brienetc.) are listed in order of 62ef91670aSDavid E. O'Brien.Dq product , 6391c8d237SDavid E. O'Brienthen building and installing a binary. 6491c8d237SDavid E. O'BrienThe general order is: 65ef91670aSDavid E. O'Brien.Va PROG Ns / Ns Va LIB Ns / Ns Va SCRIPT 6691c8d237SDavid E. O'Brien.Va FILES 6791c8d237SDavid E. O'Brien.Va LINKS 68ef91670aSDavid E. O'Brien.Oo Va NO Oc Ns Va MAN 69ef91670aSDavid E. O'Brien.Va MLINKS 7091c8d237SDavid E. O'Brien.Va INCS 71ef91670aSDavid E. O'Brien.Va SRCS 7291c8d237SDavid E. O'Brien.Va WARNS 7391c8d237SDavid E. O'Brien.Va CFLAGS 7491c8d237SDavid E. O'Brien.Va DPADD 75ef91670aSDavid E. O'Brien.Va LDADD . 7691c8d237SDavid E. O'Brien.It 7791c8d237SDavid E. O'BrienOmit 78ef91670aSDavid E. O'Brien.Va SRCS 7991c8d237SDavid E. O'Brienwhen using 80ef91670aSDavid E. O'Brien.Aq Pa bsd.prog.mk 8191c8d237SDavid E. O'Brienand there is a single source file named the same as the 8291c8d237SDavid E. O'Brien.Va PROG . 8391c8d237SDavid E. O'Brien.It 8491c8d237SDavid E. O'BrienOmit 8591c8d237SDavid E. O'Brien.Va MAN 8691c8d237SDavid E. O'Brienwhen using 87ef91670aSDavid E. O'Brien.Aq Pa bsd.prog.mk 88ef91670aSDavid E. O'Brienand the manual page is named the same as the 89ef91670aSDavid E. O'Brien.Va PROG , 9091c8d237SDavid E. O'Brienand is in section 1. 9191c8d237SDavid E. O'Brien.It 92ef91670aSDavid E. O'BrienAll variable assignments are spelled 93ef91670aSDavid E. O'Brien.Dq Va VAR Ns Ic = , 94ef91670aSDavid E. O'Brieni.e., no space between the variable name and the 95ef91670aSDavid E. O'Brien.Ic = . 9691c8d237SDavid E. O'BrienKeep values sorted alphabetically, if possible. 9791c8d237SDavid E. O'Brien.It 98ef91670aSDavid E. O'BrienDo not use 99ef91670aSDavid E. O'Brien.Ic += 10091c8d237SDavid E. O'Briento set variables that are only set once 10191c8d237SDavid E. O'Brien(or to set variables for the first time). 10291c8d237SDavid E. O'Brien.It 103ef91670aSDavid E. O'BrienDo not use vertical whitespace in simple makefiles, 10491c8d237SDavid E. O'Brienbut do use it to group locally related things in more complex/longer ones. 10591c8d237SDavid E. O'Brien.It 10691c8d237SDavid E. O'Brien.Va WARNS 10791c8d237SDavid E. O'Briencomes before 10891c8d237SDavid E. O'Brien.Va CFLAGS , 10991c8d237SDavid E. O'Brienas it is basically a 11091c8d237SDavid E. O'Brien.Va CFLAGS 11191c8d237SDavid E. O'Brienmodifier. 11291c8d237SDavid E. O'BrienIt comes before 11391c8d237SDavid E. O'Brien.Va CFLAGS 11491c8d237SDavid E. O'Brienrather than after 11591c8d237SDavid E. O'Brien.Va CFLAGS 11691c8d237SDavid E. O'Brienso it does not get lost in a sea of 11791c8d237SDavid E. O'Brien.Va CFLAGS 11891c8d237SDavid E. O'Brienstatements as 11991c8d237SDavid E. O'Brien.Va WARNS 12091c8d237SDavid E. O'Brienis an important thing. 12191c8d237SDavid E. O'Brien.It 12291c8d237SDavid E. O'BrienUnconditional 123ef91670aSDavid E. O'Brien.Dq Li "NO_WERROR= yes" 124ef91670aSDavid E. O'Brienshould not be used, 125ef91670aSDavid E. O'Brienit defeats the purpose of 12691c8d237SDavid E. O'Brien.Va WARNS . 12791c8d237SDavid E. O'Brien.It 12891c8d237SDavid E. O'Brien.Va CFLAGS 12991c8d237SDavid E. O'Brienis spelled 130ef91670aSDavid E. O'Brien.Dq Li "CFLAGS+= " . 13191c8d237SDavid E. O'Brien.It 132ef91670aSDavid E. O'BrienListing 133ef91670aSDavid E. O'Brien.Fl D Ns 's 134ef91670aSDavid E. O'Brienbefore 135ef91670aSDavid E. O'Brien.Fl I Ns 's 136ef91670aSDavid E. O'Brienin 13791c8d237SDavid E. O'Brien.Va CFLAGS 138ef91670aSDavid E. O'Brienis preferred for alphabetical ordering and to make 139ef91670aSDavid E. O'Brien.Fl D Ns 's 140ef91670aSDavid E. O'Brieneasier to see. 141ef91670aSDavid E. O'BrienThe 142ef91670aSDavid E. O'Brien.Fl D Ns 's 143ef91670aSDavid E. O'Brienoften affect conditional compilation, 144ef91670aSDavid E. O'Brienand 145ef91670aSDavid E. O'Brien.Fl I Ns 's 146ef91670aSDavid E. O'Brientend to be quite long. 14791c8d237SDavid E. O'Brien.It 148ef91670aSDavid E. O'BrienDo not use GCCisms (such as 149ef91670aSDavid E. O'Brien.Fl g 150ef91670aSDavid E. O'Brienand 151ef91670aSDavid E. O'Brien.Fl Wall ) 152ef91670aSDavid E. O'Brienin 15391c8d237SDavid E. O'Brien.Va CFLAGS . 15491c8d237SDavid E. O'Brien.It 155ef91670aSDavid E. O'BrienTypically, there is one 156ef91670aSDavid E. O'Brien.Tn ASCII 157ef91670aSDavid E. O'Brientab between 158ef91670aSDavid E. O'Brien.Va VAR Ns Ic = 15991c8d237SDavid E. O'Brienand the value in order to start the value in column 9. 160ef91670aSDavid E. O'BrienAn 161ef91670aSDavid E. O'Brien.Tn ASCII 162ef91670aSDavid E. O'Brienspace is allowed for variable names that extend beyond column 9. 163ef91670aSDavid E. O'BrienA lack of whitespace is also allowed for very long variable names. 16491c8d237SDavid E. O'Brien.It 165ef91670aSDavid E. O'Brien.Ic .include Aq Pa bsd.*.mk 16691c8d237SDavid E. O'Briengoes last. 16791c8d237SDavid E. O'Brien.El 16891c8d237SDavid E. O'Brien.Pp 16991c8d237SDavid E. O'BrienThe desire to express a logical grouping often means not obeying some of the 17091c8d237SDavid E. O'Brienabove. 171ef91670aSDavid E. O'Brien.Sh EXAMPLE 172ef91670aSDavid E. O'BrienThe simplest program 173ef91670aSDavid E. O'Brien.Pa Makefile 174ef91670aSDavid E. O'Brienis: 175ef91670aSDavid E. O'Brien.Bd -literal -offset indent 176ef91670aSDavid E. O'Brien# $FreeBSD\&$ 17791c8d237SDavid E. O'Brien 17891c8d237SDavid E. O'BrienPROG= foo 17991c8d237SDavid E. O'Brien 18091c8d237SDavid E. O'Brien\&.include <bsd.prog.mk> 181ef91670aSDavid E. O'Brien.Ed 18291c8d237SDavid E. O'Brien.Pp 183ef91670aSDavid E. O'BrienThe simplest library 184ef91670aSDavid E. O'Brien.Pa Makefile 185ef91670aSDavid E. O'Brienis: 186ef91670aSDavid E. O'Brien.Bd -literal -offset indent 187ef91670aSDavid E. O'Brien# $FreeBSD\&$ 18891c8d237SDavid E. O'Brien 18991c8d237SDavid E. O'BrienLIB= foo 19091c8d237SDavid E. O'BrienSHLIB_MAJOR= 1 19191c8d237SDavid E. O'BrienMAN= libfoo.3 19291c8d237SDavid E. O'BrienSRCS= foo.c 19391c8d237SDavid E. O'Brien 19491c8d237SDavid E. O'Brien\&.include <bsd.lib.mk> 195ef91670aSDavid E. O'Brien.Ed 19691c8d237SDavid E. O'Brien.Sh SEE ALSO 197ef91670aSDavid E. O'Brien.Xr make 1 , 19891c8d237SDavid E. O'Brien.Xr style 9 19991c8d237SDavid E. O'Brien.Sh HISTORY 200ef91670aSDavid E. O'BrienThis manual page is inspired from the same source as 20191c8d237SDavid E. O'Brien.Xr style 9 202ef91670aSDavid E. O'Brienmanual page in 20391c8d237SDavid E. O'Brien.Fx . 20491c8d237SDavid E. O'Brien.Sh BUGS 20591c8d237SDavid E. O'BrienThere are few hard and fast style rules here. 206ef91670aSDavid E. O'BrienThe style of many things is too dependent on the context of the whole makefile, 20791c8d237SDavid E. O'Brienor the lines surrounding it. 208