Commit | Line | Data |
---|---|---|
2cf63a09 KB |
1 | |
2 | MAKE= pmake # for now... | |
c27da6a8 | 3 | CPP= newcpp |
2cf63a09 KB |
4 | |
5 | # libraries used for dependency lines | |
68cbfc75 | 6 | LIBUTIL= /usr/lib/libutil.a |
2cf63a09 KB |
7 | LIBMATH= /usr/lib/libm.a |
8 | LIBKRB= /usr/lib/libkrb.a | |
9 | LIBDES= /usr/lib/libdes.a | |
10 | LIBCOMPAT= /usr/lib/libcompat.a | |
272f5bac | 11 | |
2cf63a09 KB |
12 | # any specified manual pages -- if none have been specified at this point, |
13 | # we make assumptions about what they are and what they're called. | |
14 | MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} | |
68cbfc75 | 15 | |
2cf63a09 KB |
16 | # user defines: |
17 | # SUBDIR -- the list of subdirectories to be processed | |
18 | # | |
19 | # if SUBDIR is set, we're in a makefile that processes subdirectories; | |
20 | # for all the standard targets, change to the subdirectory and make the | |
21 | # target. If making one of the subdirectories, change to it and make | |
22 | # the target "all". Machine dependent subdirectories take precedence | |
23 | # over standard subdirectories. | |
24 | .if defined(SUBDIR) | |
c27da6a8 | 25 | all depend clean cleandir lint install tags: |
2cf63a09 | 26 | @for entry in ${SUBDIR}; do |
c27da6a8 | 27 | (echo "====> $$entry" |
2cf63a09 KB |
28 | if test -d $${entry}.${MACHINE}; then |
29 | cd $${entry}.${MACHINE} | |
30 | else | |
31 | cd $${entry} | |
32 | fi | |
33 | ${MAKE} ${.TARGET}) | |
34 | done | |
68cbfc75 | 35 | |
2cf63a09 KB |
36 | ${SUBDIR}: |
37 | @if test -d ${.TARGET}.${MACHINE}; then | |
38 | cd ${.TARGET}.${MACHINE} | |
39 | else | |
40 | cd ${.TARGET} | |
41 | fi | |
42 | ${MAKE} all | |
43 | ||
44 | .else # !SUBDIR | |
45 | ||
46 | # user defines: | |
47 | # SHAREDSTRINGS -- boolean variable, if sharing strings in objects. | |
48 | # | |
49 | # if SHAREDSTRINGS is defined, use XSTR to build objects. | |
50 | # | |
51 | .if defined(SHAREDSTRINGS) | |
52 | .NOTPARALLEL: | |
53 | XSTR= xstr | |
54 | .c.o: | |
55 | ${CC} -E ${.INCLUDES} ${CFLAGS} ${.IMPSRC} | ${XSTR} -c - | |
56 | @${CC} ${.INCLUDES} ${CFLAGS} -c x.c -o ${.TARGET} | |
57 | @rm -f x.c | |
58 | .endif | |
68cbfc75 | 59 | |
2cf63a09 | 60 | # the default target is all |
68cbfc75 | 61 | .MAIN: all |
2cf63a09 KB |
62 | |
63 | # user defines: | |
64 | # PROGC -- the name of a program composed of a single source module | |
65 | # PROGO -- the name of a program composed of several object modules | |
66 | # SRCLIB -- the list of libraries that the program depends on; | |
67 | # normally from the LIB* list at the top of this file. | |
68 | # LDLIB -- the list of libraries that the program loads, in the | |
69 | # format expected by the loader. | |
70 | ||
272f5bac KB |
71 | all: ${PROGC} ${PROGO} |
72 | ||
2cf63a09 KB |
73 | # if the program is composed of a single source module, that module is |
74 | # C source with the same name as the program. If no manual pages have | |
75 | # been defined, it's in section 1 with the same name as the program. | |
272f5bac KB |
76 | .if defined(PROGC) |
77 | SRCS= ${PROGC}.c | |
78 | ||
c27da6a8 | 79 | .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8) |
2cf63a09 KB |
80 | MAN1= ${PROGC}.0 |
81 | .endif | |
272f5bac | 82 | |
2cf63a09 KB |
83 | ${PROGC}: ${SRCS} ${LIBC} ${SRCLIB} |
84 | ${CC} ${CFLAGS} -o ${.TARGET} ${SRCS} ${LDLIB} | |
272f5bac | 85 | |
c27da6a8 KB |
86 | .depend: ${SRCS} |
87 | set - | |
88 | ${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC} | | |
89 | sed "s/^/${PROGC}: /" > ${DEPENDFILE}.new | |
90 | mv ${DEPENDFILE}.new ${DEPENDFILE} | |
68cbfc75 | 91 | |
2cf63a09 | 92 | .endif # PROGC |
272f5bac | 93 | |
2cf63a09 KB |
94 | # if the program is composed of several object modules, the modules are |
95 | # the list of sources with the .o's translated to .c's. If no manual | |
96 | # pages have been defined, it's in section 1 with the same name as the | |
97 | # program. Objects depend on their C source counterparts. | |
68cbfc75 | 98 | .if defined(PROGO) |
2cf63a09 | 99 | |
68cbfc75 | 100 | OBJS= ${SRCS:.c=.o} |
272f5bac | 101 | |
c27da6a8 | 102 | .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8) |
2cf63a09 KB |
103 | MAN1= ${PROGO}.0 |
104 | .endif | |
105 | ||
68cbfc75 | 106 | ${PROGO}: ${OBJS} ${LIBC} ${SRCLIB} |
2cf63a09 | 107 | ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDLIB} |
272f5bac | 108 | |
c27da6a8 KB |
109 | .depend: ${SRCS} |
110 | set - | |
111 | set ${OBJS} | |
112 | rm -f ${DEPENDFILE}.new | |
113 | for entry in ${.ALLSRC}; do | |
114 | ${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} $$entry | | |
115 | sed "s/^/$$1: /" >> ${DEPENDFILE}.new | |
116 | shift | |
117 | done | |
118 | mv ${DEPENDFILE}.new ${DEPENDFILE} | |
272f5bac | 119 | |
68cbfc75 KB |
120 | ${OBJS}: ${.PREFIX}.c |
121 | ||
2cf63a09 | 122 | .endif # PROGO |
272f5bac | 123 | |
c27da6a8 KB |
124 | depend: .depend |
125 | ||
2cf63a09 KB |
126 | # user defines: |
127 | # CLEANFILES -- list of files to be removed for the target clean; | |
128 | # used, for example, to specify .c's produced from | |
129 | # .y's. | |
c27da6a8 | 130 | JUNKFILES= a.out Errs errs mklog core |
2cf63a09 | 131 | clean: |
c27da6a8 | 132 | rm -f ${PROGC} ${PROGO} ${OBJS} ${CLEANFILES} ${JUNKFILES} |
272f5bac | 133 | |
2cf63a09 | 134 | TAGSFILE= tags |
272f5bac KB |
135 | cleandir: clean |
136 | rm -f ${MANALL} ${TAGSFILE} ${DEPENDFILE} | |
137 | ||
68cbfc75 KB |
138 | LINTFLAGS= -chapbx |
139 | lint: ${SRCS} | |
140 | lint ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | |
141 | ||
68cbfc75 KB |
142 | tags: ${SRCS} |
143 | ctags ${.ALLSRC} | |
144 | ||
2cf63a09 | 145 | # user defines: |
c27da6a8 | 146 | # MDIR -- default manual page installation directory |
2cf63a09 KB |
147 | # MANMODE -- default manual page installation mode |
148 | # STRIP -- default strip flag | |
149 | # BINMODE -- default binary installation mode | |
150 | # BINOWN -- default binary owner | |
151 | # BINGRP -- default binary group | |
c27da6a8 | 152 | MDIR?= /usr/share/man/cat |
2cf63a09 KB |
153 | MANMODE?= 444 |
154 | STRIP?= -s | |
155 | BINMODE?= 755 | |
156 | BINOWN?= bin | |
157 | BINGRP?= bin | |
158 | ||
159 | # install target -- creates manual pages, then installs the binaries, | |
160 | # manual pages, and manual page links. | |
272f5bac | 161 | install: ${MANALL} |
2cf63a09 | 162 | install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ |
68cbfc75 | 163 | ${PROGC} ${PROGO} ${DESTDIR}${DIR} |
272f5bac | 164 | .if defined(MAN1) |
2cf63a09 KB |
165 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN1} \ |
166 | ${DESTDIR}${MDIR}1 | |
167 | .endif | |
272f5bac | 168 | .if defined(MAN2) |
2cf63a09 KB |
169 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN2} \ |
170 | ${DESTDIR}${MDIR}2 | |
171 | .endif | |
272f5bac | 172 | .if defined(MAN3) |
2cf63a09 KB |
173 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN3} \ |
174 | ${DESTDIR}${MDIR}3 | |
175 | .endif | |
272f5bac | 176 | .if defined(MAN4) |
2cf63a09 KB |
177 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN4} \ |
178 | ${DESTDIR}${MDIR}4 | |
179 | .endif | |
272f5bac | 180 | .if defined(MAN5) |
2cf63a09 KB |
181 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN5} \ |
182 | ${DESTDIR}${MDIR}5 | |
183 | .endif | |
272f5bac | 184 | .if defined(MAN6) |
2cf63a09 KB |
185 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN6} \ |
186 | ${DESTDIR}${MDIR}6 | |
187 | .endif | |
272f5bac | 188 | .if defined(MAN7) |
2cf63a09 KB |
189 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN7} \ |
190 | ${DESTDIR}${MDIR}7 | |
272f5bac | 191 | .endif |
2cf63a09 KB |
192 | .if defined(MAN8) |
193 | install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN8} \ | |
194 | ${DESTDIR}${MDIR}8 | |
272f5bac | 195 | .endif |
2cf63a09 | 196 | # user defines: |
c27da6a8 KB |
197 | # LINKS -- list of binary links of the form "link target |
198 | # link target"; for example, "/bin/[ /usr/bin/test" | |
199 | # would link /bin/[ to /usr/bin/test"; not particularly | |
200 | # labor saving, but prevents needing your own install | |
201 | # target. | |
202 | # MLINKS -- list of manual page linkes of the form "link target | |
2cf63a09 KB |
203 | # link target"; for example, "a.1 b.2 c.3 d.4" would |
204 | # link ${MDIR}1/a.0 to ${MDIR}2/b.0 and ${MDIR}3/c.0 | |
205 | # to ${MDIR}4/d.0. | |
206 | .if defined(LINKS) | |
c27da6a8 KB |
207 | @set ${LINKS} |
208 | @while :; do | |
209 | if `test $$# -lt 2`; then | |
210 | break; | |
211 | fi | |
212 | t=$$1 | |
213 | shift | |
214 | l=$$1 | |
215 | shift | |
216 | echo $$l -\> $$t | |
217 | rm -f $$t | |
218 | ln ${DESTDIR}$$l ${DESTDIR}$$t | |
219 | done | |
220 | .endif # LINKS | |
221 | .if defined(MLINKS) | |
222 | @set ${MLINKS} | |
2cf63a09 KB |
223 | @while :; do |
224 | if `test $$# -lt 2`; then | |
225 | break; | |
226 | fi | |
227 | name=$$1 | |
2cf63a09 | 228 | shift |
c27da6a8 KB |
229 | dir=${MDIR}`expr $$name : '[^\.]*\.\(.*\)'` |
230 | t=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0 | |
2cf63a09 | 231 | name=$$1 |
c27da6a8 KB |
232 | shift |
233 | dir=${MDIR}`expr $$name : '[^\.]*\.\(.*\)'` | |
2cf63a09 | 234 | l=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0 |
2cf63a09 | 235 | echo $$l -\> $$t |
c27da6a8 | 236 | rm -f $$t |
2cf63a09 | 237 | ln $$l $$t |
2cf63a09 | 238 | done |
c27da6a8 | 239 | .endif # MLINKS |
2cf63a09 | 240 | .endif # SUBDIR |