bsd.prog.mk revision 27782
1#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.prog.mk,v 1.52 1997/06/28 08:14:10 pst Exp $
3
4.if exists(${.CURDIR}/../Makefile.inc)
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
8.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9
10CFLAGS+=${COPTS} ${DEBUG_FLAGS}
11.if defined(DESTDIR)
12CFLAGS+= -I${DESTDIR}/usr/include
13CXXINCLUDES+= -I${DESTDIR}/usr/include/g++
14.endif
15
16.if !defined(DEBUG_FLAGS)
17STRIP?=	-s
18.endif
19
20.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
21LDFLAGS+= -static
22.endif
23
24.if defined(PROG)
25.if defined(SRCS)
26
27DPSRCS+= ${SRCS:M*.h}
28OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
29
30${PROG}: ${DPSRCS} ${OBJS}
31	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
32
33.else !defined(SRCS)
34
35SRCS=	${PROG}.c
36
37# Always make an intermediate object file because:
38# - it saves time rebuilding when only the library has changed
39# - the name of the object gets put into the executable symbol table instead of
40#   the name of a variable temporary object.
41# - it's useful to keep objects around for crunching.
42OBJS=	${PROG}.o
43${PROG}: ${DPSRCS} ${OBJS}
44	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
45
46.endif
47
48.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
49	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
50	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
51MAN1=	${PROG}.1
52.endif
53.endif
54
55.MAIN: all
56all: objwarn ${PROG} all-man _SUBDIR
57
58.if !target(clean)
59clean: _SUBDIR
60	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 
61.if defined(CLEANDIRS) && !empty(CLEANDIRS)
62	rm -rf ${CLEANDIRS}
63.endif
64.endif
65
66.if defined(PROG)
67_EXTRADEPEND:
68	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
69	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
70.endif
71
72.if !target(install)
73.if !target(beforeinstall)
74beforeinstall:
75.endif
76
77realinstall: beforeinstall
78.if defined(PROG)
79	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
80	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
81.endif
82.if defined(HIDEGAME)
83	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
84	    chown games:bin ${PROG})
85.endif
86.if defined(LINKS) && !empty(LINKS)
87	@set ${LINKS}; \
88	while test $$# -ge 2; do \
89		l=${DESTDIR}$$1; \
90		shift; \
91		t=${DESTDIR}$$1; \
92		shift; \
93		${ECHO} $$t -\> $$l; \
94		rm -f $$t; \
95		ln ${LN_FLAGS} $$l $$t; \
96	done; true
97.endif
98
99install: afterinstall _SUBDIR
100.if !defined(NOMAN)
101afterinstall: realinstall maninstall
102.else
103afterinstall: realinstall
104.endif
105.endif
106
107DISTRIBUTION?=	bin
108.if !target(distribute)
109distribute: _SUBDIR
110.for dist in ${DISTRIBUTION}
111	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
112.endfor
113.endif
114
115.if !target(lint)
116lint: ${SRCS} _SUBDIR
117.if defined(PROG)
118	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
119.endif
120.endif
121
122.if defined(NOTAGS)
123tags:
124.endif
125
126.if !target(tags)
127tags: ${SRCS} _SUBDIR
128.if defined(PROG)
129	@cd ${.CURDIR} && gtags ${GTAGSFLAGS}
130.if defined(HTML)
131	@cd ${.CURDIR} && htags ${HTAGSFLAGS}
132.endif
133.endif
134.endif
135
136.if !defined(NOMAN)
137.include <bsd.man.mk>
138.elif !target(maninstall)
139maninstall:
140all-man:
141.endif
142
143.include <bsd.dep.mk>
144.include <bsd.obj.mk>
145