bsd.prog.mk revision 35838
1#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.prog.mk,v 1.71 1998/05/06 15:01:18 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
30OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
31
32${PROG}: ${OBJS}
33	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
34
35.else !defined(SRCS)
36
37.if !target(${PROG})
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
47${PROG}: ${OBJS}
48	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
49.endif
50
51.endif
52
53.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
54	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
55	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
56MAN1=	${PROG}.1
57.endif
58.endif
59
60.MAIN: all
61all: objwarn ${PROG} all-man _SUBDIR
62
63CLEANFILES+= ${PROG} ${OBJS}
64
65.if defined(PROG) && !defined(NOEXTRADEPEND)
66_EXTRADEPEND:
67.if ${BINFORMAT} == aout
68	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
69	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
70.else
71.if defined(DPADD) && !empty(DPADD)
72	echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
73.endif
74.endif
75.endif
76
77.if !target(install)
78.if !target(beforeinstall)
79beforeinstall:
80.endif
81
82realinstall: beforeinstall
83.if defined(PROG)
84	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
85	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
86.endif
87.if defined(HIDEGAME)
88	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
89	    chown games:bin ${PROG})
90.endif
91.if defined(LINKS) && !empty(LINKS)
92	@set ${LINKS}; \
93	while test $$# -ge 2; do \
94		l=${DESTDIR}$$1; \
95		shift; \
96		t=${DESTDIR}$$1; \
97		shift; \
98		${ECHO} $$t -\> $$l; \
99		rm -f $$t; \
100		ln ${LN_FLAGS} $$l $$t; \
101	done; true
102.endif
103
104install: afterinstall _SUBDIR
105.if !defined(NOMAN)
106afterinstall: realinstall maninstall
107.else
108afterinstall: realinstall
109.endif
110.endif
111
112DISTRIBUTION?=	bin
113.if !target(distribute)
114distribute: _SUBDIR
115.for dist in ${DISTRIBUTION}
116	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
117.endfor
118.endif
119
120.if !target(lint)
121lint: ${SRCS} _SUBDIR
122.if defined(PROG)
123	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
124.endif
125.endif
126
127.if defined(NOTAGS)
128tags:
129.endif
130
131.if !target(tags)
132tags: ${SRCS} _SUBDIR
133.if defined(PROG)
134	@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
135.if defined(HTML)
136	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
137.endif
138.endif
139.endif
140
141.if !defined(NOMAN)
142.include <bsd.man.mk>
143.elif !target(maninstall)
144maninstall:
145all-man:
146.endif
147
148.if !target(regress)
149regress:
150.endif
151
152.if ${BINFORMAT} != aout || make(checkdpadd)
153.include <bsd.libnames.mk>
154.endif
155
156.include <bsd.dep.mk>
157
158.if defined(PROG) && !exists(${DEPENDFILE})
159${OBJS}: ${SRCS:M*.h}
160.endif
161
162.include <bsd.obj.mk>
163