Commit | Line | Data |
---|---|---|
560a63b9 | 1 | # @(#)bsd.prog.mk 5.25 (Berkeley) %G% |
4536b9e5 | 2 | |
3d68901b KB |
3 | .if exists(${.CURDIR}/../Makefile.inc) |
4 | .include "${.CURDIR}/../Makefile.inc" | |
2cf63a09 | 5 | .endif |
68cbfc75 | 6 | |
8ae45ce0 KB |
7 | .SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0 |
8 | ||
9 | .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0: | |
560a63b9 | 10 | /usr/old/bin/nroff -mandoc ${.IMPSRC} > ${.TARGET} |
8ae45ce0 KB |
11 | |
12 | CFLAGS+=${COPTS} | |
13 | ||
ddcabc30 KB |
14 | STRIP?= -s |
15 | ||
16 | BINGRP?= bin | |
17 | BINOWN?= bin | |
18 | BINMODE?= 555 | |
19 | ||
0699d1eb | 20 | LIBC?= /usr/lib/libc.a |
3d68901b KB |
21 | LIBCOMPAT?= /usr/lib/libcompat.a |
22 | LIBCURSES?= /usr/lib/libcurses.a | |
23 | LIBDBM?= /usr/lib/libdbm.a | |
24 | LIBDES?= /usr/lib/libdes.a | |
25 | LIBL?= /usr/lib/libl.a | |
26 | LIBKDB?= /usr/lib/libkdb.a | |
27 | LIBKRB?= /usr/lib/libkrb.a | |
28 | LIBM?= /usr/lib/libm.a | |
29 | LIBMP?= /usr/lib/libmp.a | |
30 | LIBPC?= /usr/lib/libpc.a | |
31 | LIBPLOT?= /usr/lib/libplot.a | |
1a57a1db | 32 | LIBRESOLV?= /usr/lib/libresolv.a |
3d68901b KB |
33 | LIBRPC?= /usr/lib/sunrpc.a |
34 | LIBTERM?= /usr/lib/libterm.a | |
35 | LIBUTIL?= /usr/lib/libutil.a | |
68cbfc75 | 36 | |
8ae45ce0 | 37 | .if defined(SHAREDSTRINGS) |
7aa8e083 | 38 | CLEANFILES+=strings |
8ae45ce0 | 39 | .c.o: |
78768172 | 40 | ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - |
8ae45ce0 KB |
41 | @${CC} ${CFLAGS} -c x.c -o ${.TARGET} |
42 | @rm -f x.c | |
43 | .endif | |
44 | ||
3a5e4842 | 45 | .if defined(PROG) |
9e327654 | 46 | .if defined(SRCS) |
272f5bac | 47 | |
91e72ef5 | 48 | OBJS+= ${SRCS:R:S/$/.o/g} |
2cf63a09 | 49 | |
3d68901b KB |
50 | ${PROG}: ${OBJS} ${LIBC} ${DPADD} |
51 | ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} | |
68cbfc75 | 52 | |
3a5e4842 | 53 | .else defined(PROG) |
9e327654 KB |
54 | |
55 | SRCS= ${PROG}.c | |
56 | ||
3d68901b KB |
57 | ${PROG}: ${SRCS} ${LIBC} ${DPADD} |
58 | ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD} | |
9e327654 | 59 | |
d89c9bc1 KB |
60 | MKDEP= -p |
61 | ||
3d68901b | 62 | .endif |
272f5bac | 63 | |
3d68901b KB |
64 | .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ |
65 | !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ | |
66 | !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) | |
67 | MAN1= ${PROG}.0 | |
68 | .endif | |
3a5e4842 | 69 | .endif |
3d68901b | 70 | MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} |
9e327654 | 71 | |
ddcabc30 | 72 | _PROGSUBDIR: .USE |
3d68901b KB |
73 | .if defined(SUBDIR) && !empty(SUBDIR) |
74 | @for entry in ${SUBDIR}; do \ | |
ddcabc30 | 75 | (echo "===> $$entry"; \ |
3d68901b KB |
76 | if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ |
77 | cd ${.CURDIR}/$${entry}.${MACHINE}; \ | |
78 | else \ | |
79 | cd ${.CURDIR}/$${entry}; \ | |
80 | fi; \ | |
c0835e32 | 81 | ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \ |
3d68901b KB |
82 | done |
83 | .endif | |
68cbfc75 | 84 | |
3d68901b | 85 | .MAIN: all |
ddcabc30 | 86 | all: ${PROG} ${MANALL} _PROGSUBDIR |
9e327654 | 87 | |
3d68901b | 88 | .if !target(clean) |
ddcabc30 | 89 | clean: _PROGSUBDIR |
3d68901b KB |
90 | rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} |
91 | .endif | |
68cbfc75 | 92 | |
8d3c2d2e | 93 | .if !target(cleandir) |
ddcabc30 | 94 | cleandir: _PROGSUBDIR |
3d68901b KB |
95 | rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} |
96 | rm -f .depend ${.CURDIR}/tags ${MANALL} | |
8d3c2d2e | 97 | .endif |
9e327654 | 98 | |
3d68901b | 99 | # some of the rules involve .h sources, so remove them from mkdep line |
8d3c2d2e | 100 | .if !target(depend) |
55633bd7 KB |
101 | depend: .depend _PROGSUBDIR |
102 | .depend: ${SRCS} | |
4a3b34cb | 103 | .if defined(PROG) |
d89c9bc1 | 104 | mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c} |
8d3c2d2e | 105 | .endif |
4a3b34cb | 106 | .endif |
8d3c2d2e KB |
107 | |
108 | .if !target(install) | |
109 | .if !target(beforeinstall) | |
110 | beforeinstall: | |
111 | .endif | |
ddcabc30 KB |
112 | .if !target(afterinstall) |
113 | afterinstall: | |
114 | .endif | |
2cf63a09 | 115 | |
ddcabc30 KB |
116 | realinstall: _PROGSUBDIR |
117 | .if defined(PROG) | |
2cf63a09 | 118 | install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ |
9e327654 | 119 | ${PROG} ${DESTDIR}${BINDIR} |
ddcabc30 | 120 | .endif |
3d68901b KB |
121 | .if defined(HIDEGAME) |
122 | (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ | |
123 | chown games.bin ${PROG}) | |
2cf63a09 | 124 | .endif |
ddcabc30 KB |
125 | .if defined(LINKS) && !empty(LINKS) |
126 | @set ${LINKS}; \ | |
127 | while test $$# -ge 2; do \ | |
128 | l=${DESTDIR}$$1; \ | |
129 | shift; \ | |
130 | t=${DESTDIR}$$1; \ | |
131 | shift; \ | |
132 | echo $$t -\> $$l; \ | |
133 | rm -f $$t; \ | |
134 | ln $$l $$t; \ | |
135 | done; true | |
136 | .endif | |
3d68901b | 137 | |
ddcabc30 KB |
138 | install: maninstall |
139 | maninstall: afterinstall | |
140 | afterinstall: realinstall | |
141 | realinstall: beforeinstall | |
8d3c2d2e KB |
142 | .endif |
143 | ||
144 | .if !target(lint) | |
ddcabc30 | 145 | lint: ${SRCS} _PROGSUBDIR |
4a3b34cb | 146 | .if defined(PROG) |
3d68901b | 147 | @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 |
8d3c2d2e | 148 | .endif |
4a3b34cb | 149 | .endif |
3d68901b | 150 | |
1a57a1db KB |
151 | .if !target(obj) |
152 | .if defined(NOOBJ) | |
153 | obj: _PROGSUBDIR | |
154 | .else | |
155 | obj: _PROGSUBDIR | |
156 | @cd ${.CURDIR}; rm -rf obj; \ | |
157 | here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ | |
2331ee59 KB |
158 | echo "$$here -> $$dest"; ln -s $$dest obj; \ |
159 | if test -d /usr/obj -a ! -d $$dest; then \ | |
160 | mkdir -p $$dest; \ | |
161 | else \ | |
162 | true; \ | |
163 | fi; | |
1a57a1db KB |
164 | .endif |
165 | .endif | |
166 | ||
8d3c2d2e | 167 | .if !target(tags) |
ddcabc30 | 168 | tags: ${SRCS} _PROGSUBDIR |
4a3b34cb | 169 | .if defined(PROG) |
1a57a1db | 170 | -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ |
fd716964 | 171 | sed "s;\${.CURDIR}/;;" > tags |
8d3c2d2e | 172 | .endif |
4a3b34cb | 173 | .endif |
3d68901b | 174 | |
ddcabc30 KB |
175 | .if !defined(NOMAN) |
176 | .include <bsd.man.mk> | |
177 | .endif |