xref: /titanic_44/usr/src/lib/Makefile.lib (revision 40e5e17b3361b3eea56a9723071c406894a20b78)
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 2006 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
40MAPFILE-FLTR=	$(SRC)/lib/common/mapfile-filter
41
42NX_MAP_i386=	$(SRC)/cmd/mapfile_noexdata
43NX_MAP_sparc=
44
45NX_MAP=		$(NX_MAP_$(MACH))
46
47#
48# By default, we define the source directory for libraries to be
49# one level up from the ISA-specific directory, where the code is
50# actually built.  Many libraries define a 'common' directory to
51# contain the source.  These libraries must redefine SRCDIR as:
52#	SRCDIR = ../common
53# Other variations are possible (../port, ../src, etc).
54#
55SRCDIR =	..
56
57#
58# We define MAPFILES here for the benefit of most libraries,
59# those that follow the convention of having source files and other
60# common files in the $(SRCDIR) directory.  Libraries that do not
61# follow this convention must define MAPFILES for themselves.
62# Libraries that do follow this convention but that need supplemental
63# ISA-specific mapfiles can augment MAPFILES like this:
64#	MAPFILES += mapfile-vers
65#
66MAPFILES =	$(SRCDIR)/mapfile-vers
67
68C_SYNONYMS_H=	$(SRC)/lib/common/inc/c_synonyms.h
69
70#
71# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
72# install rule in lib/Makefile.targ to generate false matches if there
73# are any common directory names between / and /usr/include (`xfn' is
74# one common example).  To prevent this, we set HDRDIR to a directory
75# name that will almost surely not exist on the build machine.
76#
77HDRDIR=		/__nonexistent_directory__
78
79#
80# We don't build archive (*.a) libraries by default anymore.
81# If a component of the build needs to build an archive library
82# for its own internal purposes, it can define LIBS for itself
83# after including Makefile.lib, like this:
84# 	LIBS = $(LIBRARY)
85# or:
86# 	LIBS = $(LIBRARYCCC)
87# Archive libraries must not be installed in the proto area.
88#
89LIBS=
90MACHLIBS=	$(LIBS:%=$(MACH)/%)
91MACHLIBS64=	$(LIBS:%=$(MACH64)/%)
92DYNLIB=		$(LIBRARY:.a=.so$(VERS))
93DYNLIBPSR=	$(LIBRARY:.a=_psr.so$(VERS))
94DYNLIBCCC=	$(LIBRARYCCC:.a=.so$(VERS))
95LIBLINKS=	$(LIBRARY:.a=.so)
96LIBLINKSCCC=	$(LIBRARYCCC:.a=.so)
97LIBNAME=	$(LIBRARY:lib%.a=%)
98LIBLINKPATH=
99LIBNULL=	null.a
100ROOTHDRDIR=	$(ROOT)/usr/include
101ROOTLIBDIR=	$(ROOT)/usr/lib
102ROOTLIBDIR64=	$(ROOT)/usr/lib/$(MACH64)
103ROOTFS_LIBDIR=	$(ROOT)/lib
104ROOTFS_LIBDIR64=	$(ROOT)/lib/$(MACH64)
105ROOTLINTDIR=	$(ROOTLIBDIR)
106ROOTFS_LINTDIR=	$(ROOTFS_LIBDIR)
107ROOTFS_LINTDIR64=	$(ROOTFS_LIBDIR64)
108ROOTHDRS=	$(HDRS:%=$(ROOTHDRDIR)/%)
109HDRSRCS=	$(HDRS:%=$(HDRDIR)/%)
110CHECKHDRS=	$(HDRSRCS:%.h=%.check)
111ROOTLIBS=	$(LIBS:%=$(ROOTLIBDIR)/%)
112ROOTLIBS64=	$(LIBS:%=$(ROOTLIBDIR64)/%)
113ROOTFS_LIBS=	$(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
114ROOTFS_LIBS64=	$(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
115ROOTLINKS=	$(ROOTLIBDIR)/$(LIBLINKS)
116ROOTLINKS64=	$(ROOTLIBDIR64)/$(LIBLINKS)
117ROOTFS_LINKS=	$(ROOTFS_LIBDIR)/$(LIBLINKS)
118ROOTFS_LINKS64=	$(ROOTFS_LIBDIR64)/$(LIBLINKS)
119ROOTLINKSCCC=	$(ROOTLIBDIR)/$(LIBLINKSCCC)
120ROOTLINKSCCC64=	$(ROOTLIBDIR64)/$(LIBLINKSCCC)
121ROOTFS_LINKSCCC=	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
122ROOTFS_LINKSCCC64=	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
123ROOTLINT=	$(LINTSRC:%=$(ROOTLINTDIR)/%)
124ROOTFS_LINT=	$(LINTSRC:%=$(ROOTFS_LINTDIR)/%)
125ROOTFS_LINT64=	$(LINTSRC:%=$(ROOTFS_LINTDIR64)/%)
126ROOTMAN3=     $(ROOT)/usr/share/man/man3
127ROOTMAN3FILES=        $(MAN3FILES:%=$(ROOTMAN3)/%)
128$(ROOTMAN3FILES) := FILEMODE= 444
129$(ROOTMAN3FILES) := OWNER= root
130$(ROOTMAN3FILES) := GROUP= bin
131
132#
133# Begin /usr/sfw freeware rules for freeware that has "External"
134# taxonomy stability level.
135#
136ROOTSFW=	$(ROOT)/usr/sfw
137ROOTSFWBIN=	$(ROOT)/usr/sfw/bin
138ROOTSFWSBIN=	$(ROOT)/usr/sfw/sbin
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) $(ZCOMBRELOC) \
172		$(MAPFILES:%=-M%) $(PGA_MAPFILE:%=-M%) $(NX_MAP:%=-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) $(ZCOMBRELOC) \
246		$(MAPFILES:%=-M%) $(PGA_MAPFILE:%=-M%) $(NX_MAP:%=-M%) \
247		$(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