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