xref: /dflybsd-src/contrib/bmake/mk/lib.mk (revision 9e7ae5a0527a977cab412aede3a532cfe2903bbb)
1*6eef5f0cSAntonio Huete Jimenez# $Id: lib.mk,v 1.73 2021/12/08 05:56:50 sjg Exp $
25f1e34d9SAlexandre Perrin
35f1e34d9SAlexandre Perrin.if !target(__${.PARSEFILE}__)
4*6eef5f0cSAntonio Huete Jimenez__${.PARSEFILE}__: .NOTMAIN
55f1e34d9SAlexandre Perrin
65f1e34d9SAlexandre Perrin.include <init.mk>
75f1e34d9SAlexandre Perrin
85f1e34d9SAlexandre Perrin.if ${OBJECT_FMT} == "ELF"
95f1e34d9SAlexandre PerrinNEED_SOLINKS?= yes
105f1e34d9SAlexandre Perrin.endif
115f1e34d9SAlexandre Perrin
12ca58f742SDaniel FojtSHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version
13ca58f742SDaniel Fojt.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})
14ca58f742SDaniel FojtSHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
15ca58f742SDaniel FojtSHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
16ca58f742SDaniel FojtSHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
175f1e34d9SAlexandre Perrin.endif
185f1e34d9SAlexandre Perrin
19ca58f742SDaniel Fojt.for x in major minor teeny
20ca58f742SDaniel Fojtprint-shlib-$x:
21ca58f742SDaniel Fojt.if defined(SHLIB_${x:tu}) && ${MK_PIC} != "no"
22ca58f742SDaniel Fojt	@echo ${SHLIB_${x:tu}}
235f1e34d9SAlexandre Perrin.else
245f1e34d9SAlexandre Perrin	@false
255f1e34d9SAlexandre Perrin.endif
26ca58f742SDaniel Fojt.endfor
275f1e34d9SAlexandre Perrin
285f1e34d9SAlexandre PerrinSHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.}
295f1e34d9SAlexandre PerrinSHLIB_FULLVERSION := ${SHLIB_FULLVERSION}
305f1e34d9SAlexandre Perrin
315f1e34d9SAlexandre Perrin# add additional suffixes not exported.
325f1e34d9SAlexandre Perrin# .po is used for profiling object files.
33ca58f742SDaniel Fojt# ${PICO} is used for PIC object files.
34ca58f742SDaniel FojtPICO?= .pico
35ca58f742SDaniel Fojt.SUFFIXES: .out .a .ln ${PICO} .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
365f1e34d9SAlexandre Perrin.SUFFIXES: .sh .m4 .m
375f1e34d9SAlexandre Perrin
385f1e34d9SAlexandre PerrinCFLAGS+=	${COPTS}
395f1e34d9SAlexandre Perrin
40ca58f742SDaniel FojtMETA_NOECHO?= echo
41ca58f742SDaniel Fojt
42ca58f742SDaniel Fojt# Originally derrived from NetBSD-1.6
435f1e34d9SAlexandre Perrin
445f1e34d9SAlexandre Perrin# Set PICFLAGS to cc flags for producing position-independent code,
455f1e34d9SAlexandre Perrin# if not already set.  Includes -DPIC, if required.
465f1e34d9SAlexandre Perrin
475f1e34d9SAlexandre Perrin# Data-driven table using make variables to control how shared libraries
485f1e34d9SAlexandre Perrin# are built for different platforms and object formats.
495f1e34d9SAlexandre Perrin# OBJECT_FMT:		currently either "ELF" or "a.out", from <bsd.own.mk>
505f1e34d9SAlexandre Perrin# SHLIB_SOVERSION:	version number to be compiled into a shared library
516a91b982SJohn Marino#			via -soname. Usually ${SHLIB_MAJOR} on ELF.
525f1e34d9SAlexandre Perrin#			NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
535f1e34d9SAlexandre Perrin#			[.${SHLIB_TEENY}]]
545f1e34d9SAlexandre Perrin# SHLIB_SHFLAGS:	Flags to tell ${LD} to emit shared library.
555f1e34d9SAlexandre Perrin#			with ELF, also set shared-lib version for ld.so.
565f1e34d9SAlexandre Perrin# SHLIB_LDSTARTFILE:	support .o file, call C++ file-level constructors
575f1e34d9SAlexandre Perrin# SHLIB_LDENDFILE:	support .o file, call C++ file-level destructors
58ca58f742SDaniel Fojt# FPICFLAGS:		flags for ${FC} to compile .[fF] files to ${PICO} objects.
595f1e34d9SAlexandre Perrin# CPPICFLAGS:		flags for ${CPP} to preprocess .[sS] files for ${AS}
60ca58f742SDaniel Fojt# CPICFLAGS:		flags for ${CC} to compile .[cC] files to ${PICO} objects.
615f1e34d9SAlexandre Perrin# CAPICFLAGS		flags for {$CC} to compiling .[Ss] files
625f1e34d9SAlexandre Perrin#		 	(usually just ${CPPPICFLAGS} ${CPICFLAGS})
63ca58f742SDaniel Fojt# APICFLAGS:		flags for ${AS} to assemble .[sS] to ${PICO} objects.
645f1e34d9SAlexandre Perrin
655f1e34d9SAlexandre Perrin.if ${TARGET_OSNAME} == "NetBSD"
665f1e34d9SAlexandre Perrin.if ${MACHINE_ARCH} == "alpha"
675f1e34d9SAlexandre Perrin		# Alpha-specific shared library flags
685f1e34d9SAlexandre PerrinFPICFLAGS ?= -fPIC
695f1e34d9SAlexandre PerrinCPICFLAGS ?= -fPIC -DPIC
705f1e34d9SAlexandre PerrinCPPPICFLAGS?= -DPIC
715f1e34d9SAlexandre PerrinCAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
725f1e34d9SAlexandre PerrinAPICFLAGS ?=
735f1e34d9SAlexandre Perrin.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
745f1e34d9SAlexandre Perrin		# mips-specific shared library flags
755f1e34d9SAlexandre Perrin
765f1e34d9SAlexandre Perrin# On mips, all libs are compiled with ABIcalls, not just sharedlibs.
775f1e34d9SAlexandre PerrinMKPICLIB= no
785f1e34d9SAlexandre Perrin
795f1e34d9SAlexandre Perrin# so turn shlib PIC flags on for ${AS}.
805f1e34d9SAlexandre PerrinAINC+=-DABICALLS
815f1e34d9SAlexandre PerrinAFLAGS+= -fPIC
825f1e34d9SAlexandre PerrinAS+=	-KPIC
835f1e34d9SAlexandre Perrin
845f1e34d9SAlexandre Perrin.elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF"
855f1e34d9SAlexandre Perrin# On the VAX, all object are PIC by default, not just sharedlibs.
865f1e34d9SAlexandre PerrinMKPICLIB= no
875f1e34d9SAlexandre Perrin
885f1e34d9SAlexandre Perrin.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
895f1e34d9SAlexandre Perrin       ${OBJECT_FMT} == "ELF"
905f1e34d9SAlexandre Perrin# If you use -fPIC you need to define BIGPIC to turn on 32-bit
915f1e34d9SAlexandre Perrin# relocations in asm code
925f1e34d9SAlexandre PerrinFPICFLAGS ?= -fPIC
935f1e34d9SAlexandre PerrinCPICFLAGS ?= -fPIC -DPIC
945f1e34d9SAlexandre PerrinCPPPICFLAGS?= -DPIC -DBIGPIC
955f1e34d9SAlexandre PerrinCAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
965f1e34d9SAlexandre PerrinAPICFLAGS ?= -KPIC
975f1e34d9SAlexandre Perrin
985f1e34d9SAlexandre Perrin.else
995f1e34d9SAlexandre Perrin
1005f1e34d9SAlexandre Perrin# Platform-independent flags for NetBSD a.out shared libraries
1015f1e34d9SAlexandre PerrinSHLIB_SOVERSION=${SHLIB_FULLVERSION}
1025f1e34d9SAlexandre PerrinSHLIB_SHFLAGS=
1035f1e34d9SAlexandre PerrinFPICFLAGS ?= -fPIC
1045f1e34d9SAlexandre PerrinCPICFLAGS?= -fPIC -DPIC
1055f1e34d9SAlexandre PerrinCPPPICFLAGS?= -DPIC
1065f1e34d9SAlexandre PerrinCAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
1075f1e34d9SAlexandre PerrinAPICFLAGS?= -k
1085f1e34d9SAlexandre Perrin
1095f1e34d9SAlexandre Perrin.endif
1105f1e34d9SAlexandre Perrin
1115f1e34d9SAlexandre Perrin# Platform-independent linker flags for ELF shared libraries
1125f1e34d9SAlexandre Perrin.if ${OBJECT_FMT} == "ELF"
1135f1e34d9SAlexandre PerrinSHLIB_SOVERSION=	${SHLIB_MAJOR}
1145f1e34d9SAlexandre PerrinSHLIB_SHFLAGS=		-soname lib${LIB}.so.${SHLIB_SOVERSION}
1155f1e34d9SAlexandre PerrinSHLIB_LDSTARTFILE?=	/usr/lib/crtbeginS.o
1165f1e34d9SAlexandre PerrinSHLIB_LDENDFILE?=	/usr/lib/crtendS.o
1175f1e34d9SAlexandre Perrin.endif
1185f1e34d9SAlexandre Perrin
1196a91b982SJohn Marino# for compatibility with the following
1205f1e34d9SAlexandre PerrinCC_PIC?= ${CPICFLAGS}
1215f1e34d9SAlexandre PerrinLD_shared=${SHLIB_SHFLAGS}
1225f1e34d9SAlexandre Perrin
1235f1e34d9SAlexandre Perrin.endif # NetBSD
1245f1e34d9SAlexandre Perrin
1255f1e34d9SAlexandre Perrin.if ${TARGET_OSNAME} == "FreeBSD"
1265f1e34d9SAlexandre Perrin.if ${OBJECT_FMT} == "ELF"
1275f1e34d9SAlexandre PerrinSHLIB_SOVERSION=	${SHLIB_MAJOR}
1285f1e34d9SAlexandre PerrinSHLIB_SHFLAGS=		-soname lib${LIB}.so.${SHLIB_SOVERSION}
1295f1e34d9SAlexandre Perrin.else
1305f1e34d9SAlexandre PerrinSHLIB_SHFLAGS=		-assert pure-text
1315f1e34d9SAlexandre Perrin.endif
1325f1e34d9SAlexandre PerrinSHLIB_LDSTARTFILE=
1335f1e34d9SAlexandre PerrinSHLIB_LDENDFILE=
1345f1e34d9SAlexandre PerrinCC_PIC?= -fpic
1355f1e34d9SAlexandre PerrinLD_shared=${SHLIB_SHFLAGS}
1365f1e34d9SAlexandre Perrin
1375f1e34d9SAlexandre Perrin.endif # FreeBSD
1385f1e34d9SAlexandre Perrin
1395f1e34d9SAlexandre PerrinMKPICLIB?= yes
1405f1e34d9SAlexandre Perrin
1415f1e34d9SAlexandre Perrin# sys.mk can override these
1425f1e34d9SAlexandre PerrinLD_X?=-X
1435f1e34d9SAlexandre PerrinLD_x?=-x
1445f1e34d9SAlexandre PerrinLD_r?=-r
1455f1e34d9SAlexandre Perrin
1465f1e34d9SAlexandre Perrin# Non BSD machines will be using bmake.
1475f1e34d9SAlexandre Perrin.if ${TARGET_OSNAME} == "SunOS"
1485f1e34d9SAlexandre PerrinLD_shared=-assert pure-text
1495f1e34d9SAlexandre Perrin.if ${OBJECT_FMT} == "ELF" || ${MACHINE} == "solaris"
1505f1e34d9SAlexandre Perrin# Solaris
1515f1e34d9SAlexandre PerrinLD_shared=-h lib${LIB}.so.${SHLIB_MAJOR} -G
1525f1e34d9SAlexandre Perrin.endif
1535f1e34d9SAlexandre Perrin.elif ${TARGET_OSNAME} == "HP-UX"
1545f1e34d9SAlexandre PerrinLD_shared=-b
1555f1e34d9SAlexandre PerrinLD_so=sl
1565f1e34d9SAlexandre PerrinDLLIB=
1575f1e34d9SAlexandre Perrin# HPsUX lorder does not grok anything but .o
158ca58f742SDaniel FojtLD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'`
1595f1e34d9SAlexandre PerrinLD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
1605f1e34d9SAlexandre Perrin.elif ${TARGET_OSNAME} == "OSF1"
1615f1e34d9SAlexandre PerrinLD_shared= -msym -shared -expect_unresolved '*'
1625f1e34d9SAlexandre PerrinLD_solib= -all lib${LIB}_pic.a
1635f1e34d9SAlexandre PerrinDLLIB=
1645f1e34d9SAlexandre Perrin# lorder does not grok anything but .o
165ca58f742SDaniel FojtLD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'`
1665f1e34d9SAlexandre PerrinLD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
1675f1e34d9SAlexandre PerrinAR_cq= -cqs
1685f1e34d9SAlexandre Perrin.elif ${TARGET_OSNAME} == "FreeBSD"
1695f1e34d9SAlexandre PerrinLD_solib= lib${LIB}_pic.a
1705f1e34d9SAlexandre Perrin.elif ${TARGET_OSNAME} == "Linux"
1716a91b982SJohn MarinoSHLIB_LD = ${CC}
1725f1e34d9SAlexandre Perrin# this is ambiguous of course
173*6eef5f0cSAntonio Huete JimenezLD_shared=-shared -Wl,-soname,lib${LIB}.so.${SHLIB_MAJOR}
1746a91b982SJohn MarinoLD_solib= -Wl,--whole-archive lib${LIB}_pic.a -Wl,--no-whole-archive
175ca58f742SDaniel Fojt.if ${COMPILER_TYPE} == "gcc"
1765f1e34d9SAlexandre Perrin# Linux uses GNU ld, which is a multi-pass linker
1775f1e34d9SAlexandre Perrin# so we don't need to use lorder or tsort
1785f1e34d9SAlexandre PerrinLD_objs = ${OBJS}
1795f1e34d9SAlexandre PerrinLD_pobjs = ${POBJS}
1805f1e34d9SAlexandre PerrinLD_sobjs = ${SOBJS}
181ca58f742SDaniel Fojt.endif
1825f1e34d9SAlexandre Perrin.elif ${TARGET_OSNAME} == "Darwin"
1835f1e34d9SAlexandre PerrinSHLIB_LD = ${CC}
1845f1e34d9SAlexandre PerrinSHLIB_INSTALL_VERSION ?= ${SHLIB_MAJOR}
1855f1e34d9SAlexandre PerrinSHLIB_COMPATABILITY_VERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR:U0}
1865f1e34d9SAlexandre PerrinSHLIB_COMPATABILITY ?= \
1875f1e34d9SAlexandre Perrin	-compatibility_version ${SHLIB_COMPATABILITY_VERSION} \
1885f1e34d9SAlexandre Perrin	-current_version ${SHLIB_FULLVERSION}
1895f1e34d9SAlexandre PerrinLD_shared = -dynamiclib \
1905f1e34d9SAlexandre Perrin	-flat_namespace -undefined suppress \
1915f1e34d9SAlexandre Perrin	-install_name ${LIBDIR}/lib${LIB}.${SHLIB_INSTALL_VERSION}.${LD_solink} \
1925f1e34d9SAlexandre Perrin	${SHLIB_COMPATABILITY}
1935f1e34d9SAlexandre PerrinSHLIB_LINKS =
1945f1e34d9SAlexandre Perrin.for v in ${SHLIB_COMPATABILITY_VERSION} ${SHLIB_INSTALL_VERSION}
1955f1e34d9SAlexandre Perrin.if "$v" != "${SHLIB_FULLVERSION}"
1965f1e34d9SAlexandre PerrinSHLIB_LINKS += lib${LIB}.$v.${LD_solink}
1975f1e34d9SAlexandre Perrin.endif
1985f1e34d9SAlexandre Perrin.endfor
1995f1e34d9SAlexandre Perrin.if ${MK_LINKLIB} != "no"
2005f1e34d9SAlexandre PerrinSHLIB_LINKS += lib${LIB}.${LD_solink}
2015f1e34d9SAlexandre Perrin.endif
2025f1e34d9SAlexandre Perrin
2035f1e34d9SAlexandre PerrinLD_so = ${SHLIB_FULLVERSION}.dylib
2045f1e34d9SAlexandre PerrinLD_sobjs = ${SOBJS:O:u}
2055f1e34d9SAlexandre PerrinLD_solib = ${LD_sobjs}
2065f1e34d9SAlexandre PerrinSOLIB = ${LD_sobjs}
2075f1e34d9SAlexandre PerrinLD_solink = dylib
2085f1e34d9SAlexandre Perrin.if ${MACHINE_ARCH} == "i386"
2095f1e34d9SAlexandre PerrinPICFLAG ?= -fPIC
2105f1e34d9SAlexandre Perrin.else
2115f1e34d9SAlexandre PerrinPICFLAG ?= -fPIC -fno-common
2125f1e34d9SAlexandre Perrin.endif
2135f1e34d9SAlexandre PerrinRANLIB = :
2145f1e34d9SAlexandre Perrin.endif
2155f1e34d9SAlexandre Perrin
2165f1e34d9SAlexandre PerrinSHLIB_LD ?= ${LD}
2175f1e34d9SAlexandre Perrin
2185f1e34d9SAlexandre Perrin.if !empty(SHLIB_MAJOR)
2195f1e34d9SAlexandre Perrin.if ${NEED_SOLINKS} && empty(SHLIB_LINKS)
2205f1e34d9SAlexandre Perrin.if ${MK_LINKLIB} != "no"
2215f1e34d9SAlexandre PerrinSHLIB_LINKS = lib${LIB}.${LD_solink}
2225f1e34d9SAlexandre Perrin.endif
2235f1e34d9SAlexandre Perrin.if "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
2245f1e34d9SAlexandre PerrinSHLIB_LINKS += lib${LIB}.${LD_solink}.${SHLIB_MAJOR}
2255f1e34d9SAlexandre Perrin.endif
2265f1e34d9SAlexandre Perrin.endif
2275f1e34d9SAlexandre Perrin.endif
2285f1e34d9SAlexandre Perrin
2295f1e34d9SAlexandre PerrinLIBTOOL?=libtool
2305f1e34d9SAlexandre PerrinLD_shared ?= -Bshareable -Bforcearchive
2315f1e34d9SAlexandre PerrinLD_so ?= so.${SHLIB_FULLVERSION}
2325f1e34d9SAlexandre PerrinLD_solink ?= so
2335f1e34d9SAlexandre Perrin.if empty(LORDER)
2345f1e34d9SAlexandre PerrinLD_objs ?= ${OBJS}
2355f1e34d9SAlexandre PerrinLD_pobjs ?= ${POBJS}
2365f1e34d9SAlexandre PerrinLD_sobjs ?= ${SOBJS}
2375f1e34d9SAlexandre Perrin.else
2385f1e34d9SAlexandre PerrinLD_objs ?= `${LORDER} ${OBJS} | ${TSORT}`
2395f1e34d9SAlexandre PerrinLD_sobjs ?= `${LORDER} ${SOBJS} | ${TSORT}`
2405f1e34d9SAlexandre PerrinLD_pobjs ?= `${LORDER} ${POBJS} | ${TSORT}`
2415f1e34d9SAlexandre Perrin.endif
2425f1e34d9SAlexandre PerrinLD_solib ?= ${LD_sobjs}
2435f1e34d9SAlexandre PerrinAR_cq ?= cq
2445f1e34d9SAlexandre Perrin.if exists(/netbsd) && exists(${DESTDIR}/usr/lib/libdl.so)
2455f1e34d9SAlexandre PerrinDLLIB ?= -ldl
2465f1e34d9SAlexandre Perrin.endif
2475f1e34d9SAlexandre Perrin
248ca58f742SDaniel Fojt# some libs have lots of objects, and scanning all .o, .po and ${PICO} meta files
2495f1e34d9SAlexandre Perrin# is a waste of time, this tells meta.autodep.mk to just pick one
250ca58f742SDaniel Fojt# (typically ${PICO})
2515f1e34d9SAlexandre Perrin# yes, 42 is a random number.
252f445c897SJohn Marino.if ${MK_DIRDEPS_BUILD} == "yes" && ${SRCS:Uno:[\#]} > 42
2535f1e34d9SAlexandre PerrinOPTIMIZE_OBJECT_META_FILES ?= yes
2545f1e34d9SAlexandre Perrin.endif
2555f1e34d9SAlexandre Perrin
2565f1e34d9SAlexandre Perrin
2575f1e34d9SAlexandre Perrin.if ${MK_LIBTOOL} == "yes"
2586a91b982SJohn Marino# because libtool is so fascist about naming the object files,
2595f1e34d9SAlexandre Perrin# we cannot (yet) build profiled libs
2605f1e34d9SAlexandre PerrinMK_PROFILE=no
2615f1e34d9SAlexandre Perrin_LIBS=lib${LIB}.a
2625f1e34d9SAlexandre Perrin.if exists(${.CURDIR}/shlib_version)
2635f1e34d9SAlexandre PerrinSHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
2645f1e34d9SAlexandre Perrin.endif
2655f1e34d9SAlexandre Perrin.else
2665f1e34d9SAlexandre Perrin# for the normal .a we do not want to strip symbols
2675f1e34d9SAlexandre Perrin.c.o:
2685f1e34d9SAlexandre Perrin	${COMPILE.c} ${.IMPSRC}
2695f1e34d9SAlexandre Perrin
2705f1e34d9SAlexandre Perrin# for the normal .a we do not want to strip symbols
271f445c897SJohn Marino${CXX_SUFFIXES:%=%.o}:
2725f1e34d9SAlexandre Perrin	${COMPILE.cc} ${.IMPSRC}
2735f1e34d9SAlexandre Perrin
2745f1e34d9SAlexandre Perrin.S.o .s.o:
275ca58f742SDaniel Fojt	${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
2765f1e34d9SAlexandre Perrin
2775f1e34d9SAlexandre Perrin.if (${LD_X} == "")
2785f1e34d9SAlexandre Perrin.c.po:
2795f1e34d9SAlexandre Perrin	${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
2805f1e34d9SAlexandre Perrin
281f445c897SJohn Marino${CXX_SUFFIXES:%=%.po}:
2825f1e34d9SAlexandre Perrin	${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
2835f1e34d9SAlexandre Perrin
284ca58f742SDaniel Fojt.S${PICO} .s${PICO}:
2855f1e34d9SAlexandre Perrin	${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
2865f1e34d9SAlexandre Perrin.else
2875f1e34d9SAlexandre Perrin.c.po:
288ca58f742SDaniel Fojt	${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o
2895f1e34d9SAlexandre Perrin	@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
2905f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}.o
2915f1e34d9SAlexandre Perrin
292f445c897SJohn Marino${CXX_SUFFIXES:%=%.po}:
293ca58f742SDaniel Fojt	${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o
294ca58f742SDaniel Fojt	${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
2955f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}.o
2965f1e34d9SAlexandre Perrin
297ca58f742SDaniel Fojt.S${PICO} .s${PICO}:
298ca58f742SDaniel Fojt	${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
299ca58f742SDaniel Fojt	${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
3005f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}.o
3015f1e34d9SAlexandre Perrin.endif
3025f1e34d9SAlexandre Perrin
3035f1e34d9SAlexandre Perrin.if (${LD_x} == "")
304ca58f742SDaniel Fojt.c${PICO}:
3055f1e34d9SAlexandre Perrin	${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
3065f1e34d9SAlexandre Perrin
307ca58f742SDaniel Fojt${CXX_SUFFIXES:%=%${PICO}}:
3085f1e34d9SAlexandre Perrin	${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
3095f1e34d9SAlexandre Perrin
3105f1e34d9SAlexandre Perrin.S.po .s.po:
3115f1e34d9SAlexandre Perrin	${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
3125f1e34d9SAlexandre Perrin.else
3135f1e34d9SAlexandre Perrin
314ca58f742SDaniel Fojt.c${PICO}:
315ca58f742SDaniel Fojt	${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
316ca58f742SDaniel Fojt	${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
3175f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}.o
3185f1e34d9SAlexandre Perrin
319ca58f742SDaniel Fojt${CXX_SUFFIXES:%=%${PICO}}:
320ca58f742SDaniel Fojt	${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
321ca58f742SDaniel Fojt	${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
3225f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}.o
3235f1e34d9SAlexandre Perrin
3245f1e34d9SAlexandre Perrin.S.po .s.po:
325ca58f742SDaniel Fojt	${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
326ca58f742SDaniel Fojt	${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
3275f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}.o
3285f1e34d9SAlexandre Perrin
3295f1e34d9SAlexandre Perrin.endif
3305f1e34d9SAlexandre Perrin.endif
3315f1e34d9SAlexandre Perrin
3325f1e34d9SAlexandre Perrin.c.ln:
3335f1e34d9SAlexandre Perrin	${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
3345f1e34d9SAlexandre Perrin
3355f1e34d9SAlexandre Perrin.if ${MK_LIBTOOL} != "yes"
3365f1e34d9SAlexandre Perrin
3375f1e34d9SAlexandre Perrin.if !defined(PICFLAG)
3385f1e34d9SAlexandre PerrinPICFLAG=-fpic
3395f1e34d9SAlexandre Perrin.endif
3405f1e34d9SAlexandre Perrin
3415f1e34d9SAlexandre Perrin_LIBS=
3425f1e34d9SAlexandre Perrin
3435f1e34d9SAlexandre Perrin.if ${MK_ARCHIVE} != "no"
3445f1e34d9SAlexandre Perrin_LIBS += lib${LIB}.a
3455f1e34d9SAlexandre Perrin.endif
3465f1e34d9SAlexandre Perrin
3475f1e34d9SAlexandre Perrin.if ${MK_PROFILE} != "no"
3485f1e34d9SAlexandre Perrin_LIBS+=lib${LIB}_p.a
3495f1e34d9SAlexandre PerrinPOBJS+=${OBJS:.o=.po}
3505f1e34d9SAlexandre Perrin.endif
3515f1e34d9SAlexandre Perrin
3525f1e34d9SAlexandre Perrin.if ${MK_PIC} != "no"
3535f1e34d9SAlexandre Perrin.if ${MK_PICLIB} == "no"
3545f1e34d9SAlexandre PerrinSOLIB ?= lib${LIB}.a
3555f1e34d9SAlexandre Perrin.else
3565f1e34d9SAlexandre PerrinSOLIB=lib${LIB}_pic.a
3575f1e34d9SAlexandre Perrin_LIBS+=${SOLIB}
3585f1e34d9SAlexandre Perrin.endif
3595f1e34d9SAlexandre Perrin.if !empty(SHLIB_FULLVERSION)
3605f1e34d9SAlexandre Perrin_LIBS+=lib${LIB}.${LD_so}
3615f1e34d9SAlexandre Perrin.endif
3625f1e34d9SAlexandre Perrin.endif
3635f1e34d9SAlexandre Perrin
3645f1e34d9SAlexandre Perrin.if ${MK_LINT} != "no"
3655f1e34d9SAlexandre Perrin_LIBS+=llib-l${LIB}.ln
3665f1e34d9SAlexandre Perrin.endif
3675f1e34d9SAlexandre Perrin
3685f1e34d9SAlexandre Perrin# here is where you can define what LIB* are
3695f1e34d9SAlexandre Perrin.-include <libnames.mk>
3705f1e34d9SAlexandre Perrin.if ${MK_DPADD_MK} == "yes"
3715f1e34d9SAlexandre Perrin# lots of cool magic, but might not suit everyone.
3725f1e34d9SAlexandre Perrin.include <dpadd.mk>
3735f1e34d9SAlexandre Perrin.endif
3745f1e34d9SAlexandre Perrin
375ca58f742SDaniel Fojt.if empty(LIB)
376ca58f742SDaniel Fojt_LIBS=
377ca58f742SDaniel Fojt.elif ${MK_LDORDER_MK} != "no"
378ca58f742SDaniel Fojt# Record any libs that we need to be linked with
379ca58f742SDaniel Fojt_LIBS+= ${libLDORDER_INC}
380ca58f742SDaniel Fojt
381ca58f742SDaniel Fojt.include <ldorder.mk>
382ca58f742SDaniel Fojt.endif
383ca58f742SDaniel Fojt
3845f1e34d9SAlexandre Perrin.if !defined(_SKIP_BUILD)
385ca58f742SDaniel Fojtrealbuild: ${_LIBS}
3865f1e34d9SAlexandre Perrin.endif
387ca58f742SDaniel Fojt
3885f1e34d9SAlexandre Perrinall: _SUBDIRUSE
3895f1e34d9SAlexandre Perrin
3905f1e34d9SAlexandre Perrin.for s in ${SRCS:N*.h:M*/*}
391ca58f742SDaniel Fojt${.o ${PICO} .po .lo:L:@o@${s:T:R}$o@}: $s
3925f1e34d9SAlexandre Perrin.endfor
3935f1e34d9SAlexandre Perrin
3945f1e34d9SAlexandre PerrinOBJS+=	${SRCS:T:N*.h:R:S/$/.o/g}
3955f1e34d9SAlexandre Perrin.NOPATH:	${OBJS}
3965f1e34d9SAlexandre Perrin
3975f1e34d9SAlexandre Perrin.if ${MK_LIBTOOL} == "yes"
3985f1e34d9SAlexandre Perrin.if ${MK_PIC} == "no"
3995f1e34d9SAlexandre PerrinLT_STATIC=-static
4005f1e34d9SAlexandre Perrin.else
4015f1e34d9SAlexandre PerrinLT_STATIC=
4025f1e34d9SAlexandre Perrin.endif
4035f1e34d9SAlexandre PerrinSHLIB_AGE?=0
4045f1e34d9SAlexandre Perrin
4055f1e34d9SAlexandre Perrin# .lo's are created as a side effect
4065f1e34d9SAlexandre Perrin.s.o .S.o .c.o:
4075f1e34d9SAlexandre Perrin	${LIBTOOL} --mode=compile ${CC} ${LT_STATIC} ${CFLAGS} ${CPPFLAGS} ${IMPFLAGS} -c ${.IMPSRC}
4085f1e34d9SAlexandre Perrin
4096a91b982SJohn Marino# can't really do profiled libs with libtool - its too fascist about
4105f1e34d9SAlexandre Perrin# naming the output...
411ca58f742SDaniel Fojtlib${LIB}.a: ${OBJS}
4125f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}
4135f1e34d9SAlexandre Perrin	${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}
4145f1e34d9SAlexandre Perrin	@ln .libs/${.TARGET} .
4155f1e34d9SAlexandre Perrin
416ca58f742SDaniel Fojtlib${LIB}.${LD_so}: lib${LIB}.a
4175f1e34d9SAlexandre Perrin	@[ -s ${.TARGET}.${SHLIB_AGE} ] || { ln -s .libs/lib${LIB}.${LD_so}* . 2>/dev/null; : }
4185f1e34d9SAlexandre Perrin	@[ -s ${.TARGET} ] || ln -s ${.TARGET}.${SHLIB_AGE} ${.TARGET}
4195f1e34d9SAlexandre Perrin
4205f1e34d9SAlexandre Perrin.else  # MK_LIBTOOL=yes
4215f1e34d9SAlexandre Perrin
422ca58f742SDaniel Fojtlib${LIB}.a: ${OBJS}
423ca58f742SDaniel Fojt	@${META_NOECHO} building standard ${LIB} library
4245f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}
4255f1e34d9SAlexandre Perrin	@${AR} ${AR_cq} ${.TARGET} ${LD_objs}
4265f1e34d9SAlexandre Perrin	${RANLIB} ${.TARGET}
4275f1e34d9SAlexandre Perrin
4285f1e34d9SAlexandre PerrinPOBJS+=	${OBJS:.o=.po}
4295f1e34d9SAlexandre Perrin.NOPATH:	${POBJS}
430ca58f742SDaniel Fojtlib${LIB}_p.a: ${POBJS}
431ca58f742SDaniel Fojt	@${META_NOECHO} building profiled ${LIB} library
4325f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}
4335f1e34d9SAlexandre Perrin	@${AR} ${AR_cq} ${.TARGET} ${LD_pobjs}
4345f1e34d9SAlexandre Perrin	${RANLIB} ${.TARGET}
4355f1e34d9SAlexandre Perrin
436ca58f742SDaniel FojtSOBJS+=	${OBJS:.o=${PICO}}
4375f1e34d9SAlexandre Perrin.NOPATH:	${SOBJS}
438ca58f742SDaniel Fojtlib${LIB}_pic.a: ${SOBJS}
439ca58f742SDaniel Fojt	@${META_NOECHO} building shared object ${LIB} library
4405f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}
4415f1e34d9SAlexandre Perrin	@${AR} ${AR_cq} ${.TARGET} ${LD_sobjs}
4425f1e34d9SAlexandre Perrin	${RANLIB} ${.TARGET}
4435f1e34d9SAlexandre Perrin
4445f1e34d9SAlexandre Perrin#SHLIB_LDADD?= ${LDADD}
4455f1e34d9SAlexandre Perrin
4465f1e34d9SAlexandre Perrin# bound to be non-portable...
4475f1e34d9SAlexandre Perrin# this is known to work for NetBSD 1.6 and FreeBSD 4.2
4485f1e34d9SAlexandre Perrinlib${LIB}.${LD_so}: ${SOLIB} ${DPADD}
449ca58f742SDaniel Fojt	@${META_NOECHO} building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
4505f1e34d9SAlexandre Perrin	@rm -f ${.TARGET}
4515f1e34d9SAlexandre Perrin.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD"
4525f1e34d9SAlexandre Perrin.if ${OBJECT_FMT} == "ELF"
4535f1e34d9SAlexandre Perrin	${SHLIB_LD} -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
4545f1e34d9SAlexandre Perrin	    ${SHLIB_LDSTARTFILE} \
4555f1e34d9SAlexandre Perrin	    --whole-archive ${SOLIB} --no-whole-archive ${SHLIB_LDADD} \
4565f1e34d9SAlexandre Perrin	    ${SHLIB_LDENDFILE}
4575f1e34d9SAlexandre Perrin.else
4585f1e34d9SAlexandre Perrin	${SHLIB_LD} ${LD_x} ${LD_shared} \
4595f1e34d9SAlexandre Perrin	    -o ${.TARGET} ${SOLIB} ${SHLIB_LDADD}
4605f1e34d9SAlexandre Perrin.endif
4615f1e34d9SAlexandre Perrin.else
4625f1e34d9SAlexandre Perrin	${SHLIB_LD} -o ${.TARGET} ${LD_shared} ${LD_solib} ${DLLIB} ${SHLIB_LDADD}
4635f1e34d9SAlexandre Perrin.endif
4645f1e34d9SAlexandre Perrin.endif
4655f1e34d9SAlexandre Perrin.if !empty(SHLIB_LINKS)
4665f1e34d9SAlexandre Perrin	rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s ${.TARGET} $x;@}
4675f1e34d9SAlexandre Perrin.endif
4685f1e34d9SAlexandre Perrin
4695f1e34d9SAlexandre PerrinLOBJS+=	${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
4705f1e34d9SAlexandre Perrin.NOPATH:	${LOBJS}
4715f1e34d9SAlexandre PerrinLLIBS?=	-lc
4725f1e34d9SAlexandre Perrinllib-l${LIB}.ln: ${LOBJS}
473ca58f742SDaniel Fojt	@${META_NOECHO} building llib-l${LIB}.ln
4745f1e34d9SAlexandre Perrin	@rm -f llib-l${LIB}.ln
4755f1e34d9SAlexandre Perrin	@${LINT} -C${LIB} ${LOBJS} ${LLIBS}
4765f1e34d9SAlexandre Perrin
4775f1e34d9SAlexandre Perrin.if !target(clean)
4785f1e34d9SAlexandre Perrincleanlib: .PHONY
4795f1e34d9SAlexandre Perrin	rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
4805f1e34d9SAlexandre Perrin	rm -f lib${LIB}.a ${OBJS}
4815f1e34d9SAlexandre Perrin	rm -f lib${LIB}_p.a ${POBJS}
4825f1e34d9SAlexandre Perrin	rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
4835f1e34d9SAlexandre Perrin	rm -f llib-l${LIB}.ln ${LOBJS}
4845f1e34d9SAlexandre Perrin.if !empty(SHLIB_LINKS)
4855f1e34d9SAlexandre Perrin	rm -f ${SHLIB_LINKS}
4865f1e34d9SAlexandre Perrin.endif
4875f1e34d9SAlexandre Perrin
4885f1e34d9SAlexandre Perrinclean: _SUBDIRUSE cleanlib
4895f1e34d9SAlexandre Perrincleandir: _SUBDIRUSE cleanlib
4905f1e34d9SAlexandre Perrin.else
4915f1e34d9SAlexandre Perrincleandir: _SUBDIRUSE clean
4925f1e34d9SAlexandre Perrin.endif
4935f1e34d9SAlexandre Perrin
4945f1e34d9SAlexandre Perrin.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep)
4955f1e34d9SAlexandre Perrinafterdepend: .depend
4965f1e34d9SAlexandre Perrin	@(TMP=/tmp/_depend$$$$; \
497ca58f742SDaniel Fojt	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1${PICO} \1.ln:/' \
4985f1e34d9SAlexandre Perrin	      < .depend > $$TMP; \
4995f1e34d9SAlexandre Perrin	    mv $$TMP .depend)
5005f1e34d9SAlexandre Perrin.endif
5015f1e34d9SAlexandre Perrin
5025f1e34d9SAlexandre Perrin.if !target(install)
5035f1e34d9SAlexandre Perrin.if !target(beforeinstall)
5045f1e34d9SAlexandre Perrinbeforeinstall:
5055f1e34d9SAlexandre Perrin.endif
5065f1e34d9SAlexandre Perrin
5075f1e34d9SAlexandre Perrin.if !empty(LIBOWN)
5085f1e34d9SAlexandre PerrinLIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
5095f1e34d9SAlexandre Perrin.endif
5105f1e34d9SAlexandre Perrin
5115f1e34d9SAlexandre Perrin.include <links.mk>
5125f1e34d9SAlexandre Perrin
513ca58f742SDaniel Fojt.if !target(libinstall) && !empty(LIB)
5145f1e34d9SAlexandre Perrinrealinstall: libinstall
5155f1e34d9SAlexandre Perrinlibinstall:
5165f1e34d9SAlexandre Perrin	[ -d ${DESTDIR}/${LIBDIR} ] || \
5175f1e34d9SAlexandre Perrin	${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR}
5185f1e34d9SAlexandre Perrin.if ${MK_ARCHIVE} != "no"
519ca58f742SDaniel Fojt	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 lib${LIB}.a \
5205f1e34d9SAlexandre Perrin	    ${DESTDIR}${LIBDIR}
5215f1e34d9SAlexandre Perrin	${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}.a
5225f1e34d9SAlexandre Perrin	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
5235f1e34d9SAlexandre Perrin.endif
5245f1e34d9SAlexandre Perrin.if ${MK_PROFILE} != "no"
525ca58f742SDaniel Fojt	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 \
5265f1e34d9SAlexandre Perrin	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
5275f1e34d9SAlexandre Perrin	${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
5285f1e34d9SAlexandre Perrin	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
5295f1e34d9SAlexandre Perrin.endif
530ca58f742SDaniel Fojt.if ${MK_LDORDER_MK} != "no"
531ca58f742SDaniel Fojt	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 \
532ca58f742SDaniel Fojt		lib${LIB}.ldorder.inc ${DESTDIR}${LIBDIR}
533ca58f742SDaniel Fojt.endif
5345f1e34d9SAlexandre Perrin.if ${MK_PIC} != "no"
5355f1e34d9SAlexandre Perrin.if ${MK_PICLIB} != "no"
536ca58f742SDaniel Fojt	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 \
5375f1e34d9SAlexandre Perrin	    lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
5385f1e34d9SAlexandre Perrin	${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
5395f1e34d9SAlexandre Perrin	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
5405f1e34d9SAlexandre Perrin.endif
5415f1e34d9SAlexandre Perrin.if !empty(SHLIB_MAJOR)
5425f1e34d9SAlexandre Perrin	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
5435f1e34d9SAlexandre Perrin	    lib${LIB}.${LD_so} ${DESTDIR}${LIBDIR}
5445f1e34d9SAlexandre Perrin.if !empty(SHLIB_LINKS)
5455f1e34d9SAlexandre Perrin	(cd ${DESTDIR}${LIBDIR} && { rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s lib${LIB}.${LD_so} $x;@} })
5465f1e34d9SAlexandre Perrin.endif
5475f1e34d9SAlexandre Perrin.endif
5485f1e34d9SAlexandre Perrin.endif
5495f1e34d9SAlexandre Perrin.if ${MK_LINT} != "no" && ${MK_LINKLIB} != "no" && !empty(LOBJS)
5505f1e34d9SAlexandre Perrin	${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
5515f1e34d9SAlexandre Perrin	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
5525f1e34d9SAlexandre Perrin.endif
5535f1e34d9SAlexandre Perrin.if defined(LINKS) && !empty(LINKS)
5545f1e34d9SAlexandre Perrin	@set ${LINKS}; ${_LINKS_SCRIPT}
5555f1e34d9SAlexandre Perrin.endif
5565f1e34d9SAlexandre Perrin.endif
5575f1e34d9SAlexandre Perrin
558ca58f742SDaniel Fojt.if ${MK_MAN} != "no"
5595f1e34d9SAlexandre Perrininstall: maninstall _SUBDIRUSE
5605f1e34d9SAlexandre Perrinmaninstall: afterinstall
561ca58f742SDaniel Fojt.endif
5625f1e34d9SAlexandre Perrinafterinstall: realinstall
563f445c897SJohn Marinolibinstall: beforeinstall
5645f1e34d9SAlexandre Perrinrealinstall: beforeinstall
5655f1e34d9SAlexandre Perrin.endif
5665f1e34d9SAlexandre Perrin
567ca58f742SDaniel Fojt.if defined(FILES) || defined(FILESGROUPS)
568ca58f742SDaniel Fojt.include <files.mk>
569ca58f742SDaniel Fojt.endif
570ca58f742SDaniel Fojt
5715f1e34d9SAlexandre Perrin.if ${MK_MAN} != "no"
5725f1e34d9SAlexandre Perrin.include <man.mk>
5735f1e34d9SAlexandre Perrin.endif
5745f1e34d9SAlexandre Perrin
5755f1e34d9SAlexandre Perrin.if ${MK_NLS} != "no"
5765f1e34d9SAlexandre Perrin.include <nls.mk>
5775f1e34d9SAlexandre Perrin.endif
5785f1e34d9SAlexandre Perrin
5795f1e34d9SAlexandre Perrin.include <obj.mk>
5805f1e34d9SAlexandre Perrin.include <inc.mk>
5815f1e34d9SAlexandre Perrin.include <dep.mk>
5825f1e34d9SAlexandre Perrin.include <subdir.mk>
5835f1e34d9SAlexandre Perrin.endif
5845f1e34d9SAlexandre Perrin
5855f1e34d9SAlexandre Perrin# during building we usually need/want to install libs somewhere central
5865f1e34d9SAlexandre Perrin# note that we do NOT ch{own,grp} as that would likely fail at this point.
5875f1e34d9SAlexandre Perrin# otherwise it is the same as realinstall
5885f1e34d9SAlexandre Perrin# Note that we don't need this when using dpadd.mk
5895f1e34d9SAlexandre Perrin.libinstall:	${_LIBS}
5905f1e34d9SAlexandre Perrin	test -d ${DESTDIR}${LIBDIR} || ${INSTALL} -d -m775 ${DESTDIR}${LIBDIR}
5915f1e34d9SAlexandre Perrin.for _lib in ${_LIBS:M*.a}
5925f1e34d9SAlexandre Perrin	${INSTALL} ${COPY} -m 644 ${_lib} ${DESTDIR}${LIBDIR}
5935f1e34d9SAlexandre Perrin	${RANLIB} ${DESTDIR}${LIBDIR}/${_lib}
5945f1e34d9SAlexandre Perrin.endfor
5955f1e34d9SAlexandre Perrin.for _lib in ${_LIBS:M*.${LD_solink}*:O:u}
5965f1e34d9SAlexandre Perrin	${INSTALL} ${COPY} -m ${LIBMODE} ${_lib} ${DESTDIR}${LIBDIR}
5975f1e34d9SAlexandre Perrin.if !empty(SHLIB_LINKS)
5985f1e34d9SAlexandre Perrin	(cd ${DESTDIR}${LIBDIR} && { ${SHLIB_LINKS:O:u:@x@ln -sf ${_lib} $x;@}; })
5995f1e34d9SAlexandre Perrin.endif
6005f1e34d9SAlexandre Perrin.endfor
6015f1e34d9SAlexandre Perrin	@touch ${.TARGET}
6025f1e34d9SAlexandre Perrin
603ca58f742SDaniel Fojt.if !empty(LIB)
604ca58f742SDaniel FojtSTAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR}
605ca58f742SDaniel Fojtstage_libs: ${_LIBS}
606ca58f742SDaniel Fojt.endif
607ca58f742SDaniel Fojt
6085f1e34d9SAlexandre Perrin.include <final.mk>
6095f1e34d9SAlexandre Perrin.endif
610