bsd.lib.mk revision 1.276 1 1.276 christos # $NetBSD: bsd.lib.mk,v 1.276 2008/04/26 22:28:13 christos Exp $
2 1.92 mikel # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
3 1.1 cgd
4 1.188 tv .include <bsd.init.mk>
5 1.207 thorpej .include <bsd.shlib.mk>
6 1.219 thorpej .include <bsd.gcc.mk>
7 1.227 lukem # Pull in <bsd.sys.mk> here so we can override its .c.o rule
8 1.227 lukem .include <bsd.sys.mk>
9 1.97 mycroft
10 1.188 tv ##### Basic targets
11 1.246 lukem .PHONY: checkver libinstall
12 1.143 erh realinstall: checkver libinstall
13 1.183 tv clean: cleanlib
14 1.232 erh
15 1.232 erh ##### LIB specific flags.
16 1.267 mrg COPTS+= ${COPTS.lib${LIB}}
17 1.232 erh CPPFLAGS+= ${CPPFLAGS.lib${LIB}}
18 1.232 erh CXXFLAGS+= ${CXXFLAGS.lib${LIB}}
19 1.267 mrg OBJCOPTS+= ${OBJCOPTS.lib${LIB}}
20 1.232 erh LDADD+= ${LDADD.lib${LIB}}
21 1.233 erh LDFLAGS+= ${LDFLAGS.lib${LIB}}
22 1.233 erh LDSTATIC+= ${LDSTATIC.lib${LIB}}
23 1.1 cgd
24 1.256 lukem ##### Libraries that this may depend upon.
25 1.256 lukem .if defined(LIBDPLIBS) && ${MKPIC} != "no" # {
26 1.256 lukem .for _lib _dir in ${LIBDPLIBS}
27 1.256 lukem .if !defined(LIBDO.${_lib})
28 1.256 lukem LIBDO.${_lib}!= cd ${_dir} && ${PRINTOBJDIR}
29 1.256 lukem .MAKEOVERRIDES+=LIBDO.${_lib}
30 1.256 lukem .endif
31 1.256 lukem LDADD+= -L${LIBDO.${_lib}} -l${_lib}
32 1.256 lukem DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so
33 1.256 lukem .endfor
34 1.256 lukem .endif # }
35 1.256 lukem
36 1.188 tv ##### Build and install rules
37 1.240 dsl MKDEP_SUFFIXES?= .o .po .so .ln
38 1.192 thorpej CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
39 1.225 mrg CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
40 1.190 tv
41 1.252 lukem .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # {
42 1.154 simonb SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
43 1.154 simonb SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
44 1.171 christos SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
45 1.143 erh
46 1.143 erh # Check for higher installed library versions.
47 1.145 erh .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
48 1.201 lukem exists(${NETBSDSRCDIR}/lib/checkver)
49 1.143 erh checkver:
50 1.144 erh @(cd ${.CURDIR} && \
51 1.239 lukem ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
52 1.195 lukem -d ${DESTDIR}${_LIBSODIR} ${LIB})
53 1.173 christos .endif
54 1.252 lukem .endif # }
55 1.173 christos
56 1.173 christos .if !target(checkver)
57 1.143 erh checkver:
58 1.143 erh .endif
59 1.173 christos
60 1.169 thorpej print-shlib-major:
61 1.185 tv .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
62 1.169 thorpej @echo ${SHLIB_MAJOR}
63 1.173 christos .else
64 1.173 christos @false
65 1.173 christos .endif
66 1.169 thorpej
67 1.169 thorpej print-shlib-minor:
68 1.185 tv .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
69 1.169 thorpej @echo ${SHLIB_MINOR}
70 1.173 christos .else
71 1.173 christos @false
72 1.173 christos .endif
73 1.171 christos
74 1.171 christos print-shlib-teeny:
75 1.185 tv .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
76 1.171 christos @echo ${SHLIB_TEENY}
77 1.143 erh .else
78 1.169 thorpej @false
79 1.173 christos .endif
80 1.169 thorpej
81 1.252 lukem .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) # {
82 1.173 christos .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
83 1.173 christos .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
84 1.173 christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
85 1.173 christos .else
86 1.173 christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
87 1.173 christos .endif
88 1.173 christos .else
89 1.173 christos SHLIB_FULLVERSION=${SHLIB_MAJOR}
90 1.173 christos .endif
91 1.252 lukem .endif # }
92 1.1 cgd
93 1.101 mycroft # add additional suffixes not exported.
94 1.101 mycroft # .po is used for profiling object files.
95 1.101 mycroft # .so is used for PIC object files.
96 1.266 christos .SUFFIXES: .out .a .ln .so .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
97 1.118 lukem .SUFFIXES: .sh .m4 .m
98 1.82 mikel
99 1.86 jonathan
100 1.86 jonathan # Set PICFLAGS to cc flags for producing position-independent code,
101 1.86 jonathan # if not already set. Includes -DPIC, if required.
102 1.86 jonathan
103 1.164 simonb # Data-driven table using make variables to control how shared libraries
104 1.86 jonathan # are built for different platforms and object formats.
105 1.125 jonathan # OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
106 1.164 simonb # SHLIB_SOVERSION: version number to be compiled into a shared library
107 1.164 simonb # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
108 1.173 christos # NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
109 1.173 christos # [.${SHLIB_TEENY}]]
110 1.164 simonb # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
111 1.123 jonathan # with ELF, also set shared-lib version for ld.so.
112 1.123 jonathan # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
113 1.123 jonathan # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
114 1.179 dmcmahil # FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
115 1.271 tsutsui # CPPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
116 1.205 yamt # CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects.
117 1.205 yamt # CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
118 1.205 yamt # (usually includes ${CPICFLAGS})
119 1.205 yamt # CAPICFLAGS: flags for ${CC} to compiling .[Ss] files
120 1.107 jonathan # (usually just ${CPPPICFLAGS} ${CPICFLAGS})
121 1.164 simonb # APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
122 1.86 jonathan
123 1.252 lukem .if ${MACHINE_ARCH} == "alpha" # {
124 1.209 thorpej
125 1.179 dmcmahil FPICFLAGS ?= -fPIC
126 1.165 dmcmahil CPICFLAGS ?= -fPIC -DPIC
127 1.222 lukem CPPPICFLAGS?= -DPIC
128 1.107 jonathan CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
129 1.107 jonathan APICFLAGS ?=
130 1.209 thorpej
131 1.175 mrg .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
132 1.252 lukem ${OBJECT_FMT} == "ELF" # } {
133 1.209 thorpej
134 1.222 lukem # If you use -fPIC you need to define BIGPIC to turn on 32-bit
135 1.202 eeh # relocations in asm code
136 1.179 dmcmahil FPICFLAGS ?= -fPIC
137 1.165 dmcmahil CPICFLAGS ?= -fPIC -DPIC
138 1.202 eeh CPPPICFLAGS?= -DPIC -DBIGPIC
139 1.150 christos CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
140 1.203 eeh APICFLAGS ?= -KPIC
141 1.204 fredette
142 1.252 lukem .else # } {
143 1.86 jonathan
144 1.244 skrll # Platform-independent flags for NetBSD shared libraries
145 1.171 christos SHLIB_SOVERSION=${SHLIB_FULLVERSION}
146 1.125 jonathan SHLIB_SHFLAGS=
147 1.179 dmcmahil FPICFLAGS ?= -fPIC
148 1.165 dmcmahil CPICFLAGS?= -fPIC -DPIC
149 1.222 lukem CPPPICFLAGS?= -DPIC
150 1.107 jonathan CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
151 1.107 jonathan APICFLAGS?= -k
152 1.86 jonathan
153 1.252 lukem .endif # }
154 1.160 simonb
155 1.205 yamt .if ${MKPICLIB} != "no"
156 1.205 yamt CSHLIBFLAGS+= ${CPICFLAGS}
157 1.205 yamt .endif
158 1.205 yamt
159 1.205 yamt .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
160 1.205 yamt MKSHLIBOBJS= yes
161 1.205 yamt .else
162 1.205 yamt MKSHLIBOBJS= no
163 1.205 yamt .endif
164 1.205 yamt
165 1.123 jonathan # Platform-independent linker flags for ELF shared libraries
166 1.148 lukem .if ${OBJECT_FMT} == "ELF"
167 1.182 mrg SHLIB_SOVERSION= ${SHLIB_MAJOR}
168 1.221 drochner SHLIB_SHFLAGS= -Wl,-soname,lib${LIB}.so.${SHLIB_SOVERSION}
169 1.272 christos SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel
170 1.219 thorpej SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
171 1.219 thorpej SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
172 1.123 jonathan .endif
173 1.86 jonathan
174 1.82 mikel CFLAGS+= ${COPTS}
175 1.267 mrg OBJCFLAGS+= ${OBJCOPTS}
176 1.257 simonb AFLAGS+= ${COPTS}
177 1.179 dmcmahil FFLAGS+= ${FOPTS}
178 1.1 cgd
179 1.1 cgd .c.o:
180 1.238 lukem ${_MKTARGET_COMPILE}
181 1.263 dsl ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
182 1.270 martin .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
183 1.263 dsl ${OBJCOPY} -x ${.TARGET}
184 1.153 christos .endif
185 1.1 cgd
186 1.1 cgd .c.po:
187 1.238 lukem ${_MKTARGET_COMPILE}
188 1.263 dsl ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
189 1.270 martin .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
190 1.263 dsl ${OBJCOPY} -X ${.TARGET}
191 1.153 christos .endif
192 1.17 mycroft
193 1.266 christos .c.go:
194 1.266 christos ${_MKTARGET_COMPILE}
195 1.266 christos ${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
196 1.266 christos
197 1.27 pk .c.so:
198 1.238 lukem ${_MKTARGET_COMPILE}
199 1.263 dsl ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
200 1.270 martin .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
201 1.263 dsl ${OBJCOPY} -x ${.TARGET}
202 1.153 christos .endif
203 1.27 pk
204 1.223 lukem .cc.o .cpp.o .cxx.o .C.o:
205 1.238 lukem ${_MKTARGET_COMPILE}
206 1.263 dsl ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
207 1.270 martin .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
208 1.263 dsl ${OBJCOPY} -x ${.TARGET}
209 1.153 christos .endif
210 1.17 mycroft
211 1.266 christos .cc.po .cpp.po .cxx.po .C.po:
212 1.238 lukem ${_MKTARGET_COMPILE}
213 1.263 dsl ${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
214 1.270 martin .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
215 1.263 dsl ${OBJCOPY} -X ${.TARGET}
216 1.153 christos .endif
217 1.28 cgd
218 1.266 christos .cc.go .cpp.go .cxx.go .C.go:
219 1.266 christos ${_MKTARGET_COMPILE}
220 1.266 christos ${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
221 1.266 christos
222 1.223 lukem .cc.so .cpp.so .cxx.so .C.so:
223 1.238 lukem ${_MKTARGET_COMPILE}
224 1.263 dsl ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
225 1.270 martin .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
226 1.263 dsl ${OBJCOPY} -x ${.TARGET}
227 1.153 christos .endif
228 1.118 lukem
229 1.179 dmcmahil .f.o:
230 1.238 lukem ${_MKTARGET_COMPILE}
231 1.263 dsl ${COMPILE.f} ${.IMPSRC} -o ${.TARGET}
232 1.263 dsl .if !defined(FOPTS) || empty(FOPTS:M*-g*)
233 1.263 dsl ${OBJCOPY} -x ${.TARGET}
234 1.179 dmcmahil .endif
235 1.179 dmcmahil
236 1.179 dmcmahil .f.po:
237 1.238 lukem ${_MKTARGET_COMPILE}
238 1.263 dsl ${COMPILE.f} ${PROFFLAGS} -pg ${.IMPSRC} -o ${.TARGET}
239 1.263 dsl .if !defined(FOPTS) || empty(FOPTS:M*-g*)
240 1.263 dsl ${OBJCOPY} -X ${.TARGET}
241 1.179 dmcmahil .endif
242 1.179 dmcmahil
243 1.266 christos .f.go:
244 1.266 christos ${_MKTARGET_COMPILE}
245 1.266 christos ${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
246 1.266 christos
247 1.179 dmcmahil .f.so:
248 1.238 lukem ${_MKTARGET_COMPILE}
249 1.263 dsl ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
250 1.263 dsl .if !defined(FOPTS) || empty(FOPTS:M*-g*)
251 1.263 dsl ${OBJCOPY} -x ${.TARGET}
252 1.179 dmcmahil .endif
253 1.179 dmcmahil
254 1.179 dmcmahil .f.ln:
255 1.238 lukem ${_MKTARGET_COMPILE}
256 1.217 wiz @echo Skipping lint for Fortran libraries.
257 1.179 dmcmahil
258 1.118 lukem .m.o:
259 1.238 lukem ${_MKTARGET_COMPILE}
260 1.267 mrg ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
261 1.263 dsl .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
262 1.263 dsl ${OBJCOPY} -x ${.TARGET}
263 1.153 christos .endif
264 1.118 lukem
265 1.118 lukem .m.po:
266 1.238 lukem ${_MKTARGET_COMPILE}
267 1.267 mrg ${COMPILE.m} ${PROFFLAGS} -pg ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
268 1.263 dsl .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
269 1.263 dsl ${OBJCOPY} -X ${.TARGET}
270 1.153 christos .endif
271 1.118 lukem
272 1.266 christos .m.go:
273 1.266 christos ${_MKTARGET_COMPILE}
274 1.267 mrg ${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
275 1.266 christos .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
276 1.266 christos ${OBJCOPY} -X ${.TARGET}
277 1.266 christos .endif
278 1.266 christos
279 1.118 lukem .m.so:
280 1.238 lukem ${_MKTARGET_COMPILE}
281 1.267 mrg ${COMPILE.m} ${CSHLIBFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
282 1.263 dsl .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
283 1.263 dsl ${OBJCOPY} -x ${.TARGET}
284 1.153 christos .endif
285 1.1 cgd
286 1.251 lukem .s.o:
287 1.238 lukem ${_MKTARGET_COMPILE}
288 1.263 dsl ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
289 1.263 dsl ${OBJCOPY} -x ${.TARGET}
290 1.1 cgd
291 1.251 lukem .S.o:
292 1.251 lukem ${_MKTARGET_COMPILE}
293 1.263 dsl ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
294 1.263 dsl ${OBJCOPY} -x ${.TARGET}
295 1.251 lukem
296 1.251 lukem .s.po:
297 1.251 lukem ${_MKTARGET_COMPILE}
298 1.263 dsl ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
299 1.263 dsl ${OBJCOPY} -X ${.TARGET}
300 1.251 lukem
301 1.251 lukem .S.po:
302 1.238 lukem ${_MKTARGET_COMPILE}
303 1.263 dsl ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
304 1.263 dsl ${OBJCOPY} -X ${.TARGET}
305 1.1 cgd
306 1.266 christos .s.go:
307 1.266 christos ${_MKTARGET_COMPILE}
308 1.266 christos ${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
309 1.266 christos
310 1.266 christos .S.go:
311 1.266 christos ${_MKTARGET_COMPILE}
312 1.266 christos ${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
313 1.266 christos
314 1.251 lukem .s.so:
315 1.251 lukem ${_MKTARGET_COMPILE}
316 1.263 dsl ${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
317 1.263 dsl ${OBJCOPY} -x ${.TARGET}
318 1.251 lukem
319 1.251 lukem .S.so:
320 1.238 lukem ${_MKTARGET_COMPILE}
321 1.263 dsl ${COMPILE.S} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
322 1.263 dsl ${OBJCOPY} -x ${.TARGET}
323 1.27 pk
324 1.252 lukem .if defined(LIB) # {
325 1.234 lukem .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
326 1.234 lukem || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
327 1.130 tv _LIBS=lib${LIB}.a
328 1.130 tv .else
329 1.130 tv _LIBS=
330 1.130 tv .endif
331 1.58 cgd
332 1.167 matt OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
333 1.158 christos
334 1.255 thorpej STOBJS+=${OBJS}
335 1.255 thorpej
336 1.252 lukem .if ${MKPRIVATELIB} != "no"
337 1.252 lukem # No installation is required
338 1.252 lukem libinstall::
339 1.252 lukem .else # ${MKPRIVATELIB} == "no" # {
340 1.252 lukem
341 1.268 lukem .if ${MKDEBUGLIB} != "no"
342 1.266 christos _LIBS+=lib${LIB}_g.a
343 1.266 christos GOBJS+=${OBJS:.o=.go}
344 1.266 christos DEBUGFLAGS?=-DDEBUG
345 1.266 christos .endif
346 1.266 christos
347 1.149 lukem .if ${MKPROFILE} != "no"
348 1.130 tv _LIBS+=lib${LIB}_p.a
349 1.167 matt POBJS+=${OBJS:.o=.po}
350 1.262 christos PROFFLAGS?=-DGPROF -DPROF
351 1.1 cgd .endif
352 1.1 cgd
353 1.252 lukem .if ${MKPIC} != "no" # {
354 1.160 simonb .if ${MKPICLIB} == "no"
355 1.205 yamt .if ${MKSHLIBOBJS} != "no"
356 1.205 yamt # make _pic.a, which isn't really pic,
357 1.205 yamt # since it's needed for making shared lib.
358 1.205 yamt # but don't install it.
359 1.205 yamt SOLIB=lib${LIB}_pic.a
360 1.205 yamt SOBJS+=${OBJS:.o=.so}
361 1.205 yamt .else
362 1.160 simonb SOLIB=lib${LIB}.a
363 1.205 yamt .endif
364 1.160 simonb .else
365 1.160 simonb SOLIB=lib${LIB}_pic.a
366 1.160 simonb _LIBS+=${SOLIB}
367 1.167 matt SOBJS+=${OBJS:.o=.so}
368 1.160 simonb .endif
369 1.171 christos .if defined(SHLIB_FULLVERSION)
370 1.171 christos _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
371 1.27 pk .endif
372 1.252 lukem .endif # }
373 1.27 pk
374 1.179 dmcmahil LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
375 1.179 dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
376 1.58 cgd _LIBS+=llib-l${LIB}.ln
377 1.215 christos .endif
378 1.27 pk
379 1.252 lukem .endif # ${MKPRIVATELIB} == "no" # }
380 1.252 lukem
381 1.234 lukem ALLOBJS=
382 1.234 lukem .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
383 1.234 lukem || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
384 1.255 thorpej ALLOBJS+=${STOBJS}
385 1.179 dmcmahil .endif
386 1.234 lukem ALLOBJS+=${POBJS} ${SOBJS}
387 1.179 dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
388 1.179 dmcmahil ALLOBJS+=${LOBJS}
389 1.216 christos .endif
390 1.252 lukem .else # !defined(LIB) # } {
391 1.216 christos LOBJS=
392 1.216 christos SOBJS=
393 1.252 lukem .endif # !defined(LIB) # }
394 1.186 tv
395 1.254 lukem _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
396 1.253 christos
397 1.253 christos .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
398 1.158 christos
399 1.162 mycroft realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
400 1.1 cgd
401 1.243 rtr .if !target(__archivebuild)
402 1.90 christos __archivebuild: .USE
403 1.238 lukem ${_MKTARGET_BUILD}
404 1.236 lukem rm -f ${.TARGET}
405 1.228 lukem ${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
406 1.89 christos ${RANLIB} ${.TARGET}
407 1.243 rtr .endif
408 1.89 christos
409 1.243 rtr .if !target(__archiveinstall)
410 1.89 christos __archiveinstall: .USE
411 1.238 lukem ${_MKTARGET_INSTALL}
412 1.198 lukem ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
413 1.269 dbj ${empty(PRESERVE):?-a "${RANLIB} -t":} ${.ALLSRC} ${.TARGET}
414 1.243 rtr .endif
415 1.89 christos
416 1.197 mycroft __archivesymlinkpic: .USE
417 1.238 lukem ${_MKTARGET_INSTALL}
418 1.264 jwise ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
419 1.197 mycroft
420 1.253 christos DPSRCS+= ${_YLSRCS}
421 1.253 christos CLEANFILES+= ${_YLSRCS}
422 1.230 lukem
423 1.266 christos ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
424 1.103 mycroft
425 1.255 thorpej lib${LIB}.a:: ${STOBJS} __archivebuild
426 1.1 cgd
427 1.89 christos lib${LIB}_p.a:: ${POBJS} __archivebuild
428 1.1 cgd
429 1.89 christos lib${LIB}_pic.a:: ${SOBJS} __archivebuild
430 1.27 pk
431 1.266 christos lib${LIB}_g.a:: ${GOBJS} __archivebuild
432 1.266 christos
433 1.235 lukem
434 1.235 lukem _LIBLDOPTS=
435 1.235 lukem .if ${SHLIBDIR} != "/usr/lib"
436 1.235 lukem _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
437 1.235 lukem -R${SHLIBDIR} \
438 1.235 lukem -L${DESTDIR}${SHLIBDIR}
439 1.235 lukem .elif ${SHLIBINSTALLDIR} != "/usr/lib"
440 1.235 lukem _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
441 1.235 lukem -L${DESTDIR}${SHLIBINSTALLDIR}
442 1.235 lukem .endif
443 1.235 lukem
444 1.276 christos .if !defined(LIB)
445 1.274 christos DPLIBC ?= ${DESTDIR}${LIBC_SO}
446 1.274 christos LDLIBC ?= -lc
447 1.276 christos .else
448 1.276 christos .if ${LIB} != "c" && ${LIB:M*gcc*} == ""
449 1.276 christos DPLIBC ?= ${DESTDIR}${LIBC_SO}
450 1.276 christos LDLIBC ?= -lc
451 1.276 christos .endif
452 1.274 christos .endif
453 1.274 christos
454 1.274 christos lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
455 1.88 cgd ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
456 1.238 lukem ${_MKTARGET_BUILD}
457 1.236 lukem rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
458 1.152 fair .if defined(DESTDIR)
459 1.228 lukem ${CC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
460 1.235 lukem ${_LIBLDOPTS} \
461 1.231 lukem -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
462 1.221 drochner -Wl,--whole-archive ${SOLIB} \
463 1.221 drochner -Wl,--no-whole-archive ${LDADD} \
464 1.274 christos -L${_GCC_LIBGCCDIR} ${LDLIBC}
465 1.221 drochner .else
466 1.231 lukem ${CC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
467 1.235 lukem ${_LIBLDOPTS} \
468 1.274 christos -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD} \
469 1.274 christos ${LDLIBC}
470 1.152 fair .endif
471 1.148 lukem .if ${OBJECT_FMT} == "ELF"
472 1.196 lukem # We don't use INSTALL_SYMLINK here because this is just
473 1.196 lukem # happening inside the build directory/objdir. XXX Why does
474 1.196 lukem # this spend so much effort on libraries that aren't live??? XXX
475 1.241 matt ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
476 1.177 mycroft mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
477 1.241 matt ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
478 1.177 mycroft mv -f lib${LIB}.so.tmp lib${LIB}.so
479 1.133 tv .endif
480 1.35 pk
481 1.252 lukem .if !empty(LOBJS) # {
482 1.103 mycroft LLIBS?= -lc
483 1.58 cgd llib-l${LIB}.ln: ${LOBJS}
484 1.238 lukem ${_MKTARGET_COMPILE}
485 1.236 lukem rm -f llib-l${LIB}.ln
486 1.206 thorpej .if defined(DESTDIR)
487 1.228 lukem ${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
488 1.206 thorpej .else
489 1.228 lukem ${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
490 1.206 thorpej .endif
491 1.252 lukem .endif # }
492 1.1 cgd
493 1.246 lukem cleanlib: .PHONY
494 1.48 mycroft rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
495 1.255 thorpej rm -f lib${LIB}.a ${STOBJS}
496 1.59 cgd rm -f lib${LIB}_p.a ${POBJS}
497 1.266 christos rm -f lib${LIB}_g.a ${GOBJS}
498 1.133 tv rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
499 1.266 christos rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp}
500 1.59 cgd rm -f llib-l${LIB}.ln ${LOBJS}
501 1.1 cgd
502 1.252 lukem
503 1.252 lukem .if !target(libinstall) # {
504 1.148 lukem # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
505 1.139 tv libinstall::
506 1.139 tv
507 1.234 lukem .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
508 1.89 christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
509 1.168 mycroft .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
510 1.197 mycroft
511 1.269 dbj .if ${MKUPDATE} == "no"
512 1.197 mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
513 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
514 1.89 christos .endif
515 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
516 1.197 mycroft .else
517 1.157 fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
518 1.89 christos ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
519 1.89 christos .endif
520 1.89 christos ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
521 1.130 tv .endif
522 1.197 mycroft .endif
523 1.89 christos
524 1.149 lukem .if ${MKPROFILE} != "no"
525 1.89 christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
526 1.168 mycroft .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
527 1.197 mycroft
528 1.269 dbj .if ${MKUPDATE} == "no"
529 1.197 mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
530 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
531 1.32 pk .endif
532 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
533 1.197 mycroft .else
534 1.157 fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
535 1.89 christos ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
536 1.89 christos .endif
537 1.89 christos ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
538 1.89 christos .endif
539 1.197 mycroft .endif
540 1.89 christos
541 1.268 lukem .if ${MKDEBUGLIB} != "no"
542 1.266 christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
543 1.266 christos .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
544 1.266 christos
545 1.269 dbj .if ${MKUPDATE} == "no"
546 1.266 christos .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
547 1.266 christos ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! .MADE
548 1.266 christos .endif
549 1.266 christos ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! lib${LIB}_g.a __archiveinstall
550 1.266 christos .else
551 1.266 christos .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
552 1.266 christos ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: .MADE
553 1.266 christos .endif
554 1.266 christos ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: lib${LIB}_g.a __archiveinstall
555 1.266 christos .endif
556 1.266 christos .endif
557 1.266 christos
558 1.149 lukem .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
559 1.168 mycroft libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
560 1.160 simonb .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
561 1.197 mycroft
562 1.269 dbj .if ${MKUPDATE} == "no"
563 1.197 mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
564 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
565 1.89 christos .endif
566 1.197 mycroft .if ${MKPICLIB} == "no"
567 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
568 1.197 mycroft .else
569 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
570 1.197 mycroft .endif
571 1.197 mycroft .else
572 1.157 fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
573 1.89 christos ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
574 1.33 pk .endif
575 1.160 simonb .if ${MKPICLIB} == "no"
576 1.197 mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
577 1.160 simonb .else
578 1.89 christos ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
579 1.160 simonb .endif
580 1.89 christos .endif
581 1.197 mycroft .endif
582 1.89 christos
583 1.171 christos .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
584 1.195 lukem libinstall:: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
585 1.195 lukem .PRECIOUS: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
586 1.197 mycroft
587 1.269 dbj .if ${MKUPDATE} == "no"
588 1.197 mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
589 1.197 mycroft ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! .MADE
590 1.89 christos .endif
591 1.197 mycroft ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
592 1.197 mycroft .else
593 1.171 christos .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
594 1.195 lukem ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE
595 1.89 christos .endif
596 1.195 lukem ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
597 1.197 mycroft .endif
598 1.238 lukem ${_MKTARGET_INSTALL}
599 1.188 tv ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
600 1.264 jwise ${.ALLSRC} ${.TARGET}
601 1.195 lukem .if ${_LIBSODIR} != ${LIBDIR}
602 1.264 jwise ${INSTALL_SYMLINK} \
603 1.261 lukem -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
604 1.208 perry ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
605 1.195 lukem .endif
606 1.148 lukem .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
607 1.195 lukem /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
608 1.146 thorpej .endif
609 1.148 lukem .if ${OBJECT_FMT} == "ELF"
610 1.264 jwise ${INSTALL_SYMLINK} \
611 1.208 perry lib${LIB}.so.${SHLIB_FULLVERSION} \
612 1.208 perry ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_MAJOR}
613 1.195 lukem .if ${_LIBSODIR} != ${LIBDIR}
614 1.264 jwise ${INSTALL_SYMLINK} \
615 1.265 christos -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
616 1.208 perry ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
617 1.195 lukem .endif
618 1.148 lukem .if ${MKLINKLIB} != "no"
619 1.264 jwise ${INSTALL_SYMLINK} \
620 1.208 perry lib${LIB}.so.${SHLIB_FULLVERSION} \
621 1.208 perry ${DESTDIR}${_LIBSODIR}/lib${LIB}.so
622 1.195 lukem .if ${_LIBSODIR} != ${LIBDIR}
623 1.264 jwise ${INSTALL_SYMLINK} \
624 1.260 lukem -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
625 1.208 perry ${DESTDIR}${LIBDIR}/lib${LIB}.so
626 1.195 lukem .endif
627 1.83 cgd .endif
628 1.12 cgd .endif
629 1.139 tv .endif
630 1.89 christos
631 1.179 dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
632 1.89 christos libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
633 1.168 mycroft .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
634 1.197 mycroft
635 1.269 dbj .if ${MKUPDATE} == "no"
636 1.197 mycroft .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
637 1.197 mycroft ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
638 1.89 christos .endif
639 1.197 mycroft ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
640 1.197 mycroft .else
641 1.157 fredb .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
642 1.89 christos ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
643 1.89 christos .endif
644 1.95 mycroft ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
645 1.197 mycroft .endif
646 1.238 lukem ${_MKTARGET_INSTALL}
647 1.188 tv ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
648 1.264 jwise ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
649 1.58 cgd .endif
650 1.252 lukem .endif # !target(libinstall) # }
651 1.1 cgd
652 1.188 tv ##### Pull in related .mk logic
653 1.1 cgd .include <bsd.man.mk>
654 1.57 jtc .include <bsd.nls.mk>
655 1.91 christos .include <bsd.files.mk>
656 1.89 christos .include <bsd.inc.mk>
657 1.109 cjs .include <bsd.links.mk>
658 1.24 mycroft .include <bsd.dep.mk>
659 1.117 mycroft
660 1.188 tv ${TARGETS}: # ensure existence
661