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.
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.
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]
21 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
22 # Use is subject to license terms.
25 # Definitions common to libraries.
27 # include global definitions; SRC should be defined in the shell.
28 # SRC is needed until RFE 1026993 is implemented.
30 include $(SRC)/Makefile.master
37 # By default, we define the source directory for libraries to be
38 # one level up from the ISA-specific directory, where the code is
39 # actually built. Many libraries define a 'common' directory to
40 # contain the source. These libraries must redefine SRCDIR as:
42 # Other variations are possible (../port, ../src, etc).
47 # We define MAPFILES here for the benefit of most libraries,
48 # those that follow the convention of having source files and other
49 # common files in the $(SRCDIR) directory. Libraries that do not
50 # follow this convention must define MAPFILES for themselves.
51 # Libraries that do follow this convention but that need supplemental
52 # ISA-specific mapfiles can augment MAPFILES like this:
53 # MAPFILES += mapfile-vers
55 MAPFILES = $(SRCDIR)/mapfile-vers
58 # If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
59 # install rule in lib/Makefile.targ to generate false matches if there
60 # are any common directory names between / and /usr/include (`xfn' is
61 # one common example). To prevent this, we set HDRDIR to a directory
62 # name that will almost surely not exist on the build machine.
64 HDRDIR= /__nonexistent_directory__
67 # We don't build archive (*.a) libraries by default anymore.
68 # If a component of the build needs to build an archive library
69 # for its own internal purposes, it can define LIBS for itself
70 # after including Makefile.lib, like this:
73 # LIBS = $(LIBRARYCCC)
74 # Archive libraries must not be installed in the proto area.
77 MACHLIBS= $(LIBS:%=$(MACH)/%)
78 MACHLIBS64= $(LIBS:%=$(MACH64)/%)
79 DYNLIB= $(LIBRARY:.a=.so$(VERS))
80 DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS))
81 DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS))
82 LIBLINKS= $(LIBRARY:.a=.so)
83 LIBLINKSCCC= $(LIBRARYCCC:.a=.so)
84 LIBNAME= $(LIBRARY:lib%.a=%)
87 ROOTHDRDIR= $(ROOT)/usr/include
88 ROOTLIBDIR= $(ROOT)/usr/lib
89 ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64)
90 ROOTFS_LIBDIR= $(ROOT)/lib
91 ROOTFS_LIBDIR64= $(ROOT)/lib/$(MACH64)
92 ROOTLINTDIR= $(ROOTLIBDIR)
93 ROOTFS_LINTDIR= $(ROOTFS_LIBDIR)
94 ROOTFS_LINTDIR64= $(ROOTFS_LIBDIR64)
95 ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
96 HDRSRCS= $(HDRS:%=$(HDRDIR)/%)
97 CHECKHDRS= $(HDRSRCS:%.h=%.check)
98 ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%)
99 ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%)
100 ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
101 ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
102 ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS)
103 ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS)
104 ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS)
105 ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS)
106 ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC)
107 ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC)
108 ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
109 ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
110 ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%)
111 ROOTFS_LINT= $(LINTSRC:%=$(ROOTFS_LINTDIR)/%)
112 ROOTFS_LINT64= $(LINTSRC:%=$(ROOTFS_LINTDIR64)/%)
113 ROOTMAN3= $(ROOT)/usr/share/man/man3
114 ROOTMAN3FILES= $(MAN3FILES:%=$(ROOTMAN3)/%)
115 $(ROOTMAN3FILES) := FILEMODE= 444
116 $(ROOTMAN3FILES) := OWNER= root
117 $(ROOTMAN3FILES) := GROUP= bin
121 DEMOFILESRCDIR= common
122 ROOTDEMODIRBASE= __nonexistent_directory__
124 ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
125 $(ROOTDEMODIRS) := OWNER = root
126 $(ROOTDEMODIRS) := GROUP = bin
127 $(ROOTDEMODIRS) := DIRMODE = 755
129 LINTLIB= llib-l$(LIBNAME).ln
131 LINTFLAGS64= -uaxm -m64
132 LINTSRC= $(LINTLIB:%.ln=%)
136 # For most libraries, we should be able to resolve all symbols at link time,
137 # either within the library or as dependencies, all text should be pure, and
138 # combining relocations into one relocation table reduces startup costs.
139 # All options are tunable to allow overload/omission from lower makefiles.
143 DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
144 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
146 LDLIBS= $(LDLIBS.lib)
148 OBJS= $(OBJECTS:%=objs/%)
149 PICS= $(OBJECTS:%=pics/%)
151 # Declare that all library .o's can all be made in parallel.
152 # The DUMMY target is for those instances where OBJS and PICS
153 # are empty (to avoid an unconditional .PARALLEL declaration).
154 .PARALLEL: $(OBJS) $(PICS) DUMMY
156 # default value for "portable" source
157 SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c)
159 # default build of an archive and a shared object,
160 # overridden locally when extra processing is needed
161 BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS)
162 BUILD.SO= $(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
163 BUILDCCC.SO= $(CCC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
165 # default dynamic library symlink
166 INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
167 INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
169 # default 64-bit dynamic library symlink
170 INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
171 INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
174 # If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
175 # processing. We'd like to just conditionally append to POST_PROCESS_O and
176 # POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
177 # sometimes get appended more than once, which will cause ctfconvert to fail.
178 # So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
179 # appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
180 # processing should be done.
184 POST_PROCESS_O += ; $(CTFCONVERT_POST)
185 POST_PROCESS_SO += ; $(CTFMERGE_POST)
187 CTFMERGE_LIB = $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
189 # conditional assignments
191 $(OBJS) := sparc_CFLAGS += -xregs=no%appl
193 $(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
194 $(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
195 $(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS)
196 $(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS)
197 $(PICS) := CCFLAGS += $(CC_PICFLAGS)
198 $(PICS) := CPPFLAGS += -DPIC -D_REENTRANT
199 $(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
200 $(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
201 $(PICS) := CFLAGS += $(CTF_FLAGS)
202 $(PICS) := CFLAGS64 += $(CTF_FLAGS)
203 $(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O)
204 $(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB)
206 $(LINTLIB):= LOG = -DLOGGING
207 $(LIBRARY):= AROBJS = $(OBJS)
208 $(LIBRARY):= DIR = objs
209 $(DYNLIB):= DIR = pics
210 $(DYNLIBCCC):= DIR = pics
212 SONAMECCC= $(DYNLIBCCC)
213 HSONAMECCC= -h $(SONAMECCC)
215 # Keep in sync with the standard DYNFLAGS
217 $(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \
218 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \
219 $(BDIRECT) $(NORUNPATH)
222 # build rule for "portable" source
223 objs/%.o pics/%.o: %.c
224 $(COMPILE.c) -o $@ $<
227 objs/%.o pics/%.o: %.cc
228 $(COMPILE.cc) -o $@ $<
233 # Define the majority text domain in this directory.
234 TEXT_DOMAIN= SUNW_OST_OSLIB
236 $(ROOTMAN3)/%: %.sunman
240 # For library source code, we expect that some symbols may not be used or
241 # may *appear* to be able to rescoped to static; shut lint up. Never add
242 # a flag here unless you're *sure* that all libraries need to be linted
245 LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2
246 LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2
249 # Target Architecture
254 # Allow people to define their own clobber rules. Normal makefiles
255 # shouldn't override this - they should override $(CLOBBERFILES) instead.
257 CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)