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