• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

MakefileD05-Oct-2008508 158

bsd.READMED07-May-200816.1 KiB498352

bsd.cfwrap.mkD19-Aug-20134.2 KiB179138

bsd.dep.mkD10-Apr-20082.1 KiB7663

bsd.doc.mkD10-Apr-20081.4 KiB6647

bsd.lib.mkD18-Mar-201313.9 KiB490416

bsd.lkm.mkD10-Dec-20083.8 KiB158130

bsd.lt.mkD05-Oct-2008995 3528

bsd.man.mkD10-Apr-20082.3 KiB8966

bsd.obj.mkD11-Jul-20081.6 KiB6956

bsd.own.mkD23-Dec-20105.6 KiB224179

bsd.prog.mkD10-Dec-20083.9 KiB169138

bsd.subdir.mkD22-Mar-20092.7 KiB118101

bsd.sys.mkD12-Dec-20092.5 KiB8664

sys.mkD19-Feb-20146.4 KiB282232

bsd.README

1# $MirOS: src/share/mk/bsd.README,v 1.13 2008/05/07 13:50:21 tg Exp $
2# $OpenBSD: bsd.README,v 1.37 2005/04/15 17:18:57 espie Exp $
3# $NetBSD: bsd.README,v 1.17 1996/04/13 02:08:08 thorpej Exp $
4# @(#)bsd.README	5.1 (Berkeley) 5/11/90
5
6This is the README file for the new make "include" files for the BSD
7source tree.  The files are installed in /usr/share/mk, and are, by
8convention, named with the suffix ".mk".
9
10bsd.dep.mk		- handle Makefile dependencies
11bsd.doc.mk		- building *roff system documents
12bsd.lib.mk		- support for building libraries
13bsd.lkm.mk		- building loadable kernel modules
14bsd.man.mk		- installing manual pages and their links
15bsd.obj.mk		- creating 'obj' directories and cleaning up
16bsd.own.mk		- define common variables
17bsd.port.mk		- building ports
18bsd.port.subdir.mk	- targets for building subdirectories for ports
19bsd.prog.mk		- building programs from source files
20bsd.subdir.mk		- targets for building subdirectories
21bsd.sys.mk		- building bsd from the source tree
22
23Note, this file is not intended to replace reading through the .mk
24files for anything tricky. It's also not been updated for a long time.
25
26All of the files bear no explicit copyright notice or licence, please
27feel free to use them as fit. The MirOS Project would like to receive
28due credit if possible, though.
29
30=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
31
32RANDOM THINGS WORTH KNOWING:
33
34The files are simply C-style #include files, and pretty much behave like
35you'd expect.  The syntax is slightly different in that a single '.' is
36used instead of the hash mark, i.e. ".include <bsd.prog.mk>".
37
38One difference that will save you lots of debugging time is that inclusion
39of the file is normally done at the *end* of the Makefile.  The reason for
40this is because .mk files often modify variables and behavior based on the
41values of variables set in the Makefile.  To make this work, remember that
42the FIRST target found is the target that is used, i.e. if the Makefile has:
43
44	a:
45		echo a
46	a:
47		echo a number two
48
49the command "make a" will echo "a".  To make things confusing, the SECOND
50variable assignment is the overriding one, i.e. if the Makefile has:
51
52	a=	foo
53	a=	bar
54
55	b:
56		echo ${a}
57
58the command "make b" will echo "bar".  This is for compatibility with the
59way the V7 make behaved.
60
61To make things even more confusing, make uses lazy evaluation. All
62variables are expanded only when needed. Which means that, in
63
64	a=	foo
65
66	b: $(a)
67		echo $(.ALLSRC)
68		echo $(a)
69
70	foo:
71		touch foo
72
73   	a=	bar
74
75the command "make b" will echo "foo"; echo "bar".  The first $(a) means
76"foo", because it's needed to generate the dependency rule when it's read,
77but the second $(a) is only expanded when needed, at which point a contains
78bar.
79
80It's fairly difficult to make the BSD .mk files work when you're building
81multiple programs in a single directory.  It's a lot easier to split up the
82programs than to deal with the problem.  Most of the agony comes from making
83the "obj" directory stuff work right, not because we switched to a new version
84of make.  So, don't get mad at us, figure out a better way to handle multiple
85architectures so we can quit using the symbolic link stuff.  (Imake doesn't
86count.)
87
88The file .depend in the source directory is expected to contain dependencies
89for the source files.  This file is read automatically by make after reading
90the Makefile.
91
92The variable DESTDIR works as before.  It's not set anywhere but will change
93the tree where the file gets installed.
94
95=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
96
97The include file <sys.mk> has the default rules for all makes, in the BSD
98environment or otherwise.  You probably don't want to touch this file.
99
100# We want at least the following defines: (samples)
101# MACHINE		i386			amiga
102# MACHINE_ARCH		i386			m68k
103# MACHINE_OS		BSD			GNU
104# OStype		MirBSD			Debian (...)
105# OSrev			7			version
106# OSrpl			128			patchlevel
107# OSNAME		MirBSD			uname -s
108# OSname		mirbsd			uname -s in lowercase
109# OScompat		3.5			equivalent OpenBSD version
110# OStriplet		i386-ecce-mirbsd8	... for GNU software
111
112=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
113
114The include file <bsd.man.mk> handles installing manual pages and their
115links.
116
117It has a single target:
118
119	maninstall:
120		Install the manual pages and their links.
121
122It sets/uses the following variables:
123
124MANDIR		Base path for manual installation.
125
126MANGRP		Manual group.
127
128MANOWN		Manual owner.
129
130MANMODE		Manual mode.
131
132MAN		The manual pages to be installed (use a .1 - .9 suffix).
133
134MLINKS		List of manual page links (using a .1 - .9 suffix).  The
135		linked-to file must come first, the linked file second,
136		and there may be multiple pairs.  The files are soft-linked.
137
138The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
139it exists.
140
141=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
142
143The include file <bsd.own.mk> contains source tree configuration parameters,
144such as the owners, groups, etc. for both manual pages and binaries, and
145a few global "feature configuration" parameters.
146
147It has no targets.
148
149To get system-specific configuration parameters, bsd.own.mk will try to
150include the file specified by the "MAKECONF" variable.  If MAKECONF is not
151set, or no such file exists, the system make configuration file,
152/etc/${MAKE}.cfg, is included.  These files may define any of the variables
153described below.
154
155bsd.own.mk sets the following variables, if they are not already defined
156(defaults are in brackets):
157
158BSDSRCDIR	The real path to the system sources, so that 'make obj'
159		will work correctly. [/usr/src]
160
161BSDOBJDIR	The real path to the system 'obj' tree, so that 'make obj'
162		will work correctly. [/usr/obj]
163
164BINGRP		Binary group. [bin]
165
166BINOWN		Binary owner. [root]
167
168BINMODE		Binary mode. [555]
169
170NONBINMODE	Mode for non-executable files. [444]
171
172DIRMODE		Mode for new directories. [755]
173
174MANDIR		Base path for manual installation. [/usr/share/man/cat]
175
176MANGRP		Manual group. [bin]
177
178MANOWN		Manual owner. [root]
179
180MANMODE		Manual mode. [${NONBINMODE}]
181
182LIBDIR		Base path for library installation. [/usr/lib]
183
184LINTLIBDIR	Base path for lint(1) library installation. [/usr/libdata/lint]
185
186LIBGRP		Library group. [${BINGRP}]
187
188LIBOWN		Library owner. [${BINOWN}]
189
190LIBMODE		Library mode. [${NONBINMODE}]
191
192DOCDIR		Base path for system documentation (e.g. PSD, USD, etc.)
193	        installation. [/usr/share/doc]
194
195DOCGRP		Documentation group. [bin]
196
197DOCOWN		Documentation owner. [root]
198
199DOCMODE		Documentation mode. [${NONBINMODE}]
200
201INSTALL_STRIP	The flag passed to the install program to cause the binary
202		to be stripped.  This is to be used when building your
203		own install script so that the entire system can be made
204		stripped/not-stripped using a single knob.  Note that
205		INSTALL_STRIP is not set if ${DEBUG} is defined. [-s]
206
207INSTALL_COPY	The old usage of this flag is obsolescent since install(1)
208		now copies by default.  However, it can also be used to
209		specify that a file not be copied unless it is different
210		(via the -p option).  See install(1) for details.  This
211		is to be used when building our own install script so
212		that the entire system can either be installed with copies,
213		or copy-if-different using a single knob. [-c]
214
215Additionally, the following variables may be set by bsd.own.mk or in a
216make configuration file to modify the behaviour of the system build
217process (default values are in brackets along with comments, if set by
218bsd.own.mk):
219
220SKEY		Compile in support for S/key authentication. [yes, set
221		unconditionally]
222
223SYS_INCLUDE	Copy or symlink kernel include files into /usr/include.
224		Possible values are "symlinks" or "copies" (which is
225		the same as the variable being unset).
226
227NOPIC		Do not build PIC versions of system libraries, and
228		do not build shared libraries. [no]
229
230NOLINT		Do not build lint libraries. [yes]
231
232DEBUG		Add -g to assembly, C compiler and linking passes.  Also
233		doesn't	set INSTALL_STRIP to -s per default if defined.
234
235WARNINGS	Adds appropriate warning flags (defined in CDIAGFLAGS,
236		e.g., -Wall...) to compiles. [no]
237
238SUDO		Command to run when doing "make install" portion of
239		"make build".  If set to sudo, this allows one to run
240		"make build" as a user other than root (assuming sudo
241		is setup for that user).
242
243PIPE		If set to "-pipe" gcc will be given the -pipe option
244		which can speed up compiles on machines with memory
245		to spare.  Instead of using temp files, gcc uses pipes
246		for the temporary data.
247
248bsd.own.mk is generally useful when building your own Makefiles so that
249they use the same default owners etc. as the rest of the tree.
250
251=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
252
253The include file <bsd.prog.mk> handles building programs from one or
254more source files, along with their manual pages.  It has a limited number
255of suffixes, consistent with the current needs of the BSD tree.
256
257It has eight targets:
258
259	all:
260		build the program and its manual page
261	clean:
262		remove the program, any object files and the files a.out,
263		Errs, errs, mklog, and core.
264	cleandir:
265		remove all of the files removed by the target clean, as
266		well as .depend, tags, and any manual pages.
267	depend:
268		make the dependencies for the source files, and store
269		them in the file .depend.
270	includes:
271		install any header files.
272	install:
273		install the program and its manual pages; if the Makefile
274		does not itself define the target install, the targets
275		beforeinstall and afterinstall may also be used to cause
276		actions immediately before and after the install target
277		is executed.
278	lint:
279		run lint on the source files
280	tags:
281		create a tags file for the source files.
282
283It sets/uses the following variables:
284
285BINGRP		Binary group.
286
287BINOWN		Binary owner.
288
289BINMODE		Binary mode.
290
291CLEANFILES	Additional files to remove for the clean and cleandir targets.
292
293COPTS		Additional flags to the compiler when creating C objects.
294
295LDADD		Additional loader objects.  Usually used for libraries.
296		For example, to load with the compatibility and utility
297		libraries, use:
298
299			LDADD+=-lutil -lcompat
300
301		There can only be library invocations (-lfoo) and
302		objects directly given.
303
304LDADD_CYCLIC	Define this to make the order of LDADD objects irrelevant.
305		This is, according to the ld(texinfo) manual, slow.
306
307LDFLAGS		Additional loader flags.
308
309LINKS		The list of binary links; should be full pathnames, the
310		linked-to file coming first, followed by the linked
311		file.  The files are hard-linked.  For example, to link
312		/bin/test and /bin/[, use:
313
314			LINKS=	${DESTDIR}/bin/test ${DESTDIR}/bin/[
315
316MAN		Manual pages (should end in .1 - .9).  If no MAN variable is
317		defined, "MAN=${PROG}.1" is assumed.
318
319PROG		The name of the program to build.  If not supplied, nothing
320		is built.
321
322SRCS		List of source files to build the program.  If it's not
323		defined, it's assumed to be ${PROG}.c.
324
325DPADD		Additional dependencies for the program.  Usually used for
326		libraries.  For example, to depend on the compatibility and
327		utility libraries use:
328
329			DPADD+=${LIBCOMPAT} ${LIBUTIL}
330
331		The following libraries are predefined for DPADD:
332
333			LIBC		/usr/lib/libc.a
334			LIBCOMPAT	/usr/lib/libcompat.a
335			LIBCRYPTO	/usr/lib/libcrypto.a
336			LIBCURSES	/usr/lib/libcurses.a
337			LIBDES		/usr/lib/libdes.a
338			LIBEDIT		/usr/lib/libedit.a
339			LIBEVENT	/usr/lib/libevent.a
340			LIBGCC		/usr/lib/libgcc.a
341			LIBKEYNOTE	/usr/lib/libkeynote.a
342			LIBKVM		/usr/lib/libkvm.a
343			LIBL		/usr/lib/libl.a
344			LIBM		/usr/lib/libm.a
345			LIBOLDCURSES	/usr/lib/libocurses.a
346			LIBPCAP		/usr/lib/libpcap.a
347			LIBPERL		/usr/lib/libperl.a
348			LIBRPCSVC	/usr/lib/librpcsvc.a
349			LIBSECTOK	/usr/lib/libsectok.a
350			LIBSKEY		/usr/lib/libskey.a
351			LIBSSL		/usr/lib/libssl.a
352			LIBTELNET	/usr/lib/libtelnet.a
353			LIBTERMCAP	/usr/lib/libtermcap.a
354			LIBTERMLIB	/usr/lib/libtermlib.a
355			LIBUSB		/usr/lib/libusbhid.a
356			LIBUTIL		/usr/lib/libutil.a
357			LIBWRAP		/usr/lib/libwrap.a
358			LIBY		/usr/lib/liby.a
359			LIBZ		/usr/lib/libz.a
360			LIBARCH		arch-dependent stuff
361
362SUBDIR		A list of subdirectories that should be built as well.
363		Each of the targets will execute the same target in the
364		subdirectories.
365
366The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
367if it exists, as well as the include file <bsd.man.mk>.
368
369Some simple examples:
370
371To build foo from foo.c with a manual page foo.1, use:
372
373	PROG=	foo
374
375	.include <bsd.prog.mk>
376
377To build foo from foo.c with a manual page foo.2, add the line:
378
379	MAN=	foo.2
380
381If foo does not have a manual page at all, add the line:
382
383	NOMAN=	yes
384
385If foo has multiple source files, add the line:
386
387	SRCS=	a.c b.c c.c d.c
388
389=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
390
391The include file <bsd.subdir.mk> contains the default targets for building
392subdirectories.  It has the same eight targets as <bsd.prog.mk>: all,
393clean, cleandir, depend, includes, install, lint, and tags.  For all of
394the directories listed in the variable SUBDIRS, the specified directory
395will be visited and the target made.  There is also a default target which
396allows the command "make subdir" where subdir is any directory listed in
397the variable SUBDIRS.
398
399=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
400
401The include file <bsd.sys.mk> is used by <bsd.prog.mk> and
402<bsd.lib.mk>.  It contains overrides that are used when building
403the MirOS source tree.  For instance, if "PARALLEL" is defined by
404the program/library Makefile, it includes a set of rules for lex and
405yacc that allow multiple lex and yacc targets to be built in parallel.
406
407If TRUEPREFIX is defined (usually by the MirPorts Framework), certain
408rules regarding DESTDIR are disabled, which helps ports to use the
409<bsd.prog.mk> and <bsd.lib.mk> framework.
410
411=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
412
413For <bsd.prog.mk> and <bsd.lib.mk> the following additional variables
414exist:
415
416HDRS		default: unset
417HDRS2		default: unset
418HDRSRC		default: ${.CURDIR}
419HDRDST		default: ${DESTDIR}/usr/include
420
421If HDRS or HDRS2 is defined and no includes target is defined by
422the programme or library Makefile, one is automatically defined,
423and works approximately like this:
424
425	.for srcfile in ${HDRS}
426		cd ${HDRSRC}; cp ${srcfile} ${HDRDST}/$$(basename ${srcfile})
427	.endfor
428	.for srcfile dstfile in ${HDRS2}
429		cp ${HDRSRC}/${srcfile} ${HDRDST}/${dstfile}
430	.endfor
431
432The files are only copied if they don't match. An afterincludes
433target is run automatically IFF the automatic includes target is
434used (not otherwise), eg. if HDRS and HDRS2 are defined but empty.
435
436=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
437
438The include file <bsd.lib.mk> has support for building libraries.  It has
439the same eight targets as <bsd.prog.mk>: all, clean, cleandir, depend,
440includes, install, lint, and tags.  It has a limited number of suffixes,
441consistent with the current needs of the BSD tree.
442
443It sets/uses the following variables:
444
445LIB		The name of the library to build.
446
447LIBDIR		Target directory for libraries.
448
449LINTLIBDIR	Target directory for lint libraries.
450
451LIBGRP		Library group.
452
453LIBOWN		Library owner.
454
455LIBMODE		Library mode.
456
457LDADD		Additional loader objects.
458
459MAN		The manual pages to be installed (use a .1 - .9 suffix).
460
461SRCS		List of source files to build the library.  Suffix types
462		.s, .c, and .f are supported.  Note, .s files are preferred
463		to .c files of the same name.  (This is not the default for
464		versions of make.)
465
466The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
467if it exists, as well as the include file <bsd.man.mk>.
468
469It has rules for building profiled objects; profiled libraries are
470built by default.
471
472Libraries are ranlib'd when made.
473
474=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
475
476The include file <bsd.lkm.mk> has support for building the LKM's. It has
477the same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend,
478install, lint, and tags. In addition two targets are made available
479that is specific to the LKM's: load, unload.
480
481It sets/uses the following variables (in addition to the <bsd.prog.mk>'s):
482
483LKM		LKM name to build.
484
485LKMGRP		Module group.
486
487LKMOWN		Module owner.
488
489LKMMODE		Module mode.
490
491POSTINSTALL	Program to pass with '-p' flag to the modload.
492		If not defined,
493			POSTINSTALL=${LKM}install
494		is assumed.
495
496The include file <bsd.lkm.mk> includes the file named "../Makefile.inc"
497if it exists, as well as the include file <bsd.man.mk>.
498