xref: /freebsd/share/mk/bsd.prog.mk (revision dfcf88a3a0bb232ed1831e0a00f9408ce33e16aa)
13585b293SGarrett Wollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
27f3dea24SPeter Wemm# $FreeBSD$
3afe61c15SRodney W. Grimes
4e0301e5dSPeter Wemm.if !target(__initialized__)
5e0301e5dSPeter Wemm__initialized__:
63585b293SGarrett Wollman.if exists(${.CURDIR}/../Makefile.inc)
7afe61c15SRodney W. Grimes.include "${.CURDIR}/../Makefile.inc"
8afe61c15SRodney W. Grimes.endif
9e0301e5dSPeter Wemm.endif
10afe61c15SRodney W. Grimes
11c7cbe79eSDmitrij Tejblum.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S
12afe61c15SRodney W. Grimes
13e82b0b99SJordan K. HubbardCFLAGS+=${COPTS} ${DEBUG_FLAGS}
143585b293SGarrett Wollman.if defined(DESTDIR)
153585b293SGarrett WollmanCFLAGS+= -I${DESTDIR}/usr/include
1615db27b8SSatoshi AsamiCXXINCLUDES+= -I${DESTDIR}/usr/include/g++
173585b293SGarrett Wollman.endif
18afe61c15SRodney W. Grimes
19e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS)
20afe61c15SRodney W. GrimesSTRIP?=	-s
21e82b0b99SJordan K. Hubbard.endif
22afe61c15SRodney W. Grimes
233d8cd70cSPaul Traina.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
243585b293SGarrett WollmanLDFLAGS+= -static
253585b293SGarrett Wollman.endif
26afe61c15SRodney W. Grimes
27afe61c15SRodney W. Grimes.if defined(PROG)
28afe61c15SRodney W. Grimes.if defined(SRCS)
29afe61c15SRodney W. Grimes
3070a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries.
3170a6e331SBruce Evans.if ${SRCS:M*.m} != ""
3270a6e331SBruce EvansOBJCLIBS?= -lobjc
3370a6e331SBruce EvansLDADD+=	${OBJCLIBS}
3470a6e331SBruce Evans.endif
3570a6e331SBruce Evans
363585b293SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
37afe61c15SRodney W. Grimes
38987afe2aSBruce Evans${PROG}: ${OBJS}
393585b293SGarrett Wollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
403585b293SGarrett Wollman
41fd2e43eaSBruce Evans.else !defined(SRCS)
42afe61c15SRodney W. Grimes
43f5c75051SEivind Eklund.if !target(${PROG})
44afe61c15SRodney W. GrimesSRCS=	${PROG}.c
45afe61c15SRodney W. Grimes
46a4c39c7aSBruce Evans# Always make an intermediate object file because:
47a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed
48a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of
49a4c39c7aSBruce Evans#   the name of a variable temporary object.
50a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching.
51a4c39c7aSBruce EvansOBJS=	${PROG}.o
52f5c75051SEivind Eklund
53987afe2aSBruce Evans${PROG}: ${OBJS}
54a4c39c7aSBruce Evans	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
55afe61c15SRodney W. Grimes.endif
56f5c75051SEivind Eklund
576fe6af9fSEivind Eklund.endif
58afe61c15SRodney W. Grimes
59862d3deaSRuslan Ermilov.if	!defined(NOMAN) && !defined(MAN) && \
60862d3deaSRuslan Ermilov	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
61afe61c15SRodney W. Grimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
62500d8265SRuslan Ermilov	!defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
63862d3deaSRuslan Ermilov	!defined(MAN1aout)
6419ea15a1SRuslan ErmilovMAN=	${PROG}.1
6519ea15a1SRuslan ErmilovMAN1=	${MAN}
66afe61c15SRodney W. Grimes.endif
67afe61c15SRodney W. Grimes.endif
68afe61c15SRodney W. Grimes
69afe61c15SRodney W. Grimes.MAIN: all
70862d3deaSRuslan Ermilov.if !defined(NOMAN)
71f7ee8cfeSRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} all-man _SUBDIR
72862d3deaSRuslan Ermilov.else
73f7ee8cfeSRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} _SUBDIR
74862d3deaSRuslan Ermilov.endif
75afe61c15SRodney W. Grimes
7689d11b8aSBruce EvansCLEANFILES+= ${PROG} ${OBJS}
77afe61c15SRodney W. Grimes
78218a2cd2SBruce Evans.if defined(PROG)
79663e9677SBruce Evans_EXTRADEPEND:
80cdaa52cfSJohn Birrell.if ${OBJFORMAT} == aout
81663e9677SBruce Evans	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
821c735bb4SBruce Evans	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
838c05a446SPeter Wemm.else
846e19760bSBruce Evans	echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
858c05a446SPeter Wemm.endif
86663e9677SBruce Evans.endif
87663e9677SBruce Evans
88afe61c15SRodney W. Grimes.if !target(install)
89afe61c15SRodney W. Grimes.if !target(beforeinstall)
90afe61c15SRodney W. Grimesbeforeinstall:
91afe61c15SRodney W. Grimes.endif
92afe61c15SRodney W. Grimes
93e902c1bbSTim Vanderhoek_INSTALLFLAGS:=	${INSTALLFLAGS}
94e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT}
95e902c1bbSTim Vanderhoek_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
96e902c1bbSTim Vanderhoek.endfor
97e902c1bbSTim Vanderhoek
98cd9a2f5cSJordan K. Hubbardrealinstall: beforeinstall
99afe61c15SRodney W. Grimes.if defined(PROG)
10095f8c826SRuslan Ermilov.if defined(PROGNAME)
10195f8c826SRuslan Ermilov	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
10295f8c826SRuslan Ermilov	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
10395f8c826SRuslan Ermilov.else
1043585b293SGarrett Wollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
105e902c1bbSTim Vanderhoek	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
106afe61c15SRodney W. Grimes.endif
10795f8c826SRuslan Ermilov.endif
108afe61c15SRodney W. Grimes.if defined(HIDEGAME)
109dfcf88a3SRuslan Ermilov	(cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \
110dfcf88a3SRuslan Ermilov	    chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
111afe61c15SRodney W. Grimes.endif
112afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS)
113afe61c15SRodney W. Grimes	@set ${LINKS}; \
114afe61c15SRodney W. Grimes	while test $$# -ge 2; do \
115afe61c15SRodney W. Grimes		l=${DESTDIR}$$1; \
116afe61c15SRodney W. Grimes		shift; \
117afe61c15SRodney W. Grimes		t=${DESTDIR}$$1; \
118afe61c15SRodney W. Grimes		shift; \
119a4c39c7aSBruce Evans		${ECHO} $$t -\> $$l; \
1202336a7eaSBruce Evans		ln -f $$l $$t; \
1212336a7eaSBruce Evans	done; true
1222336a7eaSBruce Evans.endif
1232336a7eaSBruce Evans.if defined(SYMLINKS) && !empty(SYMLINKS)
1242336a7eaSBruce Evans	@set ${SYMLINKS}; \
1252336a7eaSBruce Evans	while test $$# -ge 2; do \
1262336a7eaSBruce Evans		l=$$1; \
1272336a7eaSBruce Evans		shift; \
1282336a7eaSBruce Evans		t=${DESTDIR}$$1; \
1292336a7eaSBruce Evans		shift; \
1302336a7eaSBruce Evans		${ECHO} $$t -\> $$l; \
1312336a7eaSBruce Evans		ln -fs $$l $$t; \
132afe61c15SRodney W. Grimes	done; true
133afe61c15SRodney W. Grimes.endif
134afe61c15SRodney W. Grimes
135f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS)
136f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall
137f7ee8cfeSRuslan Ermilov
138f7ee8cfeSRuslan ErmilovSCRIPTSDIR?=	${BINDIR}
139f7ee8cfeSRuslan ErmilovSCRIPTSOWN?=	${BINOWN}
140f7ee8cfeSRuslan ErmilovSCRIPTSGRP?=	${BINGRP}
141f7ee8cfeSRuslan ErmilovSCRIPTSMODE?=	${BINMODE}
142f7ee8cfeSRuslan Ermilov
143f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS}
144f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME)
145f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?=	${SCRIPTSNAME}
146f7ee8cfeSRuslan Ermilov.else
147f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?=	${script:T:R}
148f7ee8cfeSRuslan Ermilov.endif
149f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?=	${SCRIPTSDIR}
150f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?=	${SCRIPTSOWN}
151f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?=	${SCRIPTSGRP}
152f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?=	${SCRIPTSMODE}
153f7ee8cfeSRuslan Ermilov_scriptsinstall: SCRIPTSINS_${script:T}
154f7ee8cfeSRuslan ErmilovSCRIPTSINS_${script:T}: ${script}
155f7ee8cfeSRuslan Ermilov	${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
156f7ee8cfeSRuslan Ermilov	    -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
157f7ee8cfeSRuslan Ermilov	    ${_INSTALLFLAGS} ${.ALLSRC} \
158f7ee8cfeSRuslan Ermilov	    ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
159f7ee8cfeSRuslan Ermilov.endfor
160f7ee8cfeSRuslan Ermilov.endif
161f7ee8cfeSRuslan Ermilov
162cd9a2f5cSJordan K. Hubbardinstall: afterinstall _SUBDIR
1633585b293SGarrett Wollman.if !defined(NOMAN)
1643585b293SGarrett Wollmanafterinstall: realinstall maninstall
1653585b293SGarrett Wollman.else
166afe61c15SRodney W. Grimesafterinstall: realinstall
1673585b293SGarrett Wollman.endif
168afe61c15SRodney W. Grimes.endif
169afe61c15SRodney W. Grimes
170d9584d76SJordan K. HubbardDISTRIBUTION?=	bin
17155ff8fb1SPoul-Henning Kamp.if !target(distribute)
172cd9a2f5cSJordan K. Hubbarddistribute: _SUBDIR
173398ac038SJordan K. Hubbard.for dist in ${DISTRIBUTION}
174398ac038SJordan K. Hubbard	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
175398ac038SJordan K. Hubbard.endfor
17655ff8fb1SPoul-Henning Kamp.endif
17755ff8fb1SPoul-Henning Kamp
178afe61c15SRodney W. Grimes.if !target(lint)
179cd9a2f5cSJordan K. Hubbardlint: ${SRCS} _SUBDIR
180afe61c15SRodney W. Grimes.if defined(PROG)
181bfc4cb26SJeroen Ruigrok van der Werven	@${LINT} ${LINTFLAGS} ${.ALLSRC} | more 2>&1
182afe61c15SRodney W. Grimes.endif
183afe61c15SRodney W. Grimes.endif
184afe61c15SRodney W. Grimes
1856eb5e456SJordan K. Hubbard.if defined(NOTAGS)
1866eb5e456SJordan K. Hubbardtags:
1876eb5e456SJordan K. Hubbard.endif
1886eb5e456SJordan K. Hubbard
189afe61c15SRodney W. Grimes.if !target(tags)
190cd9a2f5cSJordan K. Hubbardtags: ${SRCS} _SUBDIR
191afe61c15SRodney W. Grimes.if defined(PROG)
1921ed9b1c3SEivind Eklund	@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
1936eb5e456SJordan K. Hubbard.if defined(HTML)
1941ed9b1c3SEivind Eklund	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
1956eb5e456SJordan K. Hubbard.endif
196afe61c15SRodney W. Grimes.endif
197afe61c15SRodney W. Grimes.endif
198afe61c15SRodney W. Grimes
199afe61c15SRodney W. Grimes.if !defined(NOMAN)
200afe61c15SRodney W. Grimes.include <bsd.man.mk>
201918fb560SRuslan Ermilov.else
202918fb560SRuslan Ermilov.if !target(all-man)
203918fb560SRuslan Ermilovall-man:
204918fb560SRuslan Ermilov.endif
205918fb560SRuslan Ermilov.if !target(maninstall)
206afe61c15SRodney W. Grimesmaninstall:
207afe61c15SRodney W. Grimes.endif
208918fb560SRuslan Ermilov.endif
2093585b293SGarrett Wollman
21069b87d3eSEivind Eklund.if !target(regress)
21169b87d3eSEivind Eklundregress:
21269b87d3eSEivind Eklund.endif
21369b87d3eSEivind Eklund
214368c8de4SJohn Polstra.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
2158c05a446SPeter Wemm.include <bsd.libnames.mk>
2168c05a446SPeter Wemm.endif
2178c05a446SPeter Wemm
2183585b293SGarrett Wollman.include <bsd.dep.mk>
219987afe2aSBruce Evans
220987afe2aSBruce Evans.if defined(PROG) && !exists(${DEPENDFILE})
221589d9341SBruce Evans${OBJS}: ${SRCS:M*.h}
222987afe2aSBruce Evans.endif
223987afe2aSBruce Evans
224cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk>
225d510ecb4SKris Kennaway
226d510ecb4SKris Kennaway.include <bsd.sys.mk>
227