bsd.prog.mk: Avoid redefining $PROG target
[dragonfly.git] / share / mk / bsd.prog.mk
CommitLineData
984263bc
MD
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2# $FreeBSD: src/share/mk/bsd.prog.mk,v 1.86.2.17 2002/12/23 16:33:37 ru Exp $
3
4.include <bsd.init.mk>
5
6.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S
7
8CFLAGS+=${COPTS} ${DEBUG_FLAGS}
9
10.if !defined(DEBUG_FLAGS)
11STRIP?= -s
12.endif
13
14.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
15LDFLAGS+= -static
16.endif
17
18.if defined(PROG_CXX)
19PROG= ${PROG_CXX}
20.endif
21
1d5448ab
SS
22.include <bsd.patch.mk>
23
984263bc
MD
24.if defined(PROG)
25.if defined(SRCS)
26
27# If there are Objective C sources, link with Objective C libraries.
28.if ${SRCS:M*.m} != ""
29OBJCLIBS?= -lobjc
30LDADD+= ${OBJCLIBS}
31.endif
32
acbbf55b 33OBJS+= ${SRCS:N*.h:N*.patch:R:S/$/.o/g}
984263bc 34
b4061d6c 35.if !target(${PROG})
984263bc
MD
36${PROG}: ${OBJS}
37.if defined(PROG_CXX)
3c4543af 38 ${CXX_LINK} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
984263bc 39.else
3c4543af 40 ${CC_LINK} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
984263bc 41.endif
b4061d6c 42.endif
984263bc 43
584b7c3b 44.else # !defined(SRCS)
984263bc
MD
45
46.if !target(${PROG})
47.if defined(PROG_CXX)
48SRCS= ${PROG}.cc
49.else
50SRCS= ${PROG}.c
51.endif
52
53# Always make an intermediate object file because:
54# - it saves time rebuilding when only the library has changed
55# - the name of the object gets put into the executable symbol table instead of
56# the name of a variable temporary object.
57# - it's useful to keep objects around for crunching.
58OBJS= ${PROG}.o
59
60${PROG}: ${OBJS}
61.if defined(PROG_CXX)
3c4543af 62 ${CXX_LINK} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
984263bc 63.else
3c4543af 64 ${CC_LINK} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
984263bc
MD
65.endif
66.endif
67
68.endif
69
70.if !defined(NOMAN) && !defined(MAN) && \
71 !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
72 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
0bfa4a9b 73 !defined(MAN7) && !defined(MAN8) && !defined(MAN9)
984263bc
MD
74MAN= ${PROG}.1
75MAN1= ${MAN}
76.endif
77.endif
78
79all: objwarn ${PROG} ${SCRIPTS}
80.if !defined(NOMAN)
81all: _manpages
82.endif
83
84CLEANFILES+= ${PROG} ${OBJS}
85
86.if defined(PROG)
87_EXTRADEPEND:
984263bc
MD
88 echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
89.if defined(PROG_CXX)
90 echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
91.endif
92.endif
984263bc
MD
93
94.if !target(install)
95
96_INSTALLFLAGS:= ${INSTALLFLAGS}
97.for ie in ${INSTALLFLAGS_EDIT}
98_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
99.endfor
100
101.if !target(realinstall)
102realinstall: _proginstall
103.ORDER: beforeinstall _proginstall
104_proginstall:
105.if defined(PROG)
106.if defined(PROGNAME)
107 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
108 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
109.else
110 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
111 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
112.endif
113.endif
114.if defined(HIDEGAME)
062db326 115 (cd ${DESTDIR}${ORIGBINDIR}; ${LN} -fs dm ${PROG}; \
984263bc
MD
116 chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
117.endif
584b7c3b 118.endif # !target(realinstall)
984263bc
MD
119
120.if defined(SCRIPTS) && !empty(SCRIPTS)
121realinstall: _scriptsinstall
122.ORDER: beforeinstall _scriptsinstall
123
124SCRIPTSDIR?= ${BINDIR}
125SCRIPTSOWN?= ${BINOWN}
126SCRIPTSGRP?= ${BINGRP}
127SCRIPTSMODE?= ${BINMODE}
128
129.for script in ${SCRIPTS}
130.if defined(SCRIPTSNAME)
131SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME}
132.else
133SCRIPTSNAME_${script:T}?= ${script:T:R}
134.endif
135SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR}
136SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN}
137SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
138SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
139_scriptsinstall: _SCRIPTSINS_${script:T}
140_SCRIPTSINS_${script:T}: ${script}
141 ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
142 -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
143 ${.ALLSRC} \
144 ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
145.endfor
146.endif
147
3b1b9f6e
SW
148NLSNAME?= ${PROG}
149
63b52312 150.include <bsd.nls.mk>
984263bc
MD
151.include <bsd.files.mk>
152.include <bsd.incs.mk>
153.include <bsd.links.mk>
154
155.if !defined(NOMAN)
156realinstall: _maninstall
157.ORDER: beforeinstall _maninstall
158.endif
159
160.endif
161
162.if !target(lint)
163lint: ${SRCS}
164.if defined(PROG)
1ec931f4 165 -@${LINT} ${LINTFLAGS} ${CFLAGS:M-I*:S/-I/-I /g} ${.ALLSRC}
984263bc
MD
166.endif
167.endif
168
169.if !defined(NOMAN)
170.include <bsd.man.mk>
171.endif
172
173.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
174.include <bsd.libnames.mk>
175.endif
176
177.include <bsd.dep.mk>
178
179.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
180${OBJS}: ${SRCS:M*.h}
181.endif
182
183.include <bsd.obj.mk>
184
185.include <bsd.sys.mk>
1397f94a 186