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