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