xref: /csrg-svn/share/mk/bsd.README (revision 41605)
1*41605Sbostic#	@(#)bsd.README	5.1 (Berkeley) 05/11/90
2*41605Sbostic
3*41605SbosticThis is the README file for the new make "include" files for the BSD
4*41605Sbosticsource tree.  The files are installed in /usr/share/mk, and are, by
5*41605Sbosticconvention, named with the suffix ".mk".  Each ".mk" file has a
6*41605Sbosticcorresponding ".rd" file which is an explanation of the ".mk" file.
7*41605Sbostic
8*41605SbosticNote, this file is not intended to replace reading through the .mk
9*41605Sbosticfiles for anything tricky.
10*41605Sbostic
11*41605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
12*41605Sbostic
13*41605SbosticRANDOM THINGS WORTH KNOWING:
14*41605Sbostic
15*41605SbosticThe files are simply C-style #include files, and pretty much behave like
16*41605Sbosticyou'd expect.  The syntax is slightly different in that a single '.' is
17*41605Sbosticused instead of the hash mark, i.e. ".include <bsd.prog.mk>".
18*41605Sbostic
19*41605SbosticOne difference that will save you lots of debugging time is that inclusion
20*41605Sbosticof the file is normally done at the *end* of the Makefile.  The reason for
21*41605Sbosticthis is because .mk files often modify variables and behavior based on the
22*41605Sbosticvalues of variables set in the Makefile.  To make this work, remember that
23*41605Sbosticthe FIRST target found is the target that is used, i.e. if the Makefile has:
24*41605Sbostic
25*41605Sbostic	a:
26*41605Sbostic		echo a
27*41605Sbostic	a:
28*41605Sbostic		echo a number two
29*41605Sbostic
30*41605Sbosticthe command "make a" will echo "a".  To make things confusing, the SECOND
31*41605Sbosticvariable assignment is the overriding one, i.e. if the Makefile has:
32*41605Sbostic
33*41605Sbostic	a=	foo
34*41605Sbostic	a=	bar
35*41605Sbostic
36*41605Sbostic	b:
37*41605Sbostic		echo ${a}
38*41605Sbostic
39*41605Sbosticthe command "make b" will echo "bar".  This is for compatibility with the
40*41605Sbosticway the V7 make behaved.
41*41605Sbostic
42*41605SbosticIt's fairly difficult to make the BSD .mk files work when you're building
43*41605Sbosticmultiple programs in a single directory.  It's a lot easier split up the
44*41605Sbosticprograms than to deal with the problem.  Most of the agony comes from making
45*41605Sbosticthe "obj" directory stuff work right, not because we switch to a new version
46*41605Sbosticof make.  So, don't get mad at us, figure out a better way to handle multiple
47*41605Sbosticarchitectures so we can quit using the symbolic link stuff.  (Imake doesn't
48*41605Sbosticcount.)
49*41605Sbostic
50*41605SbosticThe file .depend in the source directory is expected to contain dependencies
51*41605Sbosticfor the source files.  This file is read automatically by make after reading
52*41605Sbosticthe Makefile.
53*41605Sbostic
54*41605SbosticThe variable DESTDIR works as before.  It's not set anywhere but will change
55*41605Sbosticthe tree where the file gets installed.
56*41605Sbostic
57*41605SbosticThe profiled libraries are no longer built in a different directory than
58*41605Sbosticthe regular libraries.  A new suffix, ".po", is used to denote a profiled
59*41605Sbosticobject.
60*41605Sbostic
61*41605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
62*41605Sbostic
63*41605SbosticThe include file <sys.mk> has the default rules for all makes, in the BSD
64*41605Sbosticenvironment or otherwise.  You probably don't want to touch this file.
65*41605Sbostic
66*41605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
67*41605Sbostic
68*41605SbosticThe include file <bsd.man.mk> handles installing manual pages and their
69*41605Sbosticlinks.
70*41605Sbostic
71*41605SbosticIt has a single target:
72*41605Sbostic
73*41605Sbostic	maninstall:
74*41605Sbostic		Install the manual pages and their links.
75*41605Sbostic
76*41605SbosticIt sets/uses the following variables:
77*41605Sbostic
78*41605SbosticMANDIR		Base path for manual installation.
79*41605Sbostic
80*41605SbosticMANGRP		Manual group.
81*41605Sbostic
82*41605SbosticMANOWN		Manual owner.
83*41605Sbostic
84*41605SbosticMANMODE		Manual mode.
85*41605Sbostic
86*41605SbosticMANSUBDIR	Subdirectory under the manual page section, i.e. "/vax"
87*41605Sbostic		or "/tahoe" for machine specific manual pages.
88*41605Sbostic
89*41605SbosticMAN1 ... MAN8	The manual pages to be installed (use a .0 suffix).
90*41605Sbostic
91*41605SbosticMLINKS		List of manual page links (using a .1 - .8 suffix).  The
92*41605Sbostic		linked-to file must come first, the linked file second,
93*41605Sbostic		and there may be multiple pairs.  The files are soft-linked.
94*41605Sbostic
95*41605SbosticThe include file <bsd.man.mk> includes a file named "../Makefile.inc" if
96*41605Sbosticit exists.
97*41605Sbostic
98*41605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
99*41605Sbostic
100*41605SbosticThe include file <bsd.own.mk> contains the owners, groups, etc. for both
101*41605Sbosticmanual pages and binaries.
102*41605Sbostic
103*41605SbosticIt has no targets.
104*41605Sbostic
105*41605SbosticIt sets/uses the following variables:
106*41605Sbostic
107*41605SbosticBINGRP		Binary group.
108*41605Sbostic
109*41605SbosticBINOWN		Binary owner.
110*41605Sbostic
111*41605SbosticBINMODE		Binary mode.
112*41605Sbostic
113*41605SbosticSTRIP		The flag passed to the install program to cause the binary
114*41605Sbostic		to be stripped.  This is to be used when building your
115*41605Sbostic		own install script so that the entire system can be made
116*41605Sbostic		stripped/not-stripped using a single nob.
117*41605Sbostic
118*41605SbosticMANDIR		Base path for manual installation.
119*41605Sbostic
120*41605SbosticMANGRP		Manual group.
121*41605Sbostic
122*41605SbosticMANOWN		Manual owner.
123*41605Sbostic
124*41605SbosticMANMODE		Manual mode.
125*41605Sbostic
126*41605SbosticThis file is generally useful when building your own Makefiles so that
127*41605Sbosticthey use the same default owners etc. as the rest of the tree.
128*41605Sbostic
129*41605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
130*41605Sbostic
131*41605SbosticThe include file <bsd.prog.mk> handles building programs from one or
132*41605Sbosticmore source files, along with their manual pages.  It has a limited number
133*41605Sbosticof suffixes, consistent with the current needs of the BSD tree.
134*41605Sbostic
135*41605SbosticIt has seven targets:
136*41605Sbostic
137*41605Sbostic	all:
138*41605Sbostic		build the program and its manual page
139*41605Sbostic	clean:
140*41605Sbostic		remove the program, any object files and the files a.out,
141*41605Sbostic		Errs, errs, mklog, and core.
142*41605Sbostic	cleandir:
143*41605Sbostic		remove all of the files removed by the target clean, as
144*41605Sbostic		well as .depend, tags, and any manual pages.
145*41605Sbostic	depend:
146*41605Sbostic		make the dependencies for the source files, and store
147*41605Sbostic		them in the file .depend.
148*41605Sbostic	install:
149*41605Sbostic		install the program and its manual pages; if the Makefile
150*41605Sbostic		does not itself define the target install, the targets
151*41605Sbostic		beforeinstall and afterinstall may also be used to cause
152*41605Sbostic		actions immediately before and after the install target
153*41605Sbostic		is executed.
154*41605Sbostic	lint:
155*41605Sbostic		run lint on the source files
156*41605Sbostic	tags:
157*41605Sbostic		create a tags file for the source files.
158*41605Sbostic
159*41605SbosticIt sets/uses the following variables:
160*41605Sbostic
161*41605SbosticBINGRP		Binary group.
162*41605Sbostic
163*41605SbosticBINOWN		Binary owner.
164*41605Sbostic
165*41605SbosticBINMODE		Binary mode.
166*41605Sbostic
167*41605SbosticCLEANFILES	Additional files to remove for the clean and cleandir targets.
168*41605Sbostic
169*41605SbosticCOPTS		Additional flags to the compiler when creating C objects.
170*41605Sbostic
171*41605SbosticHIDEGAME	If HIDEGAME is defined, the binary is installed in
172*41605Sbostic		/usr/games/hide, and a symbolic link is created to
173*41605Sbostic		/usr/games/dm.
174*41605Sbostic
175*41605SbosticLDADD		Additional loader objects.  Usually used for libraries.
176*41605Sbostic		For example, to load with the compatibility and utility
177*41605Sbostic		libraries, use:
178*41605Sbostic
179*41605Sbostic			LDFILES=-lutil -lcompat
180*41605Sbostic
181*41605SbosticLDFLAGS		Additional loader flags.
182*41605Sbostic
183*41605SbosticLINKS		The list of binary links; should be full pathnames, the
184*41605Sbostic		linked-to file coming first, followed by the linked
185*41605Sbostic		file.  The files are hard-linked.  For example, to link
186*41605Sbostic		/bin/test and /bin/[, use:
187*41605Sbostic
188*41605Sbostic			LINKS=	${DESTDIR}/bin/test ${DESTDIR}/bin/[
189*41605Sbostic
190*41605SbosticMAN1...MAN8	Manual pages (should end in .0).  If no MAN variable is
191*41605Sbostic		defined, "MAN1=${PROG}.0" is assumed.
192*41605Sbostic
193*41605SbosticPROG		The name of the program to build.  If not supplied, nothing
194*41605Sbostic		is built.
195*41605Sbostic
196*41605SbosticSRCS		List of source files to build the program.  If PROG is not
197*41605Sbostic		defined, it's assumed to be ${PROG}.c.
198*41605Sbostic
199*41605SbosticDPADD		Additional dependencies for the program.  Usually used for
200*41605Sbostic		libraries.  For example, to depend on the compatibility and
201*41605Sbostic		utility libraries use:
202*41605Sbostic
203*41605Sbostic			SRCLIB=${LIBCOMPAT} ${LIBUTIL}
204*41605Sbostic
205*41605Sbostic		The following libraries are predefined for DPADD:
206*41605Sbostic
207*41605Sbostic			LIBC		/lib/libc.a
208*41605Sbostic			LIBCOMPAT	/usr/lib/libcompat.a
209*41605Sbostic			LIBCURSES	/usr/lib/libcurses.a
210*41605Sbostic			LIBDBM		/usr/lib/libdbm.a
211*41605Sbostic			LIBDES		/usr/lib/libdes.a
212*41605Sbostic			LIBL		/usr/lib/libl.a
213*41605Sbostic			LIBKDB		/usr/lib/libkdb.a
214*41605Sbostic			LIBKRB		/usr/lib/libkrb.a
215*41605Sbostic			LIBM		/usr/lib/libm.a
216*41605Sbostic			LIBMP		/usr/lib/libmp.a
217*41605Sbostic			LIBPC		/usr/lib/libpc.a
218*41605Sbostic			LIBPLOT		/usr/lib/libplot.a
219*41605Sbostic			LIBRPC		/usr/lib/sunrpc.a
220*41605Sbostic			LIBTERM		/usr/lib/libterm.a
221*41605Sbostic			LIBUTIL		/usr/lib/libutil.a
222*41605Sbostic
223*41605SbosticSHAREDSTRINGS	If defined, a new .c.o rule is used that results in shared
224*41605Sbostic		strings, using xstr(1).
225*41605Sbostic
226*41605SbosticSTRIP		The flag passed to the install program to cause the binary
227*41605Sbostic		to be stripped.
228*41605Sbostic
229*41605SbosticSUBDIR		A list of subdirectories that should be built as well.
230*41605Sbostic		Each of the targets will execute the same target in the
231*41605Sbostic		subdirectories.
232*41605Sbostic
233*41605SbosticThe include file <bsd.prog.mk> includes the file named "../Makefile.inc"
234*41605Sbosticif it exists, as well as the include file <bsd.man.mk>.
235*41605Sbostic
236*41605SbosticSome simple examples:
237*41605Sbostic
238*41605SbosticTo build foo from foo.c with a manual page foo.1, use:
239*41605Sbostic
240*41605Sbostic	PROG=	foo
241*41605Sbostic
242*41605Sbostic	.include <bsd.prog.mk>
243*41605Sbostic
244*41605SbosticTo build foo from foo.c with a manual page foo.2, add the line:
245*41605Sbostic
246*41605Sbostic	MAN2=	foo.0
247*41605Sbostic
248*41605SbosticIf foo does not have a manual page at all, add the line:
249*41605Sbostic
250*41605Sbostic	NOMAN=	noman
251*41605Sbostic
252*41605SbosticIf foo has multiple source files, add the line:
253*41605Sbostic
254*41605Sbostic	SRCS=	a.c b.c c.c d.c
255*41605Sbostic
256*41605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
257*41605Sbostic
258*41605SbosticThe include file <bsd.subdir.mk> contains the default targets for building
259*41605Sbosticsubdirectories.  It has the same seven targets as <bsd.prog.mk>: all, clean,
260*41605Sbosticcleandir, depend, install, lint, and tags.  For all of the directories
261*41605Sbosticlisted in the variable SUBDIRS, the specified directory will be visited
262*41605Sbosticand the target made.  There is also a default target which allows the
263*41605Sbosticcommand "make subdir" where subdir is any directory listed in the variable
264*41605SbosticSUBDIRS.
265*41605Sbostic
266*41605Sbostic=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
267*41605Sbostic
268*41605SbosticThe include file <bsd.lib.mk> has support for building libraries.  It has
269*41605Sbosticthe same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend,
270*41605Sbosticinstall, lint, and tags.  It has a limited number of suffixes, consistent
271*41605Sbosticwith the current needs of the BSD tree.
272*41605Sbostic
273*41605SbosticIt sets/uses the following variables:
274*41605Sbostic
275*41605SbosticLIBDIR		Target directory for libraries.
276*41605Sbostic
277*41605SbosticLINTLIBDIR	Target directory for lint libraries.
278*41605Sbostic
279*41605SbosticLIBGRP		Library group.
280*41605Sbostic
281*41605SbosticLIBOWN		Library owner.
282*41605Sbostic
283*41605SbosticLIBMODE		Library mode.
284*41605Sbostic
285*41605SbosticLDADD		Additional loader objects.
286*41605Sbostic
287*41605SbosticMAN1 ... MAN8	The manual pages to be installed (use a .0 suffix).
288*41605Sbostic
289*41605SbosticSRCS		List of source files to build the library.  Suffix types
290*41605Sbostic		.s, .c, and .f are supported.  Note, .s files are preferred
291*41605Sbostic		to .c files of the same name.  (This is not the default for
292*41605Sbostic		versions of make.)
293*41605Sbostic
294*41605SbosticThe include file <bsd.lib.mk> includes the file named "../Makefile.inc"
295*41605Sbosticif it exists, as well as the include file <bsd.man.mk>.
296*41605Sbostic
297*41605SbosticIt has rules for building profiled objects; profiled libraries are
298*41605Sbosticbuilt by default.
299*41605Sbostic
300*41605SbosticLibraries are ranlib'd before installation.
301