Commit | Line | Data |
---|---|---|
714d1155 | 1 | # @(#)bsd.prog.mk 8.2 (Berkeley) %G% |
4536b9e5 | 2 | |
4295ebc7 | 3 | .if !defined(NOINCLUDE) && exists(${.CURDIR}/../Makefile.inc) |
3d68901b | 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: | |
b51db38c | 10 | nroff -man ${.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 | |
ffae3743 | 28 | LIBKVM?= /usr/lib/libkvm.a |
3d68901b KB |
29 | LIBM?= /usr/lib/libm.a |
30 | LIBMP?= /usr/lib/libmp.a | |
31 | LIBPC?= /usr/lib/libpc.a | |
32 | LIBPLOT?= /usr/lib/libplot.a | |
1a57a1db | 33 | LIBRESOLV?= /usr/lib/libresolv.a |
3d68901b KB |
34 | LIBRPC?= /usr/lib/sunrpc.a |
35 | LIBTERM?= /usr/lib/libterm.a | |
36 | LIBUTIL?= /usr/lib/libutil.a | |
68cbfc75 | 37 | |
8ae45ce0 | 38 | .if defined(SHAREDSTRINGS) |
7aa8e083 | 39 | CLEANFILES+=strings |
8ae45ce0 | 40 | .c.o: |
78768172 | 41 | ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - |
8ae45ce0 KB |
42 | @${CC} ${CFLAGS} -c x.c -o ${.TARGET} |
43 | @rm -f x.c | |
44 | .endif | |
45 | ||
3a5e4842 | 46 | .if defined(PROG) |
9e327654 | 47 | .if defined(SRCS) |
272f5bac | 48 | |
91e72ef5 | 49 | OBJS+= ${SRCS:R:S/$/.o/g} |
2cf63a09 | 50 | |
3d68901b KB |
51 | ${PROG}: ${OBJS} ${LIBC} ${DPADD} |
52 | ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} | |
68cbfc75 | 53 | |
08591414 | 54 | .else defined(SRCS) |
9e327654 KB |
55 | |
56 | SRCS= ${PROG}.c | |
57 | ||
3d68901b KB |
58 | ${PROG}: ${SRCS} ${LIBC} ${DPADD} |
59 | ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD} | |
9e327654 | 60 | |
d89c9bc1 KB |
61 | MKDEP= -p |
62 | ||
3d68901b | 63 | .endif |
272f5bac | 64 | |
3d68901b KB |
65 | .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ |
66 | !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ | |
67 | !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) | |
68 | MAN1= ${PROG}.0 | |
69 | .endif | |
3a5e4842 | 70 | .endif |
922eb42d | 71 | .if !defined(NOMAN) |
3d68901b | 72 | MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} |
922eb42d KB |
73 | .else |
74 | MANALL= | |
75 | .endif | |
5052dbc8 | 76 | manpages: ${MANALL} |
9e327654 | 77 | |
ddcabc30 | 78 | _PROGSUBDIR: .USE |
3d68901b KB |
79 | .if defined(SUBDIR) && !empty(SUBDIR) |
80 | @for entry in ${SUBDIR}; do \ | |
ddcabc30 | 81 | (echo "===> $$entry"; \ |
3d68901b KB |
82 | if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ |
83 | cd ${.CURDIR}/$${entry}.${MACHINE}; \ | |
84 | else \ | |
85 | cd ${.CURDIR}/$${entry}; \ | |
86 | fi; \ | |
c0835e32 | 87 | ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \ |
3d68901b KB |
88 | done |
89 | .endif | |
68cbfc75 | 90 | |
08591414 | 91 | .if !target(all) |
3d68901b | 92 | .MAIN: all |
ddcabc30 | 93 | all: ${PROG} ${MANALL} _PROGSUBDIR |
08591414 | 94 | .endif |
9e327654 | 95 | |
3d68901b | 96 | .if !target(clean) |
ddcabc30 | 97 | clean: _PROGSUBDIR |
714d1155 | 98 | rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES} |
3d68901b | 99 | .endif |
68cbfc75 | 100 | |
8d3c2d2e | 101 | .if !target(cleandir) |
ddcabc30 | 102 | cleandir: _PROGSUBDIR |
714d1155 | 103 | rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES} |
132db4d8 | 104 | rm -f .depend ${MANALL} |
8d3c2d2e | 105 | .endif |
9e327654 | 106 | |
3d68901b | 107 | # some of the rules involve .h sources, so remove them from mkdep line |
8d3c2d2e | 108 | .if !target(depend) |
55633bd7 KB |
109 | depend: .depend _PROGSUBDIR |
110 | .depend: ${SRCS} | |
4a3b34cb | 111 | .if defined(PROG) |
d89c9bc1 | 112 | mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c} |
8d3c2d2e | 113 | .endif |
4a3b34cb | 114 | .endif |
8d3c2d2e KB |
115 | |
116 | .if !target(install) | |
117 | .if !target(beforeinstall) | |
118 | beforeinstall: | |
119 | .endif | |
ddcabc30 KB |
120 | .if !target(afterinstall) |
121 | afterinstall: | |
122 | .endif | |
2cf63a09 | 123 | |
ddcabc30 KB |
124 | realinstall: _PROGSUBDIR |
125 | .if defined(PROG) | |
2cf63a09 | 126 | install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ |
4dabe641 | 127 | ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} |
ddcabc30 | 128 | .endif |
3d68901b KB |
129 | .if defined(HIDEGAME) |
130 | (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ | |
131 | chown games.bin ${PROG}) | |
2cf63a09 | 132 | .endif |
ddcabc30 KB |
133 | .if defined(LINKS) && !empty(LINKS) |
134 | @set ${LINKS}; \ | |
135 | while test $$# -ge 2; do \ | |
136 | l=${DESTDIR}$$1; \ | |
137 | shift; \ | |
138 | t=${DESTDIR}$$1; \ | |
139 | shift; \ | |
140 | echo $$t -\> $$l; \ | |
141 | rm -f $$t; \ | |
142 | ln $$l $$t; \ | |
143 | done; true | |
144 | .endif | |
3d68901b | 145 | |
5052dbc8 | 146 | install: afterinstall maninstall |
ddcabc30 KB |
147 | afterinstall: realinstall |
148 | realinstall: beforeinstall | |
8d3c2d2e KB |
149 | .endif |
150 | ||
151 | .if !target(lint) | |
ddcabc30 | 152 | lint: ${SRCS} _PROGSUBDIR |
4a3b34cb | 153 | .if defined(PROG) |
3d68901b | 154 | @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 |
8d3c2d2e | 155 | .endif |
4a3b34cb | 156 | .endif |
3d68901b | 157 | |
1a57a1db KB |
158 | .if !target(obj) |
159 | .if defined(NOOBJ) | |
160 | obj: _PROGSUBDIR | |
161 | .else | |
162 | obj: _PROGSUBDIR | |
163 | @cd ${.CURDIR}; rm -rf obj; \ | |
164 | here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ | |
2331ee59 KB |
165 | echo "$$here -> $$dest"; ln -s $$dest obj; \ |
166 | if test -d /usr/obj -a ! -d $$dest; then \ | |
167 | mkdir -p $$dest; \ | |
168 | else \ | |
169 | true; \ | |
170 | fi; | |
1a57a1db KB |
171 | .endif |
172 | .endif | |
173 | ||
5052dbc8 MK |
174 | .if !target(objdir) |
175 | .if defined(NOOBJ) | |
176 | objdir: _PROGSUBDIR | |
177 | .else | |
178 | objdir: _PROGSUBDIR | |
179 | @cd ${.CURDIR}; \ | |
180 | here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ | |
181 | if test -d /usr/obj -a ! -d $$dest; then \ | |
182 | mkdir -p $$dest; \ | |
183 | else \ | |
184 | true; \ | |
185 | fi; | |
186 | .endif | |
187 | .endif | |
188 | ||
8d3c2d2e | 189 | .if !target(tags) |
ddcabc30 | 190 | tags: ${SRCS} _PROGSUBDIR |
4a3b34cb | 191 | .if defined(PROG) |
b57a5874 KB |
192 | -ctags -f /dev/stdout ${.ALLSRC} | \ |
193 | sed "s;${.CURDIR}/;;" > ${.CURDIR}/tags | |
8d3c2d2e | 194 | .endif |
4a3b34cb | 195 | .endif |
3d68901b | 196 | |
ddcabc30 KB |
197 | .if !defined(NOMAN) |
198 | .include <bsd.man.mk> | |
0c6b0741 KB |
199 | .else |
200 | maninstall: | |
ddcabc30 | 201 | .endif |