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 (the "License"). 6 # You may not use this file except in compliance with the License. 7 # 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. 12 # 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] 18 # 19 # CDDL HEADER END 20 # 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) 2014, Joyent, Inc. 25 # Copyright 2016 RackTop Systems. 26 # 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 33 include $(SRC)/Makefile.master 34 35 LORDER= lorder 36 TSORT= tsort 37 38 # 39 # By default, we define the source directory for libraries to be 40 # one level up from the ISA-specific directory, where the code is 41 # actually built. Many libraries define a 'common' directory to 42 # contain the source. These libraries must redefine SRCDIR as: 43 # SRCDIR = ../common 44 # Other variations are possible (../port, ../src, etc). 45 # 46 SRCDIR = .. 47 48 # 49 # We define MAPFILES here for the benefit of most libraries, those that 50 # follow the convention of having source files and other common files 51 # in the $(SRCDIR) directory. Libraries that do not follow this 52 # convention must define MAPFILES, or MAPFILEDIR for themselves. 53 # Libraries that do follow this convention but that need supplemental 54 # ISA-specific mapfiles can augment MAPFILES like this: 55 # MAPFILES += mapfile-vers 56 # 57 MAPFILEDIR = $(SRCDIR) 58 MAPFILES = $(MAPFILEDIR)/mapfile-vers 59 60 # 61 # If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/% 62 # install rule in lib/Makefile.targ to generate false matches if there 63 # are any common directory names between / and /usr/include (`xfn' is 64 # one common example). To prevent this, we set HDRDIR to a directory 65 # name that will almost surely not exist on the build machine. 66 # 67 HDRDIR= /__nonexistent_directory__ 68 69 # 70 # We don't build archive (*.a) libraries by default anymore. 71 # If a component of the build needs to build an archive library 72 # for its own internal purposes, it can define LIBS for itself 73 # after including Makefile.lib, like this: 74 # LIBS = $(LIBRARY) 75 # or: 76 # LIBS = $(LIBRARYCCC) 77 # Archive libraries must not be installed in the proto area. 78 # 79 LIBS= 80 MACHLIBS= $(LIBS:%=$(MACH)/%) 81 MACHLIBS64= $(LIBS:%=$(MACH64)/%) 82 DYNLIB= $(LIBRARY:.a=.so$(VERS)) 83 DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS)) 84 DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS)) 85 LIBLINKS= $(LIBRARY:.a=.so) 86 LIBLINKSCCC= $(LIBRARYCCC:.a=.so) 87 LIBNAME= $(LIBRARY:lib%.a=%) 88 LIBLINKPATH= 89 LIBNULL= null.a 90 ROOTHDRDIR= $(ROOT)/usr/include 91 ROOTLIBDIR= $(ROOT)/usr/lib 92 ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64) 93 ROOTFS_LIBDIR= $(ROOT)/lib 94 ROOTFS_LIBDIR64= $(ROOT)/lib/$(MACH64) 95 ROOTLINTDIR= $(ROOTLIBDIR) 96 ROOTFS_LINTDIR= $(ROOTFS_LIBDIR) 97 ROOTFS_LINTDIR64= $(ROOTFS_LIBDIR64) 98 ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%) 99 HDRSRCS= $(HDRS:%=$(HDRDIR)/%) 100 CHECKHDRS= $(HDRSRCS:%.h=%.check) 101 ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%) 102 ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%) 103 ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%) 104 ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%) 105 ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS) 106 ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS) 107 ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS) 108 ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS) 109 ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC) 110 ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC) 111 ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC) 112 ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC) 113 ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%) 114 ROOTFS_LINT= $(LINTSRC:%=$(ROOTFS_LINTDIR)/%) 115 ROOTFS_LINT64= $(LINTSRC:%=$(ROOTFS_LINTDIR64)/%) 116 ROOTMAN3= $(ROOT)/usr/share/man/man3 117 ROOTMAN3FILES= $(MAN3FILES:%=$(ROOTMAN3)/%) 118 $(ROOTMAN3FILES) := FILEMODE= 444 119 120 # Demo rules 121 DEMOFILES= 122 DEMOFILESRCDIR= common 123 ROOTDEMODIRBASE= __nonexistent_directory__ 124 ROOTDEMODIRS= 125 ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%) 126 $(ROOTDEMODIRS) := DIRMODE = 755 127 128 LINTLIB= llib-l$(LIBNAME).ln 129 LINTFLAGS= -uaxm 130 LINTFLAGS64= -uaxm -m64 131 LINTSRC= $(LINTLIB:%.ln=%) 132 LINTOUT= lint.out 133 ARFLAGS= r 134 SONAME= $(DYNLIB) 135 # For most libraries, we should be able to resolve all symbols at link time, 136 # either within the library or as dependencies, all text should be pure, and 137 # combining relocations into one relocation table reduces startup costs. 138 # All options are tunable to allow overload/omission from lower makefiles. 139 140 # 141 # DTrace related rules 142 # 143 # These allow for multiple USDT providers to be specified by a library. 144 # If a library needs to break up the set of objects that are passed to 145 # the dtrace -G invocation, then they can place the following in heir 146 # Makefile.com: 147 # 148 # pics/<provider>.o := USDT_G_PICS = <files> 149 # 150 # <provider> should be replaced with the basename of one of the USDT 151 # providers specified in USDT_PROVIDERS in their Makefile.com. 152 # 153 USDT_HEADERS= $(USDT_PROVIDERS:%.d=%_impl.h) 154 USDT_PICS= $(USDT_PROVIDERS:%.d=pics/%.o) 155 USDT_G_PICS= $(PICS) 156 157 158 HSONAME= -h$(SONAME) 159 DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \ 160 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) 161 162 LDLIBS= $(LDLIBS.lib) 163 164 OBJS= $(OBJECTS:%=objs/%) 165 PICS= $(OBJECTS:%=pics/%) 166 167 # Declare that all library .o's can all be made in parallel. 168 # The DUMMY target is for those instances where OBJS and PICS 169 # are empty (to avoid an unconditional .PARALLEL declaration). 170 .PARALLEL: $(OBJS) $(PICS) DUMMY 171 172 # default value for "portable" source 173 SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c) 174 175 # default build of an archive and a shared object, 176 # overridden locally when extra processing is needed 177 BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS) 178 BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 179 $(PICS) $(EXTPICS) $(USDT_PICS) $(LDLIBS) 180 BUILD64.SO= $(CC64) $(CFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 181 $(PICS) $(EXTPICS) $(USDT_PICS) -L $(ROOTLIBDIR64) $(LDLIBS) 182 BUILDCCC.SO= $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 183 $(PICS) $(EXTPICS) $(LDLIBS) 184 BUILDCCC64.SO= $(CCC64) $(CCFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 185 $(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED64) 186 187 # default dynamic library symlink 188 INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 189 INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 190 191 # default 64-bit dynamic library symlink 192 INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 193 INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 194 195 # 196 # If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF 197 # processing. We'd like to just conditionally append to POST_PROCESS_O and 198 # POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to 199 # sometimes get appended more than once, which will cause ctfconvert to fail. 200 # So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always 201 # appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF 202 # processing should be done. 203 # 204 CTFCONVERT_POST = : 205 CTFMERGE_POST = : 206 POST_PROCESS_O += ; $(CTFCONVERT_POST) 207 POST_PROCESS_SO += ; $(CTFMERGE_POST) 208 209 CTFMERGE_LIB = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS) 210 211 # conditional assignments 212 213 $(OBJS) := sparc_CFLAGS += -xregs=no%appl 214 215 $(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS) 216 $(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS) 217 $(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS) 218 $(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS) 219 $(PICS) := CCFLAGS += $(CC_PICFLAGS) 220 $(PICS) := CPPFLAGS += -DPIC -D_REENTRANT 221 $(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS) 222 $(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS) 223 $(PICS) := CFLAGS += $(CTF_FLAGS) 224 $(PICS) := CFLAGS64 += $(CTF_FLAGS) 225 $(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O) 226 $(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB) 227 228 $(LINTLIB):= LOG = -DLOGGING 229 $(LIBRARY):= AROBJS = $(OBJS) 230 $(LIBRARY):= DIR = objs 231 $(DYNLIB):= DIR = pics 232 $(DYNLIBCCC):= DIR = pics 233 234 SONAMECCC= $(DYNLIBCCC) 235 HSONAMECCC= -h $(SONAMECCC) 236 # 237 # Keep in sync with the standard DYNFLAGS 238 # 239 $(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \ 240 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \ 241 $(BDIRECT) $(NORUNPATH) 242 243 244 # build rule for "portable" source 245 objs/%.o pics/%.o: %.c 246 $(COMPILE.c) -o $@ $< 247 $(POST_PROCESS_O) 248 249 objs/%.o pics/%.o: %.cc 250 $(COMPILE.cc) -o $@ $< 251 $(POST_PROCESS_O) 252 253 .PRECIOUS: $(LIBS) 254 255 # Define the majority text domain in this directory. 256 TEXT_DOMAIN= SUNW_OST_OSLIB 257 258 $(ROOTMAN3)/%: %.sunman 259 $(INS.rename) 260 261 # 262 # For library source code, we expect that some symbols may not be used or 263 # may *appear* to be able to rescoped to static; shut lint up. Never add 264 # a flag here unless you're *sure* that all libraries need to be linted 265 # with it. 266 # 267 LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2 268 LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2 269 270 # 271 # Target Architecture 272 # 273 TARGETMACH= $(MACH) 274 275 # 276 # Allow people to define their own clobber rules. Normal makefiles 277 # shouldn't override this - they should override $(CLOBBERFILES) instead. 278 # 279 CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)