bsd.prog.mk revision 28945
1#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.prog.mk,v 1.54 1997/08/05 03:49:49 asami 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) && !defined(NOEXTRADEPEND)
67_EXTRADEPEND:
68.if ${BINFORMAT} == aout
69	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
70	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
71.else
72.if defined(DPADD) && ${DPADD} != ""
73	echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
74.endif
75.endif
76.endif
77
78.if !target(install)
79.if !target(beforeinstall)
80beforeinstall:
81.endif
82
83realinstall: beforeinstall
84.if defined(PROG)
85	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
86	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
87.endif
88.if defined(HIDEGAME)
89	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
90	    chown games:bin ${PROG})
91.endif
92.if defined(LINKS) && !empty(LINKS)
93	@set ${LINKS}; \
94	while test $$# -ge 2; do \
95		l=${DESTDIR}$$1; \
96		shift; \
97		t=${DESTDIR}$$1; \
98		shift; \
99		${ECHO} $$t -\> $$l; \
100		rm -f $$t; \
101		ln ${LN_FLAGS} $$l $$t; \
102	done; true
103.endif
104
105install: afterinstall _SUBDIR
106.if !defined(NOMAN)
107afterinstall: realinstall maninstall
108.else
109afterinstall: realinstall
110.endif
111.endif
112
113DISTRIBUTION?=	bin
114.if !target(distribute)
115distribute: _SUBDIR
116.for dist in ${DISTRIBUTION}
117	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
118.endfor
119.endif
120
121.if !target(lint)
122lint: ${SRCS} _SUBDIR
123.if defined(PROG)
124	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
125.endif
126.endif
127
128.if defined(NOTAGS)
129tags:
130.endif
131
132.if !target(tags)
133tags: ${SRCS} _SUBDIR
134.if defined(PROG)
135	@cd ${.CURDIR} && gtags ${GTAGSFLAGS}
136.if defined(HTML)
137	@cd ${.CURDIR} && htags ${HTAGSFLAGS}
138.endif
139.endif
140.endif
141
142.if !defined(NOMAN)
143.include <bsd.man.mk>
144.elif !target(maninstall)
145maninstall:
146all-man:
147.endif
148
149.if ${BINFORMAT} != aout
150.include <bsd.libnames.mk>
151.endif
152
153.include <bsd.dep.mk>
154.include <bsd.obj.mk>
155