Deleted Added
full compact
bsd.prog.mk (248753) bsd.prog.mk (251512)
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2# $FreeBSD: head/share/mk/bsd.prog.mk 248753 2013-03-26 20:32:46Z emaste $
2# $FreeBSD: head/share/mk/bsd.prog.mk 251512 2013-06-07 21:40:02Z emaste $
3
4.include <bsd.init.mk>
5
6.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm
7
8# XXX The use of COPTS in modern makefiles is discouraged.
9.if defined(COPTS)
10CFLAGS+=${COPTS}
11.endif
12
13.if ${MK_ASSERT_DEBUG} == "no"
14CFLAGS+= -DNDEBUG
15NO_WERROR=
16.endif
17
18.if defined(DEBUG_FLAGS)
19CFLAGS+=${DEBUG_FLAGS}
20CXXFLAGS+=${DEBUG_FLAGS}
21
22.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
23CTFFLAGS+= -g
24.endif
25.endif
26
3
4.include <bsd.init.mk>
5
6.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm
7
8# XXX The use of COPTS in modern makefiles is discouraged.
9.if defined(COPTS)
10CFLAGS+=${COPTS}
11.endif
12
13.if ${MK_ASSERT_DEBUG} == "no"
14CFLAGS+= -DNDEBUG
15NO_WERROR=
16.endif
17
18.if defined(DEBUG_FLAGS)
19CFLAGS+=${DEBUG_FLAGS}
20CXXFLAGS+=${DEBUG_FLAGS}
21
22.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
23CTFFLAGS+= -g
24.endif
25.endif
26
27.if defined(PROG_CXX)
28PROG= ${PROG_CXX}
29.endif
30
31.if defined(PROG) && target(${PROG})
32MK_DEBUG_FILES= no
33.elif !empty(LDFLAGS:M-Wl,*--oformat,*) || !empty(LDFLAGS:M-static)
34MK_DEBUG_FILES= no
35.endif
36
27.if defined(CRUNCH_CFLAGS)
28CFLAGS+=${CRUNCH_CFLAGS}
37.if defined(CRUNCH_CFLAGS)
38CFLAGS+=${CRUNCH_CFLAGS}
39.else
40.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \
41 empty(DEBUG_FLAGS:M-gdwarf-*)
42CFLAGS+= -g
43CTFFLAGS+= -g
29.endif
44.endif
45.endif
30
31.if !defined(DEBUG_FLAGS)
32STRIP?= -s
33.endif
34
35.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
36LDFLAGS+= -static
37.endif
38
46
47.if !defined(DEBUG_FLAGS)
48STRIP?= -s
49.endif
50
51.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
52LDFLAGS+= -static
53.endif
54
39.if defined(PROG_CXX)
40PROG= ${PROG_CXX}
55.if ${MK_DEBUG_FILES} != "no"
56PROG_FULL=${PROG}.full
57# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
58.if defined(BINDIR) && (\
59 ${BINDIR} == "/bin" ||\
60 ${BINDIR} == "/libexec" ||\
61 ${BINDIR} == "/sbin" ||\
62 ${BINDIR:C%/usr/(bin|bsdinstall|games|libexec|lpr|sendmail|sm.bin|sbin)(/.*)?%/usr/bin%} == "/usr/bin"\
63 )
64DEBUGFILEDIR= ${DEBUGDIR}${BINDIR}
65.else
66DEBUGFILEDIR?= ${BINDIR}/.debug
67DEBUGMKDIR=
41.endif
68.endif
69.else
70PROG_FULL= ${PROG}
71.endif
42
43.if defined(PROG)
44PROGNAME?= ${PROG}
72
73.if defined(PROG)
74PROGNAME?= ${PROG}
75
45.if defined(SRCS)
46
47OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
48
49.if target(beforelinking)
50beforelinking: ${OBJS}
76.if defined(SRCS)
77
78OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
79
80.if target(beforelinking)
81beforelinking: ${OBJS}
51${PROG}: beforelinking
82${PROG_FULL}: beforelinking
52.endif
83.endif
53${PROG}: ${OBJS}
84${PROG_FULL}: ${OBJS}
54.if defined(PROG_CXX)
55 ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
56.else
57 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
58.endif
59.if ${MK_CTF} != "no"
60 ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
61.endif
62
63.else # !defined(SRCS)
64
65.if !target(${PROG})
66.if defined(PROG_CXX)
67SRCS= ${PROG}.cc
68.else
69SRCS= ${PROG}.c
70.endif
71
72# Always make an intermediate object file because:
73# - it saves time rebuilding when only the library has changed
74# - the name of the object gets put into the executable symbol table instead of
75# the name of a variable temporary object.
76# - it's useful to keep objects around for crunching.
77OBJS+= ${PROG}.o
78
79.if target(beforelinking)
80beforelinking: ${OBJS}
85.if defined(PROG_CXX)
86 ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
87.else
88 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
89.endif
90.if ${MK_CTF} != "no"
91 ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
92.endif
93
94.else # !defined(SRCS)
95
96.if !target(${PROG})
97.if defined(PROG_CXX)
98SRCS= ${PROG}.cc
99.else
100SRCS= ${PROG}.c
101.endif
102
103# Always make an intermediate object file because:
104# - it saves time rebuilding when only the library has changed
105# - the name of the object gets put into the executable symbol table instead of
106# the name of a variable temporary object.
107# - it's useful to keep objects around for crunching.
108OBJS+= ${PROG}.o
109
110.if target(beforelinking)
111beforelinking: ${OBJS}
81${PROG}: beforelinking
112${PROG_FULL}: beforelinking
82.endif
113.endif
83${PROG}: ${OBJS}
114${PROG_FULL}: ${OBJS}
84.if defined(PROG_CXX)
85 ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
86.else
87 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
88.endif
89.if ${MK_CTF} != "no"
90 ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
91.endif
115.if defined(PROG_CXX)
116 ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
117.else
118 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
119.endif
120.if ${MK_CTF} != "no"
121 ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
122.endif
92.endif
123.endif # !target(${PROG})
93
94.endif # !defined(SRCS)
95
124
125.endif # !defined(SRCS)
126
127.if ${MK_DEBUG_FILES} != "no"
128${PROG}: ${PROG_FULL} ${PROGNAME}.debug
129 ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.debug \
130 ${PROG_FULL} ${.TARGET}
131
132${PROGNAME}.debug: ${PROG_FULL}
133 ${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET}
134.endif
135
96.if ${MK_MAN} != "no" && !defined(MAN) && \
97 !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
98 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
99 !defined(MAN7) && !defined(MAN8) && !defined(MAN9)
100MAN= ${PROG}.1
101MAN1= ${MAN}
102.endif
103.endif # defined(PROG)
104
105all: objwarn ${PROG} ${SCRIPTS}
106.if ${MK_MAN} != "no"
107all: _manpages
108.endif
109
110.if defined(PROG)
111CLEANFILES+= ${PROG}
136.if ${MK_MAN} != "no" && !defined(MAN) && \
137 !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
138 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
139 !defined(MAN7) && !defined(MAN8) && !defined(MAN9)
140MAN= ${PROG}.1
141MAN1= ${MAN}
142.endif
143.endif # defined(PROG)
144
145all: objwarn ${PROG} ${SCRIPTS}
146.if ${MK_MAN} != "no"
147all: _manpages
148.endif
149
150.if defined(PROG)
151CLEANFILES+= ${PROG}
152.if ${MK_DEBUG_FILES} != "no"
153CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug
112.endif
154.endif
155.endif
113
114.if defined(OBJS)
115CLEANFILES+= ${OBJS}
116.endif
117
118.include <bsd.libnames.mk>
119
120.if defined(PROG)
121_EXTRADEPEND:
122.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
123.if defined(DPADD) && !empty(DPADD)
124 echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
125.endif
126.else
127 echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
128.if defined(PROG_CXX)
129.if !empty(CXXFLAGS:M-stdlib=libc++)
130 echo ${PROG}: ${LIBCPLUSPLUS} >> ${DEPENDFILE}
131.else
132 echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
133.endif
134.endif
135.endif
136.endif
137
138.if !target(install)
139
140.if defined(PRECIOUSPROG)
141.if !defined(NO_FSCHG)
142INSTALLFLAGS+= -fschg
143.endif
144INSTALLFLAGS+= -S
145.endif
146
147_INSTALLFLAGS:= ${INSTALLFLAGS}
148.for ie in ${INSTALLFLAGS_EDIT}
149_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
150.endfor
151
152.if !target(realinstall) && !defined(INTERNALPROG)
153realinstall: _proginstall
154.ORDER: beforeinstall _proginstall
155_proginstall:
156.if defined(PROG)
157 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
158 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
156
157.if defined(OBJS)
158CLEANFILES+= ${OBJS}
159.endif
160
161.include <bsd.libnames.mk>
162
163.if defined(PROG)
164_EXTRADEPEND:
165.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
166.if defined(DPADD) && !empty(DPADD)
167 echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
168.endif
169.else
170 echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
171.if defined(PROG_CXX)
172.if !empty(CXXFLAGS:M-stdlib=libc++)
173 echo ${PROG}: ${LIBCPLUSPLUS} >> ${DEPENDFILE}
174.else
175 echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
176.endif
177.endif
178.endif
179.endif
180
181.if !target(install)
182
183.if defined(PRECIOUSPROG)
184.if !defined(NO_FSCHG)
185INSTALLFLAGS+= -fschg
186.endif
187INSTALLFLAGS+= -S
188.endif
189
190_INSTALLFLAGS:= ${INSTALLFLAGS}
191.for ie in ${INSTALLFLAGS_EDIT}
192_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
193.endfor
194
195.if !target(realinstall) && !defined(INTERNALPROG)
196realinstall: _proginstall
197.ORDER: beforeinstall _proginstall
198_proginstall:
199.if defined(PROG)
200 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
201 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
202.if ${MK_DEBUG_FILES} != "no"
203.if defined(DEBUGMKDIR)
204 ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR}
159.endif
205.endif
206 ${INSTALL} -T debug -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \
207 ${PROGNAME}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME}.debug
208.endif
209.endif
160.endif # !target(realinstall)
161
162.if defined(SCRIPTS) && !empty(SCRIPTS)
163realinstall: _scriptsinstall
164.ORDER: beforeinstall _scriptsinstall
165
166SCRIPTSDIR?= ${BINDIR}
167SCRIPTSOWN?= ${BINOWN}
168SCRIPTSGRP?= ${BINGRP}
169SCRIPTSMODE?= ${BINMODE}
170
171.for script in ${SCRIPTS}
172.if defined(SCRIPTSNAME)
173SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME}
174.else
175SCRIPTSNAME_${script:T}?= ${script:T:R}
176.endif
177SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR}
178SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN}
179SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
180SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
181_scriptsinstall: _SCRIPTSINS_${script:T}
182_SCRIPTSINS_${script:T}: ${script}
183 ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
184 -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
185 ${.ALLSRC} \
186 ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
187.endfor
188.endif
189
190NLSNAME?= ${PROG}
191.include <bsd.nls.mk>
192
193.include <bsd.files.mk>
194.include <bsd.incs.mk>
195.include <bsd.links.mk>
196
197.if ${MK_MAN} != "no"
198realinstall: _maninstall
199.ORDER: beforeinstall _maninstall
200.endif
201
202.endif
203
204.if !target(lint)
205lint: ${SRCS:M*.c}
206.if defined(PROG)
207 ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
208.endif
209.endif
210
211.if ${MK_MAN} != "no"
212.include <bsd.man.mk>
213.endif
214
215.include <bsd.dep.mk>
216
217.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
218${OBJS}: ${SRCS:M*.h}
219.endif
220
221.include <bsd.obj.mk>
222
223.include <bsd.sys.mk>
224
225.if defined(PORTNAME)
226.include <bsd.pkg.mk>
227.endif
210.endif # !target(realinstall)
211
212.if defined(SCRIPTS) && !empty(SCRIPTS)
213realinstall: _scriptsinstall
214.ORDER: beforeinstall _scriptsinstall
215
216SCRIPTSDIR?= ${BINDIR}
217SCRIPTSOWN?= ${BINOWN}
218SCRIPTSGRP?= ${BINGRP}
219SCRIPTSMODE?= ${BINMODE}
220
221.for script in ${SCRIPTS}
222.if defined(SCRIPTSNAME)
223SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME}
224.else
225SCRIPTSNAME_${script:T}?= ${script:T:R}
226.endif
227SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR}
228SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN}
229SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
230SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
231_scriptsinstall: _SCRIPTSINS_${script:T}
232_SCRIPTSINS_${script:T}: ${script}
233 ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
234 -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
235 ${.ALLSRC} \
236 ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
237.endfor
238.endif
239
240NLSNAME?= ${PROG}
241.include <bsd.nls.mk>
242
243.include <bsd.files.mk>
244.include <bsd.incs.mk>
245.include <bsd.links.mk>
246
247.if ${MK_MAN} != "no"
248realinstall: _maninstall
249.ORDER: beforeinstall _maninstall
250.endif
251
252.endif
253
254.if !target(lint)
255lint: ${SRCS:M*.c}
256.if defined(PROG)
257 ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
258.endif
259.endif
260
261.if ${MK_MAN} != "no"
262.include <bsd.man.mk>
263.endif
264
265.include <bsd.dep.mk>
266
267.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
268${OBJS}: ${SRCS:M*.h}
269.endif
270
271.include <bsd.obj.mk>
272
273.include <bsd.sys.mk>
274
275.if defined(PORTNAME)
276.include <bsd.pkg.mk>
277.endif