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