xref: /onnv-gate/usr/src/lib/Makefile.lib (revision 12719:bd9fb35d09c2)
10Sstevel@tonic-gate#
20Sstevel@tonic-gate# CDDL HEADER START
30Sstevel@tonic-gate#
40Sstevel@tonic-gate# The contents of this file are subject to the terms of the
52522Sraf# Common Development and Distribution License (the "License").
62522Sraf# You may not use this file except in compliance with the License.
70Sstevel@tonic-gate#
80Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate# See the License for the specific language governing permissions
110Sstevel@tonic-gate# and limitations under the License.
120Sstevel@tonic-gate#
130Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate#
190Sstevel@tonic-gate# CDDL HEADER END
200Sstevel@tonic-gate#
2112210SJames.McPherson@Sun.COM# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
220Sstevel@tonic-gate#
232522Sraf#
240Sstevel@tonic-gate# Definitions common to libraries.
250Sstevel@tonic-gate#
260Sstevel@tonic-gate# include global definitions; SRC should be defined in the shell.
270Sstevel@tonic-gate# SRC is needed until RFE 1026993 is implemented.
280Sstevel@tonic-gate
290Sstevel@tonic-gateinclude		$(SRC)/Makefile.master
300Sstevel@tonic-gate
310Sstevel@tonic-gateLORDER=		lorder
320Sstevel@tonic-gateTSORT=		tsort
330Sstevel@tonic-gateAWK=		awk
340Sstevel@tonic-gate
352522Sraf#
362522Sraf# By default, we define the source directory for libraries to be
372522Sraf# one level up from the ISA-specific directory, where the code is
382522Sraf# actually built.  Many libraries define a 'common' directory to
392522Sraf# contain the source.  These libraries must redefine SRCDIR as:
402522Sraf#	SRCDIR = ../common
412522Sraf# Other variations are possible (../port, ../src, etc).
422522Sraf#
432522SrafSRCDIR =	..
442522Sraf
452522Sraf#
469569SRod.Evans@Sun.COM# We define MAPFILES here for the benefit of most libraries, those that
479569SRod.Evans@Sun.COM# follow the convention of having source files and other common files
489569SRod.Evans@Sun.COM# in the $(SRCDIR) directory.  Libraries that do not follow this
499569SRod.Evans@Sun.COM# convention must define MAPFILES, or MAPFILEDIR for themselves.
502522Sraf# Libraries that do follow this convention but that need supplemental
512522Sraf# ISA-specific mapfiles can augment MAPFILES like this:
522522Sraf#	MAPFILES += mapfile-vers
532522Sraf#
549569SRod.Evans@Sun.COMMAPFILEDIR =	$(SRCDIR)
559569SRod.Evans@Sun.COMMAPFILES =	$(MAPFILEDIR)/mapfile-vers
562522Sraf
570Sstevel@tonic-gate#
580Sstevel@tonic-gate# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
590Sstevel@tonic-gate# install rule in lib/Makefile.targ to generate false matches if there
600Sstevel@tonic-gate# are any common directory names between / and /usr/include (`xfn' is
610Sstevel@tonic-gate# one common example).  To prevent this, we set HDRDIR to a directory
620Sstevel@tonic-gate# name that will almost surely not exist on the build machine.
630Sstevel@tonic-gate#
640Sstevel@tonic-gateHDRDIR=		/__nonexistent_directory__
652522Sraf
660Sstevel@tonic-gate#
670Sstevel@tonic-gate# We don't build archive (*.a) libraries by default anymore.
680Sstevel@tonic-gate# If a component of the build needs to build an archive library
690Sstevel@tonic-gate# for its own internal purposes, it can define LIBS for itself
700Sstevel@tonic-gate# after including Makefile.lib, like this:
710Sstevel@tonic-gate# 	LIBS = $(LIBRARY)
720Sstevel@tonic-gate# or:
730Sstevel@tonic-gate# 	LIBS = $(LIBRARYCCC)
740Sstevel@tonic-gate# Archive libraries must not be installed in the proto area.
750Sstevel@tonic-gate#
760Sstevel@tonic-gateLIBS=
770Sstevel@tonic-gateMACHLIBS=	$(LIBS:%=$(MACH)/%)
780Sstevel@tonic-gateMACHLIBS64=	$(LIBS:%=$(MACH64)/%)
790Sstevel@tonic-gateDYNLIB=		$(LIBRARY:.a=.so$(VERS))
800Sstevel@tonic-gateDYNLIBPSR=	$(LIBRARY:.a=_psr.so$(VERS))
810Sstevel@tonic-gateDYNLIBCCC=	$(LIBRARYCCC:.a=.so$(VERS))
820Sstevel@tonic-gateLIBLINKS=	$(LIBRARY:.a=.so)
830Sstevel@tonic-gateLIBLINKSCCC=	$(LIBRARYCCC:.a=.so)
840Sstevel@tonic-gateLIBNAME=	$(LIBRARY:lib%.a=%)
850Sstevel@tonic-gateLIBLINKPATH=
860Sstevel@tonic-gateLIBNULL=	null.a
870Sstevel@tonic-gateROOTHDRDIR=	$(ROOT)/usr/include
880Sstevel@tonic-gateROOTLIBDIR=	$(ROOT)/usr/lib
890Sstevel@tonic-gateROOTLIBDIR64=	$(ROOT)/usr/lib/$(MACH64)
900Sstevel@tonic-gateROOTFS_LIBDIR=	$(ROOT)/lib
910Sstevel@tonic-gateROOTFS_LIBDIR64=	$(ROOT)/lib/$(MACH64)
920Sstevel@tonic-gateROOTLINTDIR=	$(ROOTLIBDIR)
930Sstevel@tonic-gateROOTFS_LINTDIR=	$(ROOTFS_LIBDIR)
940Sstevel@tonic-gateROOTFS_LINTDIR64=	$(ROOTFS_LIBDIR64)
950Sstevel@tonic-gateROOTHDRS=	$(HDRS:%=$(ROOTHDRDIR)/%)
960Sstevel@tonic-gateHDRSRCS=	$(HDRS:%=$(HDRDIR)/%)
970Sstevel@tonic-gateCHECKHDRS=	$(HDRSRCS:%.h=%.check)
980Sstevel@tonic-gateROOTLIBS=	$(LIBS:%=$(ROOTLIBDIR)/%)
990Sstevel@tonic-gateROOTLIBS64=	$(LIBS:%=$(ROOTLIBDIR64)/%)
1000Sstevel@tonic-gateROOTFS_LIBS=	$(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
1010Sstevel@tonic-gateROOTFS_LIBS64=	$(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
1020Sstevel@tonic-gateROOTLINKS=	$(ROOTLIBDIR)/$(LIBLINKS)
1030Sstevel@tonic-gateROOTLINKS64=	$(ROOTLIBDIR64)/$(LIBLINKS)
1040Sstevel@tonic-gateROOTFS_LINKS=	$(ROOTFS_LIBDIR)/$(LIBLINKS)
1050Sstevel@tonic-gateROOTFS_LINKS64=	$(ROOTFS_LIBDIR64)/$(LIBLINKS)
1060Sstevel@tonic-gateROOTLINKSCCC=	$(ROOTLIBDIR)/$(LIBLINKSCCC)
1070Sstevel@tonic-gateROOTLINKSCCC64=	$(ROOTLIBDIR64)/$(LIBLINKSCCC)
1080Sstevel@tonic-gateROOTFS_LINKSCCC=	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
1090Sstevel@tonic-gateROOTFS_LINKSCCC64=	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
1100Sstevel@tonic-gateROOTLINT=	$(LINTSRC:%=$(ROOTLINTDIR)/%)
1110Sstevel@tonic-gateROOTFS_LINT=	$(LINTSRC:%=$(ROOTFS_LINTDIR)/%)
1120Sstevel@tonic-gateROOTFS_LINT64=	$(LINTSRC:%=$(ROOTFS_LINTDIR64)/%)
1130Sstevel@tonic-gateROOTMAN3=     $(ROOT)/usr/share/man/man3
1140Sstevel@tonic-gateROOTMAN3FILES=        $(MAN3FILES:%=$(ROOTMAN3)/%)
1150Sstevel@tonic-gate$(ROOTMAN3FILES) := FILEMODE= 444
1160Sstevel@tonic-gate
1174887Schin# Demo rules
1184887SchinDEMOFILES=
1194887SchinDEMOFILESRCDIR=		common
1204887SchinROOTDEMODIRBASE=	__nonexistent_directory__
1214887SchinROOTDEMODIRS=
1224887SchinROOTDEMOFILES=	$(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
1234887Schin$(ROOTDEMODIRS) :=	DIRMODE =	755
1244887Schin
1250Sstevel@tonic-gateLINTLIB=	llib-l$(LIBNAME).ln
1260Sstevel@tonic-gateLINTFLAGS=	-uaxm
1277684SNick.Todd@Sun.COMLINTFLAGS64=	-uaxm -m64
1280Sstevel@tonic-gateLINTSRC=	$(LINTLIB:%.ln=%)
1290Sstevel@tonic-gateLINTOUT=	lint.out
1300Sstevel@tonic-gateARFLAGS=	r
1310Sstevel@tonic-gateSONAME=		$(DYNLIB)
1320Sstevel@tonic-gate# For most libraries, we should be able to resolve all symbols at link time,
1330Sstevel@tonic-gate# either within the library or as dependencies, all text should be pure, and
1340Sstevel@tonic-gate# combining relocations into one relocation table reduces startup costs.
1350Sstevel@tonic-gate# All options are tunable to allow overload/omission from lower makefiles.
1360Sstevel@tonic-gate
1370Sstevel@tonic-gate
1380Sstevel@tonic-gateHSONAME=	-h$(SONAME)
1396543SrieDYNFLAGS=	$(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
1404271Srie		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
1410Sstevel@tonic-gate
1420Sstevel@tonic-gateLDLIBS=		$(LDLIBS.lib)
1430Sstevel@tonic-gate
1440Sstevel@tonic-gateOBJS=		$(OBJECTS:%=objs/%)
1450Sstevel@tonic-gatePICS=		$(OBJECTS:%=pics/%)
1460Sstevel@tonic-gate
1470Sstevel@tonic-gate# Declare that all library .o's can all be made in parallel.
1480Sstevel@tonic-gate# The DUMMY target is for those instances where OBJS and PICS
1490Sstevel@tonic-gate# are empty (to avoid an unconditional .PARALLEL declaration).
1500Sstevel@tonic-gate.PARALLEL:	$(OBJS) $(PICS) DUMMY
1510Sstevel@tonic-gate
1520Sstevel@tonic-gate# default value for "portable" source
1530Sstevel@tonic-gateSRCS=		$(OBJECTS:%.o=$(SRCDIR)/%.c)
1540Sstevel@tonic-gate
1550Sstevel@tonic-gate# default build of an archive and a shared object,
1560Sstevel@tonic-gate# overridden locally when extra processing is needed
1570Sstevel@tonic-gateBUILD.AR=	$(AR) $(ARFLAGS) $@ $(AROBJS)
158*12719SRod.Evans@Sun.COMBUILD.SO=	$(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(EXTPICS) $(LDLIBS)
159*12719SRod.Evans@Sun.COMBUILDCCC.SO=	$(CCC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(EXTPICS) $(LDLIBS)
1600Sstevel@tonic-gate
1610Sstevel@tonic-gate# default dynamic library symlink
16212210SJames.McPherson@Sun.COM# IMPORTANT:: If you change INS.liblink OR INS.liblink64 here, then you
16312210SJames.McPherson@Sun.COM# MUST also change the corresponding override definitions in
16412210SJames.McPherson@Sun.COM# $CLOSED/Makefile.tonic.
16512210SJames.McPherson@Sun.COM#
16612210SJames.McPherson@Sun.COM# If you do not do this, then the closedbins build for the OpenSolaris
16712210SJames.McPherson@Sun.COM# community will break. PS, the gatekeepers will be upset too.
16812210SJames.McPherson@Sun.COM#
1690Sstevel@tonic-gateINS.liblink=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
1700Sstevel@tonic-gateINS.liblinkccc=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
1710Sstevel@tonic-gate
1720Sstevel@tonic-gate# default 64-bit dynamic library symlink
1730Sstevel@tonic-gateINS.liblink64=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
1740Sstevel@tonic-gateINS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
1750Sstevel@tonic-gate
1760Sstevel@tonic-gate#
1770Sstevel@tonic-gate# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
1780Sstevel@tonic-gate# processing.  We'd like to just conditionally append to POST_PROCESS_O and
1790Sstevel@tonic-gate# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
1800Sstevel@tonic-gate# sometimes get appended more than once, which will cause ctfconvert to fail.
1810Sstevel@tonic-gate# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
1820Sstevel@tonic-gate# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
1830Sstevel@tonic-gate# processing should be done.
1840Sstevel@tonic-gate#
1850Sstevel@tonic-gateCTFCONVERT_POST = :
1860Sstevel@tonic-gateCTFMERGE_POST	= :
1870Sstevel@tonic-gatePOST_PROCESS_O += ; $(CTFCONVERT_POST)
1880Sstevel@tonic-gatePOST_PROCESS_SO += ; $(CTFMERGE_POST)
1890Sstevel@tonic-gate
1900Sstevel@tonic-gateCTFMERGE_LIB	= $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
1910Sstevel@tonic-gate
1920Sstevel@tonic-gate# conditional assignments
1930Sstevel@tonic-gate
1940Sstevel@tonic-gate$(OBJS)  :=	sparc_CFLAGS += -xregs=no%appl
1950Sstevel@tonic-gate
1960Sstevel@tonic-gate$(PICS)  :=	sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
1970Sstevel@tonic-gate$(PICS)  :=	sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
1980Sstevel@tonic-gate$(PICS)  :=	i386_CFLAGS += $(i386_C_PICFLAGS)
1990Sstevel@tonic-gate$(PICS)  :=	amd64_CFLAGS += $(amd64_C_PICFLAGS)
2000Sstevel@tonic-gate$(PICS)  :=	CCFLAGS += $(CC_PICFLAGS)
2010Sstevel@tonic-gate$(PICS)  :=	CPPFLAGS += -DPIC -D_REENTRANT
2020Sstevel@tonic-gate$(PICS)  :=	sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
2030Sstevel@tonic-gate$(PICS)  :=	amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
2040Sstevel@tonic-gate$(PICS)  :=	CFLAGS += $(CTF_FLAGS)
2050Sstevel@tonic-gate$(PICS)	 :=	CFLAGS64 += $(CTF_FLAGS)
2060Sstevel@tonic-gate$(PICS)  :=	CTFCONVERT_POST = $(CTFCONVERT_O)
2070Sstevel@tonic-gate$(DYNLIB) :=	CTFMERGE_POST = $(CTFMERGE_LIB)
2080Sstevel@tonic-gate
2090Sstevel@tonic-gate$(LINTLIB):=	LOG = -DLOGGING
2100Sstevel@tonic-gate$(LIBRARY):=	AROBJS = $(OBJS)
2110Sstevel@tonic-gate$(LIBRARY):=	DIR = objs
2120Sstevel@tonic-gate$(DYNLIB):=	DIR = pics
2130Sstevel@tonic-gate$(DYNLIBCCC):=	DIR = pics
2140Sstevel@tonic-gate
2150Sstevel@tonic-gateSONAMECCC=	$(DYNLIBCCC)
2160Sstevel@tonic-gateHSONAMECCC=	-h $(SONAMECCC)
2170Sstevel@tonic-gate#
2180Sstevel@tonic-gate# Keep in sync with the standard DYNFLAGS
2190Sstevel@tonic-gate#
2206543Srie$(DYNLIBCCC):=	DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \
2214271Srie		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \
2225905Srie		$(BDIRECT) $(NORUNPATH)
2230Sstevel@tonic-gate
2240Sstevel@tonic-gate
2250Sstevel@tonic-gate# build rule for "portable" source
2260Sstevel@tonic-gateobjs/%.o pics/%.o: %.c
2270Sstevel@tonic-gate	$(COMPILE.c) -o $@ $<
2280Sstevel@tonic-gate	$(POST_PROCESS_O)
2290Sstevel@tonic-gate
2300Sstevel@tonic-gateobjs/%.o pics/%.o: %.cc
2310Sstevel@tonic-gate	$(COMPILE.cc) -o $@ $<
2320Sstevel@tonic-gate	$(POST_PROCESS_O)
2330Sstevel@tonic-gate
2340Sstevel@tonic-gate.PRECIOUS: $(LIBS)
2350Sstevel@tonic-gate
2360Sstevel@tonic-gate# Define the majority text domain in this directory.
2370Sstevel@tonic-gateTEXT_DOMAIN= SUNW_OST_OSLIB
2380Sstevel@tonic-gate
2390Sstevel@tonic-gate$(ROOTMAN3)/%: %.sunman
2400Sstevel@tonic-gate	$(INS.rename)
2410Sstevel@tonic-gate
2420Sstevel@tonic-gate#
2430Sstevel@tonic-gate# For library source code, we expect that some symbols may not be used or
2440Sstevel@tonic-gate# may *appear* to be able to rescoped to static; shut lint up.  Never add
2450Sstevel@tonic-gate# a flag here unless you're *sure* that all libraries need to be linted
2460Sstevel@tonic-gate# with it.
2470Sstevel@tonic-gate#
2480Sstevel@tonic-gateLINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2
2490Sstevel@tonic-gateLINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2
2500Sstevel@tonic-gate
2510Sstevel@tonic-gate#
2522522Sraf# Target Architecture
2530Sstevel@tonic-gate#
2542522SrafTARGETMACH=	$(MACH)
2550Sstevel@tonic-gate
2560Sstevel@tonic-gate#
2570Sstevel@tonic-gate# Allow people to define their own clobber rules.  Normal makefiles
2580Sstevel@tonic-gate# shouldn't override this - they should override $(CLOBBERFILES) instead.
2590Sstevel@tonic-gate#
2602522SrafCLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)
261