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