xref: /csrg-svn/share/mk/bsd.README (revision 66685)
1*66685Sbostic#	@(#)bsd.README	8.2 (Berkeley) 04/02/94
241605Sbostic
341605SbosticThis is the README file for the new make "include" files for the BSD
441605Sbosticsource tree.  The files are installed in /usr/share/mk, and are, by
541605Sbosticconvention, named with the suffix ".mk".  Each ".mk" file has a
641605Sbosticcorresponding ".rd" file which is an explanation of the ".mk" file.
741605Sbostic
841605SbosticNote, this file is not intended to replace reading through the .mk
941605Sbosticfiles for anything tricky.
1041605Sbostic
1141605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1241605Sbostic
1341605SbosticRANDOM THINGS WORTH KNOWING:
1441605Sbostic
1541605SbosticThe files are simply C-style #include files, and pretty much behave like
1641605Sbosticyou'd expect.  The syntax is slightly different in that a single '.' is
1741605Sbosticused instead of the hash mark, i.e. ".include <bsd.prog.mk>".
1841605Sbostic
1941605SbosticOne difference that will save you lots of debugging time is that inclusion
2041605Sbosticof the file is normally done at the *end* of the Makefile.  The reason for
2141605Sbosticthis is because .mk files often modify variables and behavior based on the
2241605Sbosticvalues of variables set in the Makefile.  To make this work, remember that
2341605Sbosticthe FIRST target found is the target that is used, i.e. if the Makefile has:
2441605Sbostic
2541605Sbostic	a:
2641605Sbostic		echo a
2741605Sbostic	a:
2841605Sbostic		echo a number two
2941605Sbostic
3041605Sbosticthe command "make a" will echo "a".  To make things confusing, the SECOND
3141605Sbosticvariable assignment is the overriding one, i.e. if the Makefile has:
3241605Sbostic
3341605Sbostic	a=	foo
3441605Sbostic	a=	bar
3541605Sbostic
3641605Sbostic	b:
3741605Sbostic		echo ${a}
3841605Sbostic
3941605Sbosticthe command "make b" will echo "bar".  This is for compatibility with the
4041605Sbosticway the V7 make behaved.
4141605Sbostic
4241605SbosticIt's fairly difficult to make the BSD .mk files work when you're building
4341605Sbosticmultiple programs in a single directory.  It's a lot easier split up the
4441605Sbosticprograms than to deal with the problem.  Most of the agony comes from making
4541605Sbosticthe "obj" directory stuff work right, not because we switch to a new version
4641605Sbosticof make.  So, don't get mad at us, figure out a better way to handle multiple
4741605Sbosticarchitectures so we can quit using the symbolic link stuff.  (Imake doesn't
4841605Sbosticcount.)
4941605Sbostic
5041605SbosticThe file .depend in the source directory is expected to contain dependencies
5141605Sbosticfor the source files.  This file is read automatically by make after reading
5241605Sbosticthe Makefile.
5341605Sbostic
5441605SbosticThe variable DESTDIR works as before.  It's not set anywhere but will change
5541605Sbosticthe tree where the file gets installed.
5641605Sbostic
5741605SbosticThe profiled libraries are no longer built in a different directory than
5841605Sbosticthe regular libraries.  A new suffix, ".po", is used to denote a profiled
5941605Sbosticobject.
6041605Sbostic
6141605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6241605Sbostic
6341605SbosticThe include file <sys.mk> has the default rules for all makes, in the BSD
6441605Sbosticenvironment or otherwise.  You probably don't want to touch this file.
6541605Sbostic
6641605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6741605Sbostic
6841605SbosticThe include file <bsd.man.mk> handles installing manual pages and their
6941605Sbosticlinks.
7041605Sbostic
7141605SbosticIt has a single target:
7241605Sbostic
7341605Sbostic	maninstall:
7441605Sbostic		Install the manual pages and their links.
7541605Sbostic
7641605SbosticIt sets/uses the following variables:
7741605Sbostic
7841605SbosticMANDIR		Base path for manual installation.
7941605Sbostic
8041605SbosticMANGRP		Manual group.
8141605Sbostic
8241605SbosticMANOWN		Manual owner.
8341605Sbostic
8441605SbosticMANMODE		Manual mode.
8541605Sbostic
8641605SbosticMANSUBDIR	Subdirectory under the manual page section, i.e. "/vax"
8741605Sbostic		or "/tahoe" for machine specific manual pages.
8841605Sbostic
8941605SbosticMAN1 ... MAN8	The manual pages to be installed (use a .0 suffix).
9041605Sbostic
9141605SbosticMLINKS		List of manual page links (using a .1 - .8 suffix).  The
9241605Sbostic		linked-to file must come first, the linked file second,
9341605Sbostic		and there may be multiple pairs.  The files are soft-linked.
9441605Sbostic
9541605SbosticThe include file <bsd.man.mk> includes a file named "../Makefile.inc" if
9641605Sbosticit exists.
9741605Sbostic
9841605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
9941605Sbostic
10041605SbosticThe include file <bsd.own.mk> contains the owners, groups, etc. for both
10141605Sbosticmanual pages and binaries.
10241605Sbostic
10341605SbosticIt has no targets.
10441605Sbostic
10541605SbosticIt sets/uses the following variables:
10641605Sbostic
10741605SbosticBINGRP		Binary group.
10841605Sbostic
10941605SbosticBINOWN		Binary owner.
11041605Sbostic
11141605SbosticBINMODE		Binary mode.
11241605Sbostic
11341605SbosticSTRIP		The flag passed to the install program to cause the binary
11441605Sbostic		to be stripped.  This is to be used when building your
11541605Sbostic		own install script so that the entire system can be made
11641605Sbostic		stripped/not-stripped using a single nob.
11741605Sbostic
11841605SbosticMANDIR		Base path for manual installation.
11941605Sbostic
12041605SbosticMANGRP		Manual group.
12141605Sbostic
12241605SbosticMANOWN		Manual owner.
12341605Sbostic
12441605SbosticMANMODE		Manual mode.
12541605Sbostic
12641605SbosticThis file is generally useful when building your own Makefiles so that
12741605Sbosticthey use the same default owners etc. as the rest of the tree.
12841605Sbostic
12941605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
13041605Sbostic
13141605SbosticThe include file <bsd.prog.mk> handles building programs from one or
13241605Sbosticmore source files, along with their manual pages.  It has a limited number
13341605Sbosticof suffixes, consistent with the current needs of the BSD tree.
13441605Sbostic
13541605SbosticIt has seven targets:
13641605Sbostic
13741605Sbostic	all:
13841605Sbostic		build the program and its manual page
13941605Sbostic	clean:
14041605Sbostic		remove the program, any object files and the files a.out,
141*66685Sbostic		Errs, errs, mklog, and ${PROG}.core.
14241605Sbostic	cleandir:
14341605Sbostic		remove all of the files removed by the target clean, as
14441605Sbostic		well as .depend, tags, and any manual pages.
14541605Sbostic	depend:
14641605Sbostic		make the dependencies for the source files, and store
14741605Sbostic		them in the file .depend.
14841605Sbostic	install:
14941605Sbostic		install the program and its manual pages; if the Makefile
15041605Sbostic		does not itself define the target install, the targets
15141605Sbostic		beforeinstall and afterinstall may also be used to cause
15241605Sbostic		actions immediately before and after the install target
15341605Sbostic		is executed.
15441605Sbostic	lint:
15541605Sbostic		run lint on the source files
15641605Sbostic	tags:
15741605Sbostic		create a tags file for the source files.
15841605Sbostic
15941605SbosticIt sets/uses the following variables:
16041605Sbostic
16141605SbosticBINGRP		Binary group.
16241605Sbostic
16341605SbosticBINOWN		Binary owner.
16441605Sbostic
16541605SbosticBINMODE		Binary mode.
16641605Sbostic
16741605SbosticCLEANFILES	Additional files to remove for the clean and cleandir targets.
16841605Sbostic
16941605SbosticCOPTS		Additional flags to the compiler when creating C objects.
17041605Sbostic
17141605SbosticHIDEGAME	If HIDEGAME is defined, the binary is installed in
17241605Sbostic		/usr/games/hide, and a symbolic link is created to
17341605Sbostic		/usr/games/dm.
17441605Sbostic
17541605SbosticLDADD		Additional loader objects.  Usually used for libraries.
17641605Sbostic		For example, to load with the compatibility and utility
17741605Sbostic		libraries, use:
17841605Sbostic
17941605Sbostic			LDFILES=-lutil -lcompat
18041605Sbostic
18141605SbosticLDFLAGS		Additional loader flags.
18241605Sbostic
18341605SbosticLINKS		The list of binary links; should be full pathnames, the
18441605Sbostic		linked-to file coming first, followed by the linked
18541605Sbostic		file.  The files are hard-linked.  For example, to link
18641605Sbostic		/bin/test and /bin/[, use:
18741605Sbostic
18841605Sbostic			LINKS=	${DESTDIR}/bin/test ${DESTDIR}/bin/[
18941605Sbostic
19041605SbosticMAN1...MAN8	Manual pages (should end in .0).  If no MAN variable is
19141605Sbostic		defined, "MAN1=${PROG}.0" is assumed.
19241605Sbostic
19341605SbosticPROG		The name of the program to build.  If not supplied, nothing
19441605Sbostic		is built.
19541605Sbostic
19641605SbosticSRCS		List of source files to build the program.  If PROG is not
19741605Sbostic		defined, it's assumed to be ${PROG}.c.
19841605Sbostic
19941605SbosticDPADD		Additional dependencies for the program.  Usually used for
20041605Sbostic		libraries.  For example, to depend on the compatibility and
20141605Sbostic		utility libraries use:
20241605Sbostic
20341605Sbostic			SRCLIB=${LIBCOMPAT} ${LIBUTIL}
20441605Sbostic
20541605Sbostic		The following libraries are predefined for DPADD:
20641605Sbostic
20741605Sbostic			LIBC		/lib/libc.a
20841605Sbostic			LIBCOMPAT	/usr/lib/libcompat.a
20941605Sbostic			LIBCURSES	/usr/lib/libcurses.a
21041605Sbostic			LIBDBM		/usr/lib/libdbm.a
21141605Sbostic			LIBDES		/usr/lib/libdes.a
21241605Sbostic			LIBL		/usr/lib/libl.a
21341605Sbostic			LIBKDB		/usr/lib/libkdb.a
21441605Sbostic			LIBKRB		/usr/lib/libkrb.a
21541605Sbostic			LIBM		/usr/lib/libm.a
21641605Sbostic			LIBMP		/usr/lib/libmp.a
21741605Sbostic			LIBPC		/usr/lib/libpc.a
21841605Sbostic			LIBPLOT		/usr/lib/libplot.a
21941605Sbostic			LIBRPC		/usr/lib/sunrpc.a
22041605Sbostic			LIBTERM		/usr/lib/libterm.a
22141605Sbostic			LIBUTIL		/usr/lib/libutil.a
22241605Sbostic
22341605SbosticSHAREDSTRINGS	If defined, a new .c.o rule is used that results in shared
22441605Sbostic		strings, using xstr(1).
22541605Sbostic
22641605SbosticSTRIP		The flag passed to the install program to cause the binary
22741605Sbostic		to be stripped.
22841605Sbostic
22941605SbosticSUBDIR		A list of subdirectories that should be built as well.
23041605Sbostic		Each of the targets will execute the same target in the
23141605Sbostic		subdirectories.
23241605Sbostic
23341605SbosticThe include file <bsd.prog.mk> includes the file named "../Makefile.inc"
23441605Sbosticif it exists, as well as the include file <bsd.man.mk>.
23541605Sbostic
23641605SbosticSome simple examples:
23741605Sbostic
23841605SbosticTo build foo from foo.c with a manual page foo.1, use:
23941605Sbostic
24041605Sbostic	PROG=	foo
24141605Sbostic
24241605Sbostic	.include <bsd.prog.mk>
24341605Sbostic
24441605SbosticTo build foo from foo.c with a manual page foo.2, add the line:
24541605Sbostic
24641605Sbostic	MAN2=	foo.0
24741605Sbostic
24841605SbosticIf foo does not have a manual page at all, add the line:
24941605Sbostic
25041605Sbostic	NOMAN=	noman
25141605Sbostic
25241605SbosticIf foo has multiple source files, add the line:
25341605Sbostic
25441605Sbostic	SRCS=	a.c b.c c.c d.c
25541605Sbostic
25641605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
25741605Sbostic
25841605SbosticThe include file <bsd.subdir.mk> contains the default targets for building
25941605Sbosticsubdirectories.  It has the same seven targets as <bsd.prog.mk>: all, clean,
26041605Sbosticcleandir, depend, install, lint, and tags.  For all of the directories
26141605Sbosticlisted in the variable SUBDIRS, the specified directory will be visited
26241605Sbosticand the target made.  There is also a default target which allows the
26341605Sbosticcommand "make subdir" where subdir is any directory listed in the variable
26441605SbosticSUBDIRS.
26541605Sbostic
26641605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26741605Sbostic
26841605SbosticThe include file <bsd.lib.mk> has support for building libraries.  It has
26941605Sbosticthe same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend,
27041605Sbosticinstall, lint, and tags.  It has a limited number of suffixes, consistent
27141605Sbosticwith the current needs of the BSD tree.
27241605Sbostic
27341605SbosticIt sets/uses the following variables:
27441605Sbostic
27541605SbosticLIBDIR		Target directory for libraries.
27641605Sbostic
27741605SbosticLINTLIBDIR	Target directory for lint libraries.
27841605Sbostic
27941605SbosticLIBGRP		Library group.
28041605Sbostic
28141605SbosticLIBOWN		Library owner.
28241605Sbostic
28341605SbosticLIBMODE		Library mode.
28441605Sbostic
28541605SbosticLDADD		Additional loader objects.
28641605Sbostic
28741605SbosticMAN1 ... MAN8	The manual pages to be installed (use a .0 suffix).
28841605Sbostic
28941605SbosticSRCS		List of source files to build the library.  Suffix types
29041605Sbostic		.s, .c, and .f are supported.  Note, .s files are preferred
29141605Sbostic		to .c files of the same name.  (This is not the default for
29241605Sbostic		versions of make.)
29341605Sbostic
29441605SbosticThe include file <bsd.lib.mk> includes the file named "../Makefile.inc"
29541605Sbosticif it exists, as well as the include file <bsd.man.mk>.
29641605Sbostic
29741605SbosticIt has rules for building profiled objects; profiled libraries are
29841605Sbosticbuilt by default.
29941605Sbostic
30041605SbosticLibraries are ranlib'd before installation.
301