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