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