xref: /minix3/share/mk/bsd.lib.mk (revision b2ed49a5d83e311ee0fa9e5ff613639b1bf77aaf)
10a6a1f1dSLionel Sambuc#	$NetBSD: bsd.lib.mk,v 1.362 2015/09/08 16:06:42 uebayasi Exp $
2e1091647SArun Thomas#	@(#)bsd.lib.mk	8.3 (Berkeley) 4/22/94
3e1091647SArun Thomas
4e1091647SArun Thomas.include <bsd.init.mk>
54b999f19SBen Gras.include <bsd.shlib.mk>
69152e1c5SLionel Sambuc.include <bsd.gcc.mk>
7e1091647SArun Thomas# Pull in <bsd.sys.mk> here so we can override its .c.o rule
8e1091647SArun Thomas.include <bsd.sys.mk>
9e1091647SArun Thomas
1039fea0a5SBen GrasLIBISMODULE?=	no
11e1091647SArun ThomasLIBISPRIVATE?=	no
1239fea0a5SBen GrasLIBISCXX?=	no
13e1091647SArun Thomas
1439fea0a5SBen Gras.if ${LIBISMODULE} != "no"
1584d9c625SLionel Sambuc_LIB_PREFIX?=	# empty
1639fea0a5SBen GrasMKDEBUGLIB:=	no
1739fea0a5SBen GrasMKLINT:=	no
1839fea0a5SBen GrasMKPICINSTALL:=	no
1939fea0a5SBen GrasMKPROFILE:=	no
2039fea0a5SBen GrasMKSTATICLIB:=	no
2184d9c625SLionel Sambuc.else
2284d9c625SLionel Sambuc_LIB_PREFIX?=	lib
2339fea0a5SBen Gras.endif
2439fea0a5SBen Gras
2539fea0a5SBen Gras.if ${LIBISPRIVATE} != "no"
2639fea0a5SBen GrasMKDEBUGLIB:=	no
2739fea0a5SBen GrasMKLINT:=	no
2839fea0a5SBen GrasMKPICINSTALL:=	no
2939fea0a5SBen Gras. if defined(NOSTATICLIB) && ${MKPICLIB} != "no"
3039fea0a5SBen GrasMKSTATICLIB:=	no
3139fea0a5SBen Gras. else
3239fea0a5SBen GrasMKPIC:=		no
3339fea0a5SBen Gras. endif
3439fea0a5SBen GrasMKPROFILE:=	no
3539fea0a5SBen Gras.endif
36e1091647SArun Thomas
37e1091647SArun Thomas##### Basic targets
3839fea0a5SBen Gras.PHONY:		checkver libinstall
3939fea0a5SBen Grasrealinstall:	checkver libinstall
40e1091647SArun Thomas
41e1091647SArun Thomas##### LIB specific flags.
4239fea0a5SBen Gras# XXX: This is needed for programs that link with .a libraries
4339fea0a5SBen Gras# Perhaps a more correct solution is to always generate _pic.a
4439fea0a5SBen Gras# files or always have a shared library.
4539fea0a5SBen Gras.if defined(MKPIE) && (${MKPIE} != "no")
4639fea0a5SBen GrasCFLAGS+=        ${PIE_CFLAGS}
4739fea0a5SBen GrasAFLAGS+=        ${PIE_AFLAGS}
4839fea0a5SBen Gras.endif
49e1091647SArun Thomas
50e1091647SArun Thomas##### Libraries that this may depend upon.
51e1091647SArun Thomas.if defined(LIBDPLIBS) && ${MKPIC} != "no"				# {
52e1091647SArun Thomas.for _lib _dir in ${LIBDPLIBS}
53e1091647SArun Thomas.if !defined(LIBDO.${_lib})
549152e1c5SLionel SambucLIBDO.${_lib}!=	cd "${_dir}" && ${PRINTOBJDIR}
55e1091647SArun Thomas.MAKEOVERRIDES+=LIBDO.${_lib}
56e1091647SArun Thomas.endif
5784d9c625SLionel Sambuc.if ${LIBDO.${_lib}} == "_external"
5884d9c625SLionel SambucLDADD+=		-l${_lib}
5984d9c625SLionel Sambuc.else
60e1091647SArun ThomasLDADD+=		-L${LIBDO.${_lib}} -l${_lib}
6184d9c625SLionel SambucDPADD+=		${LIBDO.${_lib}}/lib${_lib}.so	# Don't use _LIB_PREFIX
6284d9c625SLionel Sambuc.endif
63e1091647SArun Thomas.endfor
64e1091647SArun Thomas.endif									# }
65e1091647SArun Thomas
66e1091647SArun Thomas##### Build and install rules
670a6a1f1dSLionel SambucMKDEP_SUFFIXES?=	.o .po .pico .go .ln .d
6839fea0a5SBen Gras
6939fea0a5SBen Gras.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})		# {
7039fea0a5SBen GrasSHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
7139fea0a5SBen GrasSHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
7239fea0a5SBen GrasSHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
7339fea0a5SBen Gras
7439fea0a5SBen GrasDPADD+=	${SHLIB_VERSION_FILE}
7539fea0a5SBen Gras
7639fea0a5SBen Gras# Check for higher installed library versions.
7739fea0a5SBen Gras.if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
7839fea0a5SBen Gras	exists(${NETBSDSRCDIR}/lib/checkver)
7939fea0a5SBen Grascheckver:
809152e1c5SLionel Sambuc	@(cd "${.CURDIR}" && \
8139fea0a5SBen Gras	    HOST_SH=${HOST_SH:Q} AWK=${TOOL_AWK:Q} \
8239fea0a5SBen Gras	    ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
8384d9c625SLionel Sambuc		    -d ${_DEST.OBJ} ${LIB})
8439fea0a5SBen Gras.endif
8539fea0a5SBen Gras.endif									# }
8639fea0a5SBen Gras
8739fea0a5SBen Gras.if !target(checkver)
8839fea0a5SBen Grascheckver:
8939fea0a5SBen Gras.endif
9039fea0a5SBen Gras
9139fea0a5SBen Grasprint-shlib-major:
9239fea0a5SBen Gras.if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
9339fea0a5SBen Gras	@echo ${SHLIB_MAJOR}
9439fea0a5SBen Gras.else
9539fea0a5SBen Gras	@false
9639fea0a5SBen Gras.endif
9739fea0a5SBen Gras
9839fea0a5SBen Grasprint-shlib-minor:
9939fea0a5SBen Gras.if defined(SHLIB_MINOR) && ${MKPIC} != "no"
10039fea0a5SBen Gras	@echo ${SHLIB_MINOR}
10139fea0a5SBen Gras.else
10239fea0a5SBen Gras	@false
10339fea0a5SBen Gras.endif
10439fea0a5SBen Gras
10539fea0a5SBen Grasprint-shlib-teeny:
10639fea0a5SBen Gras.if defined(SHLIB_TEENY) && ${MKPIC} != "no"
10739fea0a5SBen Gras	@echo ${SHLIB_TEENY}
10839fea0a5SBen Gras.else
10939fea0a5SBen Gras	@false
11039fea0a5SBen Gras.endif
11139fea0a5SBen Gras
11239fea0a5SBen Gras.if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR)				# {
11339fea0a5SBen Gras.if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
11439fea0a5SBen Gras.if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
11539fea0a5SBen GrasSHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
11639fea0a5SBen Gras.else
11739fea0a5SBen GrasSHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
11839fea0a5SBen Gras.endif
11939fea0a5SBen Gras.else
12039fea0a5SBen GrasSHLIB_FULLVERSION=${SHLIB_MAJOR}
12139fea0a5SBen Gras.endif
12239fea0a5SBen Gras.endif									# }
12339fea0a5SBen Gras
124e1091647SArun Thomas# add additional suffixes not exported.
125e1091647SArun Thomas# .po is used for profiling object files.
1269152e1c5SLionel Sambuc# .pico is used for PIC object files.
1279152e1c5SLionel Sambuc.SUFFIXES: .out .a .ln .pico .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
12839fea0a5SBen Gras.SUFFIXES: .sh .m4 .m
12939fea0a5SBen Gras
13039fea0a5SBen Gras
13139fea0a5SBen Gras# Set PICFLAGS to cc flags for producing position-independent code,
13284d9c625SLionel Sambuc# if not already set.
13339fea0a5SBen Gras
13439fea0a5SBen Gras# Data-driven table using make variables to control how shared libraries
13539fea0a5SBen Gras# are built for different platforms and object formats.
1369152e1c5SLionel Sambuc# SHLIB_MAJOR, SHLIB_MINOR, SHLIB_TEENY: Major, minor, and teeny version
1379152e1c5SLionel Sambuc#			numbers of shared library
13839fea0a5SBen Gras# SHLIB_SOVERSION:	version number to be compiled into a shared library
13939fea0a5SBen Gras#			via -soname. Usualy ${SHLIB_MAJOR} on ELF.
14039fea0a5SBen Gras#			NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
14139fea0a5SBen Gras#			[.${SHLIB_TEENY}]]
14239fea0a5SBen Gras# SHLIB_SHFLAGS:	Flags to tell ${LD} to emit shared library.
14339fea0a5SBen Gras#			with ELF, also set shared-lib version for ld.so.
14439fea0a5SBen Gras# SHLIB_LDSTARTFILE:	support .o file, call C++ file-level constructors
14539fea0a5SBen Gras# SHLIB_LDENDFILE:	support .o file, call C++ file-level destructors
14639fea0a5SBen Gras
14784d9c625SLionel SambucPICFLAGS ?= -fPIC
14839fea0a5SBen Gras
14939fea0a5SBen Gras.if ${MKPICLIB} != "no"
15084d9c625SLionel SambucCSHLIBFLAGS+= ${PICFLAGS}
15139fea0a5SBen Gras.endif
15239fea0a5SBen Gras
15339fea0a5SBen Gras.if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
15439fea0a5SBen GrasMKSHLIBOBJS= yes
15539fea0a5SBen Gras.else
15639fea0a5SBen GrasMKSHLIBOBJS= no
15739fea0a5SBen Gras.endif
15839fea0a5SBen Gras
15984d9c625SLionel Sambuc.if (defined(MKDEBUG) && (${MKDEBUG} != "no")) || \
16084d9c625SLionel Sambuc    (defined(CFLAGS) && !empty(CFLAGS:M*-g*))
16184d9c625SLionel Sambuc# We only add -g to the shared library objects
16284d9c625SLionel Sambuc# because we don't currently split .a archives.
16384d9c625SLionel SambucCSHLIBFLAGS+=	-g
16484d9c625SLionel Sambuc.if ${LIBISPRIVATE} == "yes"
16584d9c625SLionel SambucCFLAGS+=	-g
16684d9c625SLionel Sambuc.endif
16784d9c625SLionel Sambuc.endif
16884d9c625SLionel Sambuc
16939fea0a5SBen Gras# Platform-independent linker flags for ELF shared libraries
17039fea0a5SBen GrasSHLIB_SOVERSION=	${SHLIB_MAJOR}
17184d9c625SLionel SambucSHLIB_SHFLAGS=		-Wl,-soname,${_LIB}.so.${SHLIB_SOVERSION}
1720a6a1f1dSLionel Sambuc.if !defined(SHLIB_WARNTEXTREL) || ${SHLIB_WARNTEXTREL} != "no"
17339fea0a5SBen GrasSHLIB_SHFLAGS+=		-Wl,--warn-shared-textrel
1740a6a1f1dSLionel Sambuc.endif
17584d9c625SLionel Sambuc.if !defined(SHLIB_MKMAP) || ${SHLIB_MKMAP} != "no"
17684d9c625SLionel SambucSHLIB_SHFLAGS+=		-Wl,-Map=${_LIB}.so.${SHLIB_SOVERSION}.map
17784d9c625SLionel Sambuc.endif
17884d9c625SLionel SambucCLEANFILES+=		${_LIB}.so.${SHLIB_SOVERSION}.map
1799152e1c5SLionel SambucSHLIB_LDSTARTFILE?=	${_GCC_CRTI} ${_GCC_CRTBEGINS}
1809152e1c5SLionel SambucSHLIB_LDENDFILE?=	${_GCC_CRTENDS} ${_GCC_CRTN}
181e1091647SArun Thomas
182e1091647SArun ThomasCFLAGS+=	${COPTS}
183e1091647SArun ThomasOBJCFLAGS+=	${OBJCOPTS}
184e1091647SArun ThomasAFLAGS+=	${COPTS}
185e1091647SArun ThomasFFLAGS+=	${FOPTS}
186e1091647SArun Thomas
1879152e1c5SLionel Sambuc.if defined(CTFCONVERT)
1889152e1c5SLionel Sambuc.if defined(CFLAGS) && !empty(CFLAGS:M*-g*)
1899152e1c5SLionel SambucCTFFLAGS+=	-g
1900a6a1f1dSLionel Sambuc.if defined(HAVE_GCC) && ${HAVE_GCC} >= 48
1910a6a1f1dSLionel Sambuc#CFLAGS+=	-gdwarf-2
1920a6a1f1dSLionel Sambuc.endif
1939152e1c5SLionel Sambuc.endif
1949152e1c5SLionel Sambuc.endif
1959152e1c5SLionel Sambuc
19684d9c625SLionel SambucLIBSTRIPAOBJS=	yes
19784d9c625SLionel Sambuc.if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
19884d9c625SLionel SambucLIBSTRIPCOBJS=	yes
19984d9c625SLionel Sambuc.endif
20084d9c625SLionel Sambuc.if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
20184d9c625SLionel SambucLIBSTRIPOBJCOBJS=	yes
20284d9c625SLionel Sambuc.endif
20384d9c625SLionel Sambuc.if !defined(FFLAGS) || empty(FFLAGS:M*-g*)
20484d9c625SLionel SambucLIBSTRIPFOBJS=	yes
20584d9c625SLionel Sambuc.endif
20684d9c625SLionel Sambuc.if !defined(CSHLIBFLAGS) || empty(CSHLIBFLAGS:M*-g*)
20784d9c625SLionel SambucLIBSTRIPSHLIBOBJS=	yes
20884d9c625SLionel Sambuc.endif
20984d9c625SLionel Sambuc
21084d9c625SLionel Sambuc.if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
2114684ddb6SLionel SambucSHLIB_SHFLAGS+= -L ${DESTDIR}/usr/lib
2124684ddb6SLionel SambucSHLIB_SHFLAGS+= -Wl,-plugin=${GOLD_PLUGIN} \
2134684ddb6SLionel Sambuc		-Wl,-plugin-opt=-disable-opt
21484d9c625SLionel Sambuc
2159b9bea92SDavid van MoolenbroekSECTIONIFYPASS?=${NETBSDSRCDIR}/minix/llvm/bin/sectionify.so
216*b2ed49a5SDavid van Moolenbroek# dcvmoole: the following construction is a hack for libmagicrt.  For reasons
217*b2ed49a5SDavid van Moolenbroek# not entirely under our control, clang refuses to take .bc objects even when
218*b2ed49a5SDavid van Moolenbroek# using the gold linker, saying that LLVM IR code cannot be linked.  In order
219*b2ed49a5SDavid van Moolenbroek# to sidestep this, libmagicrt uses the name "foo.bc.o" instead of "foo.bc" to
220*b2ed49a5SDavid van Moolenbroek# link the its LLVM IR objects.  As all libmagicrt modules use the sectionify
221*b2ed49a5SDavid van Moolenbroek# pass below, and this step needs temporary files, we give the temporary files
222*b2ed49a5SDavid van Moolenbroek# the .o suffix (while anything would do!), and allow the libmagicrt makefile
223*b2ed49a5SDavid van Moolenbroek# to override the rename to the real file name to perform a copy instead.  As
224*b2ed49a5SDavid van Moolenbroek# a result, libmagicrt ends up with both the .bc and .bc.o objects, and it can
225*b2ed49a5SDavid van Moolenbroek# pass the latter set to clang, bypassing clang's overly strict checks.
226*b2ed49a5SDavid van MoolenbroekSECTIONIFYMV?=mv -f
2279b9bea92SDavid van Moolenbroek
2282e304675SAnton Kuijsten.S.bc: ${.TARGET:.bc=.o}
2292e304675SAnton Kuijsten	rm -f ${.TARGET}
2302e304675SAnton Kuijsten	ln ${.TARGET:.bc=.o} ${.TARGET}
2312e304675SAnton Kuijsten.c.bc:
2322e304675SAnton Kuijsten	${_MKTARGET_COMPILE}
2334684ddb6SLionel Sambuc	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} -flto
234*b2ed49a5SDavid van Moolenbroek	if [ -n '${SECTIONIFY.${.IMPSRC:T}:U${SECTIONIFY}}' ]; then \
235*b2ed49a5SDavid van Moolenbroek		${OPT} -load ${SECTIONIFYPASS} -sectionify ${SECTIONIFY.${.IMPSRC:T}:U${SECTIONIFY}} -o ${.TARGET}.o ${.TARGET} && ${SECTIONIFYMV} ${.TARGET}.o ${.TARGET}; \
2369b9bea92SDavid van Moolenbroek	fi
2374684ddb6SLionel Sambuc
2384684ddb6SLionel Sambuc.cc.bc .cxx.bc .cpp.bc:
2394684ddb6SLionel Sambuc	${_MKTARGET_COMPILE}
2404684ddb6SLionel Sambuc	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} -flto
24184d9c625SLionel Sambuc.endif # defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
242e1091647SArun Thomas.c.o:
243e1091647SArun Thomas	${_MKTARGET_COMPILE}
244e1091647SArun Thomas	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
2459152e1c5SLionel Sambuc.if defined(CTFCONVERT)
2469152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
2479152e1c5SLionel Sambuc.endif
24884d9c625SLionel Sambuc.if defined(LIBSTRIPCOBJS)
2499152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
25039fea0a5SBen Gras.endif
25139fea0a5SBen Gras
25239fea0a5SBen Gras.c.po:
25339fea0a5SBen Gras	${_MKTARGET_COMPILE}
25439fea0a5SBen Gras	${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
2559152e1c5SLionel Sambuc.if defined(CTFCONVERT)
2569152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
2579152e1c5SLionel Sambuc.endif
25884d9c625SLionel Sambuc.if defined(LIBSTRIPCOBJS)
2599152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
26039fea0a5SBen Gras.endif
26139fea0a5SBen Gras
26239fea0a5SBen Gras.c.go:
26339fea0a5SBen Gras	${_MKTARGET_COMPILE}
26439fea0a5SBen Gras	${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
26539fea0a5SBen Gras
2669152e1c5SLionel Sambuc.c.pico:
26739fea0a5SBen Gras	${_MKTARGET_COMPILE}
26839fea0a5SBen Gras	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
26984d9c625SLionel Sambuc.if defined(LIBSTRIPSHLIBOBJS)
2709152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
27139fea0a5SBen Gras.endif
272e1091647SArun Thomas
273e1091647SArun Thomas.cc.o .cpp.o .cxx.o .C.o:
274e1091647SArun Thomas	${_MKTARGET_COMPILE}
275e1091647SArun Thomas	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
27684d9c625SLionel Sambuc.if defined(LIBSTRIPCOBJS)
2779152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
27839fea0a5SBen Gras.endif
27939fea0a5SBen Gras
28039fea0a5SBen Gras.cc.po .cpp.po .cxx.po .C.po:
28139fea0a5SBen Gras	${_MKTARGET_COMPILE}
28239fea0a5SBen Gras	${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
28384d9c625SLionel Sambuc.if defined(LIBSTRIPCOBJS)
2849152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
28539fea0a5SBen Gras.endif
28639fea0a5SBen Gras
28739fea0a5SBen Gras.cc.go .cpp.go .cxx.go .C.go:
28839fea0a5SBen Gras	${_MKTARGET_COMPILE}
28939fea0a5SBen Gras	${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
29039fea0a5SBen Gras
2919152e1c5SLionel Sambuc.cc.pico .cpp.pico .cxx.pico .C.pico:
29239fea0a5SBen Gras	${_MKTARGET_COMPILE}
29339fea0a5SBen Gras	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
29484d9c625SLionel Sambuc.if defined(LIBSTRIPSHLIBOBJS)
2959152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
29639fea0a5SBen Gras.endif
29739fea0a5SBen Gras
29839fea0a5SBen Gras.f.o:
29939fea0a5SBen Gras	${_MKTARGET_COMPILE}
30039fea0a5SBen Gras	${COMPILE.f} ${.IMPSRC} -o ${.TARGET}
3019152e1c5SLionel Sambuc.if defined(CTFCONVERT)
3029152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
3039152e1c5SLionel Sambuc.endif
30484d9c625SLionel Sambuc.if defined(LIBSTRIPFOBJS)
3059152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
30639fea0a5SBen Gras.endif
30739fea0a5SBen Gras
30839fea0a5SBen Gras.f.po:
30939fea0a5SBen Gras	${_MKTARGET_COMPILE}
31039fea0a5SBen Gras	${COMPILE.f} ${PROFFLAGS} -pg ${.IMPSRC} -o ${.TARGET}
3119152e1c5SLionel Sambuc.if defined(CTFCONVERT)
3129152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
3139152e1c5SLionel Sambuc.endif
31484d9c625SLionel Sambuc.if defined(LIBSTRIPFOBJS)
3159152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
31639fea0a5SBen Gras.endif
31739fea0a5SBen Gras
31839fea0a5SBen Gras.f.go:
31939fea0a5SBen Gras	${_MKTARGET_COMPILE}
32039fea0a5SBen Gras	${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
32139fea0a5SBen Gras
3229152e1c5SLionel Sambuc.f.pico:
32339fea0a5SBen Gras	${_MKTARGET_COMPILE}
32484d9c625SLionel Sambuc	${COMPILE.f} ${PICFLAGS} ${.IMPSRC} -o ${.TARGET}
32584d9c625SLionel Sambuc.if defined(LIBSTRIPFOBJS)
3269152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
32739fea0a5SBen Gras.endif
32839fea0a5SBen Gras
32939fea0a5SBen Gras.f.ln:
33039fea0a5SBen Gras	${_MKTARGET_COMPILE}
33139fea0a5SBen Gras	@echo Skipping lint for Fortran libraries.
33239fea0a5SBen Gras
33339fea0a5SBen Gras.m.o:
33439fea0a5SBen Gras	${_MKTARGET_COMPILE}
33539fea0a5SBen Gras	${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
3369152e1c5SLionel Sambuc.if defined(CTFCONVERT)
3379152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
3389152e1c5SLionel Sambuc.endif
33984d9c625SLionel Sambuc.if defined(LIBSTRIPOBJCOBJS)
3409152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
34139fea0a5SBen Gras.endif
34239fea0a5SBen Gras
34339fea0a5SBen Gras.m.po:
34439fea0a5SBen Gras	${_MKTARGET_COMPILE}
34539fea0a5SBen Gras	${COMPILE.m} ${PROFFLAGS} -pg ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
3469152e1c5SLionel Sambuc.if defined(CTFCONVERT)
3479152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
3489152e1c5SLionel Sambuc.endif
34984d9c625SLionel Sambuc.if defined(LIBSTRIPOBJCOBJS)
3509152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
35139fea0a5SBen Gras.endif
35239fea0a5SBen Gras
35339fea0a5SBen Gras.m.go:
35439fea0a5SBen Gras	${_MKTARGET_COMPILE}
35539fea0a5SBen Gras	${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
35684d9c625SLionel Sambuc.if defined(LIBSTRIPOBJCOBJS)
3579152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
35839fea0a5SBen Gras.endif
35939fea0a5SBen Gras
3609152e1c5SLionel Sambuc.m.pico:
36139fea0a5SBen Gras	${_MKTARGET_COMPILE}
36239fea0a5SBen Gras	${COMPILE.m} ${CSHLIBFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
36384d9c625SLionel Sambuc.if defined(LIBSTRIPOBJCOBJS)
3649152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
36539fea0a5SBen Gras.endif
366e1091647SArun Thomas
367e1091647SArun Thomas.s.o:
368e1091647SArun Thomas	${_MKTARGET_COMPILE}
369e1091647SArun Thomas	${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
3709152e1c5SLionel Sambuc.if defined(CTFCONVERT)
3719152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
3729152e1c5SLionel Sambuc.endif
37384d9c625SLionel Sambuc.if defined(LIBSTRIPAOBJS)
3749152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
37584d9c625SLionel Sambuc.endif
376e1091647SArun Thomas
377e1091647SArun Thomas.S.o:
378e1091647SArun Thomas	${_MKTARGET_COMPILE}
379e1091647SArun Thomas	${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
3809152e1c5SLionel Sambuc.if defined(CTFCONVERT)
3819152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
3829152e1c5SLionel Sambuc.endif
38384d9c625SLionel Sambuc.if defined(LIBSTRIPAOBJS)
3849152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
38584d9c625SLionel Sambuc.endif
386e1091647SArun Thomas
38739fea0a5SBen Gras.s.po:
38839fea0a5SBen Gras	${_MKTARGET_COMPILE}
38939fea0a5SBen Gras	${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
3909152e1c5SLionel Sambuc.if defined(CTFCONVERT)
3919152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
3929152e1c5SLionel Sambuc.endif
39384d9c625SLionel Sambuc.if defined(LIBSTRIPAOBJS)
3949152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
39584d9c625SLionel Sambuc.endif
39639fea0a5SBen Gras
39739fea0a5SBen Gras.S.po:
39839fea0a5SBen Gras	${_MKTARGET_COMPILE}
39939fea0a5SBen Gras	${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
4009152e1c5SLionel Sambuc.if defined(CTFCONVERT)
4019152e1c5SLionel Sambuc	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
4029152e1c5SLionel Sambuc.endif
40384d9c625SLionel Sambuc.if defined(LIBSTRIPAOBJS)
4049152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
40584d9c625SLionel Sambuc.endif
40639fea0a5SBen Gras
40739fea0a5SBen Gras.s.go:
40839fea0a5SBen Gras	${_MKTARGET_COMPILE}
40939fea0a5SBen Gras	${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
41039fea0a5SBen Gras
41139fea0a5SBen Gras.S.go:
41239fea0a5SBen Gras	${_MKTARGET_COMPILE}
41339fea0a5SBen Gras	${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
41439fea0a5SBen Gras
4159152e1c5SLionel Sambuc.s.pico:
41639fea0a5SBen Gras	${_MKTARGET_COMPILE}
41784d9c625SLionel Sambuc	${COMPILE.s} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
41884d9c625SLionel Sambuc.if defined(LIBSTRIPAOBJS)
4199152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
42084d9c625SLionel Sambuc.endif
42139fea0a5SBen Gras
4229152e1c5SLionel Sambuc.S.pico:
42339fea0a5SBen Gras	${_MKTARGET_COMPILE}
42484d9c625SLionel Sambuc	${COMPILE.S} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
42584d9c625SLionel Sambuc.if defined(LIBSTRIPAOBJS)
4269152e1c5SLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
42784d9c625SLionel Sambuc.endif
42884d9c625SLionel Sambuc
42984d9c625SLionel Sambuc# Declare a few variables to make our life easier later.
43084d9c625SLionel Sambuc_LIB:=${_LIB_PREFIX}${LIB}
43184d9c625SLionel Sambuc_LIB.a:=${_LIB}.a
43284d9c625SLionel Sambuc_LIB_p.a:=${_LIB}_p.a
43384d9c625SLionel Sambuc_LIB_g.a:=${_LIB}_g.a
43484d9c625SLionel Sambuc_LIB_pic.a:=${_LIB}_pic.a
43584d9c625SLionel Sambuc_LIB.ln:=llib-l${LIB}.ln
43684d9c625SLionel Sambuc.if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
43784d9c625SLionel Sambuc_LIB_bc.a:=${_LIB}_bc.a
43884d9c625SLionel Sambuc.endif # defined(__MINIX)
43984d9c625SLionel Sambuc
44084d9c625SLionel Sambuc.if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
44184d9c625SLionel Sambuc_LIB.so:=${_LIB}.so
44284d9c625SLionel Sambuc_LIB.so.major:=${_LIB}.so.${SHLIB_MAJOR}
44384d9c625SLionel Sambuc_LIB.so.full:=${_LIB}.so.${SHLIB_FULLVERSION}
4440a6a1f1dSLionel Sambuc_LIB.so.link:=${_LIB}.so.${SHLIB_FULLVERSION}.link
44584d9c625SLionel Sambuc.if ${MKDEBUG} != "no"
44684d9c625SLionel Sambuc_LIB.so.debug:=${_LIB.so.full}.debug
44784d9c625SLionel Sambuc.endif
44884d9c625SLionel Sambuc.endif
44984d9c625SLionel Sambuc
45084d9c625SLionel Sambuc_DEST.LIB:=${DESTDIR}${LIBDIR}
45184d9c625SLionel Sambuc_DEST.OBJ:=${DESTDIR}${_LIBSODIR}
45284d9c625SLionel Sambuc_DEST.LINT:=${DESTDIR}${LINTLIBDIR}
45384d9c625SLionel Sambuc_DEST.DEBUG:=${DESTDIR}${DEBUGDIR}${LIBDIR}
45484d9c625SLionel Sambuc_DEST.ODEBUG:=${DESTDIR}${DEBUGDIR}${_LIBSODIR}
455e1091647SArun Thomas
456e1091647SArun Thomas.if defined(LIB)							# {
45739fea0a5SBen Gras.if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
45839fea0a5SBen Gras	|| ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
45984d9c625SLionel Sambuc_LIBS=${_LIB.a}
46039fea0a5SBen Gras.else
46139fea0a5SBen Gras_LIBS=
462e1091647SArun Thomas.endif
463e1091647SArun Thomas
4649152e1c5SLionel Sambuc.if ${LIBISPRIVATE} != "no" \
4659152e1c5SLionel Sambuc   && (defined(USE_COMBINE) && ${USE_COMBINE} == "yes" \
4669152e1c5SLionel Sambuc   && !defined(NOCOMBINE))						# {
4679152e1c5SLionel Sambuc.for f in ${SRCS:N*.h:N*.sh:C/\.[yl]$/.c/g}
4689152e1c5SLionel SambucCOMBINEFLAGS.${LIB}.$f := ${CPPFLAGS.$f:D1} ${CPUFLAGS.$f:D2} ${COPTS.$f:D3} ${OBJCOPTS.$f:D4} ${CXXFLAGS.$f:D5}
4699152e1c5SLionel Sambuc.if empty(COMBINEFLAGS.${LIB}.${f}) && !defined(NOCOMBINE.$f)
4709152e1c5SLionel SambucCOMBINESRCS+=	${f}
4719152e1c5SLionel SambucNODPSRCS+=	${f}
4729152e1c5SLionel Sambuc.else
4739152e1c5SLionel SambucOBJS+=  	${f:R:S/$/.o/}
4749152e1c5SLionel Sambuc.endif
4759152e1c5SLionel Sambuc.endfor
4769152e1c5SLionel Sambuc
4779152e1c5SLionel Sambuc.if !empty(COMBINESRCS)
47884d9c625SLionel SambucOBJS+=		${_LIB}_combine.o
47984d9c625SLionel Sambuc${_LIB}_combine.o: ${COMBINESRCS}
4809152e1c5SLionel Sambuc	${_MKTARGET_COMPILE}
4819152e1c5SLionel Sambuc	${COMPILE.c} -MD --combine ${.ALLSRC} -o ${.TARGET}
48284d9c625SLionel Sambuc.if defined(LIBSTRIPOBJS)
4830a6a1f1dSLionel Sambuc	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
4849152e1c5SLionel Sambuc.endif
4859152e1c5SLionel Sambuc
48684d9c625SLionel SambucCLEANFILES+=	${_LIB}_combine.d
4879152e1c5SLionel Sambuc
48884d9c625SLionel Sambuc.if exists("${_LIB}_combine.d")
48984d9c625SLionel Sambuc.include "${_LIB}_combine.d"
4909152e1c5SLionel Sambuc.endif
4919152e1c5SLionel Sambuc.endif   # empty(XSRCS.${LIB})
4929152e1c5SLionel Sambuc.else							# } {
493e1091647SArun ThomasOBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
4949152e1c5SLionel Sambuc.endif							# }
495e1091647SArun Thomas
496e1091647SArun ThomasSTOBJS+=${OBJS}
497e1091647SArun Thomas
498e1091647SArun ThomasLOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
499e1091647SArun Thomas
500e1091647SArun Thomas.if ${LIBISPRIVATE} != "no"
501e1091647SArun Thomas# No installation is required
502e1091647SArun Thomaslibinstall::
5039152e1c5SLionel Sambuc.endif
504e1091647SArun Thomas
50539fea0a5SBen Gras.if ${MKDEBUGLIB} != "no"
50684d9c625SLionel Sambuc_LIBS+=${_LIB_g.a}
50739fea0a5SBen GrasGOBJS+=${OBJS:.o=.go}
50839fea0a5SBen GrasDEBUGFLAGS?=-DDEBUG
50939fea0a5SBen Gras.endif
510e1091647SArun Thomas
51139fea0a5SBen Gras.if ${MKPROFILE} != "no"
51284d9c625SLionel Sambuc_LIBS+=${_LIB_p.a}
51339fea0a5SBen GrasPOBJS+=${OBJS:.o=.po}
51439fea0a5SBen GrasPROFFLAGS?=-DGPROF -DPROF
51539fea0a5SBen Gras.endif
51639fea0a5SBen Gras
51739fea0a5SBen Gras.if ${MKPIC} != "no"							# {
51839fea0a5SBen Gras.if ${MKPICLIB} == "no"
51939fea0a5SBen Gras.if ${MKSHLIBOBJS} != "no"
52039fea0a5SBen Gras# make _pic.a, which isn't really pic,
52139fea0a5SBen Gras# since it's needed for making shared lib.
52239fea0a5SBen Gras# but don't install it.
52384d9c625SLionel SambucSOLIB=${_LIB_pic.a}
5249152e1c5SLionel SambucSOBJS+=${OBJS:.o=.pico}
52539fea0a5SBen Gras.else
52684d9c625SLionel SambucSOLIB=${_LIB.a}
52739fea0a5SBen Gras.endif
52839fea0a5SBen Gras.else
52984d9c625SLionel SambucSOLIB=${_LIB_pic.a}
53039fea0a5SBen Gras_LIBS+=${SOLIB}
5319152e1c5SLionel SambucSOBJS+=${OBJS:.o=.pico}
53239fea0a5SBen Gras.endif
53339fea0a5SBen Gras.if defined(SHLIB_FULLVERSION)
53484d9c625SLionel Sambuc_LIBS+=${_LIB.so.full}
53539fea0a5SBen Gras.endif
53639fea0a5SBen Gras.endif									# }
53739fea0a5SBen Gras
53839fea0a5SBen Gras.if ${MKLINT} != "no" && !empty(LOBJS)
53984d9c625SLionel Sambuc_LIBS+=${_LIB.ln}
54039fea0a5SBen Gras.endif
54139fea0a5SBen Gras
54239fea0a5SBen GrasALLOBJS=
54339fea0a5SBen Gras.if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
54439fea0a5SBen Gras	|| ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
545e1091647SArun ThomasALLOBJS+=${STOBJS}
54639fea0a5SBen Gras.endif
54739fea0a5SBen GrasALLOBJS+=${POBJS} ${SOBJS}
54839fea0a5SBen Gras.if ${MKLINT} != "no" && !empty(LOBJS)
54939fea0a5SBen GrasALLOBJS+=${LOBJS}
55039fea0a5SBen Gras.endif
55139fea0a5SBen Gras.else	# !defined(LIB)							# } {
55239fea0a5SBen GrasLOBJS=
55339fea0a5SBen GrasSOBJS=
55439fea0a5SBen Gras.endif	# !defined(LIB)							# }
555e1091647SArun Thomas
556e1091647SArun Thomas_YLSRCS=	${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
557e1091647SArun Thomas
5582e304675SAnton Kuijsten.if ${USE_BITCODE:Uno} == "yes"
559*b2ed49a5SDavid van Moolenbroek.if defined(LIB)
56084d9c625SLionel Sambuc_LIBS+=${_LIB_bc.a}
561*b2ed49a5SDavid van Moolenbroek.endif
56284d9c625SLionel Sambuc.endif # ${USE_BITCODE:Uno} == "yes"
5632e304675SAnton Kuijsten
564e1091647SArun Thomas.NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
565e1091647SArun Thomas
56684d9c625SLionel Sambucrealall: ${SRCS} ${ALLOBJS:O} ${_LIBS} ${_LIB.so.debug}
567e1091647SArun Thomas
5680a6a1f1dSLionel SambucMKARZERO?= ${MKREPRO:Uno}
569e1091647SArun Thomas
57039fea0a5SBen Gras.if ${MKARZERO} == "yes"
57139fea0a5SBen Gras_ARFL=crsD
57239fea0a5SBen Gras_ARRANFL=sD
57339fea0a5SBen Gras_INSTRANLIB=
57439fea0a5SBen Gras.else
57539fea0a5SBen Gras_ARFL=crs
57639fea0a5SBen Gras_ARRANFL=s
5774684ddb6SLionel Sambuc.if ${USE_BITCODE:Uno} == "yes"
5784684ddb6SLionel Sambuc_INSTRANLIB=${empty(PRESERVE):?-a "${AR} --plugin ${GOLD_PLUGIN} -s":}
5794684ddb6SLionel Sambuc.else
5809152e1c5SLionel Sambuc_INSTRANLIB=${empty(PRESERVE):?-a "${RANLIB} -t":}
5814684ddb6SLionel Sambuc.endif # ${USE_BITCODE:Uno} == "yes"
58239fea0a5SBen Gras.endif
583e1091647SArun Thomas
58439fea0a5SBen Gras# If you change this, please consider reflecting the change in
58539fea0a5SBen Gras# the override in sys/rump/Makefile.rump.
58639fea0a5SBen Gras.if !target(__archivebuild)
587e1091647SArun Thomas__archivebuild: .USE
588e1091647SArun Thomas	${_MKTARGET_BUILD}
589e1091647SArun Thomas	rm -f ${.TARGET}
590b8a678efSLionel Sambuc	${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
59139fea0a5SBen Gras.endif
592e1091647SArun Thomas
59339fea0a5SBen Gras.if !target(__archiveinstall)
594e1091647SArun Thomas__archiveinstall: .USE
595e1091647SArun Thomas	${_MKTARGET_INSTALL}
596e1091647SArun Thomas	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
597e1091647SArun Thomas	    ${_INSTRANLIB} ${.ALLSRC} ${.TARGET}
59839fea0a5SBen Gras.endif
59939fea0a5SBen Gras
60039fea0a5SBen Gras__archivesymlinkpic: .USE
60139fea0a5SBen Gras	${_MKTARGET_INSTALL}
60239fea0a5SBen Gras	${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
603e1091647SArun Thomas
604e1091647SArun ThomasDPSRCS+=	${_YLSRCS}
605e1091647SArun ThomasCLEANFILES+=	${_YLSRCS}
606e1091647SArun Thomas
607e1091647SArun Thomas${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
608e1091647SArun Thomas
6092e304675SAnton Kuijsten.if ${USE_BITCODE:Uno} == "yes"
6104684ddb6SLionel Sambuc
6114684ddb6SLionel Sambuc.if !target(__archivebuildbc)
6124684ddb6SLionel Sambuc__archivebuildbc: .USE
6132e304675SAnton Kuijsten	${_MKTARGET_BUILD}
6142e304675SAnton Kuijsten	rm -f ${.TARGET}
6154684ddb6SLionel Sambuc	${AR} ${_ARFL} --plugin ${GOLD_PLUGIN} ${.TARGET} ${.ALLSRC:M*bc}
6164684ddb6SLionel Sambuc.endif
6174684ddb6SLionel Sambuc
6184684ddb6SLionel Sambuc# LSC: Ignore libunwind in the bitcode archive, otherwise final linking chokes
6194684ddb6SLionel Sambuc#      on libunwind hidden assembly symbols.
6204684ddb6SLionel SambucBCOBJS+=${OBJS:Nlibunwind.*:.o=.bc}
6214684ddb6SLionel SambucALLOBJS+=${BCOBJS}
6224684ddb6SLionel Sambuc${_LIB_bc.a}:: ${BCOBJS} __archivebuildbc
6234684ddb6SLionel Sambuc
62484d9c625SLionel Sambuc.endif # ${USE_BITCODE:Uno} == "yes"
6252e304675SAnton Kuijsten
62684d9c625SLionel Sambuc${_LIB.a}:: ${STOBJS} __archivebuild
627e1091647SArun Thomas
62884d9c625SLionel Sambuc${_LIB_p.a}:: ${POBJS} __archivebuild
62939fea0a5SBen Gras
63084d9c625SLionel Sambuc${_LIB_pic.a}:: ${SOBJS} __archivebuild
63139fea0a5SBen Gras
63284d9c625SLionel Sambuc${_LIB_g.a}:: ${GOBJS} __archivebuild
63339fea0a5SBen Gras
63439fea0a5SBen Gras
63539fea0a5SBen Gras_LIBLDOPTS=
6369152e1c5SLionel Sambuc.if ${SHLIBDIR} != "/usr/lib"
6379152e1c5SLionel Sambuc_LIBLDOPTS+=	-Wl,-rpath,${SHLIBDIR} \
6389152e1c5SLionel Sambuc		-L=${SHLIBDIR}
6399152e1c5SLionel Sambuc.elif ${SHLIBINSTALLDIR} != "/usr/lib"
6409152e1c5SLionel Sambuc_LIBLDOPTS+=	-Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \
6419152e1c5SLionel Sambuc		-L=${SHLIBINSTALLDIR}
6429152e1c5SLionel Sambuc.endif
64339fea0a5SBen Gras
64439fea0a5SBen Gras# gcc -shared now adds -lc automatically. For libraries other than libc and
64539fea0a5SBen Gras# libgcc* we add as a dependency the installed shared libc. For libc and
64639fea0a5SBen Gras# libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
64739fea0a5SBen Gras# -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
64839fea0a5SBen Gras# to add standard libraries, not the linker.
64939fea0a5SBen Gras.if !defined(LIB)
6509152e1c5SLionel Sambuc.if !empty(LIBC_SO)
65139fea0a5SBen GrasDPLIBC ?= ${DESTDIR}${LIBC_SO}
6529152e1c5SLionel Sambuc.endif
65339fea0a5SBen Gras.else
6540cdf705cSLionel Sambuc.if ${LIB} != "c" && ${LIB:Mgcc*} == "" \
655bad58c9cSBen Gras    && ${LIB} != "sys" && ${LIB} != "minc" && ${LIB} != "mthread" # Minix-specific libs
6569152e1c5SLionel Sambuc.if !empty(LIBC_SO)
65739fea0a5SBen GrasDPLIBC ?= ${DESTDIR}${LIBC_SO}
6589152e1c5SLionel Sambuc.endif
65939fea0a5SBen Gras.else
66039fea0a5SBen GrasLDLIBC ?= -nodefaultlibs
66184d9c625SLionel Sambuc.if ${HAVE_LIBGCC} == "yes" && (${LIB} == "c" || ${LIB} == "minc")
66284d9c625SLionel Sambuc.if !defined(__MINIX)
66384d9c625SLionel SambucLDADD+= -lgcc
66484d9c625SLionel Sambuc.else
665b8a678efSLionel SambucLDADD+= ${${ACTIVE_CC} == "gcc":? -lgcc:}
66684d9c625SLionel Sambuc.if ${MACHINE_ARCH} == "earm"
66784d9c625SLionel SambucLDADD+= ${${ACTIVE_CC} == "gcc":? -lgcc_eh:}
66884d9c625SLionel Sambuc.endif # ${MACHINE_ARCH} == "earm"
66984d9c625SLionel Sambuc.endif # !defined(__MINIX)
67039fea0a5SBen Gras.endif
67139fea0a5SBen Gras.endif
67239fea0a5SBen Gras.endif
67339fea0a5SBen Gras
67439fea0a5SBen Gras.if ${LIBISCXX} != "no"
67539fea0a5SBen GrasLIBCC:=	${CXX}
67684d9c625SLionel Sambuc. if ${MKLIBCXX} == "yes"
67784d9c625SLionel SambucLIBDPLIBS+=     c++	${.CURDIR}/../../../../../external/bsd/libc++/lib
67884d9c625SLionel Sambuc. else
6790a6a1f1dSLionel SambucLIBDPLIBS+=     stdc++	${.CURDIR}/../../../../../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libstdc++-v3
68084d9c625SLionel Sambuc. endif
68139fea0a5SBen Gras.else
68239fea0a5SBen GrasLIBCC:=	${CC}
68339fea0a5SBen Gras.endif
68439fea0a5SBen Gras
68584d9c625SLionel Sambuc_LDADD.${_LIB}=	${LDADD} ${LDADD.${_LIB}}
68684d9c625SLionel Sambuc_LDFLAGS.${_LIB}=	${LDFLAGS} ${LDFLAGS.${_LIB}}
6879152e1c5SLionel Sambuc
6880a6a1f1dSLionel Sambuc_MAINLIBDEPS=	${SOLIB} ${DPADD} ${DPLIBC} \
68939fea0a5SBen Gras		${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
6900a6a1f1dSLionel Sambuc
6910a6a1f1dSLionel Sambuc.if defined(_LIB.so.debug)
6920a6a1f1dSLionel Sambuc${_LIB.so.debug}: ${_LIB.so.link}
6930a6a1f1dSLionel Sambuc	${_MKTARGET_CREATE}
6940a6a1f1dSLionel Sambuc	(  ${OBJCOPY} --only-keep-debug \
6950a6a1f1dSLionel Sambuc		${_LIB.so.link} ${_LIB.so.debug} \
6960a6a1f1dSLionel Sambuc	) || (rm -f ${.TARGET}; false)
6970a6a1f1dSLionel Sambuc${_LIB.so.full}: ${_LIB.so.link} ${_LIB.so.debug}
6980a6a1f1dSLionel Sambuc	${_MKTARGET_CREATE}
6990a6a1f1dSLionel Sambuc	(  ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
7000a6a1f1dSLionel Sambuc		--add-gnu-debuglink=${_LIB.so.debug} \
7010a6a1f1dSLionel Sambuc		${_LIB.so.link} ${_LIB.so.full} \
7020a6a1f1dSLionel Sambuc	) || (rm -f ${.TARGET}; false)
7030a6a1f1dSLionel Sambuc${_LIB.so.link}: ${_MAINLIBDEPS}
7040a6a1f1dSLionel Sambuc.else # aka no MKDEBUG
7050a6a1f1dSLionel Sambuc${_LIB.so.full}: ${_MAINLIBDEPS}
7060a6a1f1dSLionel Sambuc.endif
70739fea0a5SBen Gras	${_MKTARGET_BUILD}
70884d9c625SLionel Sambuc	rm -f ${.TARGET}
70984d9c625SLionel Sambuc	${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} \
71084d9c625SLionel Sambuc	    ${_LDFLAGS.${_LIB}} -o ${.TARGET} ${_LIBLDOPTS} \
71184d9c625SLionel Sambuc	    -Wl,--whole-archive ${SOLIB} \
71284d9c625SLionel Sambuc	    -Wl,--no-whole-archive ${_LDADD.${_LIB}}
71339fea0a5SBen Gras#  We don't use INSTALL_SYMLINK here because this is just
71439fea0a5SBen Gras#  happening inside the build directory/objdir. XXX Why does
71539fea0a5SBen Gras#  this spend so much effort on libraries that aren't live??? XXX
7160a6a1f1dSLionel Sambuc#  XXX Also creates dead symlinks until the .full rule runs
7170a6a1f1dSLionel Sambuc#  above and creates the main link
71839fea0a5SBen Gras.if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
71939fea0a5SBen Gras    "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
72084d9c625SLionel Sambuc	${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so.major}.tmp
72184d9c625SLionel Sambuc	mv -f ${_LIB.so.major}.tmp ${_LIB.so.major}
72239fea0a5SBen Gras.endif
72384d9c625SLionel Sambuc	${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so}.tmp
72484d9c625SLionel Sambuc	mv -f ${_LIB.so}.tmp ${_LIB.so}
72539fea0a5SBen Gras.if ${MKSTRIPIDENT} != "no"
72639fea0a5SBen Gras	${OBJCOPY} -R .ident ${.TARGET}
72739fea0a5SBen Gras.endif
72839fea0a5SBen Gras
72939fea0a5SBen Gras.if !empty(LOBJS)							# {
73039fea0a5SBen GrasLLIBS?=		-lc
73184d9c625SLionel Sambuc${_LIB.ln}: ${LOBJS}
73239fea0a5SBen Gras	${_MKTARGET_COMPILE}
73384d9c625SLionel Sambuc	rm -f ${.TARGET}
73439fea0a5SBen Gras.if defined(DESTDIR)
73539fea0a5SBen Gras	${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
73639fea0a5SBen Gras.else
73739fea0a5SBen Gras	${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
73839fea0a5SBen Gras.endif
73939fea0a5SBen Gras.endif									# }
74039fea0a5SBen Gras
74139fea0a5SBen Graslint: ${LOBJS}
74239fea0a5SBen Gras.if defined(LOBJS) && !empty(LOBJS)
74339fea0a5SBen Gras	${LINT} ${LINTFLAGS} ${LOBJS}
74439fea0a5SBen Gras.endif
74539fea0a5SBen Gras
74684d9c625SLionel Sambuc
7479152e1c5SLionel Sambuc# If the number of entries in CLEANFILES is too large, then the
7489152e1c5SLionel Sambuc# commands in bsd.clean.mk encounter errors like "exec(/bin/sh)
7499152e1c5SLionel Sambuc# failed (Argument list too long)".  Avoid that by splitting the
7509152e1c5SLionel Sambuc# files to clean into several lists using different variable names.
7519152e1c5SLionel Sambuc# __cleanuse is an internal target in bsd.clean.mk; the way we
7529152e1c5SLionel Sambuc# use it here mimics the way it's used by the clean target in
7539152e1c5SLionel Sambuc# bsd.clean.mk.
7549152e1c5SLionel Sambuc#
75584d9c625SLionel Sambucclean: libclean1 libclean2 libclean3 libclean4 libclean5
7569152e1c5SLionel Sambuclibclean1: .PHONY .MADE __cleanuse LIBCLEANFILES1
7579152e1c5SLionel Sambuclibclean2: .PHONY .MADE __cleanuse LIBCLEANFILES2
7589152e1c5SLionel Sambuclibclean3: .PHONY .MADE __cleanuse LIBCLEANFILES3
7599152e1c5SLionel Sambuclibclean4: .PHONY .MADE __cleanuse LIBCLEANFILES4
7609152e1c5SLionel Sambuclibclean5: .PHONY .MADE __cleanuse LIBCLEANFILES5
76184d9c625SLionel Sambuc.if defined(__MINIX)
76284d9c625SLionel Sambuc# MINIX: core conflicts with core/ in lib/liblwip
763ee0cc364STomas HrubyCLEANFILES+= a.out [Ee]rrs mklog *.core
76484d9c625SLionel Sambuc.else
76584d9c625SLionel SambucCLEANFILES+= a.out [Ee]rrs mklog core *.core
76684d9c625SLionel Sambuc.endif # defined(__MINIX)
76784d9c625SLionel SambucLIBCLEANFILES1+= ${_LIB.a}   ${STOBJS} ${STOBJS:=.tmp}
76884d9c625SLionel SambucLIBCLEANFILES2+= ${_LIB_p.a} ${POBJS}  ${POBJS:=.tmp}
76984d9c625SLionel SambucLIBCLEANFILES3+= ${_LIB_g.a} ${GOBJS}  ${GOBJS:=.tmp}
77084d9c625SLionel SambucLIBCLEANFILES4+= ${_LIB_pic.a}
77184d9c625SLionel Sambuc.if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
77284d9c625SLionel SambucLIBCLEANFILES4+= ${_LIB.so}.* ${_LIB.so} ${_LIB.so.debug}
773ee0cc364STomas Hruby.endif
7749152e1c5SLionel SambucLIBCLEANFILES4+= ${SOBJS} ${SOBJS:=.tmp}
77584d9c625SLionel SambucLIBCLEANFILES5+= ${_LIB.ln} ${LOBJS}
77684d9c625SLionel Sambuc
77784d9c625SLionel Sambuc.if defined(__MINIX)
77884d9c625SLionel Sambucclean: libclean6
77984d9c625SLionel Sambuclibclean6: .PHONY .MADE __cleanuse LIBCLEANFILES6
78084d9c625SLionel SambucLIBCLEANFILES6+= ${_LIB_bc.a} ${BCOBJS} ${BCOBJS:=.tmp}
78184d9c625SLionel Sambuc.endif
782e1091647SArun Thomas
783e1091647SArun Thomas.if !target(libinstall)							# {
78439fea0a5SBen Gras# Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
78539fea0a5SBen Graslibinstall::
786e1091647SArun Thomas
7872e304675SAnton Kuijsten.if ${USE_BITCODE:Uno} == "yes"
7884684ddb6SLionel Sambuclibinstall:: ${_DEST.LIB}/bc/${_LIB.a}
7894684ddb6SLionel Sambuc.PRECIOUS: ${_DEST.LIB}/bc/${_LIB.a}
7902e304675SAnton Kuijsten
7912e304675SAnton Kuijsten.if ${MKUPDATE} == "no"
79284d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB_bc.a})
7934684ddb6SLionel Sambuc${_DEST.LIB}/bc/${_LIB.a}! .MADE
7942e304675SAnton Kuijsten.endif
7954684ddb6SLionel Sambuc${_DEST.LIB}/bc/${_LIB.a}! ${_LIB_bc.a} __archiveinstall
7962e304675SAnton Kuijsten.else
79784d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB_bc.a})
7984684ddb6SLionel Sambuc${_DEST.LIB}/bc/${_LIB.a}: .MADE
7992e304675SAnton Kuijsten.endif
8004684ddb6SLionel Sambuc${_DEST.LIB}/bc/${_LIB.a}: ${_LIB_bc.a} __archiveinstall
8012e304675SAnton Kuijsten.endif
8022e304675SAnton Kuijsten.endif # ${USE_BITCODE:Uno} == "yes"
8032e304675SAnton Kuijsten
80439fea0a5SBen Gras.if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
80584d9c625SLionel Sambuclibinstall:: ${_DEST.LIB}/${_LIB.a}
80684d9c625SLionel Sambuc.PRECIOUS: ${_DEST.LIB}/${_LIB.a}
807e1091647SArun Thomas
80839fea0a5SBen Gras.if ${MKUPDATE} == "no"
80984d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB.a})
81084d9c625SLionel Sambuc${_DEST.LIB}/${_LIB.a}! .MADE
81139fea0a5SBen Gras.endif
81284d9c625SLionel Sambuc${_DEST.LIB}/${_LIB.a}! ${_LIB.a} __archiveinstall
81339fea0a5SBen Gras.else
81484d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB.a})
81584d9c625SLionel Sambuc${_DEST.LIB}/${_LIB.a}: .MADE
816e1091647SArun Thomas.endif
81784d9c625SLionel Sambuc${_DEST.LIB}/${_LIB.a}: ${_LIB.a} __archiveinstall
81839fea0a5SBen Gras.endif
81939fea0a5SBen Gras.endif
820e1091647SArun Thomas
82139fea0a5SBen Gras.if ${MKPROFILE} != "no"
82284d9c625SLionel Sambuclibinstall:: ${_DEST.LIB}/${_LIB_p.a}
82384d9c625SLionel Sambuc.PRECIOUS: ${_DEST.LIB}/${_LIB_p.a}
82439fea0a5SBen Gras
82539fea0a5SBen Gras.if ${MKUPDATE} == "no"
82684d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB_p.a})
82784d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_p.a}! .MADE
82839fea0a5SBen Gras.endif
82984d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_p.a}! ${_LIB_p.a} __archiveinstall
83039fea0a5SBen Gras.else
83184d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB_p.a})
83284d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_p.a}: .MADE
83339fea0a5SBen Gras.endif
83484d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_p.a}: ${_LIB_p.a} __archiveinstall
83539fea0a5SBen Gras.endif
83639fea0a5SBen Gras.endif
83739fea0a5SBen Gras
83839fea0a5SBen Gras.if ${MKDEBUGLIB} != "no"
83984d9c625SLionel Sambuclibinstall:: ${_DEST.LIB}/${_LIB_g.a}
84084d9c625SLionel Sambuc.PRECIOUS: ${_DEST.LIB}/${_LIB_g.a}
84139fea0a5SBen Gras
84239fea0a5SBen Gras.if ${MKUPDATE} == "no"
84384d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB_g.a})
84484d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_g.a}! .MADE
84539fea0a5SBen Gras.endif
84684d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_g.a}! ${_LIB_g.a} __archiveinstall
84739fea0a5SBen Gras.else
84884d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${LIB_g.a})
84984d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_g.a}: .MADE
85039fea0a5SBen Gras.endif
85184d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_g.a}: ${_LIB_g.a} __archiveinstall
85239fea0a5SBen Gras.endif
85339fea0a5SBen Gras.endif
85439fea0a5SBen Gras
85539fea0a5SBen Gras.if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
85684d9c625SLionel Sambuclibinstall:: ${_DEST.LIB}/${_LIB_pic.a}
85784d9c625SLionel Sambuc.PRECIOUS: ${_DEST.LIB}/${_LIB_pic.a}
85839fea0a5SBen Gras
85939fea0a5SBen Gras.if ${MKUPDATE} == "no"
86084d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB_pic.a})
86184d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_pic.a}! .MADE
86239fea0a5SBen Gras.endif
86339fea0a5SBen Gras.if ${MKPICLIB} == "no"
86484d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_pic.a}! ${_LIB.a} __archivesymlinkpic
86539fea0a5SBen Gras.else
86684d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_pic.a}! ${_LIB_pic.a} __archiveinstall
86739fea0a5SBen Gras.endif
86839fea0a5SBen Gras.else
86984d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB_pic.a})
87084d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_pic.a}: .MADE
87139fea0a5SBen Gras.endif
87239fea0a5SBen Gras.if ${MKPICLIB} == "no"
87384d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_pic.a}: ${_LIB.a} __archivesymlinkpic
87439fea0a5SBen Gras.else
87584d9c625SLionel Sambuc${_DEST.LIB}/${_LIB_pic.a}: ${_LIB_pic.a} __archiveinstall
87639fea0a5SBen Gras.endif
87739fea0a5SBen Gras.endif
87839fea0a5SBen Gras.endif
87939fea0a5SBen Gras
88039fea0a5SBen Gras.if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
88139fea0a5SBen Gras
88284d9c625SLionel Sambuclibinstall:: ${_DEST.OBJ}/${_LIB.so.full}
88384d9c625SLionel Sambuc.PRECIOUS: ${_DEST.OBJ}/${_LIB.so.full}
88439fea0a5SBen Gras
88539fea0a5SBen Gras.if ${MKUPDATE} == "no"
88684d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB.so.full})
88784d9c625SLionel Sambuc${_DEST.OBJ}/${_LIB.so.full}! .MADE
88839fea0a5SBen Gras.endif
88984d9c625SLionel Sambuc${_DEST.OBJ}/${_LIB.so.full}! ${_LIB.so.full}
89039fea0a5SBen Gras.else
89184d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB.so.full})
89284d9c625SLionel Sambuc${_DEST.OBJ}/${_LIB.so.full}: .MADE
89339fea0a5SBen Gras.endif
89484d9c625SLionel Sambuc${_DEST.OBJ}/${_LIB.so.full}: ${_LIB.so.full}
89539fea0a5SBen Gras.endif
89639fea0a5SBen Gras	${_MKTARGET_INSTALL}
89739fea0a5SBen Gras	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
89839fea0a5SBen Gras	    ${.ALLSRC} ${.TARGET}
89939fea0a5SBen Gras.if ${_LIBSODIR} != ${LIBDIR}
90084d9c625SLionel Sambuc	${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \
90184d9c625SLionel Sambuc	    ${_DEST.LIB}/${_LIB.so.full}
90239fea0a5SBen Gras.endif
90339fea0a5SBen Gras.if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
90439fea0a5SBen Gras    "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
90584d9c625SLionel Sambuc	${INSTALL_SYMLINK} ${_LIB.so.full} ${_DEST.OBJ}/${_LIB.so.major}
90639fea0a5SBen Gras.if ${_LIBSODIR} != ${LIBDIR}
90784d9c625SLionel Sambuc	${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \
90884d9c625SLionel Sambuc	    ${_DEST.LIB}/${_LIB.so.major}
90939fea0a5SBen Gras.endif
91039fea0a5SBen Gras.endif
91139fea0a5SBen Gras.if ${MKLINKLIB} != "no"
91284d9c625SLionel Sambuc	${INSTALL_SYMLINK}  ${_LIB.so.full} ${_DEST.OBJ}/${_LIB.so}
91339fea0a5SBen Gras.if ${_LIBSODIR} != ${LIBDIR}
91484d9c625SLionel Sambuc	${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \
91584d9c625SLionel Sambuc	    ${_DEST.LIB}/${_LIB.so}
91639fea0a5SBen Gras.endif
91739fea0a5SBen Gras.endif
91839fea0a5SBen Gras.endif
9199152e1c5SLionel Sambuc
92084d9c625SLionel Sambuc.if defined(_LIB.so.debug)
92184d9c625SLionel Sambuclibinstall:: ${_DEST.DEBUG}/${_LIB.so.debug}
92284d9c625SLionel Sambuc.PRECIOUS: ${_DEST.DEBUG}/${_LIB.so.debug}
9239152e1c5SLionel Sambuc
92484d9c625SLionel Sambuc${_DEST.DEBUG}/${_LIB.so.debug}: ${_LIB.so.debug}
9259152e1c5SLionel Sambuc	${_MKTARGET_INSTALL}
9269152e1c5SLionel Sambuc	${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \
9279152e1c5SLionel Sambuc	    ${.ALLSRC} ${.TARGET}
92884d9c625SLionel Sambuc.if ${_LIBSODIR} != ${LIBDIR}
92984d9c625SLionel Sambuc	${INSTALL_SYMLINK} -l r ${_DEST.DEBUG}/${_LIB.so.debug} \
93084d9c625SLionel Sambuc	    ${_DEST.ODEBUG}/${_LIB.so.debug}
93184d9c625SLionel Sambuc.endif
93239fea0a5SBen Gras.endif
93339fea0a5SBen Gras
93439fea0a5SBen Gras.if ${MKLINT} != "no" && !empty(LOBJS)
93584d9c625SLionel Sambuclibinstall:: ${_DEST.LINT}/${_LIB.ln}
93684d9c625SLionel Sambuc.PRECIOUS: ${_DEST.LINT}/${_LIB.ln}
93739fea0a5SBen Gras
93839fea0a5SBen Gras.if ${MKUPDATE} == "no"
93984d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB.ln})
94084d9c625SLionel Sambuc${_DEST.LINT}/${_LIB.ln}! .MADE
94139fea0a5SBen Gras.endif
94284d9c625SLionel Sambuc${_DEST.LINT}/${_LIB.ln}! ${_LIB.ln}
94339fea0a5SBen Gras.else
94484d9c625SLionel Sambuc.if !defined(BUILD) && !make(all) && !make(${_LIB.ln})
94584d9c625SLionel Sambuc${_DEST.LINT}/${_LIB.ln}: .MADE
94639fea0a5SBen Gras.endif
94784d9c625SLionel Sambuc${_DEST.LINT}/${_LIB.ln}: ${_LIB.ln}
94839fea0a5SBen Gras.endif
94939fea0a5SBen Gras	${_MKTARGET_INSTALL}
95039fea0a5SBen Gras	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
95184d9c625SLionel Sambuc		${.ALLSRC} ${_DEST.LINT}
95239fea0a5SBen Gras.endif
953e1091647SArun Thomas.endif	# !target(libinstall)						# }
954e1091647SArun Thomas
955e1091647SArun Thomas##### Pull in related .mk logic
956e1091647SArun ThomasLINKSOWN?= ${LIBOWN}
957e1091647SArun ThomasLINKSGRP?= ${LIBGRP}
958e1091647SArun ThomasLINKSMODE?= ${LIBMODE}
95939fea0a5SBen Gras.include <bsd.man.mk>
9609152e1c5SLionel Sambuc.include <bsd.nls.mk>
961e1091647SArun Thomas.include <bsd.files.mk>
962e1091647SArun Thomas.include <bsd.inc.mk>
963e1091647SArun Thomas.include <bsd.links.mk>
964e1091647SArun Thomas.include <bsd.dep.mk>
9659152e1c5SLionel Sambuc.include <bsd.clang-analyze.mk>
9669152e1c5SLionel Sambuc.include <bsd.clean.mk>
96739fea0a5SBen Gras
96839fea0a5SBen Gras${TARGETS}:	# ensure existence
969