xref: /titanic_50/usr/src/lib/Makefile.lib (revision 672986541be54a7a471bb088e60780c37e371d7e)
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 2007 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#
126# Begin /usr/sfw freeware rules for freeware that has "External"
127# taxonomy stability level.
128#
129ROOTSFW=	$(ROOT)/usr/sfw
130ROOTSFWBIN=	$(ROOT)/usr/sfw/bin
131ROOTSFWSBIN=	$(ROOT)/usr/sfw/sbin
132ROOTSFWETC=	$(ROOT)/etc/sfw
133ROOTSFWVAR=	$(ROOT)/var/sfw
134ROOTSFWSHARE=	$(ROOT)/usr/sfw/share
135ROOTSFWSHSRC=	$(ROOT)/usr/sfw/share/src
136ROOTSFWINCLUDE=	$(ROOT)/usr/sfw/include
137ROOTSFWLIB=	$(ROOT)/usr/sfw/lib
138ROOTSFWLIB64=	$(ROOT)/usr/sfw/lib/$(MACH64)
139ROOTSFWMAN=	$(ROOT)/usr/sfw/share/man
140ROOTSFWMANN=	$(ROOT)/usr/sfw/share/mann
141ROOTSFWMAN1=	$(ROOT)/usr/sfw/share/man/man1
142ROOTSFWMAN1M=	$(ROOT)/usr/sfw/share/man/man1m
143ROOTSFWMAN3=	$(ROOT)/usr/sfw/share/man/man3
144ROOTSFWMAN5=	$(ROOT)/usr/sfw/share/man/man5
145ROOTSFWMAN7=	$(ROOT)/usr/sfw/share/man/man7
146#
147# End /usr/sfw freeware rules
148#
149
150LINTLIB=	llib-l$(LIBNAME).ln
151LINTFLAGS=	-uaxm
152LINTFLAGS64=	-uaxm -Xarch=$(MACH64:sparcv9=v9)
153LINTSRC=	$(LINTLIB:%.ln=%)
154LINTOUT=	lint.out
155ARFLAGS=	r
156SONAME=		$(DYNLIB)
157# For most libraries, we should be able to resolve all symbols at link time,
158# either within the library or as dependencies, all text should be pure, and
159# combining relocations into one relocation table reduces startup costs.
160# All options are tunable to allow overload/omission from lower makefiles.
161
162
163HSONAME=	-h$(SONAME)
164DYNFLAGS=	$(HSONAME) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) \
165		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
166
167LDLIBS=		$(LDLIBS.lib)
168
169OBJS=		$(OBJECTS:%=objs/%)
170PICS=		$(OBJECTS:%=pics/%)
171
172# Declare that all library .o's can all be made in parallel.
173# The DUMMY target is for those instances where OBJS and PICS
174# are empty (to avoid an unconditional .PARALLEL declaration).
175.PARALLEL:	$(OBJS) $(PICS) DUMMY
176
177# default value for "portable" source
178SRCS=		$(OBJECTS:%.o=$(SRCDIR)/%.c)
179
180# default build of an archive and a shared object,
181# overridden locally when extra processing is needed
182BUILD.AR=	$(AR) $(ARFLAGS) $@ $(AROBJS)
183BUILD.SO=	$(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
184BUILDCCC.SO=	$(CCC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
185
186# default dynamic library symlink
187INS.liblink=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
188INS.liblinkccc=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
189
190# default 64-bit dynamic library symlink
191INS.liblink64=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
192INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
193
194#
195# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
196# processing.  We'd like to just conditionally append to POST_PROCESS_O and
197# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
198# sometimes get appended more than once, which will cause ctfconvert to fail.
199# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
200# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
201# processing should be done.
202#
203CTFCONVERT_POST = :
204CTFMERGE_POST	= :
205POST_PROCESS_O += ; $(CTFCONVERT_POST)
206POST_PROCESS_SO += ; $(CTFMERGE_POST)
207
208CTFMERGE_LIB	= $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
209
210# conditional assignments
211
212$(OBJS)  :=	sparc_CFLAGS += -xregs=no%appl
213
214$(PICS)  :=	sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
215$(PICS)  :=	sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
216$(PICS)  :=	i386_CFLAGS += $(i386_C_PICFLAGS)
217$(PICS)  :=	amd64_CFLAGS += $(amd64_C_PICFLAGS)
218$(PICS)  :=	CCFLAGS += $(CC_PICFLAGS)
219$(PICS)  :=	CPPFLAGS += -DPIC -D_REENTRANT
220$(PICS)  :=	sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
221$(PICS)  :=	amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
222$(PICS)  :=	CFLAGS += $(CTF_FLAGS)
223$(PICS)	 :=	CFLAGS64 += $(CTF_FLAGS)
224$(PICS)  :=	CTFCONVERT_POST = $(CTFCONVERT_O)
225$(DYNLIB) :=	CTFMERGE_POST = $(CTFMERGE_LIB)
226
227$(LINTLIB):=	LOG = -DLOGGING
228$(LIBRARY):=	AROBJS = $(OBJS)
229$(LIBRARY):=	DIR = objs
230$(DYNLIB):=	DIR = pics
231$(DYNLIBCCC):=	DIR = pics
232
233SONAMECCC=	$(DYNLIBCCC)
234HSONAMECCC=	-h $(SONAMECCC)
235#
236# Keep in sync with the standard DYNFLAGS
237#
238$(DYNLIBCCC):=	DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) \
239		$(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \
240		$(NORUNPATH)
241
242
243# build rule for "portable" source
244objs/%.o pics/%.o: %.c
245	$(COMPILE.c) -o $@ $<
246	$(POST_PROCESS_O)
247
248objs/%.o pics/%.o: %.cc
249	$(COMPILE.cc) -o $@ $<
250	$(POST_PROCESS_O)
251
252.PRECIOUS: $(LIBS)
253
254# Define the majority text domain in this directory.
255TEXT_DOMAIN= SUNW_OST_OSLIB
256
257$(ROOTMAN3)/%: %.sunman
258	$(INS.rename)
259
260#
261# For library source code, we expect that some symbols may not be used or
262# may *appear* to be able to rescoped to static; shut lint up.  Never add
263# a flag here unless you're *sure* that all libraries need to be linted
264# with it.
265#
266LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2
267LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2
268
269#
270# Target Architecture
271#
272TARGETMACH=	$(MACH)
273
274#
275# Allow people to define their own clobber rules.  Normal makefiles
276# shouldn't override this - they should override $(CLOBBERFILES) instead.
277#
278CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)
279