do standard targets inline
[unix-history] / usr / src / share / mk / bsd.prog.mk
CommitLineData
3d68901b 1.include <bsd.global.mk>
272f5bac 2
3d68901b
KB
3.if exists(${.CURDIR}/../Makefile.inc)
4.include "${.CURDIR}/../Makefile.inc"
2cf63a09 5.endif
68cbfc75 6
3d68901b
KB
7LIBC?= /lib/libc.a
8LIBCOMPAT?= /usr/lib/libcompat.a
9LIBCURSES?= /usr/lib/libcurses.a
10LIBDBM?= /usr/lib/libdbm.a
11LIBDES?= /usr/lib/libdes.a
12LIBL?= /usr/lib/libl.a
13LIBKDB?= /usr/lib/libkdb.a
14LIBKRB?= /usr/lib/libkrb.a
15LIBM?= /usr/lib/libm.a
16LIBMP?= /usr/lib/libmp.a
17LIBPC?= /usr/lib/libpc.a
18LIBPLOT?= /usr/lib/libplot.a
19LIBRPC?= /usr/lib/sunrpc.a
20LIBTERM?= /usr/lib/libterm.a
21LIBUTIL?= /usr/lib/libutil.a
68cbfc75 22
9e327654 23.if defined(SRCS)
272f5bac 24
3d68901b 25OBJS+= ${SRCS:.c=.o}
2cf63a09 26
3d68901b
KB
27${PROG}: ${OBJS} ${LIBC} ${DPADD}
28 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
68cbfc75 29
9e327654
KB
30.else
31
32SRCS= ${PROG}.c
33
3d68901b
KB
34${PROG}: ${SRCS} ${LIBC} ${DPADD}
35 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
9e327654 36
3d68901b 37.endif
272f5bac 38
3d68901b
KB
39.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
40 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
41 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
42MAN1= ${PROG}.0
43.endif
44MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
9e327654 45
3d68901b
KB
46PROGSUBDIR: .USE
47.if defined(SUBDIR) && !empty(SUBDIR)
48 @for entry in ${SUBDIR}; do \
8d3c2d2e 49 (echo "===> ${PROG}/$$entry"; \
3d68901b
KB
50 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
51 cd ${.CURDIR}/$${entry}.${MACHINE}; \
52 else \
53 cd ${.CURDIR}/$${entry}; \
54 fi; \
55 ${MAKE} ${.TARGET}) \
56 done
57.endif
68cbfc75 58
3d68901b
KB
59.MAIN: all
60all: ${PROG} ${MANALL} PROGSUBDIR
9e327654 61
3d68901b
KB
62.if !target(clean)
63clean: PROGSUBDIR
64 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
65.endif
68cbfc75 66
8d3c2d2e
KB
67.if !target(cleandir)
68cleandir: PROGSUBDIR
3d68901b
KB
69 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
70 rm -f .depend ${.CURDIR}/tags ${MANALL}
8d3c2d2e 71.endif
9e327654 72
3d68901b 73# some of the rules involve .h sources, so remove them from mkdep line
8d3c2d2e
KB
74.if !target(depend)
75depend: .depend
76.depend: ${SRCS} PROGSUBDIR
3d68901b 77 mkdep ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
8d3c2d2e
KB
78.endif
79
80.if !target(install)
81.if !target(beforeinstall)
82beforeinstall:
83.endif
2cf63a09 84
8d3c2d2e 85realinstall: beforeinstall PROGSUBDIR
2cf63a09 86 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
9e327654 87 ${PROG} ${DESTDIR}${BINDIR}
3d68901b
KB
88.if defined(HIDEGAME)
89 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
90 chown games.bin ${PROG})
2cf63a09 91.endif
3d68901b 92
8d3c2d2e
KB
93install: afterinstall
94afterinstall: realinstall MANINSTALL
95.endif
96
97.if !target(lint)
98lint: ${SRCS} PROGSUBDIR
3d68901b 99 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
8d3c2d2e 100.endif
3d68901b 101
8d3c2d2e
KB
102.if !target(tags)
103tags: ${SRCS} PROGSUBDIR
104 ctags -f ${.CURDIR}/tags ${.ALLSRC}
105.endif
3d68901b
KB
106
107.include <bsd.own.mk>