summaryrefslogtreecommitdiffstats
path: root/share/man
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2003-02-26 20:43:47 +0000
committerobrien <obrien@FreeBSD.org>2003-02-26 20:43:47 +0000
commit184e8eadf9649cd2a733600aa50d21f9f58ed16c (patch)
tree786c232868e985e425727961db8a29756d1e132c /share/man
parent037412ba788b03f51dd590b7b9a43444fcce94bd (diff)
downloadFreeBSD-src-184e8eadf9649cd2a733600aa50d21f9f58ed16c.zip
FreeBSD-src-184e8eadf9649cd2a733600aa50d21f9f58ed16c.tar.gz
FreeBSD Makefile style guide.
Approved by: TRB
Diffstat (limited to 'share/man')
-rw-r--r--share/man/man5/Makefile2
-rw-r--r--share/man/man5/style.Makefile.5178
2 files changed, 179 insertions, 1 deletions
diff --git a/share/man/man5/Makefile b/share/man/man5/Makefile
index ee24d93..dc3765d 100644
--- a/share/man/man5/Makefile
+++ b/share/man/man5/Makefile
@@ -13,7 +13,7 @@ MAN= a.out.5 acct.5 core.5 devfs.5 device.hints.5 \
passwd.5 pbm.5 periodic.conf.5 \
phones.5 procfs.5 protocols.5 quota.user.5 \
rc.conf.5 remote.5 resolver.5 \
- services.5 shells.5 stab.5 sysctl.conf.5 utmp.5
+ services.5 shells.5 stab.5 style.Makefile.5 sysctl.conf.5 utmp.5
MLINKS= dir.5 dirent.5
MLINKS+=fs.5 inode.5
diff --git a/share/man/man5/style.Makefile.5 b/share/man/man5/style.Makefile.5
new file mode 100644
index 0000000..aa48513
--- /dev/null
+++ b/share/man/man5/style.Makefile.5
@@ -0,0 +1,178 @@
+.\" Copyright (c) 2002-2003 David O'Brien <obrien@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the author nor the names of any contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL DAVID O'BRIEN OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd November 27, 2002
+.Dt STYLE.MAKEFILE 5
+.Os
+.Sh NAME
+.Nm style.Makefile
+.Nd "FreeBSD Makefile file style guide"
+.Sh DESCRIPTION
+This file specifies the preferred style for Makefiles in the
+.Fx
+source tree.
+.Pp
+.Bl -bullet -compact
+.It
+All Makefiles should have an SCM ID at the start of the file,
+followed by a blank line.
+.Bd -literal
+# $FreeBSD$
+
+.Ed
+.It
+\&.PATH: comes next if needed, and is spelled
+.Pa ".PATH: <ascii space>"
+.It
+Special variables (i.e., LIB, SRCS, MLINKS, etc..) are listed in order
+of 'product',
+then building and installing a binary.
+The general order is:
+.Va PROG/LIB/SCRIPT
+.Va FILES
+.Va LINKS
+.Va [NO]MAN
+.Va MLINK
+.Va INCS
+.Va SRC
+.Va WARNS
+.Va CFLAGS
+.Va DPADD
+.Va LDADD
+.It
+Omit
+.Va SRC
+when using
+.Pa bsd.prog.mk
+and there is a single source file named the same as the
+.Va PROG .
+.It
+Omit
+.Va MAN
+when using
+.Pa bsd.prog.mk
+and the man page is named the same as the
+.Va PROG
+and is in section 1.
+.It
+All variable assignment is spelled
+.Pa "VAR=" ,
+i.e. no space between the variable name and the
+.Pa "=" .
+Keep values sorted alphabetically, if possible.
+.It
+Don't use
+.Pa "+="
+to set variables that are only set once
+(or to set variables for the first time).
+.It
+Don't use vertical whitespace in simple Makefiles,
+but do use it to group locally related things in more complex/longer ones.
+.It
+.Va WARNS
+comes before
+.Va CFLAGS ,
+as it is basically a
+.Va CFLAGS
+modifier.
+It comes before
+.Va CFLAGS
+rather than after
+.Va CFLAGS
+so it does not get lost in a sea of
+.Va CFLAGS
+statements as
+.Va WARNS
+is an important thing.
+.It
+Unconditional
+.Pa "NO_WERROR=yes"
+should not be used.
+It defeats the purpose of
+.Va WARNS .
+.It
+.Va CFLAGS
+is spelled
+.Pa "CFLAGS+=<ascii space>" .
+.It
+Listing -D's before -I's in
+.Va CFLAGS
+is preferred for alphabetical ordering and to make -D's easier to see.
+The -D's often affect conditional compilation,
+and -I's tend to be quite long.
+.It
+Don't use GCC'isms (such as -g and -Wall) in
+.Va CFLAGS .
+.It
+Typically there is one <ascii tab> between
+.Pa "VAR="
+and the value in order to start the value in column 9.
+An <ascii space> is allowed for VAR names that extend beyond column 9.
+A lack of whitespace also is allowed for very long VAR names.
+.Bd -literal
+.It
+".include <bsd.*.mk>"
+goes last.
+.El
+.Ed
+.Pp
+The desire to express a logical grouping often means not obeying some of the
+above.
+.Pp
+The simplist program Makefile is:
+.Bd -literal
+# $FreeBSD$
+
+PROG= foo
+
+\&.include <bsd.prog.mk>
+.Pp
+The simplist library Makefile is:
+.Bd -literal
+# $FreeBSD$
+
+LIB= foo
+SHLIB_MAJOR= 1
+MAN= libfoo.3
+SRCS= foo.c
+
+\&.include <bsd.lib.mk>
+.Pp
+.Sh SEE ALSO
+.Xr make 1
+.Xr style 9
+.Sh HISTORY
+This man page is inspired from the same source as
+.Xr style 9
+man page in
+.Fx .
+.Sh BUGS
+There are few hard and fast style rules here.
+The style of many things are too dependent on the context of the whole Makefile,
+or the lines surrounding it.
OpenPOWER on IntegriCloud