xref: /titanic_44/usr/src/lib/Makefile.lib (revision 8339b41da2395f0525c46ceedfeb01961893ec44)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
22#
23#
24# Definitions common to libraries.
25#
26# include global definitions; SRC should be defined in the shell.
27# SRC is needed until RFE 1026993 is implemented.
28
29include		$(SRC)/Makefile.master
30
31LORDER=		lorder
32TSORT=		tsort
33AWK=		awk
34
35#
36# By default, we define the source directory for libraries to be
37# one level up from the ISA-specific directory, where the code is
38# actually built.  Many libraries define a 'common' directory to
39# contain the source.  These libraries must redefine SRCDIR as:
40#	SRCDIR = ../common
41# Other variations are possible (../port, ../src, etc).
42#
43SRCDIR =	..
44
45#
46# We define MAPFILES here for the benefit of most libraries, those that
47# follow the convention of having source files and other common files
48# in the $(SRCDIR) directory.  Libraries that do not follow this
49# convention must define MAPFILES, or MAPFILEDIR for themselves.
50# Libraries that do follow this convention but that need supplemental
51# ISA-specific mapfiles can augment MAPFILES like this:
52#	MAPFILES += mapfile-vers
53#
54MAPFILEDIR =	$(SRCDIR)
55MAPFILES =	$(MAPFILEDIR)/mapfile-vers
56
57#
58# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
59# install rule in lib/Makefile.targ to generate false matches if there
60# are any common directory names between / and /usr/include (`xfn' is
61# one common example).  To prevent this, we set HDRDIR to a directory
62# name that will almost surely not exist on the build machine.
63#
64HDRDIR=		/__nonexistent_directory__
65
66#
67# We don't build archive (*.a) libraries by default anymore.
68# If a component of the build needs to build an archive library
69# for its own internal purposes, it can define LIBS for itself
70# after including Makefile.lib, like this:
71# 	LIBS = $(LIBRARY)
72# or:
73# 	LIBS = $(LIBRARYCCC)
74# Archive libraries must not be installed in the proto area.
75#
76LIBS=
77MACHLIBS=	$(LIBS:%=$(MACH)/%)
78MACHLIBS64=	$(LIBS:%=$(MACH64)/%)
79DYNLIB=		$(LIBRARY:.a=.so$(VERS))
80DYNLIBPSR=	$(LIBRARY:.a=_psr.so$(VERS))
81DYNLIBCCC=	$(LIBRARYCCC:.a=.so$(VERS))
82LIBLINKS=	$(LIBRARY:.a=.so)
83LIBLINKSCCC=	$(LIBRARYCCC:.a=.so)
84LIBNAME=	$(LIBRARY:lib%.a=%)
85LIBLINKPATH=
86LIBNULL=	null.a
87ROOTHDRDIR=	$(ROOT)/usr/include
88ROOTLIBDIR=	$(ROOT)/usr/lib
89ROOTLIBDIR64=	$(ROOT)/usr/lib/$(MACH64)
90ROOTFS_LIBDIR=	$(ROOT)/lib
91ROOTFS_LIBDIR64=	$(ROOT)/lib/$(MACH64)
92ROOTLINTDIR=	$(ROOTLIBDIR)
93ROOTFS_LINTDIR=	$(ROOTFS_LIBDIR)
94ROOTFS_LINTDIR64=	$(ROOTFS_LIBDIR64)
95ROOTHDRS=	$(HDRS:%=$(ROOTHDRDIR)/%)
96HDRSRCS=	$(HDRS:%=$(HDRDIR)/%)
97CHECKHDRS=	$(HDRSRCS:%.h=%.check)
98ROOTLIBS=	$(LIBS:%=$(ROOTLIBDIR)/%)
99ROOTLIBS64=	$(LIBS:%=$(ROOTLIBDIR64)/%)
100ROOTFS_LIBS=	$(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
101ROOTFS_LIBS64=	$(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
102ROOTLINKS=	$(ROOTLIBDIR)/$(LIBLINKS)
103ROOTLINKS64=	$(ROOTLIBDIR64)/$(LIBLINKS)
104ROOTFS_LINKS=	$(ROOTFS_LIBDIR)/$(LIBLINKS)
105ROOTFS_LINKS64=	$(ROOTFS_LIBDIR64)/$(LIBLINKS)
106ROOTLINKSCCC=	$(ROOTLIBDIR)/$(LIBLINKSCCC)
107ROOTLINKSCCC64=	$(ROOTLIBDIR64)/$(LIBLINKSCCC)
108ROOTFS_LINKSCCC=	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
109ROOTFS_LINKSCCC64=	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
110ROOTLINT=	$(LINTSRC:%=$(ROOTLINTDIR)/%)
111ROOTFS_LINT=	$(LINTSRC:%=$(ROOTFS_LINTDIR)/%)
112ROOTFS_LINT64=	$(LINTSRC:%=$(ROOTFS_LINTDIR64)/%)
113ROOTMAN3=     $(ROOT)/usr/share/man/man3
114ROOTMAN3FILES=        $(MAN3FILES:%=$(ROOTMAN3)/%)
115$(ROOTMAN3FILES) := FILEMODE= 444
116
117# Demo rules
118DEMOFILES=
119DEMOFILESRCDIR=		common
120ROOTDEMODIRBASE=	__nonexistent_directory__
121ROOTDEMODIRS=
122ROOTDEMOFILES=	$(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
123$(ROOTDEMODIRS) :=	DIRMODE =	755
124
125LINTLIB=	llib-l$(LIBNAME).ln
126LINTFLAGS=	-uaxm
127LINTFLAGS64=	-uaxm -m64
128LINTSRC=	$(LINTLIB:%.ln=%)
129LINTOUT=	lint.out
130ARFLAGS=	r
131SONAME=		$(DYNLIB)
132# For most libraries, we should be able to resolve all symbols at link time,
133# either within the library or as dependencies, all text should be pure, and
134# combining relocations into one relocation table reduces startup costs.
135# All options are tunable to allow overload/omission from lower makefiles.
136
137
138HSONAME=	-h$(SONAME)
139DYNFLAGS=	$(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
140		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
141
142LDLIBS=		$(LDLIBS.lib)
143
144OBJS=		$(OBJECTS:%=objs/%)
145PICS=		$(OBJECTS:%=pics/%)
146
147# Declare that all library .o's can all be made in parallel.
148# The DUMMY target is for those instances where OBJS and PICS
149# are empty (to avoid an unconditional .PARALLEL declaration).
150.PARALLEL:	$(OBJS) $(PICS) DUMMY
151
152# default value for "portable" source
153SRCS=		$(OBJECTS:%.o=$(SRCDIR)/%.c)
154
155# default build of an archive and a shared object,
156# overridden locally when extra processing is needed
157BUILD.AR=	$(AR) $(ARFLAGS) $@ $(AROBJS)
158BUILD.SO=	$(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
159BUILDCCC.SO=	$(CCC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
160
161# default dynamic library symlink
162# IMPORTANT:: If you change INS.liblink OR INS.liblink64 here, then you
163# MUST also change the corresponding override definitions in
164# $CLOSED/Makefile.tonic.
165#
166# If you do not do this, then the closedbins build for the OpenSolaris
167# community will break. PS, the gatekeepers will be upset too.
168#
169INS.liblink=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
170INS.liblinkccc=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
171
172# default 64-bit dynamic library symlink
173INS.liblink64=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
174INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
175
176#
177# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
178# processing.  We'd like to just conditionally append to POST_PROCESS_O and
179# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
180# sometimes get appended more than once, which will cause ctfconvert to fail.
181# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
182# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
183# processing should be done.
184#
185CTFCONVERT_POST = :
186CTFMERGE_POST	= :
187POST_PROCESS_O += ; $(CTFCONVERT_POST)
188POST_PROCESS_SO += ; $(CTFMERGE_POST)
189
190CTFMERGE_LIB	= $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
191
192# conditional assignments
193
194$(OBJS)  :=	sparc_CFLAGS += -xregs=no%appl
195
196$(PICS)  :=	sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
197$(PICS)  :=	sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
198$(PICS)  :=	i386_CFLAGS += $(i386_C_PICFLAGS)
199$(PICS)  :=	amd64_CFLAGS += $(amd64_C_PICFLAGS)
200$(PICS)  :=	CCFLAGS += $(CC_PICFLAGS)
201$(PICS)  :=	CPPFLAGS += -DPIC -D_REENTRANT
202$(PICS)  :=	sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
203$(PICS)  :=	amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
204$(PICS)  :=	CFLAGS += $(CTF_FLAGS)
205$(PICS)	 :=	CFLAGS64 += $(CTF_FLAGS)
206$(PICS)  :=	CTFCONVERT_POST = $(CTFCONVERT_O)
207$(DYNLIB) :=	CTFMERGE_POST = $(CTFMERGE_LIB)
208
209$(LINTLIB):=	LOG = -DLOGGING
210$(LIBRARY):=	AROBJS = $(OBJS)
211$(LIBRARY):=	DIR = objs
212$(DYNLIB):=	DIR = pics
213$(DYNLIBCCC):=	DIR = pics
214
215SONAMECCC=	$(DYNLIBCCC)
216HSONAMECCC=	-h $(SONAMECCC)
217#
218# Keep in sync with the standard DYNFLAGS
219#
220$(DYNLIBCCC):=	DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \
221		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \
222		$(BDIRECT) $(NORUNPATH)
223
224
225# build rule for "portable" source
226objs/%.o pics/%.o: %.c
227	$(COMPILE.c) -o $@ $<
228	$(POST_PROCESS_O)
229
230objs/%.o pics/%.o: %.cc
231	$(COMPILE.cc) -o $@ $<
232	$(POST_PROCESS_O)
233
234.PRECIOUS: $(LIBS)
235
236# Define the majority text domain in this directory.
237TEXT_DOMAIN= SUNW_OST_OSLIB
238
239$(ROOTMAN3)/%: %.sunman
240	$(INS.rename)
241
242#
243# For library source code, we expect that some symbols may not be used or
244# may *appear* to be able to rescoped to static; shut lint up.  Never add
245# a flag here unless you're *sure* that all libraries need to be linted
246# with it.
247#
248LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2
249LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2
250
251#
252# Target Architecture
253#
254TARGETMACH=	$(MACH)
255
256#
257# Allow people to define their own clobber rules.  Normal makefiles
258# shouldn't override this - they should override $(CLOBBERFILES) instead.
259#
260CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)
261