1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
# Copyright 2015 Gary Mills
# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
# Copyright 2016 RackTop Systems.
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2019, Joyent, Inc.
#
#
# Definitions common to libraries.
#
# include global definitions; SRC should be defined in the shell.
# SRC is needed until RFE 1026993 is implemented.
include $(SRC)/Makefile.master
LORDER= lorder
TSORT= tsort
#
# By default, we define the source directory for libraries to be
# one level up from the ISA-specific directory, where the code is
# actually built. Many libraries define a 'common' directory to
# contain the source. These libraries must redefine SRCDIR as:
# SRCDIR = ../common
# Other variations are possible (../port, ../src, etc).
#
SRCDIR = ..
#
# We define MAPFILES here for the benefit of most libraries, those that
# follow the convention of having source files and other common files
# in the $(SRCDIR) directory. Libraries that do not follow this
# convention must define MAPFILES, or MAPFILEDIR for themselves.
# Libraries that do follow this convention but that need supplemental
# ISA-specific mapfiles can augment MAPFILES like this:
# MAPFILES += mapfile-vers
#
MAPFILEDIR = $(SRCDIR)
MAPFILES = $(MAPFILEDIR)/mapfile-vers
#
# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
# install rule in lib/Makefile.targ to generate false matches if there
# are any common directory names between / and /usr/include (`xfn' is
# one common example). To prevent this, we set HDRDIR to a directory
# name that will almost surely not exist on the build machine.
#
HDRDIR= /__nonexistent_directory__
#
# We don't build archive (*.a) libraries by default anymore.
# If a component of the build needs to build an archive library
# for its own internal purposes, it can define LIBS for itself
# after including Makefile.lib, like this:
# LIBS = $(LIBRARY)
# or:
# LIBS = $(LIBRARYCCC)
# Archive libraries must not be installed in the proto area.
#
LIBS=
MACHLIBS= $(LIBS:%=$(MACH)/%)
MACHLIBS64= $(LIBS:%=$(MACH64)/%)
DYNLIB= $(LIBRARY:.a=.so$(VERS))
DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS))
DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS))
LIBLINKS= $(LIBRARY:.a=.so)
LIBLINKSCCC= $(LIBRARYCCC:.a=.so)
LIBNAME= $(LIBRARY:lib%.a=%)
LIBLINKPATH=
LIBNULL= null.a
ROOTHDRDIR= $(ROOT)/usr/include
ROOTLIBDIR= $(ROOT)/usr/lib
ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64)
ROOTFS_LIBDIR= $(ROOT)/lib
ROOTFS_LIBDIR64= $(ROOT)/lib/$(MACH64)
ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
HDRSRCS= $(HDRS:%=$(HDRDIR)/%)
CHECKHDRS= $(HDRSRCS:%.h=%.check)
ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%)
ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%)
ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS)
ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS)
ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS)
ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS)
ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC)
ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC)
ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
# Demo rules
DEMOFILES=
DEMOFILESRCDIR= common
ROOTDEMODIRBASE= __nonexistent_directory__
ROOTDEMODIRS=
ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
$(ROOTDEMODIRS) := DIRMODE = 755
ARFLAGS= r
SONAME= $(DYNLIB)
# For most libraries, we should be able to resolve all symbols at link time,
# either within the library or as dependencies, all text should be pure, and
# combining relocations into one relocation table reduces startup costs.
# All options are tunable to allow overload/omission from lower makefiles.
#
# DTrace related rules
#
# These allow for multiple USDT providers to be specified by a library.
# If a library needs to break up the set of objects that are passed to
# the dtrace -G invocation, then they can place the following in heir
# Makefile.com:
#
# pics/<provider>.o := USDT_G_PICS = <files>
#
# <provider> should be replaced with the basename of one of the USDT
# providers specified in USDT_PROVIDERS in their Makefile.com.
#
USDT_HEADERS= $(USDT_PROVIDERS:%.d=%_impl.h)
USDT_PICS= $(USDT_PROVIDERS:%.d=pics/%.o)
USDT_G_PICS= $(PICS)
HSONAME= -h$(SONAME)
DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
$(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%) \
$(LDCHECKS)
LDLIBS= $(LDLIBS.lib)
OBJS= $(OBJECTS:%=objs/%)
PICS= $(OBJECTS:%=pics/%)
# Declare that all library .o's can all be made in parallel.
# The DUMMY target is for those instances where OBJS and PICS
# are empty (to avoid an unconditional .PARALLEL declaration).
.PARALLEL: $(OBJS) $(PICS) DUMMY
# default value for "portable" source
SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c)
# default build of an archive and a shared object,
# overridden locally when extra processing is needed
BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS)
BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
$(PICS) $(EXTPICS) $(USDT_PICS) $(LDLIBS)
BUILD64.SO= $(CC64) $(CFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \
$(PICS) $(EXTPICS) -L $(ROOTLIBDIR64) $(LDLIBS)
BUILDCCC.SO= $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
$(PICS) $(EXTPICS) $(LDLIBS)
BUILDCCC64.SO= $(CCC64) $(CCFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \
$(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED64)
# default dynamic library symlink
INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
# default 64-bit dynamic library symlink
INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
#
# Default to adding stack protection to all libraries.
#
CFLAGS += $(CCSTACKPROTECT)
CFLAGS64 += $(CCSTACKPROTECT)
LDLIBS += $(LDSTACKPROTECT)
#
# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
# processing. We'd like to just conditionally append to POST_PROCESS_O and
# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
# sometimes get appended more than once, which will cause ctfconvert to fail.
# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
# processing should be done.
#
CTFCONVERT_POST = :
CTFMERGE_POST = :
POST_PROCESS_O += ; $(CTFCONVERT_POST)
POST_PROCESS_SO += ; $(CTFMERGE_POST)
CTFMERGE_LIB = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS)
# conditional assignments
$(OBJS) := sparc_CFLAGS += -xregs=no%appl
$(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
$(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
$(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS)
$(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS)
$(PICS) := CCFLAGS += $(CC_PICFLAGS)
$(PICS) := CPPFLAGS += -DPIC -D_REENTRANT
$(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
$(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
$(PICS) := CFLAGS += $(CTF_FLAGS)
$(PICS) := CFLAGS64 += $(CTF_FLAGS)
$(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O)
$(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB)
$(LIBRARY):= AROBJS = $(OBJS)
$(LIBRARY):= DIR = objs
$(DYNLIB):= DIR = pics
$(DYNLIBCCC):= DIR = pics
SONAMECCC= $(DYNLIBCCC)
HSONAMECCC= -h $(SONAMECCC)
#
# Keep in sync with the standard DYNFLAGS
#
$(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \
$(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%) \
$(BDIRECT) $(NORUNPATH)
# build rule for "portable" source
objs/%.o pics/%.o: %.c
$(COMPILE.c) -o $@ $<
$(POST_PROCESS_O)
objs/%.o pics/%.o: %.cc
$(COMPILE.cc) -o $@ $<
$(POST_PROCESS_CC_O)
.PRECIOUS: $(LIBS)
# Define the majority text domain in this directory.
TEXT_DOMAIN= SUNW_OST_OSLIB
#
# Target Architecture
#
TARGETMACH= $(MACH)
#
# Allow people to define their own clobber rules. Normal makefiles
# shouldn't override this - they should override $(CLOBBERFILES) instead.
#
CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)
#
# Define the default ctfdiff invocation used to check a list of types
# supplied by a user of a library. The goal is to validate that a given
# series of types is the same in both a 32-bit and 64-bit artifact. This
# is only defined if we have a 64-bit build to do.
#
TYPECHECK_LIB32 = $(TYPECHECK_LIB:%=$(MACH)/%)
TYPECHECK_LIB64 = $(TYPECHECK_LIB:%=$(MACH64)/%)
TYPECHECK_LIST= $(TYPELIST:%=-T %)
$(BUILD64)TYPECHECK.lib = $(CTFDIFF) -t -I $(TYPECHECK_LIST) \
$(TYPECHECK_LIB32) $(TYPECHECK_LIB64)
TYPECHECK = $(TYPECHECK_LIB:%=%.typecheck)
# Links we need to create for compatibility
COMPATLINKS=
COMPATLINKS64=
ROOTCOMPATLINKS= $(COMPATLINKS:%=$(ROOT)/%)
ROOTCOMPATLINKS64= $(COMPATLINKS64:%=$(ROOT)/%)
# So if someone doesn't set the target-specific variable they get a clue what
# went wrong.
COMPATLINKTARGET= /__you_didnt_use_COMPATLINKS_properly__
|