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 2016 RackTop Systems. 25 # 26 # 27 # Definitions common to libraries. 28 # 29 # include global definitions; SRC should be defined in the shell. 30 # SRC is needed until RFE 1026993 is implemented. 31 32 include $(SRC)/Makefile.master 33 34 LORDER= lorder 35 TSORT= tsort 36 37 # 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: 42 # SRCDIR = ../common 43 # Other variations are possible (../port, ../src, etc). 44 # 45 SRCDIR = .. 46 47 # 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 55 # 56 MAPFILEDIR = $(SRCDIR) 57 MAPFILES = $(MAPFILEDIR)/mapfile-vers 58 59 # 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. 65 # 66 HDRDIR= /__nonexistent_directory__ 67 68 # 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: 73 # LIBS = $(LIBRARY) 74 # or: 75 # LIBS = $(LIBRARYCCC) 76 # Archive libraries must not be installed in the proto area. 77 # 78 LIBS= 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=%) 87 LIBLINKPATH= 88 LIBNULL= null.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 ROOTLINTDIR= $(ROOTLIBDIR) 95 ROOTFS_LINTDIR= $(ROOTFS_LIBDIR) 96 ROOTFS_LINTDIR64= $(ROOTFS_LIBDIR64) 97 ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%) 98 HDRSRCS= $(HDRS:%=$(HDRDIR)/%) 99 CHECKHDRS= $(HDRSRCS:%.h=%.check) 100 ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%) 101 ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%) 102 ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%) 103 ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%) 104 ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS) 105 ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS) 106 ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS) 107 ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS) 108 ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC) 109 ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC) 110 ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC) 111 ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC) 112 ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%) 113 ROOTFS_LINT= $(LINTSRC:%=$(ROOTFS_LINTDIR)/%) 114 ROOTFS_LINT64= $(LINTSRC:%=$(ROOTFS_LINTDIR64)/%) 115 ROOTMAN3= $(ROOT)/usr/share/man/man3 116 ROOTMAN3FILES= $(MAN3FILES:%=$(ROOTMAN3)/%) 117 $(ROOTMAN3FILES) := FILEMODE= 444 118 119 # Demo rules 120 DEMOFILES= 121 DEMOFILESRCDIR= common 122 ROOTDEMODIRBASE= __nonexistent_directory__ 123 ROOTDEMODIRS= 124 ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%) 125 $(ROOTDEMODIRS) := DIRMODE = 755 126 127 LINTLIB= llib-l$(LIBNAME).ln 128 LINTFLAGS= -uaxm 129 LINTFLAGS64= -uaxm -m64 130 LINTSRC= $(LINTLIB:%.ln=%) 131 LINTOUT= lint.out 132 ARFLAGS= r 133 SONAME= $(DYNLIB) 134 # For most libraries, we should be able to resolve all symbols at link time, 135 # either within the library or as dependencies, all text should be pure, and 136 # combining relocations into one relocation table reduces startup costs. 137 # All options are tunable to allow overload/omission from lower makefiles. 138 139 140 HSONAME= -h$(SONAME) 141 DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \ 142 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) 143 144 LDLIBS= $(LDLIBS.lib) 145 146 OBJS= $(OBJECTS:%=objs/%) 147 PICS= $(OBJECTS:%=pics/%) 148 149 # Declare that all library .o's can all be made in parallel. 150 # The DUMMY target is for those instances where OBJS and PICS 151 # are empty (to avoid an unconditional .PARALLEL declaration). 152 .PARALLEL: $(OBJS) $(PICS) DUMMY 153 154 # default value for "portable" source 155 SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c) 156 157 # default build of an archive and a shared object, 158 # overridden locally when extra processing is needed 159 BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS) 160 BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 161 $(PICS) $(EXTPICS) $(LDLIBS) 162 BUILD64.SO= $(CC64) $(CFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 163 $(PICS) $(EXTPICS) -L $(ROOTLIBDIR64) $(LDLIBS) 164 BUILDCCC.SO= $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 165 $(PICS) $(EXTPICS) $(LDLIBS) 166 BUILDCCC64.SO= $(CCC64) $(CCFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 167 $(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED64) 168 169 # default dynamic library symlink 170 INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 171 INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 172 173 # default 64-bit dynamic library symlink 174 INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 175 INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 176 177 # 178 # If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF 179 # processing. We'd like to just conditionally append to POST_PROCESS_O and 180 # POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to 181 # sometimes get appended more than once, which will cause ctfconvert to fail. 182 # So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always 183 # appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF 184 # processing should be done. 185 # 186 CTFCONVERT_POST = : 187 CTFMERGE_POST = : 188 POST_PROCESS_O += ; $(CTFCONVERT_POST) 189 POST_PROCESS_SO += ; $(CTFMERGE_POST) 190 191 CTFMERGE_LIB = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS) 192 193 # conditional assignments 194 195 $(OBJS) := sparc_CFLAGS += -xregs=no%appl 196 197 $(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS) 198 $(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS) 199 $(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS) 200 $(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS) 201 $(PICS) := CCFLAGS += $(CC_PICFLAGS) 202 $(PICS) := CPPFLAGS += -DPIC -D_REENTRANT 203 $(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS) 204 $(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS) 205 $(PICS) := CFLAGS += $(CTF_FLAGS) 206 $(PICS) := CFLAGS64 += $(CTF_FLAGS) 207 $(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O) 208 $(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB) 209 210 $(LINTLIB):= LOG = -DLOGGING 211 $(LIBRARY):= AROBJS = $(OBJS) 212 $(LIBRARY):= DIR = objs 213 $(DYNLIB):= DIR = pics 214 $(DYNLIBCCC):= DIR = pics 215 216 SONAMECCC= $(DYNLIBCCC) 217 HSONAMECCC= -h $(SONAMECCC) 218 # 219 # Keep in sync with the standard DYNFLAGS 220 # 221 $(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \ 222 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \ 223 $(BDIRECT) $(NORUNPATH) 224 225 226 # build rule for "portable" source 227 objs/%.o pics/%.o: %.c 228 $(COMPILE.c) -o $@ $< 229 $(POST_PROCESS_O) 230 231 objs/%.o pics/%.o: %.cc 232 $(COMPILE.cc) -o $@ $< 233 $(POST_PROCESS_O) 234 235 .PRECIOUS: $(LIBS) 236 237 # Define the majority text domain in this directory. 238 TEXT_DOMAIN= SUNW_OST_OSLIB 239 240 $(ROOTMAN3)/%: %.sunman 241 $(INS.rename) 242 243 # 244 # For library source code, we expect that some symbols may not be used or 245 # may *appear* to be able to rescoped to static; shut lint up. Never add 246 # a flag here unless you're *sure* that all libraries need to be linted 247 # with it. 248 # 249 LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2 250 LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2 251 252 # 253 # Target Architecture 254 # 255 TARGETMACH= $(MACH) 256 257 # 258 # Allow people to define their own clobber rules. Normal makefiles 259 # shouldn't override this - they should override $(CLOBBERFILES) instead. 260 # 261 CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)