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