]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.prog.mk
Merge wpa_supplicant and hostapd 0.7.3.
[FreeBSD/FreeBSD.git] / share / mk / bsd.prog.mk
1 #       from: @(#)bsd.prog.mk   5.26 (Berkeley) 6/25/91
2 # $FreeBSD$
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)
10 CFLAGS+=${COPTS}
11 .endif
12
13 .if ${MK_ASSERT_DEBUG} == "no"
14 CFLAGS+= -DNDEBUG
15 NO_WERROR=
16 .endif
17
18 # Enable CTF conversion on request.
19 .if defined(WITH_CTF)
20 .undef NO_CTF
21 .endif
22
23 .if defined(DEBUG_FLAGS)
24 CFLAGS+=${DEBUG_FLAGS}
25 CXXFLAGS+=${DEBUG_FLAGS}
26
27 .if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "")
28 CTFFLAGS+= -g
29 .endif
30 .endif
31
32 .if defined(CRUNCH_CFLAGS)
33 CFLAGS+=${CRUNCH_CFLAGS}
34 .endif
35
36 .if !defined(DEBUG_FLAGS)
37 STRIP?= -s
38 .endif
39
40 .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
41 LDFLAGS+= -static
42 .endif
43
44 .if defined(PROG_CXX)
45 PROG=   ${PROG_CXX}
46 .endif
47
48 .if defined(PROG)
49 .if defined(SRCS)
50
51 # If there are Objective C sources, link with Objective C libraries.
52 .if !empty(SRCS:M*.m)
53 .if defined(OBJCLIBS)
54 LDADD+= ${OBJCLIBS}
55 .else
56 DPADD+= ${LIBOBJC} ${LIBPTHREAD}
57 LDADD+= -lobjc -lpthread
58 .endif
59 .endif
60
61 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
62
63 .if target(beforelinking)
64 ${PROG}: ${OBJS} beforelinking
65 .else
66 ${PROG}: ${OBJS}
67 .endif
68 .if defined(PROG_CXX)
69         ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
70 .else
71         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
72 .endif
73         @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || \
74                 (${ECHO} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} && \
75                 ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS})
76
77 .else   # !defined(SRCS)
78
79 .if !target(${PROG})
80 .if defined(PROG_CXX)
81 SRCS=   ${PROG}.cc
82 .else
83 SRCS=   ${PROG}.c
84 .endif
85
86 # Always make an intermediate object file because:
87 # - it saves time rebuilding when only the library has changed
88 # - the name of the object gets put into the executable symbol table instead of
89 #   the name of a variable temporary object.
90 # - it's useful to keep objects around for crunching.
91 OBJS=   ${PROG}.o
92
93 .if target(beforelinking)
94 ${PROG}: ${OBJS} beforelinking
95 .else
96 ${PROG}: ${OBJS}
97 .endif
98 .if defined(PROG_CXX)
99         ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
100 .else
101         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
102 .endif
103         @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || \
104                 (${ECHO} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} && \
105                 ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS})
106 .endif
107
108 .endif
109
110 .if     ${MK_MAN} != "no" && !defined(MAN) && \
111         !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
112         !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
113         !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
114         !defined(MAN1aout)
115 MAN=    ${PROG}.1
116 MAN1=   ${MAN}
117 .endif
118 .endif
119
120 all: objwarn ${PROG} ${SCRIPTS}
121 .if ${MK_MAN} != "no"
122 all: _manpages
123 .endif
124
125 .if defined(PROG)
126 CLEANFILES+= ${PROG}
127 .endif
128
129 .if defined(OBJS)
130 CLEANFILES+= ${OBJS}
131 .endif
132
133 .include <bsd.libnames.mk>
134
135 .if defined(PROG)
136 _EXTRADEPEND:
137 .if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
138 .if defined(DPADD) && !empty(DPADD)
139         echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
140 .endif
141 .else
142         echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
143 .if defined(PROG_CXX)
144         echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
145 .endif
146 .endif
147 .endif
148
149 .if !target(install)
150
151 .if defined(PRECIOUSPROG)
152 .if !defined(NO_FSCHG)
153 INSTALLFLAGS+= -fschg
154 .endif
155 INSTALLFLAGS+= -S
156 .endif
157
158 _INSTALLFLAGS:= ${INSTALLFLAGS}
159 .for ie in ${INSTALLFLAGS_EDIT}
160 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
161 .endfor
162
163 .if !target(realinstall) && !defined(INTERNALPROG)
164 realinstall: _proginstall
165 .ORDER: beforeinstall _proginstall
166 _proginstall:
167 .if defined(PROG)
168 .if defined(PROGNAME)
169         ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
170             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
171 .else
172         ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
173             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
174 .endif
175 .endif
176 .endif  # !target(realinstall)
177
178 .if defined(SCRIPTS) && !empty(SCRIPTS)
179 realinstall: _scriptsinstall
180 .ORDER: beforeinstall _scriptsinstall
181
182 SCRIPTSDIR?=    ${BINDIR}
183 SCRIPTSOWN?=    ${BINOWN}
184 SCRIPTSGRP?=    ${BINGRP}
185 SCRIPTSMODE?=   ${BINMODE}
186
187 .for script in ${SCRIPTS}
188 .if defined(SCRIPTSNAME)
189 SCRIPTSNAME_${script:T}?=       ${SCRIPTSNAME}
190 .else
191 SCRIPTSNAME_${script:T}?=       ${script:T:R}
192 .endif
193 SCRIPTSDIR_${script:T}?=        ${SCRIPTSDIR}
194 SCRIPTSOWN_${script:T}?=        ${SCRIPTSOWN}
195 SCRIPTSGRP_${script:T}?=        ${SCRIPTSGRP}
196 SCRIPTSMODE_${script:T}?=       ${SCRIPTSMODE}
197 _scriptsinstall: _SCRIPTSINS_${script:T}
198 _SCRIPTSINS_${script:T}: ${script}
199         ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
200             -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
201             ${.ALLSRC} \
202             ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
203 .endfor
204 .endif
205
206 NLSNAME?=       ${PROG}
207 .include <bsd.nls.mk>
208
209 .include <bsd.files.mk>
210 .include <bsd.incs.mk>
211 .include <bsd.links.mk>
212
213 .if ${MK_MAN} != "no"
214 realinstall: _maninstall
215 .ORDER: beforeinstall _maninstall
216 .endif
217
218 .endif
219
220 .if !target(lint)
221 lint: ${SRCS:M*.c}
222 .if defined(PROG)
223         ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
224 .endif
225 .endif
226
227 .if ${MK_MAN} != "no"
228 .include <bsd.man.mk>
229 .endif
230
231 .include <bsd.dep.mk>
232
233 .if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
234 ${OBJS}: ${SRCS:M*.h}
235 .endif
236
237 .include <bsd.obj.mk>
238
239 .include <bsd.sys.mk>
240
241 .if defined(PORTNAME)
242 .include <bsd.pkg.mk>
243 .endif