don't use an obj directory, add bsd.doc.mk
[unix-history] / usr / src / share / mk / bsd.prog.mk
CommitLineData
78768172 1# @(#)bsd.prog.mk 5.16 (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:
10 nroff -man -h ${.IMPSRC} > ${.TARGET}
11
12CFLAGS+=${COPTS}
13
ddcabc30
KB
14STRIP?= -s
15
16BINGRP?= bin
17BINOWN?= bin
18BINMODE?= 555
19
3d68901b
KB
20LIBC?= /lib/libc.a
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
32LIBRPC?= /usr/lib/sunrpc.a
33LIBTERM?= /usr/lib/libterm.a
34LIBUTIL?= /usr/lib/libutil.a
68cbfc75 35
8ae45ce0
KB
36.if defined(SHAREDSTRINGS)
37.c.o:
78768172 38 ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
8ae45ce0
KB
39 @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
40 @rm -f x.c
41.endif
42
3a5e4842 43.if defined(PROG)
9e327654 44.if defined(SRCS)
272f5bac 45
3d68901b 46OBJS+= ${SRCS:.c=.o}
2cf63a09 47
3d68901b
KB
48${PROG}: ${OBJS} ${LIBC} ${DPADD}
49 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
68cbfc75 50
3a5e4842 51.else defined(PROG)
9e327654
KB
52
53SRCS= ${PROG}.c
54
3d68901b
KB
55${PROG}: ${SRCS} ${LIBC} ${DPADD}
56 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
9e327654 57
3d68901b 58.endif
272f5bac 59
3d68901b
KB
60.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
61 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
62 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
63MAN1= ${PROG}.0
64.endif
3a5e4842 65.endif
3d68901b 66MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
9e327654 67
ddcabc30 68_PROGSUBDIR: .USE
3d68901b
KB
69.if defined(SUBDIR) && !empty(SUBDIR)
70 @for entry in ${SUBDIR}; do \
ddcabc30 71 (echo "===> $$entry"; \
3d68901b
KB
72 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
73 cd ${.CURDIR}/$${entry}.${MACHINE}; \
74 else \
75 cd ${.CURDIR}/$${entry}; \
76 fi; \
4a3b34cb 77 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}) \
3d68901b
KB
78 done
79.endif
68cbfc75 80
3d68901b 81.MAIN: all
ddcabc30 82all: ${PROG} ${MANALL} _PROGSUBDIR
9e327654 83
3d68901b 84.if !target(clean)
ddcabc30 85clean: _PROGSUBDIR
3d68901b
KB
86 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
87.endif
68cbfc75 88
8d3c2d2e 89.if !target(cleandir)
ddcabc30 90cleandir: _PROGSUBDIR
3d68901b
KB
91 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
92 rm -f .depend ${.CURDIR}/tags ${MANALL}
8d3c2d2e 93.endif
9e327654 94
3d68901b 95# some of the rules involve .h sources, so remove them from mkdep line
8d3c2d2e 96.if !target(depend)
55633bd7
KB
97depend: .depend _PROGSUBDIR
98.depend: ${SRCS}
4a3b34cb 99.if defined(PROG)
3d68901b 100 mkdep ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
8d3c2d2e 101.endif
4a3b34cb 102.endif
8d3c2d2e
KB
103
104.if !target(install)
105.if !target(beforeinstall)
106beforeinstall:
107.endif
ddcabc30
KB
108.if !target(afterinstall)
109afterinstall:
110.endif
2cf63a09 111
ddcabc30
KB
112realinstall: _PROGSUBDIR
113.if defined(PROG)
2cf63a09 114 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
9e327654 115 ${PROG} ${DESTDIR}${BINDIR}
ddcabc30 116.endif
3d68901b
KB
117.if defined(HIDEGAME)
118 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
119 chown games.bin ${PROG})
2cf63a09 120.endif
ddcabc30
KB
121.if defined(LINKS) && !empty(LINKS)
122 @set ${LINKS}; \
123 while test $$# -ge 2; do \
124 l=${DESTDIR}$$1; \
125 shift; \
126 t=${DESTDIR}$$1; \
127 shift; \
128 echo $$t -\> $$l; \
129 rm -f $$t; \
130 ln $$l $$t; \
131 done; true
132.endif
3d68901b 133
ddcabc30
KB
134install: maninstall
135maninstall: afterinstall
136afterinstall: realinstall
137realinstall: beforeinstall
8d3c2d2e
KB
138.endif
139
140.if !target(lint)
ddcabc30 141lint: ${SRCS} _PROGSUBDIR
4a3b34cb 142.if defined(PROG)
3d68901b 143 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
8d3c2d2e 144.endif
4a3b34cb 145.endif
3d68901b 146
8d3c2d2e 147.if !target(tags)
ddcabc30 148tags: ${SRCS} _PROGSUBDIR
4a3b34cb 149.if defined(PROG)
fd716964
KB
150 cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
151 sed "s;\${.CURDIR}/;;" > tags
8d3c2d2e 152.endif
4a3b34cb 153.endif
3d68901b 154
ddcabc30
KB
155.if !defined(NOMAN)
156.include <bsd.man.mk>
157.endif