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 
  22 #
  23 # Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  24 # Copyright 2016 RackTop Systems.
  25 #
  26 
  27 # Standard install rules
  28 # The VAR_SGSBIN and VAR_SGSBIN64 install rules included here are applicable
  29 # to Solaris 10 and earlier releases. For post Solaris 10 releases, the 
  30 # standard ROOTBIN and ROOTBIN64 rules defined in ../Makefile.cmd are used.
  31 # The new rules here are included to allow for easier backporting. Making
  32 # the appropriate updates in ./Makefile.var, will allow the SGS components
  33 # to be installed in /usr/ccs/bin rather than the current /usr/bin.
  34 #
  35 $(VAR_SGSBIN)/%: %
  36         $(INS.file)
  37 
  38 $(VAR_SGSBIN64)/%: %
  39         $(INS.file)
  40 
  41 ################################################################################
  42 #
  43 # Linting the Linker Libraries
  44 #
  45 #  Several of the linker's libraries are, in whole or in part, built in two
  46 #  passes, once as Elf32 and once as Elf64 (i.e. with -D_ELF64 defined).  Lint
  47 #  needs to be able to do both passes, but combining the two is problematic for
  48 #  the 2nd pass of lint, as it sees many interfaces as being defined both ways
  49 #  and considers them to be incompatible.  The targets defined here allow for
  50 #  both passes to live independently.  This means that both the lint.out, and
  51 #  the lint library itself get generated separately, to different output files.
  52 #  The lint.out's get combined into a single lint.out report, and the lint
  53 #  libraries get generated with a 32/64 suffix.  The dependents on these lint
  54 #  libraries, then, choose which version they need to use.  Substitutions can
  55 #  be made automatically if the macro's defined in ./Makefile.com are used to
  56 #  specify the dependency, for those libs that need them.
  57 #
  58 # Don't
  59 #
  60 #  Don't use the /*LINTLIBRARY*/ directive in linker libraries, this disables
  61 #  some important checks, including the ability to test format strings from the
  62 #  msg.h files.
  63 #
  64 #  Don't use the `-x' option to lint when linting linker libraries.  This masks
  65 #  all the dead wood in our own header files.  Instead, there has been added to
  66 #  the relevant common directories a file called `lintsup.c' which is used to
  67 #  mask out the headers that we aren't interested in.  This method is used for
  68 #  libraries, like libld, which have their own header files, but is irrelevant
  69 #  to libraries like libldstab which exports no interface of it's own.
  70 #
  71 #  The `lintsup.c' file can also be used, in some cases, to mask out other
  72 #  issues that lint won't otherwise shut up about.
  73 #
  74 # Other Lint Options
  75 #
  76 #  `-m' has been added to the LINTFLAGS.  Warnings about globals that could be
  77 #  static are irrelevant as we use mapfiles to scope down unnecessary globals.
  78 #
  79 #  `-u' is used in the LINTFLAGS for libraries, otherwise lint tends to be very
  80 #  noisy.
  81 #
  82 #  `-x' is avoided for libraries, but is used for executables because all we
  83 #  care about is that what we use is defined, not about declarations in public
  84 #  headers that we don't use.
  85 #
  86 # Relevant variables:
  87 #
  88 # */Makefile.com
  89 #       SRCS=           ../common/llib-l<libname>
  90 #       LINTSRCS=       <source files>
  91 #       LDLIBS=         ... [$(LDDBG_LIB) $(LD_LIB)]
  92 #       LINTFLAGS=      ...
  93 #       LINTFLAGS64=    ...
  94 #       CLEANFILES +=   ... $(LINTOUTS)
  95 #       CLOBBERFILES += ... $(LINTLIBS)
  96 #
  97 # Relevant targets:
  98 #
  99 # */Makefile.targ
 100 #       # this file for SGS lint targets.
 101 #       include         $(SRC)/cmd/sgs/Makefile.targ
 102 #
 103 #       lint:           <choose the desired functionality> $(SGSLINTOUT)
 104 #
 105 #               $(LINTLIB32),
 106 #               $(LINTLIB64)    Create an Elf32 or Elf64 lint library from
 107 #                               a proto file indicated by the $(SRCS) variable.
 108 #
 109 #               $(LINTOUT32),
 110 #               $(LINTOUT64)    Run lint on the sources indicated by the
 111 #                               $(LINTSRCS) variable with respect to Elf32
 112 #                               or Elf64.  Dependencies are gathered from
 113 #                               the $(LDLIBS) variable.
 114 #
 115 #               $(SGSLINTOUT)   Create a `lint.out' file as the concatination
 116 #                               of the lint output from the previous targets.
 117 #                               This should be specified *last* in the list.
 118 #
 119 ################################################################################
 120 
 121 #
 122 # Override the OS's $(LINTOUT) target to avoid confusion.
 123 #
 124 LINTOUT =       $(LINTOUT1)
 125 
 126 #
 127 # If LD_LIB, LDDBG_LIB, or CONV_LIB is added to LDLIBS, then the right lint
 128 # library should be picked up automatically.
 129 #
 130 $(LINTOUT32) := LD_LIB=$(LD_LIB32)
 131 $(LINTOUT32) := LDDBG_LIB=$(LDDBG_LIB32)
 132 $(LINTOUT32) := CONV_LIB=$(CONV_LIB32)
 133 
 134 $(LINTOUT64) := LD_LIB=$(LD_LIB64)
 135 $(LINTOUT64) := LDDBG_LIB=$(LDDBG_LIB64)
 136 $(LINTOUT64) := CONV_LIB=$(CONV_LIB64)
 137 
 138 #
 139 # Force $(LINTLIB) in order to help the $(SGSLINTOUT)
 140 # target produce the same output on successive runs.
 141 #
 142 $(LINTLIB):     FRC
 143 
 144 $(LINTLIB32):   $(SRCS)
 145         $(LINT.c) -o $(LIBNAME32) $(SRCS)
 146 
 147 $(LINTLIB64):   $(SRCS)
 148         $(LINT.c) -D_ELF64 -o $(LIBNAME64) $(SRCS)
 149 
 150 $(LINTOUT32):   $(LINTSRCS) $(LINTSRCS32)
 151         $(LINT.c) $(LINTSRCS) $(LINTSRCS32) $(LDLIBS) > $(LINTOUT32) 2>&1
 152 
 153 $(LINTOUT64):   $(LINTSRCS) $(LINTSRCS64)
 154         $(LINT.c) -D_ELF64 $(LINTSRCS) $(LINTSRCS64) \
 155             $(LDLIBS) > $(LINTOUT64) 2>&1
 156 
 157 #
 158 # A couple of macros used in the SGSLINTOUT rule below
 159 #
 160 #       LINT_HDR - Use sgs/tools/lint_hdr.pl to generate lint output headers
 161 #       LINT_TEE - Use tee to write output to stdout and also capture it
 162 #               in the SGSLINT output file.
 163 #
 164 # An additional complexity: We produce headers for all the lint
 165 # output so that we can tell what came from where when we look
 166 # at the resulting file. We also cat these headers to stdout so that
 167 # the user of make will see them. However, we don't want the headers
 168 # to go to stdout if there is only one of LINTOUT32 and LINTOUT64. To
 169 # the interactive user, the headers are only interesting as a way to
 170 # separate the two ELF classes. We only bother with this for the
 171 # non-DYNLIB and non-RTLD case, because at the current time, both of these
 172 # cases always have both 32 and 64-bit ELFCLASS support.
 173 #
 174 LINT_HDR=       perl $(SGSTOOLS)/lint_hdr.pl
 175 LINT_TEE=       tee -a $(SGSLINTOUT)
 176 
 177 $(SGSLINTOUT): FRC
 178         @ rm -f $(SGSLINTOUT)
 179         @ if [ -r $(LINTOUT1) ]; then                   \
 180                 $(LINT_HDR) $(LINTLIB) | $(LINT_TEE);   \
 181                 cat $(LINTOUT1) | $(LINT_TEE);  \
 182         fi
 183         @ if [ -r $(LINTOUT32) ]; then                  \
 184                 if [ -n "$(DYNLIB)" ] ; then            \
 185                         $(LINT_HDR) $(DYNLIB) 32 | $(LINT_TEE); \
 186                 elif [ -n "$(RTLD)" ] ; then            \
 187                         $(LINT_HDR) $(RTLD) 32 | $(LINT_TEE); \
 188                 else \
 189                         if [ -r $(LINTOUT64) ]; then \
 190                                 $(LINT_HDR) $(PROG) 32 | $(LINT_TEE);   \
 191                         else \
 192                                 $(LINT_HDR) $(PROG) 32 >> $(SGSLINTOUT); \
 193                         fi; \
 194                 fi; \
 195                 cat $(LINTOUT32) | $(LINT_TEE); \
 196         fi
 197         @ if [ -r $(LINTOUT64) ]; then                  \
 198                 if [ -n "$(DYNLIB)" ] ; then            \
 199                         if [ $(DYNLIB) = "libld.so.2" ] ; then \
 200                                 $(LINT_HDR) libld.so.3 64 | $(LINT_TEE); \
 201                         else \
 202                                 $(LINT_HDR) $(DYNLIB) 64 | $(LINT_TEE); \
 203                         fi; \
 204                 elif [ -n "$(RTLD)" ] ; then            \
 205                         $(LINT_HDR) $(RTLD) 64 | $(LINT_TEE); \
 206                 else \
 207                         if [ -r $(LINTOUT32) ]; then \
 208                                 $(LINT_HDR) $(PROG) 64 | $(LINT_TEE); \
 209                         else \
 210                                 $(LINT_HDR) $(PROG) 64 >> $(SGSLINTOUT); \
 211                         fi; \
 212                 fi; \
 213                 cat $(LINTOUT64) | $(LINT_TEE); \
 214         fi
 215         @ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64)
 216 
 217 #
 218 # For those that install the lint library source file.
 219 #
 220 $(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
 221         $(INS.file) ../common/$(LINTLIBSRC)
 222 
 223 $(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
 224         $(INS.liblink)
 225 
 226 $(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
 227         $(INS.liblink64)
 228 
 229 $(ROOTFS_LIBDIR)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS)
 230         $(INS.liblinkccc)
 231 
 232 $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS)
 233         $(INS.liblinkccc64)
 234 
 235 #
 236 # For those that install into the SGSPROTO directory.
 237 #
 238 $(SGSPROTO):
 239         $(INS.dir)
 240 
 241 $(SGSBINDIR): $(SGSPROTO)
 242         $(INS.dir)
 243 
 244 $(SGSPREFIX): $(SGSPROTO)
 245         $(INS.dir)
 246 
 247 $(SGSLIBDIR): $(SGSPREFIX)
 248         $(INS.dir)
 249 
 250 FRC: