Commit | Line | Data |
---|---|---|
9e327654 KB |
1 | # A Makefile for the BSD source tree. |
2 | # | |
ad89ed4a | 3 | # @(#)bsd.prog.mk 5.6 (Berkeley) %G% |
9e327654 | 4 | # |
2cf63a09 | 5 | |
9e327654 KB |
6 | # user defines: |
7 | # BINDIR, BINGRP, BINMODE, BINOWN | |
8 | # binary target directory, group, mode, owner | |
9 | # CLEANFILES | |
10 | # list of files to be removed for the target clean; used, | |
11 | # for example, to specify .c's produced from .y's. | |
12 | # LDLIB the list of libraries that the program loads, in the format | |
13 | # expected by the loader. | |
14 | # LINKS list of binary links of the form "link target link target"; | |
15 | # for example, "/bin/[ /usr/bin/test" would link /bin/[ to | |
16 | # /usr/bin/test"; not particularly labor saving, but prevents | |
17 | # needing your own install target. | |
18 | # MANDIR, MANMODE | |
19 | # manual page installation directory, mode | |
20 | # MLINKS list of man page links of the form "link target link target", | |
21 | # with some trickiness so the suffix specifies the directory to | |
22 | # use. For example, "a.1 b.2 c.3 d.4" would link ${MANDIR}1/a.0 | |
23 | # to ${MANDIR}2/b.0 and ${MANDIR}3/c.0 to ${MANDIR}4/d.0. | |
24 | # PROG program name | |
25 | # SHAREDSTRINGS | |
26 | # objects share strings using ${XSTR} | |
27 | # SRCS list of .c sources if the program has multiple files. | |
28 | # SRCLIB the list of libraries that the program depends on; normally | |
29 | # from the LIB* list in this file. | |
30 | # STRIP strip flag | |
31 | # | |
32 | # user macros: | |
33 | # STDALL standard all target | |
34 | # STDCLEAN | |
35 | # standard clean target | |
36 | # STDCLEANDIR | |
37 | # standard cleandir target | |
38 | # STDDEPEND | |
39 | # standard depend target | |
40 | # STDLINT | |
41 | # standard lint target | |
42 | # STDINSTALL | |
43 | # standard install target | |
44 | # STDTAGS standard tags target | |
45 | ||
46 | # permit a hierarchy of Makefile include files | |
47 | .if exists(../Make.include) | |
48 | .include "../Make.include" | |
49 | .endif | |
2cf63a09 | 50 | |
9e327654 KB |
51 | # name of the dependency file |
52 | DEPENDFILE= .depend | |
ad89ed4a KB |
53 | .if exists(.depend) |
54 | .include ".depend" | |
55 | .endif | |
272f5bac | 56 | |
9e327654 KB |
57 | # standard libraries |
58 | LIBC= /lib/libc.a | |
59 | LIBCOMPAT= /usr/lib/libcompat.a | |
60 | LIBDES= /usr/lib/libdes.a | |
61 | LIBKRB= /usr/lib/libkrb.a | |
62 | LIBMATH= /usr/lib/libm.a | |
63 | LIBUTIL= /usr/lib/libutil.a | |
68cbfc75 | 64 | |
9e327654 KB |
65 | # read-only version of standard .c.o rule |
66 | READONLY: .USE | |
67 | ${CC} ${CFLAGS} -c -R ${.IMPSRC} | |
2cf63a09 | 68 | |
9e327654 KB |
69 | # if the user defines SHAREDSTRINGS, they want objects to share strings. |
70 | # Turn off parallel makes (the strings file is single threaded) and | |
71 | # rewrite the .c.o rule to use XSTR to build the objects. | |
2cf63a09 KB |
72 | .if defined(SHAREDSTRINGS) |
73 | .NOTPARALLEL: | |
9e327654 | 74 | XSTR=/usr/bin/xstr |
2cf63a09 | 75 | .c.o: |
9e327654 KB |
76 | ${CC} -E ${CFLAGS} ${.IMPSRC} | ${XSTR} -c - |
77 | @${CC} ${CFLAGS} -c x.c -o ${.TARGET} | |
2cf63a09 KB |
78 | @rm -f x.c |
79 | .endif | |
68cbfc75 | 80 | |
9e327654 | 81 | # the default target. |
68cbfc75 | 82 | .MAIN: all |
2cf63a09 | 83 | |
9e327654 KB |
84 | # manual pages -- if the Makefile doesn't specify one, assume that they're |
85 | # named in a standard way, i.e. it's in section 1 with the same name as the | |
86 | # program. | |
87 | MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} | |
272f5bac | 88 | |
9e327654 KB |
89 | # In the BSD source tree, each program Makefile should specify PROG, the |
90 | # name of the program. | |
91 | all: ${PROG} | |
68cbfc75 | 92 | |
9e327654 | 93 | .if defined(SRCS) |
272f5bac | 94 | |
2cf63a09 | 95 | # if the program is composed of several object modules, the modules are |
9e327654 | 96 | # the list of sources with the .o's translated to .c's. |
68cbfc75 | 97 | OBJS= ${SRCS:.c=.o} |
272f5bac | 98 | |
9e327654 KB |
99 | .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && \ |
100 | !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8) | |
101 | MAN1= ${PROG}.0 | |
2cf63a09 KB |
102 | .endif |
103 | ||
9e327654 | 104 | ${PROG}: ${OBJS} ${LIBC} ${SRCLIB} |
2cf63a09 | 105 | ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDLIB} |
272f5bac | 106 | |
c27da6a8 | 107 | .depend: ${SRCS} |
ad89ed4a KB |
108 | @set ${OBJS}; \ |
109 | for entry in ${.ALLSRC}; do \ | |
9e327654 | 110 | echo "$$1:" \ |
ad89ed4a KB |
111 | `${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} $$entry`; \ |
112 | shift; \ | |
9e327654 | 113 | done > ${DEPENDFILE} |
272f5bac | 114 | |
68cbfc75 KB |
115 | ${OBJS}: ${.PREFIX}.c |
116 | ||
9e327654 KB |
117 | .else |
118 | ||
119 | SRCS= ${PROG}.c | |
120 | ||
121 | .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && \ | |
122 | !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8) | |
123 | MAN1= ${PROG}.0 | |
124 | .endif | |
125 | ||
126 | ${PROG}: ${SRCS} ${LIBC} ${SRCLIB} | |
ad89ed4a | 127 | ${CC} ${CFLAGS} -o ${.TARGET} ${CURDIR}/${SRCS} ${LDLIB} |
9e327654 KB |
128 | |
129 | .depend: ${SRCS} | |
ad89ed4a | 130 | @echo "${PROG}:" \ |
9e327654 KB |
131 | `${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC}` \ |
132 | > ${DEPENDFILE} | |
133 | ||
134 | .endif # defined(SRCS) | |
272f5bac | 135 | |
9e327654 | 136 | # standard targets |
c27da6a8 KB |
137 | depend: .depend |
138 | ||
9e327654 KB |
139 | STDCLEAN: .USE |
140 | rm -f a.out Errs errs mklog core ${CLEANFILES} ${PROG} ${OBJS} | |
141 | ||
142 | clean: STDCLEAN | |
143 | ||
144 | STDCLEANDIR: .USE | |
272f5bac KB |
145 | rm -f ${MANALL} ${TAGSFILE} ${DEPENDFILE} |
146 | ||
9e327654 KB |
147 | cleandir: clean STDCLEANDIR |
148 | ||
149 | LINTFLAGS=-chapbx | |
150 | STDLINT: .USE | |
68cbfc75 KB |
151 | lint ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} |
152 | ||
9e327654 KB |
153 | lint: ${SRCS} STDLINT |
154 | ||
155 | TAGSFILE=tags | |
156 | STDTAGS: .USE | |
68cbfc75 KB |
157 | ctags ${.ALLSRC} |
158 | ||
9e327654 KB |
159 | tags: ${SRCS} STDTAGS |
160 | ||
161 | MANDIR?= /usr/share/man/cat | |
2cf63a09 KB |
162 | MANMODE?= 444 |
163 | STRIP?= -s | |
164 | BINMODE?= 755 | |
165 | BINOWN?= bin | |
166 | BINGRP?= bin | |
167 | ||
168 | # install target -- creates manual pages, then installs the binaries, | |
9e327654 KB |
169 | # links, manual pages, and manual page links. |
170 | STDINSTALL: .USE | |
2cf63a09 | 171 | install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ |
9e327654 | 172 | ${PROG} ${DESTDIR}${BINDIR} |
272f5bac | 173 | .if defined(MAN1) |
2cf63a09 | 174 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN1} \ |
9e327654 | 175 | ${DESTDIR}${MANDIR}1 |
2cf63a09 | 176 | .endif |
272f5bac | 177 | .if defined(MAN2) |
2cf63a09 | 178 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN2} \ |
9e327654 | 179 | ${DESTDIR}${MANDIR}2 |
2cf63a09 | 180 | .endif |
272f5bac | 181 | .if defined(MAN3) |
2cf63a09 | 182 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN3} \ |
9e327654 | 183 | ${DESTDIR}${MANDIR}3 |
2cf63a09 | 184 | .endif |
272f5bac | 185 | .if defined(MAN4) |
2cf63a09 | 186 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN4} \ |
9e327654 | 187 | ${DESTDIR}${MANDIR}4 |
2cf63a09 | 188 | .endif |
272f5bac | 189 | .if defined(MAN5) |
2cf63a09 | 190 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN5} \ |
9e327654 | 191 | ${DESTDIR}${MANDIR}5 |
2cf63a09 | 192 | .endif |
272f5bac | 193 | .if defined(MAN6) |
2cf63a09 | 194 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN6} \ |
9e327654 | 195 | ${DESTDIR}${MANDIR}6 |
2cf63a09 | 196 | .endif |
272f5bac | 197 | .if defined(MAN7) |
2cf63a09 | 198 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN7} \ |
9e327654 | 199 | ${DESTDIR}${MANDIR}7 |
272f5bac | 200 | .endif |
2cf63a09 KB |
201 | .if defined(MAN8) |
202 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN8} \ | |
9e327654 | 203 | ${DESTDIR}${MANDIR}8 |
272f5bac | 204 | .endif |
2cf63a09 | 205 | .if defined(LINKS) |
9e327654 KB |
206 | @set ${LINKS}; \ |
207 | while test $$# -ge 2; do \ | |
208 | t=$$1; \ | |
209 | shift; \ | |
210 | l=$$1; \ | |
211 | shift; \ | |
212 | echo $$l -\> $$t; \ | |
213 | rm -f $$t; \ | |
214 | ln ${DESTDIR}$$l ${DESTDIR}$$t; \ | |
215 | done; true | |
c27da6a8 KB |
216 | .endif # LINKS |
217 | .if defined(MLINKS) | |
9e327654 KB |
218 | @set ${MLINKS}; \ |
219 | while test $$# -ge 2; do \ | |
220 | name=$$1; \ | |
221 | shift; \ | |
222 | dir=${MANDIR}`expr $$name : '[^\.]*\.\(.*\)'`; \ | |
223 | t=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0; \ | |
224 | name=$$1; \ | |
225 | shift; \ | |
226 | dir=${MANDIR}`expr $$name : '[^\.]*\.\(.*\)'`; \ | |
227 | l=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0; \ | |
228 | echo $$l -\> $$t; \ | |
229 | rm -f $$t; \ | |
230 | ln $$l $$t; \ | |
231 | done; true | |
c27da6a8 | 232 | .endif # MLINKS |
9e327654 KB |
233 | |
234 | install: ${MANALL} STDINSTALL |