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 2015 Gary Mills
22 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
23 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright (c) 2015, Joyent, Inc.
27 # Definitions common to libraries.
29 # include global definitions; SRC should be defined in the shell.
30 # SRC is needed until RFE 1026993 is implemented.
32 include $(SRC)/Makefile.master
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:
43 # Other variations are possible (../port, ../src, etc).
48 # We define MAPFILES here for the benefit of most libraries, those that
49 # follow the convention of having source files and other common files
50 # in the $(SRCDIR) directory. Libraries that do not follow this
51 # convention must define MAPFILES, or MAPFILEDIR 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
56 MAPFILEDIR = $(SRCDIR)
57 MAPFILES = $(MAPFILEDIR)/mapfile-vers
60 # If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
61 # install rule in lib/Makefile.targ to generate false matches if there
62 # are any common directory names between / and /usr/include (`xfn' is
63 # one common example). To prevent this, we set HDRDIR to a directory
64 # name that will almost surely not exist on the build machine.
66 HDRDIR= /__nonexistent_directory__
69 # We don't build archive (*.a) libraries by default anymore.
70 # If a component of the build needs to build an archive library
71 # for its own internal purposes, it can define LIBS for itself
72 # after including Makefile.lib, like this:
75 # LIBS = $(LIBRARYCCC)
76 # Archive libraries must not be installed in the proto area.
79 MACHLIBS= $(LIBS:%=$(MACH)/%)
80 MACHLIBS64= $(LIBS:%=$(MACH64)/%)
81 DYNLIB= $(LIBRARY:.a=.so$(VERS))
82 DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS))
83 DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS))
84 LIBLINKS= $(LIBRARY:.a=.so)
85 LIBLINKSCCC= $(LIBRARYCCC:.a=.so)
86 LIBNAME= $(LIBRARY:lib%.a=%)
89 ROOTHDRDIR= $(ROOT)/usr/include
90 ROOTLIBDIR= $(ROOT)/usr/lib
91 ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64)
92 ROOTFS_LIBDIR= $(ROOT)/lib
93 ROOTFS_LIBDIR64= $(ROOT)/lib/$(MACH64)
94 ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
95 HDRSRCS= $(HDRS:%=$(HDRDIR)/%)
96 CHECKHDRS= $(HDRSRCS:%.h=%.check)
97 ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%)
98 ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%)
99 ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
100 ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
101 ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS)
102 ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS)
103 ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS)
104 ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS)
105 ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC)
106 ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC)
107 ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
108 ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
112 DEMOFILESRCDIR= common
113 ROOTDEMODIRBASE= __nonexistent_directory__
115 ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
116 $(ROOTDEMODIRS) := DIRMODE = 755
119 # For most libraries, we should be able to resolve all symbols at link time,
120 # either within the library or as dependencies, all text should be pure, and
121 # combining relocations into one relocation table reduces startup costs.
122 # All options are tunable to allow overload/omission from lower makefiles.
125 HSONAME= -Wl,-h$(SONAME)
126 DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
127 $(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%)
129 LDLIBS= $(LDLIBS.lib)
131 OBJS= $(OBJECTS:%=objs/%)
132 PICS= $(OBJECTS:%=pics/%)
134 # Declare that all library .o's can all be made in parallel.
135 # The DUMMY target is for those instances where OBJS and PICS
136 # are empty (to avoid an unconditional .PARALLEL declaration).
137 .PARALLEL: $(OBJS) $(PICS) DUMMY
139 # default value for "portable" source
140 SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c)
142 # default build of an archive and a shared object,
143 # overridden locally when extra processing is needed
144 BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS)
145 BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
146 $(PICS) $(EXTPICS) $(LDLIBS)
147 BUILDCCC.SO= $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
148 $(PICS) $(EXTPICS) $(LDLIBS)
150 # default dynamic library symlink
151 INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
152 INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
154 # default 64-bit dynamic library symlink
155 INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
156 INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
159 # If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
160 # processing. We'd like to just conditionally append to POST_PROCESS_O and
161 # POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
162 # sometimes get appended more than once, which will cause ctfconvert to fail.
163 # So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
164 # appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
165 # processing should be done.
169 POST_PROCESS_O += ; $(CTFCONVERT_POST)
170 POST_PROCESS_SO += ; $(CTFMERGE_POST)
172 CTFMERGE_LIB = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS)
174 # conditional assignments
176 $(OBJS) := sparc_CFLAGS += -mno-app-regs
178 $(PICS) := sparc_CFLAGS += -mno-app-regs $(sparc_C_PICFLAGS)
179 $(PICS) := sparcv9_CFLAGS += -mno-app-regs $(sparcv9_C_PICFLAGS)
180 $(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS)
181 $(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS)
182 $(PICS) := CCFLAGS += $(CC_PICFLAGS)
183 $(PICS) := CPPFLAGS += -DPIC
184 $(PICS) := sparcv9_CCFLAGS += -mno-app-regs $(sparcv9_CC_PICFLAGS)
185 $(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
186 $(PICS) := CFLAGS += $(CTF_FLAGS)
187 $(PICS) := CFLAGS64 += $(CTF_FLAGS)
188 $(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O)
189 $(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB)
191 $(LIBRARY):= AROBJS = $(OBJS)
192 $(LIBRARY):= DIR = objs
193 $(DYNLIB):= DIR = pics
194 $(DYNLIBCCC):= DIR = pics
196 SONAMECCC= $(DYNLIBCCC)
197 HSONAMECCC= -Wl,-h$(SONAMECCC)
199 # Keep in sync with the standard DYNFLAGS
201 $(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \
202 $(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(BDIRECT)
205 # build rule for "portable" source
206 objs/%.o pics/%.o: %.c
207 $(COMPILE.c) -o $@ $<
210 objs/%.o pics/%.o: %.cc
211 $(COMPILE.cc) -o $@ $<
216 # Define the majority text domain in this directory.
217 TEXT_DOMAIN= SUNW_OST_OSLIB
220 # Target Architecture
225 # Allow people to define their own clobber rules. Normal makefiles
226 # shouldn't override this - they should override $(CLOBBERFILES) instead.
228 CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)
231 # Define the default ctfdiff invocation used to check a list of types
232 # supplied by a user of a library. The goal is to validate that a given
233 # series of types is the same in both a 32-bit and 64-bit artifact. This
234 # is only defined if we have a 64-bit build to do.
236 TYPECHECK_LIB32 = $(TYPECHECK_LIB:%=$(MACH)/%)
237 TYPECHECK_LIB64 = $(TYPECHECK_LIB:%=$(MACH64)/%)
238 TYPECHECK_LIST= $(TYPELIST:%=-T %)
239 $(BUILD64)TYPECHECK.lib = $(CTFDIFF) -t -I $(TYPECHECK_LIST) $(TYPECHECK_LIB32) $(TYPECHECK_LIB64)
240 TYPECHECK = $(TYPECHECK_LIB:%=%.typecheck)