bsd.prog.mk revision 34081
1#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.prog.mk,v 1.63 1998/02/25 02:56:58 bde Exp $
3
4.if exists(${.CURDIR}/../Makefile.inc)
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
8# Default executable format
9BINFORMAT?=	aout
10
11.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
12
13CFLAGS+=${COPTS} ${DEBUG_FLAGS}
14.if defined(DESTDIR)
15CFLAGS+= -I${DESTDIR}/usr/include
16CXXINCLUDES+= -I${DESTDIR}/usr/include/g++
17.endif
18
19.if !defined(DEBUG_FLAGS)
20STRIP?=	-s
21.endif
22
23.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
24LDFLAGS+= -static
25.endif
26
27.if defined(PROG)
28.if defined(SRCS)
29
30DPSRCS+= ${SRCS:M*.h}
31OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
32
33${PROG}: ${OBJS}
34	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
35
36.else !defined(SRCS)
37
38.if !target(${PROG})
39SRCS=	${PROG}.c
40
41# Always make an intermediate object file because:
42# - it saves time rebuilding when only the library has changed
43# - the name of the object gets put into the executable symbol table instead of
44#   the name of a variable temporary object.
45# - it's useful to keep objects around for crunching.
46OBJS=	${PROG}.o
47
48${PROG}: ${OBJS}
49	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
50.endif
51
52.endif
53
54.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
55	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
56	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
57MAN1=	${PROG}.1
58.endif
59.endif
60
61.MAIN: all
62all: objwarn ${PROG} all-man _SUBDIR
63
64CLEANFILES+= ${PROG} ${OBJS}
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) && !empty(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 || make(checkdpadd)
150.include <bsd.libnames.mk>
151.endif
152
153.include <bsd.dep.mk>
154
155.if defined(PROG) && !exists(${DEPENDFILE})
156${OBJS}: ${DPSRCS}
157.endif
158
159.include <bsd.obj.mk>
160