xref: /titanic_41/usr/src/lib/Makefile.lib (revision fb49a0d14105507530a42288b4a7bec770c7b016)
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#
22# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26#
27
28#
29# Definitions common to libraries.
30#
31# include global definitions; SRC should be defined in the shell.
32# SRC is needed until RFE 1026993 is implemented.
33
34include		$(SRC)/Makefile.master
35
36LORDER=		lorder
37TSORT=		tsort
38AWK=		awk
39
40#
41# By default, we define the source directory for libraries to be
42# one level up from the ISA-specific directory, where the code is
43# actually built.  Many libraries define a 'common' directory to
44# contain the source.  These libraries must redefine SRCDIR as:
45#	SRCDIR = ../common
46# Other variations are possible (../port, ../src, etc).
47#
48SRCDIR =	..
49
50#
51# We define MAPFILES here for the benefit of most libraries,
52# those that follow the convention of having source files and other
53# common files in the $(SRCDIR) directory.  Libraries that do not
54# follow this convention must define MAPFILES for themselves.
55# Libraries that do follow this convention but that need supplemental
56# ISA-specific mapfiles can augment MAPFILES like this:
57#	MAPFILES += mapfile-vers
58#
59MAPFILES =	$(SRCDIR)/mapfile-vers
60
61C_SYNONYMS_H=	$(SRC)/lib/common/inc/c_synonyms.h
62
63#
64# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
65# install rule in lib/Makefile.targ to generate false matches if there
66# are any common directory names between / and /usr/include (`xfn' is
67# one common example).  To prevent this, we set HDRDIR to a directory
68# name that will almost surely not exist on the build machine.
69#
70HDRDIR=		/__nonexistent_directory__
71
72#
73# We don't build archive (*.a) libraries by default anymore.
74# If a component of the build needs to build an archive library
75# for its own internal purposes, it can define LIBS for itself
76# after including Makefile.lib, like this:
77# 	LIBS = $(LIBRARY)
78# or:
79# 	LIBS = $(LIBRARYCCC)
80# Archive libraries must not be installed in the proto area.
81#
82LIBS=
83MACHLIBS=	$(LIBS:%=$(MACH)/%)
84MACHLIBS64=	$(LIBS:%=$(MACH64)/%)
85DYNLIB=		$(LIBRARY:.a=.so$(VERS))
86DYNLIBPSR=	$(LIBRARY:.a=_psr.so$(VERS))
87DYNLIBCCC=	$(LIBRARYCCC:.a=.so$(VERS))
88LIBLINKS=	$(LIBRARY:.a=.so)
89LIBLINKSCCC=	$(LIBRARYCCC:.a=.so)
90LIBNAME=	$(LIBRARY:lib%.a=%)
91LIBLINKPATH=
92LIBNULL=	null.a
93ROOTHDRDIR=	$(ROOT)/usr/include
94ROOTLIBDIR=	$(ROOT)/usr/lib
95ROOTLIBDIR64=	$(ROOT)/usr/lib/$(MACH64)
96ROOTFS_LIBDIR=	$(ROOT)/lib
97ROOTFS_LIBDIR64=	$(ROOT)/lib/$(MACH64)
98ROOTLINTDIR=	$(ROOTLIBDIR)
99ROOTFS_LINTDIR=	$(ROOTFS_LIBDIR)
100ROOTFS_LINTDIR64=	$(ROOTFS_LIBDIR64)
101ROOTHDRS=	$(HDRS:%=$(ROOTHDRDIR)/%)
102HDRSRCS=	$(HDRS:%=$(HDRDIR)/%)
103CHECKHDRS=	$(HDRSRCS:%.h=%.check)
104ROOTLIBS=	$(LIBS:%=$(ROOTLIBDIR)/%)
105ROOTLIBS64=	$(LIBS:%=$(ROOTLIBDIR64)/%)
106ROOTFS_LIBS=	$(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
107ROOTFS_LIBS64=	$(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
108ROOTLINKS=	$(ROOTLIBDIR)/$(LIBLINKS)
109ROOTLINKS64=	$(ROOTLIBDIR64)/$(LIBLINKS)
110ROOTFS_LINKS=	$(ROOTFS_LIBDIR)/$(LIBLINKS)
111ROOTFS_LINKS64=	$(ROOTFS_LIBDIR64)/$(LIBLINKS)
112ROOTLINKSCCC=	$(ROOTLIBDIR)/$(LIBLINKSCCC)
113ROOTLINKSCCC64=	$(ROOTLIBDIR64)/$(LIBLINKSCCC)
114ROOTFS_LINKSCCC=	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
115ROOTFS_LINKSCCC64=	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
116ROOTLINT=	$(LINTSRC:%=$(ROOTLINTDIR)/%)
117ROOTFS_LINT=	$(LINTSRC:%=$(ROOTFS_LINTDIR)/%)
118ROOTFS_LINT64=	$(LINTSRC:%=$(ROOTFS_LINTDIR64)/%)
119ROOTMAN3=     $(ROOT)/usr/share/man/man3
120ROOTMAN3FILES=        $(MAN3FILES:%=$(ROOTMAN3)/%)
121$(ROOTMAN3FILES) := FILEMODE= 444
122$(ROOTMAN3FILES) := OWNER= root
123$(ROOTMAN3FILES) := GROUP= bin
124
125# Demo rules
126DEMOFILES=
127DEMOFILESRCDIR=		common
128ROOTDEMODIRBASE=	__nonexistent_directory__
129ROOTDEMODIRS=
130ROOTDEMOFILES=	$(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
131$(ROOTDEMODIRS) :=	OWNER =		root
132$(ROOTDEMODIRS) :=	GROUP =		bin
133$(ROOTDEMODIRS) :=	DIRMODE =	755
134
135#
136# Begin /usr/sfw freeware rules for freeware that has "External"
137# taxonomy stability level.
138#
139ROOTSFW=	$(ROOT)/usr/sfw
140ROOTSFWBIN=	$(ROOT)/usr/sfw/bin
141ROOTSFWSBIN=	$(ROOT)/usr/sfw/sbin
142ROOTSFWETC=	$(ROOT)/etc/sfw
143ROOTSFWVAR=	$(ROOT)/var/sfw
144ROOTSFWSHARE=	$(ROOT)/usr/sfw/share
145ROOTSFWSHSRC=	$(ROOT)/usr/sfw/share/src
146ROOTSFWINCLUDE=	$(ROOT)/usr/sfw/include
147ROOTSFWLIB=	$(ROOT)/usr/sfw/lib
148ROOTSFWLIB64=	$(ROOT)/usr/sfw/lib/$(MACH64)
149ROOTSFWMAN=	$(ROOT)/usr/sfw/share/man
150ROOTSFWMANN=	$(ROOT)/usr/sfw/share/mann
151ROOTSFWMAN1=	$(ROOT)/usr/sfw/share/man/man1
152ROOTSFWMAN1M=	$(ROOT)/usr/sfw/share/man/man1m
153ROOTSFWMAN3=	$(ROOT)/usr/sfw/share/man/man3
154ROOTSFWMAN5=	$(ROOT)/usr/sfw/share/man/man5
155ROOTSFWMAN7=	$(ROOT)/usr/sfw/share/man/man7
156#
157# End /usr/sfw freeware rules
158#
159
160LINTLIB=	llib-l$(LIBNAME).ln
161LINTFLAGS=	-uaxm
162LINTFLAGS64=	-uaxm -Xarch=$(MACH64:sparcv9=v9)
163LINTSRC=	$(LINTLIB:%.ln=%)
164LINTOUT=	lint.out
165ARFLAGS=	r
166SONAME=		$(DYNLIB)
167# For most libraries, we should be able to resolve all symbols at link time,
168# either within the library or as dependencies, all text should be pure, and
169# combining relocations into one relocation table reduces startup costs.
170# All options are tunable to allow overload/omission from lower makefiles.
171
172
173HSONAME=	-h$(SONAME)
174DYNFLAGS=	$(HSONAME) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) $(BDIRECT) \
175		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
176
177LDLIBS=		$(LDLIBS.lib)
178
179OBJS=		$(OBJECTS:%=objs/%)
180PICS=		$(OBJECTS:%=pics/%)
181
182# Declare that all library .o's can all be made in parallel.
183# The DUMMY target is for those instances where OBJS and PICS
184# are empty (to avoid an unconditional .PARALLEL declaration).
185.PARALLEL:	$(OBJS) $(PICS) DUMMY
186
187# default value for "portable" source
188SRCS=		$(OBJECTS:%.o=$(SRCDIR)/%.c)
189
190# default build of an archive and a shared object,
191# overridden locally when extra processing is needed
192BUILD.AR=	$(AR) $(ARFLAGS) $@ $(AROBJS)
193BUILD.SO=	$(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
194BUILDCCC.SO=	$(CCC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
195
196# default dynamic library symlink
197INS.liblink=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
198INS.liblinkccc=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
199
200# default 64-bit dynamic library symlink
201INS.liblink64=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
202INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
203
204#
205# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
206# processing.  We'd like to just conditionally append to POST_PROCESS_O and
207# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
208# sometimes get appended more than once, which will cause ctfconvert to fail.
209# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
210# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
211# processing should be done.
212#
213CTFCONVERT_POST = :
214CTFMERGE_POST	= :
215POST_PROCESS_O += ; $(CTFCONVERT_POST)
216POST_PROCESS_SO += ; $(CTFMERGE_POST)
217
218CTFMERGE_LIB	= $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
219
220# conditional assignments
221
222$(OBJS)  :=	sparc_CFLAGS += -xregs=no%appl
223
224$(PICS)  :=	sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
225$(PICS)  :=	sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
226$(PICS)  :=	i386_CFLAGS += $(i386_C_PICFLAGS)
227$(PICS)  :=	amd64_CFLAGS += $(amd64_C_PICFLAGS)
228$(PICS)  :=	CCFLAGS += $(CC_PICFLAGS)
229$(PICS)  :=	CPPFLAGS += -DPIC -D_REENTRANT
230$(PICS)  :=	sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
231$(PICS)  :=	amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
232$(PICS)  :=	CFLAGS += $(CTF_FLAGS)
233$(PICS)	 :=	CFLAGS64 += $(CTF_FLAGS)
234$(PICS)  :=	CTFCONVERT_POST = $(CTFCONVERT_O)
235$(DYNLIB) :=	CTFMERGE_POST = $(CTFMERGE_LIB)
236
237$(LINTLIB):=	LOG = -DLOGGING
238$(LIBRARY):=	AROBJS = $(OBJS)
239$(LIBRARY):=	DIR = objs
240$(DYNLIB):=	DIR = pics
241$(DYNLIBCCC):=	DIR = pics
242
243SONAMECCC=	$(DYNLIBCCC)
244HSONAMECCC=	-h $(SONAMECCC)
245#
246# Keep in sync with the standard DYNFLAGS
247#
248$(DYNLIBCCC):=	DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) \
249		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \
250		$(BDIRECT) $(NORUNPATH)
251
252
253# build rule for "portable" source
254objs/%.o pics/%.o: %.c
255	$(COMPILE.c) -o $@ $<
256	$(POST_PROCESS_O)
257
258objs/%.o pics/%.o: %.cc
259	$(COMPILE.cc) -o $@ $<
260	$(POST_PROCESS_O)
261
262.PRECIOUS: $(LIBS)
263
264# Define the majority text domain in this directory.
265TEXT_DOMAIN= SUNW_OST_OSLIB
266
267$(ROOTMAN3)/%: %.sunman
268	$(INS.rename)
269
270#
271# For library source code, we expect that some symbols may not be used or
272# may *appear* to be able to rescoped to static; shut lint up.  Never add
273# a flag here unless you're *sure* that all libraries need to be linted
274# with it.
275#
276LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2
277LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2
278
279#
280# Target Architecture
281#
282TARGETMACH=	$(MACH)
283
284#
285# Allow people to define their own clobber rules.  Normal makefiles
286# shouldn't override this - they should override $(CLOBBERFILES) instead.
287#
288CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)
289