bsd.README revision 1638
11638Srgrimes# @(#)bsd.README 8.2 (Berkeley) 4/2/94 21638Srgrimes 31638SrgrimesThis is the README file for the new make "include" files for the BSD 41638Srgrimessource tree. The files are installed in /usr/share/mk, and are, by 51638Srgrimesconvention, named with the suffix ".mk". Each ".mk" file has a 61638Srgrimescorresponding ".rd" file which is an explanation of the ".mk" file. 71638Srgrimes 81638SrgrimesNote, this file is not intended to replace reading through the .mk 91638Srgrimesfiles for anything tricky. 101638Srgrimes 111638Srgrimes=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 121638Srgrimes 131638SrgrimesRANDOM THINGS WORTH KNOWING: 141638Srgrimes 151638SrgrimesThe files are simply C-style #include files, and pretty much behave like 161638Srgrimesyou'd expect. The syntax is slightly different in that a single '.' is 171638Srgrimesused instead of the hash mark, i.e. ".include <bsd.prog.mk>". 181638Srgrimes 191638SrgrimesOne difference that will save you lots of debugging time is that inclusion 201638Srgrimesof the file is normally done at the *end* of the Makefile. The reason for 211638Srgrimesthis is because .mk files often modify variables and behavior based on the 221638Srgrimesvalues of variables set in the Makefile. To make this work, remember that 231638Srgrimesthe FIRST target found is the target that is used, i.e. if the Makefile has: 241638Srgrimes 251638Srgrimes a: 261638Srgrimes echo a 271638Srgrimes a: 281638Srgrimes echo a number two 291638Srgrimes 301638Srgrimesthe command "make a" will echo "a". To make things confusing, the SECOND 311638Srgrimesvariable assignment is the overriding one, i.e. if the Makefile has: 321638Srgrimes 331638Srgrimes a= foo 341638Srgrimes a= bar 351638Srgrimes 361638Srgrimes b: 371638Srgrimes echo ${a} 381638Srgrimes 391638Srgrimesthe command "make b" will echo "bar". This is for compatibility with the 401638Srgrimesway the V7 make behaved. 411638Srgrimes 421638SrgrimesIt's fairly difficult to make the BSD .mk files work when you're building 431638Srgrimesmultiple programs in a single directory. It's a lot easier split up the 441638Srgrimesprograms than to deal with the problem. Most of the agony comes from making 451638Srgrimesthe "obj" directory stuff work right, not because we switch to a new version 461638Srgrimesof make. So, don't get mad at us, figure out a better way to handle multiple 471638Srgrimesarchitectures so we can quit using the symbolic link stuff. (Imake doesn't 481638Srgrimescount.) 491638Srgrimes 501638SrgrimesThe file .depend in the source directory is expected to contain dependencies 511638Srgrimesfor the source files. This file is read automatically by make after reading 521638Srgrimesthe Makefile. 531638Srgrimes 541638SrgrimesThe variable DESTDIR works as before. It's not set anywhere but will change 551638Srgrimesthe tree where the file gets installed. 561638Srgrimes 571638SrgrimesThe profiled libraries are no longer built in a different directory than 581638Srgrimesthe regular libraries. A new suffix, ".po", is used to denote a profiled 591638Srgrimesobject. 601638Srgrimes 611638Srgrimes=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 621638Srgrimes 631638SrgrimesThe include file <sys.mk> has the default rules for all makes, in the BSD 641638Srgrimesenvironment or otherwise. You probably don't want to touch this file. 651638Srgrimes 661638Srgrimes=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 671638Srgrimes 681638SrgrimesThe include file <bsd.man.mk> handles installing manual pages and their 691638Srgrimeslinks. 701638Srgrimes 711638SrgrimesIt has a single target: 721638Srgrimes 731638Srgrimes maninstall: 741638Srgrimes Install the manual pages and their links. 751638Srgrimes 761638SrgrimesIt sets/uses the following variables: 771638Srgrimes 781638SrgrimesMANDIR Base path for manual installation. 791638Srgrimes 801638SrgrimesMANGRP Manual group. 811638Srgrimes 821638SrgrimesMANOWN Manual owner. 831638Srgrimes 841638SrgrimesMANMODE Manual mode. 851638Srgrimes 861638SrgrimesMANSUBDIR Subdirectory under the manual page section, i.e. "/vax" 871638Srgrimes or "/tahoe" for machine specific manual pages. 881638Srgrimes 891638SrgrimesMAN1 ... MAN8 The manual pages to be installed (use a .0 suffix). 901638Srgrimes 911638SrgrimesMLINKS List of manual page links (using a .1 - .8 suffix). The 921638Srgrimes linked-to file must come first, the linked file second, 931638Srgrimes and there may be multiple pairs. The files are soft-linked. 941638Srgrimes 951638SrgrimesThe include file <bsd.man.mk> includes a file named "../Makefile.inc" if 961638Srgrimesit exists. 971638Srgrimes 981638Srgrimes=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 991638Srgrimes 1001638SrgrimesThe include file <bsd.own.mk> contains the owners, groups, etc. for both 1011638Srgrimesmanual pages and binaries. 1021638Srgrimes 1031638SrgrimesIt has no targets. 1041638Srgrimes 1051638SrgrimesIt sets/uses the following variables: 1061638Srgrimes 1071638SrgrimesBINGRP Binary group. 1081638Srgrimes 1091638SrgrimesBINOWN Binary owner. 1101638Srgrimes 1111638SrgrimesBINMODE Binary mode. 1121638Srgrimes 1131638SrgrimesSTRIP The flag passed to the install program to cause the binary 1141638Srgrimes to be stripped. This is to be used when building your 1151638Srgrimes own install script so that the entire system can be made 1161638Srgrimes stripped/not-stripped using a single nob. 1171638Srgrimes 1181638SrgrimesMANDIR Base path for manual installation. 1191638Srgrimes 1201638SrgrimesMANGRP Manual group. 1211638Srgrimes 1221638SrgrimesMANOWN Manual owner. 1231638Srgrimes 1241638SrgrimesMANMODE Manual mode. 1251638Srgrimes 1261638SrgrimesThis file is generally useful when building your own Makefiles so that 1271638Srgrimesthey use the same default owners etc. as the rest of the tree. 1281638Srgrimes 1291638Srgrimes=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 1301638Srgrimes 1311638SrgrimesThe include file <bsd.prog.mk> handles building programs from one or 1321638Srgrimesmore source files, along with their manual pages. It has a limited number 1331638Srgrimesof suffixes, consistent with the current needs of the BSD tree. 1341638Srgrimes 1351638SrgrimesIt has seven targets: 1361638Srgrimes 1371638Srgrimes all: 1381638Srgrimes build the program and its manual page 1391638Srgrimes clean: 1401638Srgrimes remove the program, any object files and the files a.out, 1411638Srgrimes Errs, errs, mklog, and ${PROG}.core. 1421638Srgrimes cleandir: 1431638Srgrimes remove all of the files removed by the target clean, as 1441638Srgrimes well as .depend, tags, and any manual pages. 1451638Srgrimes depend: 1461638Srgrimes make the dependencies for the source files, and store 1471638Srgrimes them in the file .depend. 1481638Srgrimes install: 1491638Srgrimes install the program and its manual pages; if the Makefile 1501638Srgrimes does not itself define the target install, the targets 1511638Srgrimes beforeinstall and afterinstall may also be used to cause 1521638Srgrimes actions immediately before and after the install target 1531638Srgrimes is executed. 1541638Srgrimes lint: 1551638Srgrimes run lint on the source files 1561638Srgrimes tags: 1571638Srgrimes create a tags file for the source files. 1581638Srgrimes 1591638SrgrimesIt sets/uses the following variables: 1601638Srgrimes 1611638SrgrimesBINGRP Binary group. 1621638Srgrimes 1631638SrgrimesBINOWN Binary owner. 1641638Srgrimes 1651638SrgrimesBINMODE Binary mode. 1661638Srgrimes 1671638SrgrimesCLEANFILES Additional files to remove for the clean and cleandir targets. 1681638Srgrimes 1691638SrgrimesCOPTS Additional flags to the compiler when creating C objects. 1701638Srgrimes 1711638SrgrimesHIDEGAME If HIDEGAME is defined, the binary is installed in 1721638Srgrimes /usr/games/hide, and a symbolic link is created to 1731638Srgrimes /usr/games/dm. 1741638Srgrimes 1751638SrgrimesLDADD Additional loader objects. Usually used for libraries. 1761638Srgrimes For example, to load with the compatibility and utility 1771638Srgrimes libraries, use: 1781638Srgrimes 1791638Srgrimes LDFILES=-lutil -lcompat 1801638Srgrimes 1811638SrgrimesLDFLAGS Additional loader flags. 1821638Srgrimes 1831638SrgrimesLINKS The list of binary links; should be full pathnames, the 1841638Srgrimes linked-to file coming first, followed by the linked 1851638Srgrimes file. The files are hard-linked. For example, to link 1861638Srgrimes /bin/test and /bin/[, use: 1871638Srgrimes 1881638Srgrimes LINKS= ${DESTDIR}/bin/test ${DESTDIR}/bin/[ 1891638Srgrimes 1901638SrgrimesMAN1...MAN8 Manual pages (should end in .0). If no MAN variable is 1911638Srgrimes defined, "MAN1=${PROG}.0" is assumed. 1921638Srgrimes 1931638SrgrimesPROG The name of the program to build. If not supplied, nothing 1941638Srgrimes is built. 1951638Srgrimes 1961638SrgrimesSRCS List of source files to build the program. If PROG is not 1971638Srgrimes defined, it's assumed to be ${PROG}.c. 1981638Srgrimes 1991638SrgrimesDPADD Additional dependencies for the program. Usually used for 2001638Srgrimes libraries. For example, to depend on the compatibility and 2011638Srgrimes utility libraries use: 2021638Srgrimes 2031638Srgrimes SRCLIB=${LIBCOMPAT} ${LIBUTIL} 2041638Srgrimes 2051638Srgrimes The following libraries are predefined for DPADD: 2061638Srgrimes 2071638Srgrimes LIBC /lib/libc.a 2081638Srgrimes LIBCOMPAT /usr/lib/libcompat.a 2091638Srgrimes LIBCURSES /usr/lib/libcurses.a 2101638Srgrimes LIBDBM /usr/lib/libdbm.a 2111638Srgrimes LIBDES /usr/lib/libdes.a 2121638Srgrimes LIBL /usr/lib/libl.a 2131638Srgrimes LIBKDB /usr/lib/libkdb.a 2141638Srgrimes LIBKRB /usr/lib/libkrb.a 2151638Srgrimes LIBM /usr/lib/libm.a 2161638Srgrimes LIBMP /usr/lib/libmp.a 2171638Srgrimes LIBPC /usr/lib/libpc.a 2181638Srgrimes LIBPLOT /usr/lib/libplot.a 2191638Srgrimes LIBRPC /usr/lib/sunrpc.a 2201638Srgrimes LIBTERM /usr/lib/libterm.a 2211638Srgrimes LIBUTIL /usr/lib/libutil.a 2221638Srgrimes 2231638SrgrimesSHAREDSTRINGS If defined, a new .c.o rule is used that results in shared 2241638Srgrimes strings, using xstr(1). 2251638Srgrimes 2261638SrgrimesSTRIP The flag passed to the install program to cause the binary 2271638Srgrimes to be stripped. 2281638Srgrimes 2291638SrgrimesSUBDIR A list of subdirectories that should be built as well. 2301638Srgrimes Each of the targets will execute the same target in the 2311638Srgrimes subdirectories. 2321638Srgrimes 2331638SrgrimesThe include file <bsd.prog.mk> includes the file named "../Makefile.inc" 2341638Srgrimesif it exists, as well as the include file <bsd.man.mk>. 2351638Srgrimes 2361638SrgrimesSome simple examples: 2371638Srgrimes 2381638SrgrimesTo build foo from foo.c with a manual page foo.1, use: 2391638Srgrimes 2401638Srgrimes PROG= foo 2411638Srgrimes 2421638Srgrimes .include <bsd.prog.mk> 2431638Srgrimes 2441638SrgrimesTo build foo from foo.c with a manual page foo.2, add the line: 2451638Srgrimes 2461638Srgrimes MAN2= foo.0 2471638Srgrimes 2481638SrgrimesIf foo does not have a manual page at all, add the line: 2491638Srgrimes 2501638Srgrimes NOMAN= noman 2511638Srgrimes 2521638SrgrimesIf foo has multiple source files, add the line: 2531638Srgrimes 2541638Srgrimes SRCS= a.c b.c c.c d.c 2551638Srgrimes 2561638Srgrimes=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 2571638Srgrimes 2581638SrgrimesThe include file <bsd.subdir.mk> contains the default targets for building 2591638Srgrimessubdirectories. It has the same seven targets as <bsd.prog.mk>: all, clean, 2601638Srgrimescleandir, depend, install, lint, and tags. For all of the directories 2611638Srgrimeslisted in the variable SUBDIRS, the specified directory will be visited 2621638Srgrimesand the target made. There is also a default target which allows the 2631638Srgrimescommand "make subdir" where subdir is any directory listed in the variable 2641638SrgrimesSUBDIRS. 2651638Srgrimes 2661638Srgrimes=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 2671638Srgrimes 2681638SrgrimesThe include file <bsd.lib.mk> has support for building libraries. It has 2691638Srgrimesthe same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend, 2701638Srgrimesinstall, lint, and tags. It has a limited number of suffixes, consistent 2711638Srgrimeswith the current needs of the BSD tree. 2721638Srgrimes 2731638SrgrimesIt sets/uses the following variables: 2741638Srgrimes 2751638SrgrimesLIBDIR Target directory for libraries. 2761638Srgrimes 2771638SrgrimesLINTLIBDIR Target directory for lint libraries. 2781638Srgrimes 2791638SrgrimesLIBGRP Library group. 2801638Srgrimes 2811638SrgrimesLIBOWN Library owner. 2821638Srgrimes 2831638SrgrimesLIBMODE Library mode. 2841638Srgrimes 2851638SrgrimesLDADD Additional loader objects. 2861638Srgrimes 2871638SrgrimesMAN1 ... MAN8 The manual pages to be installed (use a .0 suffix). 2881638Srgrimes 2891638SrgrimesSRCS List of source files to build the library. Suffix types 2901638Srgrimes .s, .c, and .f are supported. Note, .s files are preferred 2911638Srgrimes to .c files of the same name. (This is not the default for 2921638Srgrimes versions of make.) 2931638Srgrimes 2941638SrgrimesThe include file <bsd.lib.mk> includes the file named "../Makefile.inc" 2951638Srgrimesif it exists, as well as the include file <bsd.man.mk>. 2961638Srgrimes 2971638SrgrimesIt has rules for building profiled objects; profiled libraries are 2981638Srgrimesbuilt by default. 2991638Srgrimes 3001638SrgrimesLibraries are ranlib'd before installation. 301