16615 ena assertion failure in ena_tx_intr_work()
[illumos-gate.git] / usr / src / lib / Makefile.lib
blob24f1919264e70dbb5b07ee58bf3107f485d09c4c
2 # CDDL HEADER START
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]
19 # CDDL HEADER END
21 # Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
22 # Copyright 2015 Gary Mills
23 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
24 # Copyright 2016 RackTop Systems.
25 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
26 # Copyright 2019, Joyent, Inc.
29 # Definitions common to libraries.
31 # include global definitions; SRC should be defined in the shell.
32 # SRC is needed until RFE 1026993 is implemented.
34 include         $(SRC)/Makefile.master
36 LORDER=         lorder
37 TSORT=          tsort
40 # By default, we define the source directory for libraries to be
41 # one level up from the ISA-specific directory, where the code is
42 # actually built.  Many libraries define a 'common' directory to
43 # contain the source.  These libraries must redefine SRCDIR as:
44 #       SRCDIR = ../common
45 # Other variations are possible (../port, ../src, etc).
47 SRCDIR =        ..
50 # We define MAPFILES here for the benefit of most libraries, those that
51 # follow the convention of having source files and other common files
52 # in the $(SRCDIR) directory.  Libraries that do not follow this
53 # convention must define MAPFILES, or MAPFILEDIR for themselves.
54 # Libraries that do follow this convention but that need supplemental
55 # ISA-specific mapfiles can augment MAPFILES like this:
56 #       MAPFILES += mapfile-vers
58 MAPFILEDIR =    $(SRCDIR)
59 MAPFILES =      $(MAPFILEDIR)/mapfile-vers
62 # If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
63 # install rule in lib/Makefile.targ to generate false matches if there
64 # are any common directory names between / and /usr/include (`xfn' is
65 # one common example).  To prevent this, we set HDRDIR to a directory
66 # name that will almost surely not exist on the build machine.
68 HDRDIR=         /__nonexistent_directory__
71 # We don't build archive (*.a) libraries by default anymore.
72 # If a component of the build needs to build an archive library
73 # for its own internal purposes, it can define LIBS for itself
74 # after including Makefile.lib, like this:
75 #       LIBS = $(LIBRARY)
76 # or:
77 #       LIBS = $(LIBRARYCCC)
78 # Archive libraries must not be installed in the proto area.
80 LIBS=
81 MACHLIBS=       $(LIBS:%=$(MACH)/%)
82 MACHLIBS64=     $(LIBS:%=$(MACH64)/%)
83 DYNLIB=         $(LIBRARY:.a=.so$(VERS))
84 DYNLIBPSR=      $(LIBRARY:.a=_psr.so$(VERS))
85 DYNLIBCCC=      $(LIBRARYCCC:.a=.so$(VERS))
86 LIBLINKS=       $(LIBRARY:.a=.so)
87 LIBLINKSCCC=    $(LIBRARYCCC:.a=.so)
88 LIBNAME=        $(LIBRARY:lib%.a=%)
89 LIBLINKPATH=
90 LIBNULL=        null.a
91 ROOTHDRDIR=     $(ROOT)/usr/include
92 ROOTLIBDIR=     $(ROOT)/usr/lib
93 ROOTLIBDIR64=   $(ROOT)/usr/lib/$(MACH64)
94 ROOTFS_LIBDIR=  $(ROOT)/lib
95 ROOTFS_LIBDIR64=        $(ROOT)/lib/$(MACH64)
96 ROOTHDRS=       $(HDRS:%=$(ROOTHDRDIR)/%)
97 HDRSRCS=        $(HDRS:%=$(HDRDIR)/%)
98 CHECKHDRS=      $(HDRSRCS:%.h=%.check)
99 ROOTLIBS=       $(LIBS:%=$(ROOTLIBDIR)/%)
100 ROOTLIBS64=     $(LIBS:%=$(ROOTLIBDIR64)/%)
101 # explicitly use usr/lib here instead of ROOTLIBDIR, so that pc files always
102 # end up under /usr/lib, even if a library includes lib/Makefile.rootfs
103 ROOTLIBPCDIR=   $(ROOT)/usr/lib/pkgconfig
104 ROOTLIBPCDIR64= $(ROOT)/usr/lib/$(MACH64)/pkgconfig
105 ROOTLIBPC=      $(PCFILE:%=$(ROOTLIBPCDIR)/%)
106 ROOTLIBPC64=    $(PCFILE:%=$(ROOTLIBPCDIR64)/%)
107 PCLIBDIR = lib
108 PCLIBDIR64 = lib/$(MACH64)
109 ROOTFS_LIBS=    $(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
110 ROOTFS_LIBS64=  $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
111 ROOTLINKS=      $(ROOTLIBDIR)/$(LIBLINKS)
112 ROOTLINKS64=    $(ROOTLIBDIR64)/$(LIBLINKS)
113 ROOTFS_LINKS=   $(ROOTFS_LIBDIR)/$(LIBLINKS)
114 ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS)
115 ROOTLINKSCCC=   $(ROOTLIBDIR)/$(LIBLINKSCCC)
116 ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC)
117 ROOTFS_LINKSCCC=        $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
118 ROOTFS_LINKSCCC64=      $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
120 # Demo rules
121 DEMOFILES=
122 DEMOFILESRCDIR=         common
123 ROOTDEMODIRBASE=        __nonexistent_directory__
124 ROOTDEMODIRS=
125 ROOTDEMOFILES=  $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
126 $(ROOTDEMODIRS) :=      DIRMODE =       755
128 ARFLAGS=        r
129 SONAME=         $(DYNLIB)
131 # For most libraries, we should be able to resolve all symbols at link time,
132 # either within the library or as dependencies, all text should be pure, and
133 # combining relocations into one relocation table reduces startup costs.
134 # All options are tunable to allow overload/omission from lower makefiles.
135 HSONAME=        -Wl,-h$(SONAME)
136 DYNFLAGS=       $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
137                 $(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%) \
138                 $(LDCHECKS)
140 LDLIBS=         $(LDLIBS.lib)
142 OBJS=           $(OBJECTS:%=objs/%)
143 PICS=           $(OBJECTS:%=pics/%)
145 # Declare that all library .o's can all be made in parallel.
146 # The DUMMY target is for those instances where OBJS and PICS
147 # are empty (to avoid an unconditional .PARALLEL declaration).
148 .PARALLEL:      $(OBJS) $(PICS) DUMMY
150 # default value for "portable" source
151 SRCS=           $(OBJECTS:%.o=$(SRCDIR)/%.c)
153 # default build of an archive and a shared object,
154 # overridden locally when extra processing is needed
155 BUILD.AR=       $(AR) $(ARFLAGS) $@ $(AROBJS)
156 BUILD.SO=       $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
157                 $(PICS) $(EXTPICS) $(LDLIBS)
158 BUILD64.SO=     $(CC64) $(CFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \
159                 $(PICS) $(EXTPICS) $(LDLIBS)
160 BUILDCCC.SO=    $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
161                 $(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED)
162 BUILDCCC64.SO=  $(CCC64) $(CCFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \
163                 $(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED64)
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 # Default to adding stack protection to all libraries.
176 CFLAGS +=       $(CCSTACKPROTECT)
177 CFLAGS64 +=     $(CCSTACKPROTECT)
178 LDLIBS +=       $(LDSTACKPROTECT)
181 # If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
182 # processing.  We'd like to just conditionally append to POST_PROCESS_O and
183 # POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
184 # sometimes get appended more than once, which will cause ctfconvert to fail.
185 # So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
186 # appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
187 # processing should be done.
189 CTFCONVERT_POST = :
190 CTFMERGE_POST   = :
191 POST_PROCESS_O += ; $(CTFCONVERT_POST)
192 POST_PROCESS_SO += ; $(CTFMERGE_POST)
194 CTFMERGE_LIB    = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS)
196 # conditional assignments
198 $(PICS)  :=     sparc_CFLAGS += $(sparc_C_PICFLAGS)
199 $(PICS)  :=     sparcv9_CFLAGS += $(sparcv9_C_PICFLAGS)
200 $(PICS)  :=     i386_CFLAGS += $(i386_C_PICFLAGS)
201 $(PICS)  :=     amd64_CFLAGS += $(amd64_C_PICFLAGS)
202 $(PICS)  :=     CCFLAGS += $(CC_PICFLAGS)
203 $(PICS)  :=     CPPFLAGS += -DPIC -D_REENTRANT
204 $(PICS)  :=     sparcv9_CCFLAGS += $(sparcv9_CC_PICFLAGS)
205 $(PICS)  :=     amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
206 $(PICS)  :=     CFLAGS += $(CTF_FLAGS)
207 $(PICS)  :=     CFLAGS64 += $(CTF_FLAGS)
208 $(PICS)  :=     CTFCONVERT_POST = $(CTFCONVERT_O)
209 $(DYNLIB) :=    CTFMERGE_POST = $(CTFMERGE_LIB)
211 $(LIBRARY):=    AROBJS = $(OBJS)
212 $(LIBRARY):=    DIR = objs
213 $(DYNLIB):=     DIR = pics
214 $(DYNLIBCCC):=  DIR = pics
216 SONAMECCC=      $(DYNLIBCCC)
217 HSONAMECCC=     -Wl,-h$(SONAMECCC)
219 # Keep in sync with the standard DYNFLAGS
221 $(DYNLIBCCC):=  DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \
222                 $(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%) \
223                 $(BDIRECT) $(NORUNPATH)
226 # build rule for "portable" source
227 objs/%.o pics/%.o: %.c
228         $(COMPILE.c) -o $@ $<
229         $(POST_PROCESS_O)
231 objs/%.o pics/%.o: %.cc
232         $(COMPILE.cc) -o $@ $<
233         $(POST_PROCESS_CC_O)
235 .PRECIOUS: $(LIBS)
237 # Define the majority text domain in this directory.
238 TEXT_DOMAIN= SUNW_OST_OSLIB
241 # Target Architecture
243 TARGETMACH=     $(MACH)
246 # Allow people to define their own clobber rules.  Normal makefiles
247 # shouldn't override this - they should override $(CLOBBERFILES) instead.
249 CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES) $(PCFILE)
252 # Define the default ctfdiff invocation used to check a list of types
253 # supplied by a user of a library. The goal is to validate that a given
254 # series of types is the same in both a 32-bit and 64-bit artifact. This
255 # is only defined if we have a 64-bit build to do.
257 TYPECHECK_LIB32 =               $(TYPECHECK_LIB:%=$(MACH)/%)
258 TYPECHECK_LIB64 =               $(TYPECHECK_LIB:%=$(MACH64)/%)
259 TYPECHECK_LIST=                 $(TYPELIST:%=-T %)
260 $(BUILD64)TYPECHECK.lib =       $(CTFDIFF) -t -I $(TYPECHECK_LIST) \
261         $(TYPECHECK_LIB32) $(TYPECHECK_LIB64)
262 TYPECHECK =                     $(TYPECHECK_LIB:%=%.typecheck)
264 # Links we need to create for compatibility
265 COMPATLINKS=
266 COMPATLINKS64=
267 ROOTCOMPATLINKS=        $(COMPATLINKS:%=$(ROOT)/%)
268 ROOTCOMPATLINKS64=      $(COMPATLINKS64:%=$(ROOT)/%)
270 # So if someone doesn't set the target-specific variable they get a clue what
271 # went wrong.
272 COMPATLINKTARGET=       /__you_didnt_use_COMPATLINKS_properly__