xref: /freebsd/contrib/bmake/mk/lib.mk (revision 7d8f797b725e3efc0a4256554654780df83c456c)
1# $Id: lib.mk,v 1.51 2014/05/23 01:30:36 sjg Exp $
2
3.if !target(__${.PARSEFILE}__)
4__${.PARSEFILE}__:
5
6.include <init.mk>
7
8.if ${OBJECT_FMT} == "ELF"
9NEED_SOLINKS?= yes
10.endif
11
12.if exists(${.CURDIR}/shlib_version)
13SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
14SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
15.endif
16
17print-shlib-major:
18.if defined(SHLIB_MAJOR) && ${MK_PIC} != "no"
19	@echo ${SHLIB_MAJOR}
20.else
21	@false
22.endif
23
24print-shlib-minor:
25.if defined(SHLIB_MINOR) && ${MK_PIC} != "no"
26	@echo ${SHLIB_MINOR}
27.else
28	@false
29.endif
30
31print-shlib-teeny:
32.if defined(SHLIB_TEENY) && ${MK_PIC} != "no"
33	@echo ${SHLIB_TEENY}
34.else
35	@false
36.endif
37
38SHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.}
39SHLIB_FULLVERSION := ${SHLIB_FULLVERSION}
40
41# add additional suffixes not exported.
42# .po is used for profiling object files.
43# .so is used for PIC object files.
44.SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
45.SUFFIXES: .sh .m4 .m
46
47CFLAGS+=	${COPTS}
48
49# Derrived from NetBSD-1.6
50
51# Set PICFLAGS to cc flags for producing position-independent code,
52# if not already set.  Includes -DPIC, if required.
53
54# Data-driven table using make variables to control how shared libraries
55# are built for different platforms and object formats.
56# OBJECT_FMT:		currently either "ELF" or "a.out", from <bsd.own.mk>
57# SHLIB_SOVERSION:	version number to be compiled into a shared library
58#			via -soname. Usually ${SHLIB_MAJOR} on ELF.
59#			NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
60#			[.${SHLIB_TEENY}]]
61# SHLIB_SHFLAGS:	Flags to tell ${LD} to emit shared library.
62#			with ELF, also set shared-lib version for ld.so.
63# SHLIB_LDSTARTFILE:	support .o file, call C++ file-level constructors
64# SHLIB_LDENDFILE:	support .o file, call C++ file-level destructors
65# FPICFLAGS:		flags for ${FC} to compile .[fF] files to .so objects.
66# CPPICFLAGS:		flags for ${CPP} to preprocess .[sS] files for ${AS}
67# CPICFLAGS:		flags for ${CC} to compile .[cC] files to .so objects.
68# CAPICFLAGS		flags for {$CC} to compiling .[Ss] files
69#		 	(usually just ${CPPPICFLAGS} ${CPICFLAGS})
70# APICFLAGS:		flags for ${AS} to assemble .[sS] to .so objects.
71
72.if ${TARGET_OSNAME} == "NetBSD"
73.if ${MACHINE_ARCH} == "alpha"
74		# Alpha-specific shared library flags
75FPICFLAGS ?= -fPIC
76CPICFLAGS ?= -fPIC -DPIC
77CPPPICFLAGS?= -DPIC
78CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
79APICFLAGS ?=
80.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
81		# mips-specific shared library flags
82
83# On mips, all libs are compiled with ABIcalls, not just sharedlibs.
84MKPICLIB= no
85
86# so turn shlib PIC flags on for ${AS}.
87AINC+=-DABICALLS
88AFLAGS+= -fPIC
89AS+=	-KPIC
90
91.elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF"
92# On the VAX, all object are PIC by default, not just sharedlibs.
93MKPICLIB= no
94
95.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
96       ${OBJECT_FMT} == "ELF"
97# If you use -fPIC you need to define BIGPIC to turn on 32-bit
98# relocations in asm code
99FPICFLAGS ?= -fPIC
100CPICFLAGS ?= -fPIC -DPIC
101CPPPICFLAGS?= -DPIC -DBIGPIC
102CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
103APICFLAGS ?= -KPIC
104
105.else
106
107# Platform-independent flags for NetBSD a.out shared libraries
108SHLIB_SOVERSION=${SHLIB_FULLVERSION}
109SHLIB_SHFLAGS=
110FPICFLAGS ?= -fPIC
111CPICFLAGS?= -fPIC -DPIC
112CPPPICFLAGS?= -DPIC
113CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
114APICFLAGS?= -k
115
116.endif
117
118# Platform-independent linker flags for ELF shared libraries
119.if ${OBJECT_FMT} == "ELF"
120SHLIB_SOVERSION=	${SHLIB_MAJOR}
121SHLIB_SHFLAGS=		-soname lib${LIB}.so.${SHLIB_SOVERSION}
122SHLIB_LDSTARTFILE?=	/usr/lib/crtbeginS.o
123SHLIB_LDENDFILE?=	/usr/lib/crtendS.o
124.endif
125
126# for compatibility with the following
127CC_PIC?= ${CPICFLAGS}
128LD_shared=${SHLIB_SHFLAGS}
129
130.endif # NetBSD
131
132.if ${TARGET_OSNAME} == "FreeBSD"
133.if ${OBJECT_FMT} == "ELF"
134SHLIB_SOVERSION=	${SHLIB_MAJOR}
135SHLIB_SHFLAGS=		-soname lib${LIB}.so.${SHLIB_SOVERSION}
136.else
137SHLIB_SHFLAGS=		-assert pure-text
138.endif
139SHLIB_LDSTARTFILE=
140SHLIB_LDENDFILE=
141CC_PIC?= -fpic
142LD_shared=${SHLIB_SHFLAGS}
143
144.endif # FreeBSD
145
146MKPICLIB?= yes
147
148# sys.mk can override these
149LD_X?=-X
150LD_x?=-x
151LD_r?=-r
152
153# Non BSD machines will be using bmake.
154.if ${TARGET_OSNAME} == "SunOS"
155LD_shared=-assert pure-text
156.if ${OBJECT_FMT} == "ELF" || ${MACHINE} == "solaris"
157# Solaris
158LD_shared=-h lib${LIB}.so.${SHLIB_MAJOR} -G
159.endif
160.elif ${TARGET_OSNAME} == "HP-UX"
161LD_shared=-b
162LD_so=sl
163DLLIB=
164# HPsUX lorder does not grok anything but .o
165LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
166LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
167.elif ${TARGET_OSNAME} == "OSF1"
168LD_shared= -msym -shared -expect_unresolved '*'
169LD_solib= -all lib${LIB}_pic.a
170DLLIB=
171# lorder does not grok anything but .o
172LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
173LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
174AR_cq= -cqs
175.elif ${TARGET_OSNAME} == "FreeBSD"
176LD_solib= lib${LIB}_pic.a
177.elif ${TARGET_OSNAME} == "Linux"
178SHLIB_LD = ${CC}
179# this is ambiguous of course
180LD_shared=-shared -Wl,"-h lib${LIB}.so.${SHLIB_MAJOR}"
181LD_solib= -Wl,--whole-archive lib${LIB}_pic.a -Wl,--no-whole-archive
182# Linux uses GNU ld, which is a multi-pass linker
183# so we don't need to use lorder or tsort
184LD_objs = ${OBJS}
185LD_pobjs = ${POBJS}
186LD_sobjs = ${SOBJS}
187.elif ${TARGET_OSNAME} == "Darwin"
188SHLIB_LD = ${CC}
189SHLIB_INSTALL_VERSION ?= ${SHLIB_MAJOR}
190SHLIB_COMPATABILITY_VERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR:U0}
191SHLIB_COMPATABILITY ?= \
192	-compatibility_version ${SHLIB_COMPATABILITY_VERSION} \
193	-current_version ${SHLIB_FULLVERSION}
194LD_shared = -dynamiclib \
195	-flat_namespace -undefined suppress \
196	-install_name ${LIBDIR}/lib${LIB}.${SHLIB_INSTALL_VERSION}.${LD_solink} \
197	${SHLIB_COMPATABILITY}
198SHLIB_LINKS =
199.for v in ${SHLIB_COMPATABILITY_VERSION} ${SHLIB_INSTALL_VERSION}
200.if "$v" != "${SHLIB_FULLVERSION}"
201SHLIB_LINKS += lib${LIB}.$v.${LD_solink}
202.endif
203.endfor
204.if ${MK_LINKLIB} != "no"
205SHLIB_LINKS += lib${LIB}.${LD_solink}
206.endif
207
208LD_so = ${SHLIB_FULLVERSION}.dylib
209LD_sobjs = ${SOBJS:O:u}
210LD_solib = ${LD_sobjs}
211SOLIB = ${LD_sobjs}
212LD_solink = dylib
213.if ${MACHINE_ARCH} == "i386"
214PICFLAG ?= -fPIC
215.else
216PICFLAG ?= -fPIC -fno-common
217.endif
218RANLIB = :
219.endif
220
221SHLIB_LD ?= ${LD}
222
223.if !empty(SHLIB_MAJOR)
224.if ${NEED_SOLINKS} && empty(SHLIB_LINKS)
225.if ${MK_LINKLIB} != "no"
226SHLIB_LINKS = lib${LIB}.${LD_solink}
227.endif
228.if "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
229SHLIB_LINKS += lib${LIB}.${LD_solink}.${SHLIB_MAJOR}
230.endif
231.endif
232.endif
233
234LIBTOOL?=libtool
235LD_shared ?= -Bshareable -Bforcearchive
236LD_so ?= so.${SHLIB_FULLVERSION}
237LD_solink ?= so
238.if empty(LORDER)
239LD_objs ?= ${OBJS}
240LD_pobjs ?= ${POBJS}
241LD_sobjs ?= ${SOBJS}
242.else
243LD_objs ?= `${LORDER} ${OBJS} | ${TSORT}`
244LD_sobjs ?= `${LORDER} ${SOBJS} | ${TSORT}`
245LD_pobjs ?= `${LORDER} ${POBJS} | ${TSORT}`
246.endif
247LD_solib ?= ${LD_sobjs}
248AR_cq ?= cq
249.if exists(/netbsd) && exists(${DESTDIR}/usr/lib/libdl.so)
250DLLIB ?= -ldl
251.endif
252
253# some libs have lots of objects, and scanning all .o, .po and .So meta files
254# is a waste of time, this tells meta.autodep.mk to just pick one
255# (typically .So)
256# yes, 42 is a random number.
257.if ${MK_META_MODE} == "yes" && ${SRCS:Uno:[\#]} > 42
258OPTIMIZE_OBJECT_META_FILES ?= yes
259.endif
260
261
262.if ${MK_LIBTOOL} == "yes"
263# because libtool is so fascist about naming the object files,
264# we cannot (yet) build profiled libs
265MK_PROFILE=no
266_LIBS=lib${LIB}.a
267.if exists(${.CURDIR}/shlib_version)
268SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
269.endif
270.else
271# for the normal .a we do not want to strip symbols
272.c.o:
273	${COMPILE.c} ${.IMPSRC}
274
275# for the normal .a we do not want to strip symbols
276.cc.o .C.o:
277	${COMPILE.cc} ${.IMPSRC}
278
279.S.o .s.o:
280	@echo ${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
281	@${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
282
283.if (${LD_X} == "")
284.c.po:
285	${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
286
287.cc.po .C.po:
288	${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
289
290.S.so .s.so:
291	${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
292.else
293.c.po:
294	@echo ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
295	@${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o
296	@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
297	@rm -f ${.TARGET}.o
298
299.cc.po .C.po:
300	@echo ${COMPILE.cc} ${CXX_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
301	@${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o
302	@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
303	@rm -f ${.TARGET}.o
304
305.S.so .s.so:
306	@echo ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
307	@${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
308	@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
309	@rm -f ${.TARGET}.o
310.endif
311
312.if (${LD_x} == "")
313.c.so:
314	${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
315
316.cc.so .C.so:
317	${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
318
319.S.po .s.po:
320	${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
321.else
322
323.c.so:
324	@echo ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
325	@${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
326	@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
327	@rm -f ${.TARGET}.o
328
329.cc.so .C.so:
330	@echo ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
331	@${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
332	@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
333	@rm -f ${.TARGET}.o
334
335.S.po .s.po:
336	@echo ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
337	@${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
338	@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
339	@rm -f ${.TARGET}.o
340
341.endif
342.endif
343
344.c.ln:
345	${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
346
347.if ${MK_LIBTOOL} != "yes"
348
349.if !defined(PICFLAG)
350PICFLAG=-fpic
351.endif
352
353_LIBS=
354
355.if ${MK_ARCHIVE} != "no"
356_LIBS += lib${LIB}.a
357.endif
358
359.if ${MK_PROFILE} != "no"
360_LIBS+=lib${LIB}_p.a
361POBJS+=${OBJS:.o=.po}
362.endif
363
364.if ${MK_PIC} != "no"
365.if ${MK_PICLIB} == "no"
366SOLIB ?= lib${LIB}.a
367.else
368SOLIB=lib${LIB}_pic.a
369_LIBS+=${SOLIB}
370.endif
371.if !empty(SHLIB_FULLVERSION)
372_LIBS+=lib${LIB}.${LD_so}
373.endif
374.endif
375
376.if ${MK_LINT} != "no"
377_LIBS+=llib-l${LIB}.ln
378.endif
379
380# here is where you can define what LIB* are
381.-include <libnames.mk>
382.if ${MK_DPADD_MK} == "yes"
383# lots of cool magic, but might not suit everyone.
384.include <dpadd.mk>
385.endif
386
387.if !defined(_SKIP_BUILD)
388all: prebuild .WAIT ${_LIBS}
389# a hook for things that must be done early
390prebuild:
391.if !defined(.PARSEDIR)
392# no-op is the best we can do if not bmake.
393.WAIT:
394.endif
395.endif
396all: _SUBDIRUSE
397
398.for s in ${SRCS:N*.h:M*/*}
399${.o .so .po .lo:L:@o@${s:T:R}$o@}: $s
400.endfor
401
402OBJS+=	${SRCS:T:N*.h:R:S/$/.o/g}
403.NOPATH:	${OBJS}
404
405.if ${MK_LIBTOOL} == "yes"
406.if ${MK_PIC} == "no"
407LT_STATIC=-static
408.else
409LT_STATIC=
410.endif
411SHLIB_AGE?=0
412
413# .lo's are created as a side effect
414.s.o .S.o .c.o:
415	${LIBTOOL} --mode=compile ${CC} ${LT_STATIC} ${CFLAGS} ${CPPFLAGS} ${IMPFLAGS} -c ${.IMPSRC}
416
417# can't really do profiled libs with libtool - its too fascist about
418# naming the output...
419lib${LIB}.a:: ${OBJS}
420	@rm -f ${.TARGET}
421	${LIBTOOL} --mode=link ${CC} ${LT_STATIC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} -rpath ${SHLIBDIR}:/usr/lib -version-info ${SHLIB_MAJOR}:${SHLIB_MINOR}:${SHLIB_AGE}
422	@ln .libs/${.TARGET} .
423
424lib${LIB}.${LD_so}:: lib${LIB}.a
425	@[ -s ${.TARGET}.${SHLIB_AGE} ] || { ln -s .libs/lib${LIB}.${LD_so}* . 2>/dev/null; : }
426	@[ -s ${.TARGET} ] || ln -s ${.TARGET}.${SHLIB_AGE} ${.TARGET}
427
428.else  # MK_LIBTOOL=yes
429
430lib${LIB}.a:: ${OBJS}
431	@echo building standard ${LIB} library
432	@rm -f ${.TARGET}
433	@${AR} ${AR_cq} ${.TARGET} ${LD_objs}
434	${RANLIB} ${.TARGET}
435
436POBJS+=	${OBJS:.o=.po}
437.NOPATH:	${POBJS}
438lib${LIB}_p.a:: ${POBJS}
439	@echo building profiled ${LIB} library
440	@rm -f ${.TARGET}
441	@${AR} ${AR_cq} ${.TARGET} ${LD_pobjs}
442	${RANLIB} ${.TARGET}
443
444SOBJS+=	${OBJS:.o=.so}
445.NOPATH:	${SOBJS}
446lib${LIB}_pic.a:: ${SOBJS}
447	@echo building shared object ${LIB} library
448	@rm -f ${.TARGET}
449	@${AR} ${AR_cq} ${.TARGET} ${LD_sobjs}
450	${RANLIB} ${.TARGET}
451
452#SHLIB_LDADD?= ${LDADD}
453
454# bound to be non-portable...
455# this is known to work for NetBSD 1.6 and FreeBSD 4.2
456lib${LIB}.${LD_so}: ${SOLIB} ${DPADD}
457	@echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
458	@rm -f ${.TARGET}
459.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD"
460.if ${OBJECT_FMT} == "ELF"
461	${SHLIB_LD} -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
462	    ${SHLIB_LDSTARTFILE} \
463	    --whole-archive ${SOLIB} --no-whole-archive ${SHLIB_LDADD} \
464	    ${SHLIB_LDENDFILE}
465.else
466	${SHLIB_LD} ${LD_x} ${LD_shared} \
467	    -o ${.TARGET} ${SOLIB} ${SHLIB_LDADD}
468.endif
469.else
470	${SHLIB_LD} -o ${.TARGET} ${LD_shared} ${LD_solib} ${DLLIB} ${SHLIB_LDADD}
471.endif
472.endif
473.if !empty(SHLIB_LINKS)
474	rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s ${.TARGET} $x;@}
475.endif
476
477LOBJS+=	${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
478.NOPATH:	${LOBJS}
479LLIBS?=	-lc
480llib-l${LIB}.ln: ${LOBJS}
481	@echo building llib-l${LIB}.ln
482	@rm -f llib-l${LIB}.ln
483	@${LINT} -C${LIB} ${LOBJS} ${LLIBS}
484
485.if !target(clean)
486cleanlib: .PHONY
487	rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
488	rm -f lib${LIB}.a ${OBJS}
489	rm -f lib${LIB}_p.a ${POBJS}
490	rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
491	rm -f llib-l${LIB}.ln ${LOBJS}
492.if !empty(SHLIB_LINKS)
493	rm -f ${SHLIB_LINKS}
494.endif
495
496clean: _SUBDIRUSE cleanlib
497cleandir: _SUBDIRUSE cleanlib
498.else
499cleandir: _SUBDIRUSE clean
500.endif
501
502.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep)
503afterdepend: .depend
504	@(TMP=/tmp/_depend$$$$; \
505	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
506	      < .depend > $$TMP; \
507	    mv $$TMP .depend)
508.endif
509
510.if !target(install)
511.if !target(beforeinstall)
512beforeinstall:
513.endif
514
515.if !empty(LIBOWN)
516LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
517.endif
518
519.include <links.mk>
520
521.if !target(realinstall)
522realinstall: libinstall
523.endif
524.if !target(libinstall)
525libinstall:
526	[ -d ${DESTDIR}/${LIBDIR} ] || \
527	${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR}
528.if ${MK_ARCHIVE} != "no"
529	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 lib${LIB}.a \
530	    ${DESTDIR}${LIBDIR}
531	${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}.a
532	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
533.endif
534.if ${MK_PROFILE} != "no"
535	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \
536	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
537	${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
538	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
539.endif
540.if ${MK_PIC} != "no"
541.if ${MK_PICLIB} != "no"
542	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \
543	    lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
544	${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
545	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
546.endif
547.if !empty(SHLIB_MAJOR)
548	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
549	    lib${LIB}.${LD_so} ${DESTDIR}${LIBDIR}
550.if !empty(SHLIB_LINKS)
551	(cd ${DESTDIR}${LIBDIR} && { rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s lib${LIB}.${LD_so} $x;@} })
552.endif
553.endif
554.endif
555.if ${MK_LINT} != "no" && ${MK_LINKLIB} != "no" && !empty(LOBJS)
556	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
557	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
558.endif
559.if defined(LINKS) && !empty(LINKS)
560	@set ${LINKS}; ${_LINKS_SCRIPT}
561.endif
562.endif
563
564install: maninstall _SUBDIRUSE
565maninstall: afterinstall
566afterinstall: realinstall
567realinstall: beforeinstall
568.endif
569
570.if ${MK_MAN} != "no"
571.include <man.mk>
572.endif
573
574.if ${MK_NLS} != "no"
575.include <nls.mk>
576.endif
577
578.include <obj.mk>
579.include <inc.mk>
580.include <dep.mk>
581.include <subdir.mk>
582.endif
583
584# during building we usually need/want to install libs somewhere central
585# note that we do NOT ch{own,grp} as that would likely fail at this point.
586# otherwise it is the same as realinstall
587# Note that we don't need this when using dpadd.mk
588.libinstall:	${_LIBS}
589	test -d ${DESTDIR}${LIBDIR} || ${INSTALL} -d -m775 ${DESTDIR}${LIBDIR}
590.for _lib in ${_LIBS:M*.a}
591	${INSTALL} ${COPY} -m 644 ${_lib} ${DESTDIR}${LIBDIR}
592	${RANLIB} ${DESTDIR}${LIBDIR}/${_lib}
593.endfor
594.for _lib in ${_LIBS:M*.${LD_solink}*:O:u}
595	${INSTALL} ${COPY} -m ${LIBMODE} ${_lib} ${DESTDIR}${LIBDIR}
596.if !empty(SHLIB_LINKS)
597	(cd ${DESTDIR}${LIBDIR} && { ${SHLIB_LINKS:O:u:@x@ln -sf ${_lib} $x;@}; })
598.endif
599.endfor
600	@touch ${.TARGET}
601
602.include <final.mk>
603.endif
604