if NOMAN is defined, need maninstall now
[unix-history] / usr / src / share / mk / bsd.prog.mk
CommitLineData
0c6b0741 1# @(#)bsd.prog.mk 5.29 (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:
b51db38c 10 nroff -man ${.IMPSRC} > ${.TARGET}
8ae45ce0
KB
11
12CFLAGS+=${COPTS}
13
ddcabc30
KB
14STRIP?= -s
15
16BINGRP?= bin
17BINOWN?= bin
18BINMODE?= 555
19
0699d1eb 20LIBC?= /usr/lib/libc.a
3d68901b
KB
21LIBCOMPAT?= /usr/lib/libcompat.a
22LIBCURSES?= /usr/lib/libcurses.a
23LIBDBM?= /usr/lib/libdbm.a
24LIBDES?= /usr/lib/libdes.a
25LIBL?= /usr/lib/libl.a
26LIBKDB?= /usr/lib/libkdb.a
27LIBKRB?= /usr/lib/libkrb.a
28LIBM?= /usr/lib/libm.a
29LIBMP?= /usr/lib/libmp.a
30LIBPC?= /usr/lib/libpc.a
31LIBPLOT?= /usr/lib/libplot.a
1a57a1db 32LIBRESOLV?= /usr/lib/libresolv.a
3d68901b
KB
33LIBRPC?= /usr/lib/sunrpc.a
34LIBTERM?= /usr/lib/libterm.a
35LIBUTIL?= /usr/lib/libutil.a
68cbfc75 36
8ae45ce0 37.if defined(SHAREDSTRINGS)
7aa8e083 38CLEANFILES+=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 48OBJS+= ${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
55SRCS= ${PROG}.c
56
3d68901b
KB
57${PROG}: ${SRCS} ${LIBC} ${DPADD}
58 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
9e327654 59
d89c9bc1
KB
60MKDEP= -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)
67MAN1= ${PROG}.0
68.endif
3a5e4842 69.endif
3d68901b 70MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
5052dbc8 71manpages: ${MANALL}
9e327654 72
ddcabc30 73_PROGSUBDIR: .USE
3d68901b
KB
74.if defined(SUBDIR) && !empty(SUBDIR)
75 @for entry in ${SUBDIR}; do \
ddcabc30 76 (echo "===> $$entry"; \
3d68901b
KB
77 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
78 cd ${.CURDIR}/$${entry}.${MACHINE}; \
79 else \
80 cd ${.CURDIR}/$${entry}; \
81 fi; \
c0835e32 82 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
3d68901b
KB
83 done
84.endif
68cbfc75 85
3d68901b 86.MAIN: all
ddcabc30 87all: ${PROG} ${MANALL} _PROGSUBDIR
9e327654 88
3d68901b 89.if !target(clean)
ddcabc30 90clean: _PROGSUBDIR
3d68901b
KB
91 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
92.endif
68cbfc75 93
8d3c2d2e 94.if !target(cleandir)
ddcabc30 95cleandir: _PROGSUBDIR
3d68901b 96 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
132db4d8 97 rm -f .depend ${MANALL}
8d3c2d2e 98.endif
9e327654 99
3d68901b 100# some of the rules involve .h sources, so remove them from mkdep line
8d3c2d2e 101.if !target(depend)
55633bd7
KB
102depend: .depend _PROGSUBDIR
103.depend: ${SRCS}
4a3b34cb 104.if defined(PROG)
d89c9bc1 105 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
8d3c2d2e 106.endif
4a3b34cb 107.endif
8d3c2d2e
KB
108
109.if !target(install)
110.if !target(beforeinstall)
111beforeinstall:
112.endif
ddcabc30
KB
113.if !target(afterinstall)
114afterinstall:
115.endif
2cf63a09 116
ddcabc30
KB
117realinstall: _PROGSUBDIR
118.if defined(PROG)
2cf63a09 119 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
9e327654 120 ${PROG} ${DESTDIR}${BINDIR}
ddcabc30 121.endif
3d68901b
KB
122.if defined(HIDEGAME)
123 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
124 chown games.bin ${PROG})
2cf63a09 125.endif
ddcabc30
KB
126.if defined(LINKS) && !empty(LINKS)
127 @set ${LINKS}; \
128 while test $$# -ge 2; do \
129 l=${DESTDIR}$$1; \
130 shift; \
131 t=${DESTDIR}$$1; \
132 shift; \
133 echo $$t -\> $$l; \
134 rm -f $$t; \
135 ln $$l $$t; \
136 done; true
137.endif
3d68901b 138
5052dbc8 139install: afterinstall maninstall
ddcabc30
KB
140afterinstall: realinstall
141realinstall: beforeinstall
8d3c2d2e
KB
142.endif
143
144.if !target(lint)
ddcabc30 145lint: ${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)
153obj: _PROGSUBDIR
154.else
155obj: _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
5052dbc8
MK
167.if !target(objdir)
168.if defined(NOOBJ)
169objdir: _PROGSUBDIR
170.else
171objdir: _PROGSUBDIR
172 @cd ${.CURDIR}; \
173 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
174 if test -d /usr/obj -a ! -d $$dest; then \
175 mkdir -p $$dest; \
176 else \
177 true; \
178 fi;
179.endif
180.endif
181
8d3c2d2e 182.if !target(tags)
ddcabc30 183tags: ${SRCS} _PROGSUBDIR
4a3b34cb 184.if defined(PROG)
1a57a1db 185 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
fd716964 186 sed "s;\${.CURDIR}/;;" > tags
8d3c2d2e 187.endif
4a3b34cb 188.endif
3d68901b 189
ddcabc30
KB
190.if !defined(NOMAN)
191.include <bsd.man.mk>
0c6b0741
KB
192.else
193maninstall:
ddcabc30 194.endif