1*6c5021acSasou# $OpenBSD: bsd.README,v 1.86 2023/07/25 20:19:14 asou Exp $ 2ad3614a8Sderaadt# $NetBSD: bsd.README,v 1.17 1996/04/13 02:08:08 thorpej Exp $ 3df930be7Sderaadt# @(#)bsd.README 5.1 (Berkeley) 5/11/90 4df930be7Sderaadt 56cf4b331SschwarzeThis is the README file for the make "include" files for the BSD 6df930be7Sderaadtsource tree. The files are installed in /usr/share/mk, and are, by 7df930be7Sderaadtconvention, named with the suffix ".mk". 8df930be7Sderaadt 962b42693Sespiebsd.dep.mk - handle Makefile dependencies 1062b42693Sespiebsd.lib.mk - support for building libraries 1162b42693Sespiebsd.man.mk - installing manual pages and their links 1262b42693Sespiebsd.obj.mk - creating 'obj' directories and cleaning up 1362b42693Sespiebsd.own.mk - define common variables 14e8e70738Sespiebsd.port.mk - building ports (see bsd.port.mk(5)) 156ffa1175Sespiebsd.port.arch.mk - glue for building ports with MD stuff 1662b42693Sespiebsd.port.subdir.mk - targets for building subdirectories for ports 1762b42693Sespiebsd.prog.mk - building programs from source files 18e8e70738Sespiebsd.regress.mk - regression tests (see bsd.regress.mk(5)) 1962b42693Sespiebsd.subdir.mk - targets for building subdirectories 20cd0b30ffSschwarzebsd.sys.mk - overrides for <sys.mk> for building OpenBSD 21cd0b30ffSschwarzesys.mk - global default rules, mostly POSIX 2262b42693Sespie 23df930be7SderaadtNote, this file is not intended to replace reading through the .mk 24df930be7Sderaadtfiles for anything tricky. 25df930be7Sderaadt 26df930be7Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 27df930be7Sderaadt 28df930be7SderaadtRANDOM THINGS WORTH KNOWING: 29df930be7Sderaadt 30df930be7SderaadtThe files are simply C-style #include files, and pretty much behave like 31df930be7Sderaadtyou'd expect. The syntax is slightly different in that a single '.' is 32df930be7Sderaadtused instead of the hash mark, i.e. ".include <bsd.prog.mk>". 33df930be7Sderaadt 34df930be7SderaadtOne difference that will save you lots of debugging time is that inclusion 35df930be7Sderaadtof the file is normally done at the *end* of the Makefile. The reason for 36df930be7Sderaadtthis is because .mk files often modify variables and behavior based on the 37df930be7Sderaadtvalues of variables set in the Makefile. To make this work, remember that 38df930be7Sderaadtthe FIRST target found is the target that is used, i.e. if the Makefile has: 39df930be7Sderaadt 40df930be7Sderaadt a: 41df930be7Sderaadt echo a 42df930be7Sderaadt a: 43df930be7Sderaadt echo a number two 44df930be7Sderaadt 45df930be7Sderaadtthe command "make a" will echo "a". To make things confusing, the SECOND 46df930be7Sderaadtvariable assignment is the overriding one, i.e. if the Makefile has: 47df930be7Sderaadt 48df930be7Sderaadt a= foo 49df930be7Sderaadt a= bar 50df930be7Sderaadt 51df930be7Sderaadt b: 52df930be7Sderaadt echo ${a} 53df930be7Sderaadt 54df930be7Sderaadtthe command "make b" will echo "bar". This is for compatibility with the 55df930be7Sderaadtway the V7 make behaved. 56df930be7Sderaadt 572fff9d1bSespieTo make things even more confusing, make uses lazy evaluation. All 582fff9d1bSespievariables are expanded only when needed. Which means that, in 592fff9d1bSespie 602fff9d1bSespie a= foo 612fff9d1bSespie 622fff9d1bSespie b: $(a) 632fff9d1bSespie echo $(.ALLSRC) 642fff9d1bSespie echo $(a) 652fff9d1bSespie 662fff9d1bSespie foo: 672fff9d1bSespie touch foo 682fff9d1bSespie 692fff9d1bSespie a= bar 702fff9d1bSespie 712fff9d1bSespiethe command "make b" will echo "foo"; echo "bar". The first $(a) means 722fff9d1bSespie"foo", because it's needed to generate the dependency rule when it's read, 732fff9d1bSespiebut the second $(a) is only expanded when needed, at which point a contains 742fff9d1bSespiebar. 752fff9d1bSespie 76df930be7SderaadtIt's fairly difficult to make the BSD .mk files work when you're building 777d335010Sespiemultiple programs in a single directory. It's a lot easier to split up the 78df930be7Sderaadtprograms than to deal with the problem. Most of the agony comes from making 797d335010Sespiethe "obj" directory stuff work right, not because we switched to a new version 80df930be7Sderaadtof make. So, don't get mad at us, figure out a better way to handle multiple 81df930be7Sderaadtarchitectures so we can quit using the symbolic link stuff. (Imake doesn't 82df930be7Sderaadtcount.) 83df930be7Sderaadt 84831839dcSespieDependencies are handled using the compiler's -M* options, resulting in 85a0e6e9a5Sespielots of .d files. These are manually included through <bsd.dep.mk>. 86a0e6e9a5Sespie 87a0e6e9a5Sespie<bsd.dep.mk> also provides an empty depend target to <bsd.prog.mk> and 88a0e6e9a5Sespie<bsd.lib.mk>, for backward compatibility. 89df930be7Sderaadt 90df930be7SderaadtThe variable DESTDIR works as before. It's not set anywhere but will change 91df930be7Sderaadtthe tree where the file gets installed. 92df930be7Sderaadt 93df930be7SderaadtThe profiled libraries are no longer built in a different directory than 94df930be7Sderaadtthe regular libraries. A new suffix, ".po", is used to denote a profiled 95df930be7Sderaadtobject. 96df930be7Sderaadt 97df930be7Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 98df930be7Sderaadt 99df930be7SderaadtThe include file <sys.mk> has the default rules for all makes, in the BSD 100df930be7Sderaadtenvironment or otherwise. You probably don't want to touch this file. 101df930be7Sderaadt 102df930be7Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 103df930be7Sderaadt 1049d07a0feSschwarzeThe include file <bsd.sys.mk> is used by <bsd.prog.mk> and 1059d07a0feSschwarze<bsd.lib.mk>. It overrides parts of <sys.mk> for building the 1069d07a0feSschwarzeOpenBSD source tree. For example, it contains a better yacc(1) 1079d07a0feSschwarzerule assigning the proper names to all output files. 1089d07a0feSschwarze 1099d07a0feSschwarze=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 1109d07a0feSschwarze 111df930be7SderaadtThe include file <bsd.man.mk> handles installing manual pages and their 112df930be7Sderaadtlinks. 113df930be7Sderaadt 114df930be7SderaadtIt has a single target: 115df930be7Sderaadt 116df930be7Sderaadt maninstall: 117df930be7Sderaadt Install the manual pages and their links. 118df930be7Sderaadt 119df930be7SderaadtIt sets/uses the following variables: 120df930be7Sderaadt 121df930be7SderaadtMANDIR Base path for manual installation. 122df930be7Sderaadt 123df930be7SderaadtMANGRP Manual group. 124df930be7Sderaadt 125df930be7SderaadtMANOWN Manual owner. 126df930be7Sderaadt 127df930be7SderaadtMANMODE Manual mode. 128df930be7Sderaadt 129696cd27bSderaadtMANSUBDIR Subdirectory under the manual page section, i.e. "amd64" 130696cd27bSderaadt or "sparc64" for machine specific manual pages. 131df930be7Sderaadt 132a6d8f24eSniklasMAN The manual pages to be installed (use a .1 - .9 suffix). 133df930be7Sderaadt 134a6d8f24eSniklasMLINKS List of manual page links (using a .1 - .9 suffix). The 135df930be7Sderaadt linked-to file must come first, the linked file second, 136df930be7Sderaadt and there may be multiple pairs. The files are soft-linked. 137df930be7Sderaadt 138455476f3SespieBEFOREMAN List of extra targets that must be already built before the 139455476f3Sespie man target can be run. Those targets must be real files (and 140455476f3Sespie not .PHONY targets). 141455476f3Sespie 142df930be7SderaadtThe include file <bsd.man.mk> includes a file named "../Makefile.inc" if 143df930be7Sderaadtit exists. 144df930be7Sderaadt 145df930be7Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 146df930be7Sderaadt 147ad3614a8SderaadtThe include file <bsd.own.mk> contains source tree configuration parameters, 148ad3614a8Sderaadtsuch as the owners, groups, etc. for both manual pages and binaries, and 149ad3614a8Sderaadta few global "feature configuration" parameters. 150df930be7Sderaadt 151df930be7SderaadtIt has no targets. 152df930be7Sderaadt 153ad3614a8SderaadtTo get system-specific configuration parameters, bsd.own.mk will try to 154ad3614a8Sderaadtinclude the file specified by the "MAKECONF" variable. If MAKECONF is not 155ad3614a8Sderaadtset, or no such file exists, the system make configuration file, /etc/mk.conf 156ad3614a8Sderaadtis included. These files may define any of the variables described below. 157ad3614a8Sderaadt 158ad3614a8Sderaadtbsd.own.mk sets the following variables, if they are not already defined 159ad3614a8Sderaadt(defaults are in brackets): 160df930be7Sderaadt 161a6d8f24eSniklasBSDSRCDIR The real path to the system sources, so that 'make obj' 162a6d8f24eSniklas will work correctly. [/usr/src] 163df930be7Sderaadt 164a6d8f24eSniklasBSDOBJDIR The real path to the system 'obj' tree, so that 'make obj' 165a6d8f24eSniklas will work correctly. [/usr/obj] 166df930be7Sderaadt 167a6d8f24eSniklasBINGRP Binary group. [bin] 168a6d8f24eSniklas 169c31f107aSderaadtBINOWN Binary owner. [root] 170a6d8f24eSniklas 171a6d8f24eSniklasBINMODE Binary mode. [555] 172a6d8f24eSniklas 173a6d8f24eSniklasNONBINMODE Mode for non-executable files. [444] 174a6d8f24eSniklas 1752fff9d1bSespieDIRMODE Mode for new directories. [755] 1762fff9d1bSespie 177d9fb19d2SschwarzeMANDIR Base path for manual installation. [/usr/share/man/man] 178a6d8f24eSniklas 179a6d8f24eSniklasMANGRP Manual group. [bin] 180a6d8f24eSniklas 18179232957SmillertMANOWN Manual owner. [root] 182a6d8f24eSniklas 183a6d8f24eSniklasMANMODE Manual mode. [${NONBINMODE}] 184a6d8f24eSniklas 185a6d8f24eSniklasLIBDIR Base path for library installation. [/usr/lib] 186a6d8f24eSniklas 187a6d8f24eSniklasLIBGRP Library group. [${BINGRP}] 188a6d8f24eSniklas 189a6d8f24eSniklasLIBOWN Library owner. [${BINOWN}] 190a6d8f24eSniklas 191a6d8f24eSniklasLIBMODE Library mode. [${NONBINMODE}] 192a6d8f24eSniklas 1933750de46SjmcDOCDIR Base path for system documentation 194a6d8f24eSniklas installation. [/usr/share/doc] 195a6d8f24eSniklas 196a6d8f24eSniklasDOCGRP Documentation group. [bin] 197a6d8f24eSniklas 19879232957SmillertDOCOWN Documentation owner. [root] 199a6d8f24eSniklas 200a6d8f24eSniklasDOCMODE Documentation mode. [${NONBINMODE}] 201a6d8f24eSniklas 2028ce5f3d3SmillertINSTALL_STRIP The flag passed to the install program to cause the binary 203df930be7Sderaadt to be stripped. This is to be used when building your 204df930be7Sderaadt own install script so that the entire system can be made 2058ce5f3d3Smillert stripped/not-stripped using a single knob. Note that 2068ce5f3d3Smillert INSTALL_STRIP is not set if ${DEBUG} is defined. [-s] 207df930be7Sderaadt 2088ce5f3d3SmillertINSTALL_COPY The old usage of this flag is obsolescent since install(1) 2098ce5f3d3Smillert now copies by default. However, it can also be used to 2108ce5f3d3Smillert specify that a file not be copied unless it is different 2118ce5f3d3Smillert (via the -p option). See install(1) for details. This 2128ce5f3d3Smillert is to be used when building our own install script so 2138ce5f3d3Smillert that the entire system can either be installed with copies, 2148ce5f3d3Smillert or copy-if-different using a single knob. [-c] 215df930be7Sderaadt 216ad3614a8SderaadtAdditionally, the following variables may be set by bsd.own.mk or in a 217ad3614a8Sderaadtmake configuration file to modify the behaviour of the system build 218ad3614a8Sderaadtprocess (default values are in brackets along with comments, if set by 219ad3614a8Sderaadtbsd.own.mk): 220df930be7Sderaadt 221a6d8f24eSniklasSKEY Compile in support for S/key authentication. [yes, set 222a6d8f24eSniklas unconditionally] 223df930be7Sderaadt 224a6d8f24eSniklasSYS_INCLUDE Copy or symlink kernel include files into /usr/include. 225a6d8f24eSniklas Possible values are "symlinks" or "copies" (which is 226a6d8f24eSniklas the same as the variable being unset). 227a6d8f24eSniklas 228c1444107SbradNOPROFILE Do not build profiled versions of system libraries. 229a6d8f24eSniklas 230a6d8f24eSniklasNOPIC Do not build PIC versions of system libraries, and 231c1444107Sbrad do not build shared libraries. 232a6d8f24eSniklas 233dec03fdfSpascalNOPIE Do not build PIE objects or executables. 234dec03fdfSpascal 235db0201d0SniklasDEBUG Add -g to assembly, C compiler and linking passes. Also 236db0201d0Sniklas doesn't set STRIP to -s per default if defined. 237db0201d0Sniklas 238720d3b93SespieWARNINGS Adds appropriate warning flags (defined in CDIAGFLAGS, 239720d3b93Sespie e.g., -Wall...) to compiles. [no] 240720d3b93Sespie 2410b7ca014SmillertSUDO Command to run when doing "make install" portion of 24230d4312eSgsoares "make build". If set to /usr/bin/doas, this allows one 24330d4312eSgsoares to run "make build" as a user other than root (assuming 24430d4312eSgsoares doas is setup for that user). 2450b7ca014Smillert 2460b7ca014SmillertPIPE If set to "-pipe" gcc will be given the -pipe option 2470b7ca014Smillert which can speed up compiles on machines with memory 2480b7ca014Smillert to spare. Instead of using temp files, gcc uses pipes 2490b7ca014Smillert for the temporary data. 2500b7ca014Smillert 2518e422146SkstaileyGLOBAL_AUTOCONF_CACHE 2528e422146Skstailey Set to the name of a file that all cached GNU autoconf 2538e422146Skstailey test results will be saved in. Reduces redundant tests. 2542fff9d1bSespie Be careful! Redundant tests may not be redundant if you 2552fff9d1bSespie are installing substantially updated gnu programs. 2562fff9d1bSespie 257ad3614a8Sderaadtbsd.own.mk is generally useful when building your own Makefiles so that 258df930be7Sderaadtthey use the same default owners etc. as the rest of the tree. 259df930be7Sderaadt 260df930be7Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 261df930be7Sderaadt 262df930be7SderaadtThe include file <bsd.prog.mk> handles building programs from one or 263df930be7Sderaadtmore source files, along with their manual pages. It has a limited number 264df930be7Sderaadtof suffixes, consistent with the current needs of the BSD tree. 265df930be7Sderaadt 266a0e6e9a5SespieIt has six targets: 267df930be7Sderaadt 268df930be7Sderaadt all: 269df930be7Sderaadt build the program and its manual page 270df930be7Sderaadt clean: 2717f876bb6Sschwarze remove the program, any object files, and some other 2727f876bb6Sschwarze files that are automatically generated. 273df930be7Sderaadt cleandir: 274df930be7Sderaadt remove all of the files removed by the target clean, as 2757f876bb6Sschwarze well as the tags file. 276ad3614a8Sderaadt includes: 277ad3614a8Sderaadt install any header files. 278df930be7Sderaadt install: 279df930be7Sderaadt install the program and its manual pages; if the Makefile 280df930be7Sderaadt does not itself define the target install, the targets 281df930be7Sderaadt beforeinstall and afterinstall may also be used to cause 282df930be7Sderaadt actions immediately before and after the install target 283df930be7Sderaadt is executed. 284df930be7Sderaadt tags: 285df930be7Sderaadt create a tags file for the source files. 286df930be7Sderaadt 2876cf4b331SschwarzeIt uses the following variables: 288df930be7Sderaadt 289df930be7SderaadtBINGRP Binary group. 290df930be7Sderaadt 291df930be7SderaadtBINOWN Binary owner. 292df930be7Sderaadt 293df930be7SderaadtBINMODE Binary mode. 294df930be7Sderaadt 295831839dcSespieBUILDFIRST Stuff that needs to be built before anything else, in 296831839dcSespie terms of dependencies. 297831839dcSespie 298634c5674SespieBUILDAFTER Stuff that comes later (usually don't touch, defined correctly 299831839dcSespie by <bsd.prog.mk> and <bsd.lib.mk>) 300831839dcSespie 301df930be7SderaadtCLEANFILES Additional files to remove for the clean and cleandir targets. 302df930be7Sderaadt 303df930be7SderaadtCOPTS Additional flags to the compiler when creating C objects. 304df930be7Sderaadt 305*6c5021acSasouCXXOPTS Additional flags to the compiler when creating C++ objects. 306*6c5021acSasou 307fd043bc3SschwarzeLDADD Additional linker objects. Usually used for libraries. 308fd043bc3Sschwarze For example, to link with the crypto and utility 309df930be7Sderaadt libraries, use: 310df930be7Sderaadt 3116c13836aSderaadt LDADD+=-lutil -lcrypto 312df930be7Sderaadt 313fd043bc3SschwarzeLDFLAGS Additional linker flags. 314df930be7Sderaadt 315df930be7SderaadtLINKS The list of binary links; should be full pathnames, the 316df930be7Sderaadt linked-to file coming first, followed by the linked 317df930be7Sderaadt file. The files are hard-linked. For example, to link 318df930be7Sderaadt /bin/test and /bin/[, use: 319df930be7Sderaadt 320df930be7Sderaadt LINKS= ${DESTDIR}/bin/test ${DESTDIR}/bin/[ 321df930be7Sderaadt 322a6d8f24eSniklasMAN Manual pages (should end in .1 - .9). If no MAN variable is 323df930be7Sderaadt defined, "MAN=${PROG}.1" is assumed. 324df930be7Sderaadt 325df930be7SderaadtPROG The name of the program to build. If not supplied, nothing 326df930be7Sderaadt is built. 327df930be7Sderaadt 32804c09525SmickeySRCS List of source files to build the program. If it's not 329df930be7Sderaadt defined, it's assumed to be ${PROG}.c. 330df930be7Sderaadt 331df930be7SderaadtDPADD Additional dependencies for the program. Usually used for 3326c13836aSderaadt libraries. For example, to depend on the crypto and 333df930be7Sderaadt utility libraries use: 334df930be7Sderaadt 3356c13836aSderaadt DPADD+=${LIBCRYPTO} ${LIBUTIL} 336df930be7Sderaadt 337df930be7Sderaadt The following libraries are predefined for DPADD: 338df930be7Sderaadt 3396d68987dSespie LIBC /usr/lib/libc.a 340f4c6e777Sjsg LIBCBOR /usr/lib/libcbor.a 3411258728dSmillert LIBCRYPTO /usr/lib/libcrypto.a 3426d68987dSespie LIBCURSES /usr/lib/libcurses.a 3431258728dSmillert LIBEDIT /usr/lib/libedit.a 344694c1c28Sjsg LIBELF /usr/lib/libelf.a 345558f3d96Smillert LIBEVENT /usr/lib/libevent.a 34649a9729aSmiod LIBEXPAT /usr/lib/libexpat.a 347f4c6e777Sjsg LIBFIDO2 /usr/lib/libfido2.a 34849a9729aSmiod LIBFORM /usr/lib/libform.a 34949a9729aSmiod LIBFORMW /usr/lib/libformw.a 3501258728dSmillert LIBKEYNOTE /usr/lib/libkeynote.a 351df930be7Sderaadt LIBKVM /usr/lib/libkvm.a 3521258728dSmillert LIBL /usr/lib/libl.a 353df930be7Sderaadt LIBM /usr/lib/libm.a 35449a9729aSmiod LIBMENU /usr/lib/libmenu.a 35549a9729aSmiod LIBMENUW /usr/lib/libmenuw.a 3560eaf192dSyasuoka LIBRADIUS /usr/lib/libradius.a 35749a9729aSmiod LIBOSSAUDIO /usr/lib/libossaudio.a 35849a9729aSmiod LIBPANEL /usr/lib/libpanel.a 35949a9729aSmiod LIBPANELW /usr/lib/libpanelw.a 3606d68987dSespie LIBPCAP /usr/lib/libpcap.a 3611258728dSmillert LIBPERL /usr/lib/libperl.a 36249a9729aSmiod LIBPTHREAD /usr/lib/libpthread.a 3631258728dSmillert LIBRPCSVC /usr/lib/librpcsvc.a 3641258728dSmillert LIBSKEY /usr/lib/libskey.a 36549a9729aSmiod LIBSNDIO /usr/lib/libsndio.a 3661258728dSmillert LIBSSL /usr/lib/libssl.a 3676e3d4b76Smartijn LIBAGENTX /usr/lib/libagentx.a 368c3f5d593Stholo LIBTERMCAP /usr/lib/libtermcap.a 369c3f5d593Stholo LIBTERMLIB /usr/lib/libtermlib.a 370b600beedSjsing LIBTLS /usr/lib/libtls.a 371dd3da175Sjsg LIBUSBHID /usr/lib/libusbhid.a 372df930be7Sderaadt LIBUTIL /usr/lib/libutil.a 3731258728dSmillert LIBY /usr/lib/liby.a 3746d68987dSespie LIBZ /usr/lib/libz.a 3756d68987dSespie LIBARCH arch-dependent stuff 376df930be7Sderaadt 377df930be7SderaadtSTRIP The flag passed to the install program to cause the binary 378df930be7Sderaadt to be stripped. 379df930be7Sderaadt 380df930be7SderaadtSUBDIR A list of subdirectories that should be built as well. 381df930be7Sderaadt Each of the targets will execute the same target in the 382df930be7Sderaadt subdirectories. 383df930be7Sderaadt 384df930be7SderaadtThe include file <bsd.prog.mk> includes the file named "../Makefile.inc" 385df930be7Sderaadtif it exists, as well as the include file <bsd.man.mk>. 386df930be7Sderaadt 387df930be7SderaadtSome simple examples: 388df930be7Sderaadt 389df930be7SderaadtTo build foo from foo.c with a manual page foo.1, use: 390df930be7Sderaadt 391df930be7Sderaadt PROG= foo 392df930be7Sderaadt 393df930be7Sderaadt .include <bsd.prog.mk> 394df930be7Sderaadt 395df930be7SderaadtTo build foo from foo.c with a manual page foo.2, add the line: 396df930be7Sderaadt 397df930be7Sderaadt MAN= foo.2 398df930be7Sderaadt 399df930be7SderaadtIf foo does not have a manual page at all, add the line: 400df930be7Sderaadt 401df930be7Sderaadt NOMAN= noman 402df930be7Sderaadt 403df930be7SderaadtIf foo has multiple source files, add the line: 404df930be7Sderaadt 405df930be7Sderaadt SRCS= a.c b.c c.c d.c 406df930be7Sderaadt 407a0e6e9a5SespieSRCS may contain lex and yacc files, in which case the framework will 408a0e6e9a5Sespieconvert these files to C and header files first, before building anything 409a0e6e9a5Sespieelse. 410a0e6e9a5Sespie 411a0e6e9a5SespieSRCS may contain C++ files, in which case the C++ compiler will be used 412a0e6e9a5Sespiefor linking. 413a0e6e9a5Sespie 414a0e6e9a5SespieIf YFLAGS contains -d, the header file will be named like the C file, 415a0e6e9a5Sespieand a proper rule tying both together will be generated. For instance, if 416a0e6e9a5SespieSRCS contains grammar.y, then effectively you will have 417a0e6e9a5Sespie 418a0e6e9a5Sespiegrammar.c grammar.h: grammar.y 419a0e6e9a5Sespie ${YACC.Y} -o grammar.c grammar.y 420a0e6e9a5Sespie 4218809da58Sespie 422ca69bddbSschwarze<bsd.prog.mk> provides a limited capability to build several 423ca69bddbSschwarzeprograms in a single directory by defining the list of programs 424ca69bddbSschwarzeas PROGS instead of using PROG, for instance: PROGS = foo bar 425ca69bddbSschwarze 426ca69bddbSschwarzeThis only works if all programs in the directory use the same 427ca69bddbSschwarzecompiler and linker flags. Also, the programs cannot use source 428ca69bddbSschwarzefiles with the same file name but different content. 4298809da58Sespie 4308809da58SespieEach program of the list, for instance foo, will use SRCS_foo instead 4318809da58Sespieof SRCS to find its sources. SRCS_foo still defaults to foo.c, and 4328809da58SespieMAN still defaults to section 1 manpages: MAN = foo.1 bar.1. 4338809da58Sespie 4348809da58SespieEach program can have its separate LDADD_foo and DPADD_foo definitions. 4358809da58SespieIf not defined, these default to LDADD/DPADD. 4368809da58Sespie 4378809da58SespieSome simple examples: 4388809da58SespieTo build foo from foo.c and bar from bar.c with manual pages foo.1 and bar.1: 4398809da58Sespie 4408809da58Sespie PROGS = foo bar 4418809da58Sespie 4428809da58Sespie .include <bsd.prog.mk> 4438809da58Sespie 4448809da58SespieIf bar has manual page bar.8 instead, add the line: 4458809da58Sespie MAN = foo.1 bar.8 4468809da58Sespie 4478809da58SespieIf bar has multiple source files, add the line: 4488809da58Sespie SRCS_bar = a.c b.c c.c d.c 4498809da58Sespie 4508809da58SespieNote that foo and bar may share some source files, like so: 4518809da58Sespie SRCS_foo = foo.c common.c 4528809da58Sespie SRCS_bar = bar.c common.c 4538809da58Sespie 454df930be7Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 455df930be7Sderaadt 456df930be7SderaadtThe include file <bsd.subdir.mk> contains the default targets for building 457a0e6e9a5Sespiesubdirectories. It has the same six targets as <bsd.prog.mk>: all, 458a0e6e9a5Sespieclean, cleandir, includes, install, and tags. For all of 459fb766b08Sjmcthe directories listed in the variable SUBDIR, the specified directory 460ad3614a8Sderaadtwill be visited and the target made. There is also a default target which 461ad3614a8Sderaadtallows the command "make subdir" where subdir is any directory listed in 462fb766b08Sjmcthe variable SUBDIR. 463df930be7Sderaadt 464482ae328Sderaadt 465482ae328Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 466482ae328Sderaadt 467df930be7SderaadtThe include file <bsd.lib.mk> has support for building libraries. It has 4686cf4b331Sschwarzethe same six targets as <bsd.prog.mk>: all, clean, cleandir, 46948922441Sjsgincludes, install, and tags. It has a limited number of suffixes, 470ad3614a8Sderaadtconsistent with the current needs of the BSD tree. 471df930be7Sderaadt 4726cf4b331SschwarzeIt uses the following variables: 473df930be7Sderaadt 4746cf4b331SschwarzeBUILDFIRST/BUILDAFTER 4756cf4b331Sschwarze See <bsd.prog.mk>. 476831839dcSespie 477df930be7SderaadtLIB The name of the library to build. 478df930be7Sderaadt 479df930be7SderaadtLIBDIR Target directory for libraries. 480df930be7Sderaadt 481df930be7SderaadtLIBGRP Library group. 482df930be7Sderaadt 483df930be7SderaadtLIBOWN Library owner. 484df930be7Sderaadt 485df930be7SderaadtLIBMODE Library mode. 486df930be7Sderaadt 487fd043bc3SschwarzeLDADD Additional linker objects. 488df930be7Sderaadt 489a6d8f24eSniklasMAN The manual pages to be installed (use a .1 - .9 suffix). 490df930be7Sderaadt 491df930be7SderaadtSRCS List of source files to build the library. Suffix types 492df930be7Sderaadt .s, .c, and .f are supported. Note, .s files are preferred 493df930be7Sderaadt to .c files of the same name. (This is not the default for 494a0e6e9a5Sespie POSIX make without bsd.lib.mk). 495a0e6e9a5Sespie 496a0e6e9a5Sespie The same support for yacc and lex files as <bsd.prog.mk> 497a0e6e9a5Sespie is provided. 498df930be7Sderaadt 499df930be7SderaadtThe include file <bsd.lib.mk> includes the file named "../Makefile.inc" 500df930be7Sderaadtif it exists, as well as the include file <bsd.man.mk>. 501df930be7Sderaadt 502df930be7SderaadtIt has rules for building profiled objects; profiled libraries are 503df930be7Sderaadtbuilt by default. 504df930be7Sderaadt 50540fd575dSderaadtStatic libraries are ranlib'd when made. 50604c09525Smickey 507ae85352fSguentherIn addition, a reduced version of a library, including just specific 508ae85352fSguentherobjects that are compiled with additional options to reduce their 509ae85352fSguenthersize may be built. This is used by the distrib/ tree and crunchgen 510ae85352fSguentherwhen building ramdisks. This sets/uses the following variables: 511ae85352fSguenther 512ae85352fSguentherDIST_LIB The path of the library to build. [lib${LIB}_d.a] 513ae85352fSguenther 514ae85352fSguentherDIST_OBJS The (sub)set of .o files to include in ${DIST_LIB}. [${OBJS}] 515ae85352fSguenther 516ae85352fSguentherDIST_CFLAGS Additional flags for the C compiler and assembler. 51743c1315fSderaadt [-Oz] 518ae85352fSguenther 519