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