stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 1 | # |
| 2 | # CDDL HEADER START |
| 3 | # |
| 4 | # The contents of this file are subject to the terms of the |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 5 | # Common Development and Distribution License (the "License"). |
| 6 | # You may not use this file except in compliance with the License. |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 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 | # |
Gary Mills | ee63735 | 2015-04-25 14:44:01 -0500 | [diff] [blame] | 21 | # Copyright 2015 Gary Mills |
Igor Kozhukhov | 7b07063 | 2015-10-24 19:18:16 +0300 | [diff] [blame] | 22 | # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> |
jmcp | b83ec4e | 2010-04-21 22:25:54 -0700 | [diff] [blame] | 23 | # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 24 | # |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 25 | # |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 26 | # Definitions common to libraries. |
| 27 | # |
| 28 | # include global definitions; SRC should be defined in the shell. |
| 29 | # SRC is needed until RFE 1026993 is implemented. |
| 30 | |
| 31 | include $(SRC)/Makefile.master |
| 32 | |
| 33 | LORDER= lorder |
| 34 | TSORT= tsort |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 35 | |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 36 | # |
| 37 | # By default, we define the source directory for libraries to be |
| 38 | # one level up from the ISA-specific directory, where the code is |
| 39 | # actually built. Many libraries define a 'common' directory to |
| 40 | # contain the source. These libraries must redefine SRCDIR as: |
| 41 | # SRCDIR = ../common |
| 42 | # Other variations are possible (../port, ../src, etc). |
| 43 | # |
| 44 | SRCDIR = .. |
| 45 | |
| 46 | # |
Rod Evans | 2a8d6eb | 2009-05-07 16:01:18 -0700 | [diff] [blame] | 47 | # We define MAPFILES here for the benefit of most libraries, those that |
| 48 | # follow the convention of having source files and other common files |
| 49 | # in the $(SRCDIR) directory. Libraries that do not follow this |
| 50 | # convention must define MAPFILES, or MAPFILEDIR for themselves. |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 51 | # Libraries that do follow this convention but that need supplemental |
| 52 | # ISA-specific mapfiles can augment MAPFILES like this: |
| 53 | # MAPFILES += mapfile-vers |
| 54 | # |
Rod Evans | 2a8d6eb | 2009-05-07 16:01:18 -0700 | [diff] [blame] | 55 | MAPFILEDIR = $(SRCDIR) |
| 56 | MAPFILES = $(MAPFILEDIR)/mapfile-vers |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 57 | |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 58 | # |
| 59 | # If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/% |
| 60 | # install rule in lib/Makefile.targ to generate false matches if there |
| 61 | # are any common directory names between / and /usr/include (`xfn' is |
| 62 | # one common example). To prevent this, we set HDRDIR to a directory |
| 63 | # name that will almost surely not exist on the build machine. |
| 64 | # |
| 65 | HDRDIR= /__nonexistent_directory__ |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 66 | |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 67 | # |
| 68 | # We don't build archive (*.a) libraries by default anymore. |
| 69 | # If a component of the build needs to build an archive library |
| 70 | # for its own internal purposes, it can define LIBS for itself |
| 71 | # after including Makefile.lib, like this: |
| 72 | # LIBS = $(LIBRARY) |
| 73 | # or: |
| 74 | # LIBS = $(LIBRARYCCC) |
| 75 | # Archive libraries must not be installed in the proto area. |
| 76 | # |
| 77 | LIBS= |
| 78 | MACHLIBS= $(LIBS:%=$(MACH)/%) |
| 79 | MACHLIBS64= $(LIBS:%=$(MACH64)/%) |
| 80 | DYNLIB= $(LIBRARY:.a=.so$(VERS)) |
| 81 | DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS)) |
| 82 | DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS)) |
| 83 | LIBLINKS= $(LIBRARY:.a=.so) |
| 84 | LIBLINKSCCC= $(LIBRARYCCC:.a=.so) |
| 85 | LIBNAME= $(LIBRARY:lib%.a=%) |
| 86 | LIBLINKPATH= |
| 87 | LIBNULL= null.a |
| 88 | ROOTHDRDIR= $(ROOT)/usr/include |
| 89 | ROOTLIBDIR= $(ROOT)/usr/lib |
| 90 | ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64) |
| 91 | ROOTFS_LIBDIR= $(ROOT)/lib |
| 92 | ROOTFS_LIBDIR64= $(ROOT)/lib/$(MACH64) |
| 93 | ROOTLINTDIR= $(ROOTLIBDIR) |
| 94 | ROOTFS_LINTDIR= $(ROOTFS_LIBDIR) |
| 95 | ROOTFS_LINTDIR64= $(ROOTFS_LIBDIR64) |
| 96 | ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%) |
| 97 | HDRSRCS= $(HDRS:%=$(HDRDIR)/%) |
| 98 | CHECKHDRS= $(HDRSRCS:%.h=%.check) |
| 99 | ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%) |
| 100 | ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%) |
| 101 | ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%) |
| 102 | ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%) |
| 103 | ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS) |
| 104 | ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS) |
| 105 | ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS) |
| 106 | ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS) |
| 107 | ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC) |
| 108 | ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC) |
| 109 | ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC) |
| 110 | ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC) |
| 111 | ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%) |
| 112 | ROOTFS_LINT= $(LINTSRC:%=$(ROOTFS_LINTDIR)/%) |
| 113 | ROOTFS_LINT64= $(LINTSRC:%=$(ROOTFS_LINTDIR64)/%) |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 114 | |
chin | da2e3eb | 2007-08-17 12:01:52 -0700 | [diff] [blame] | 115 | # Demo rules |
| 116 | DEMOFILES= |
| 117 | DEMOFILESRCDIR= common |
| 118 | ROOTDEMODIRBASE= __nonexistent_directory__ |
| 119 | ROOTDEMODIRS= |
| 120 | ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%) |
chin | da2e3eb | 2007-08-17 12:01:52 -0700 | [diff] [blame] | 121 | $(ROOTDEMODIRS) := DIRMODE = 755 |
| 122 | |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 123 | LINTLIB= llib-l$(LIBNAME).ln |
| 124 | LINTFLAGS= -uaxm |
Nick Todd | 0bb0739 | 2008-09-25 00:47:48 +0100 | [diff] [blame] | 125 | LINTFLAGS64= -uaxm -m64 |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 126 | LINTSRC= $(LINTLIB:%.ln=%) |
| 127 | LINTOUT= lint.out |
| 128 | ARFLAGS= r |
| 129 | SONAME= $(DYNLIB) |
| 130 | # For most libraries, we should be able to resolve all symbols at link time, |
| 131 | # either within the library or as dependencies, all text should be pure, and |
| 132 | # combining relocations into one relocation table reduces startup costs. |
| 133 | # All options are tunable to allow overload/omission from lower makefiles. |
| 134 | |
| 135 | |
| 136 | HSONAME= -h$(SONAME) |
rie | 67e3a03 | 2008-05-02 15:01:06 -0700 | [diff] [blame] | 137 | DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \ |
rie | 24da5b3 | 2007-05-17 16:27:31 -0700 | [diff] [blame] | 138 | $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 139 | |
| 140 | LDLIBS= $(LDLIBS.lib) |
| 141 | |
| 142 | OBJS= $(OBJECTS:%=objs/%) |
| 143 | PICS= $(OBJECTS:%=pics/%) |
| 144 | |
| 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 |
| 149 | |
| 150 | # default value for "portable" source |
| 151 | SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c) |
| 152 | |
| 153 | # default build of an archive and a shared object, |
| 154 | # overridden locally when extra processing is needed |
| 155 | BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS) |
Gary Mills | ee63735 | 2015-04-25 14:44:01 -0500 | [diff] [blame] | 156 | BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ |
| 157 | $(PICS) $(EXTPICS) $(LDLIBS) |
| 158 | BUILDCCC.SO= $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ |
| 159 | $(PICS) $(EXTPICS) $(LDLIBS) |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 160 | |
| 161 | # default dynamic library symlink |
| 162 | INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ |
| 163 | INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ |
| 164 | |
| 165 | # default 64-bit dynamic library symlink |
| 166 | INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ |
| 167 | INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ |
| 168 | |
| 169 | # |
| 170 | # If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF |
| 171 | # processing. We'd like to just conditionally append to POST_PROCESS_O and |
| 172 | # POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to |
| 173 | # sometimes get appended more than once, which will cause ctfconvert to fail. |
| 174 | # So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always |
| 175 | # appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF |
| 176 | # processing should be done. |
| 177 | # |
| 178 | CTFCONVERT_POST = : |
| 179 | CTFMERGE_POST = : |
| 180 | POST_PROCESS_O += ; $(CTFCONVERT_POST) |
| 181 | POST_PROCESS_SO += ; $(CTFMERGE_POST) |
| 182 | |
Richard Lowe | d69cdb3 | 2013-06-23 17:17:05 -0400 | [diff] [blame] | 183 | CTFMERGE_LIB = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS) |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 184 | |
| 185 | # conditional assignments |
| 186 | |
| 187 | $(OBJS) := sparc_CFLAGS += -xregs=no%appl |
| 188 | |
| 189 | $(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS) |
| 190 | $(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS) |
| 191 | $(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS) |
| 192 | $(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS) |
| 193 | $(PICS) := CCFLAGS += $(CC_PICFLAGS) |
| 194 | $(PICS) := CPPFLAGS += -DPIC -D_REENTRANT |
| 195 | $(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS) |
| 196 | $(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS) |
| 197 | $(PICS) := CFLAGS += $(CTF_FLAGS) |
| 198 | $(PICS) := CFLAGS64 += $(CTF_FLAGS) |
| 199 | $(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O) |
| 200 | $(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB) |
| 201 | |
| 202 | $(LINTLIB):= LOG = -DLOGGING |
| 203 | $(LIBRARY):= AROBJS = $(OBJS) |
| 204 | $(LIBRARY):= DIR = objs |
| 205 | $(DYNLIB):= DIR = pics |
| 206 | $(DYNLIBCCC):= DIR = pics |
| 207 | |
| 208 | SONAMECCC= $(DYNLIBCCC) |
| 209 | HSONAMECCC= -h $(SONAMECCC) |
| 210 | # |
| 211 | # Keep in sync with the standard DYNFLAGS |
| 212 | # |
rie | 67e3a03 | 2008-05-02 15:01:06 -0700 | [diff] [blame] | 213 | $(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \ |
rie | 24da5b3 | 2007-05-17 16:27:31 -0700 | [diff] [blame] | 214 | $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \ |
rie | f6acbf7 | 2008-01-24 16:39:56 -0800 | [diff] [blame] | 215 | $(BDIRECT) $(NORUNPATH) |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 216 | |
| 217 | |
| 218 | # build rule for "portable" source |
| 219 | objs/%.o pics/%.o: %.c |
| 220 | $(COMPILE.c) -o $@ $< |
| 221 | $(POST_PROCESS_O) |
| 222 | |
| 223 | objs/%.o pics/%.o: %.cc |
| 224 | $(COMPILE.cc) -o $@ $< |
| 225 | $(POST_PROCESS_O) |
| 226 | |
| 227 | .PRECIOUS: $(LIBS) |
| 228 | |
| 229 | # Define the majority text domain in this directory. |
| 230 | TEXT_DOMAIN= SUNW_OST_OSLIB |
| 231 | |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 232 | # |
| 233 | # For library source code, we expect that some symbols may not be used or |
| 234 | # may *appear* to be able to rescoped to static; shut lint up. Never add |
| 235 | # a flag here unless you're *sure* that all libraries need to be linted |
| 236 | # with it. |
| 237 | # |
| 238 | LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2 |
| 239 | LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2 |
| 240 | |
| 241 | # |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 242 | # Target Architecture |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 243 | # |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 244 | TARGETMACH= $(MACH) |
stevel@tonic-gate | 7c478bd | 2005-06-14 00:00:00 -0700 | [diff] [blame] | 245 | |
| 246 | # |
| 247 | # Allow people to define their own clobber rules. Normal makefiles |
| 248 | # shouldn't override this - they should override $(CLOBBERFILES) instead. |
| 249 | # |
raf | f808c85 | 2006-08-08 23:21:36 -0700 | [diff] [blame] | 250 | CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES) |