bsd.prog.mk revision 31815
1#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.prog.mk,v 1.57 1997/12/17 13:40:00 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}: ${DPSRCS} ${OBJS}
34	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
35
36.else !defined(SRCS)
37
38SRCS=	${PROG}.c
39
40# Always make an intermediate object file because:
41# - it saves time rebuilding when only the library has changed
42# - the name of the object gets put into the executable symbol table instead of
43#   the name of a variable temporary object.
44# - it's useful to keep objects around for crunching.
45OBJS=	${PROG}.o
46${PROG}: ${DPSRCS} ${OBJS}
47	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
48
49.endif
50
51.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
52	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
53	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
54MAN1=	${PROG}.1
55.endif
56.endif
57
58.MAIN: all
59all: objwarn ${PROG} all-man _SUBDIR
60
61.if !target(clean)
62clean: _SUBDIR
63.if defined(PROG) && !empty(PROG) || defined(OBJS) && !empty(OBJS) || \
64    defined(CLEANFILES) && !empty(CLEANFILES)
65	rm -f ${PROG} ${OBJS} ${CLEANFILES} 
66.endif
67	rm -f ${PROG} ${OBJS} ${CLEANFILES} 
68.if defined(CLEANDIRS) && !empty(CLEANDIRS)
69	rm -rf ${CLEANDIRS}
70.endif
71.endif
72
73.if defined(PROG) && !defined(NOEXTRADEPEND)
74_EXTRADEPEND:
75.if ${BINFORMAT} == aout
76	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
77	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
78.else
79.if defined(DPADD) && !empty(DPADD)
80	echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
81.endif
82.endif
83.endif
84
85.if !target(install)
86.if !target(beforeinstall)
87beforeinstall:
88.endif
89
90realinstall: beforeinstall
91.if defined(PROG)
92	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
93	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
94.endif
95.if defined(HIDEGAME)
96	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
97	    chown games:bin ${PROG})
98.endif
99.if defined(LINKS) && !empty(LINKS)
100	@set ${LINKS}; \
101	while test $$# -ge 2; do \
102		l=${DESTDIR}$$1; \
103		shift; \
104		t=${DESTDIR}$$1; \
105		shift; \
106		${ECHO} $$t -\> $$l; \
107		rm -f $$t; \
108		ln ${LN_FLAGS} $$l $$t; \
109	done; true
110.endif
111
112install: afterinstall _SUBDIR
113.if !defined(NOMAN)
114afterinstall: realinstall maninstall
115.else
116afterinstall: realinstall
117.endif
118.endif
119
120DISTRIBUTION?=	bin
121.if !target(distribute)
122distribute: _SUBDIR
123.for dist in ${DISTRIBUTION}
124	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
125.endfor
126.endif
127
128.if !target(lint)
129lint: ${SRCS} _SUBDIR
130.if defined(PROG)
131	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
132.endif
133.endif
134
135.if defined(NOTAGS)
136tags:
137.endif
138
139.if !target(tags)
140tags: ${SRCS} _SUBDIR
141.if defined(PROG)
142	@cd ${.CURDIR} && gtags ${GTAGSFLAGS}
143.if defined(HTML)
144	@cd ${.CURDIR} && htags ${HTAGSFLAGS}
145.endif
146.endif
147.endif
148
149.if !defined(NOMAN)
150.include <bsd.man.mk>
151.elif !target(maninstall)
152maninstall:
153all-man:
154.endif
155
156.if ${BINFORMAT} != aout || make(checkdpadd)
157.include <bsd.libnames.mk>
158.endif
159
160.include <bsd.dep.mk>
161.include <bsd.obj.mk>
162