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.
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.
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]
23 # Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright 2016 RackTop Systems.
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.
41 ################################################################################
43 # Linting the Linker Libraries
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.
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
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.
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.
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.
79 # `-u' is used in the LINTFLAGS for libraries, otherwise lint tends to be very
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.
89 # SRCS= ../common/llib-l<libname>
90 # LINTSRCS= <source files>
91 # LDLIBS= ... [$(LDDBG_LIB) $(LD_LIB)]
94 # CLEANFILES += ... $(LINTOUTS)
95 # CLOBBERFILES += ... $(LINTLIBS)
100 # # this file for SGS lint targets.
101 # include $(SRC)/cmd/sgs/Makefile.targ
103 # lint: <choose the desired functionality> $(SGSLINTOUT)
106 # $(LINTLIB64) Create an Elf32 or Elf64 lint library from
107 # a proto file indicated by the $(SRCS) variable.
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.
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.
119 ################################################################################
122 # Override the OS's $(LINTOUT) target to avoid confusion.
124 LINTOUT = $(LINTOUT1)
127 # If LD_LIB, LDDBG_LIB, or CONV_LIB is added to LDLIBS, then the right lint
128 # library should be picked up automatically.
130 $(LINTOUT32) := LD_LIB=$(LD_LIB32)
131 $(LINTOUT32) := LDDBG_LIB=$(LDDBG_LIB32)
132 $(LINTOUT32) := CONV_LIB=$(CONV_LIB32)
134 $(LINTOUT64) := LD_LIB=$(LD_LIB64)
135 $(LINTOUT64) := LDDBG_LIB=$(LDDBG_LIB64)
136 $(LINTOUT64) := CONV_LIB=$(CONV_LIB64)
139 # Force $(LINTLIB) in order to help the $(SGSLINTOUT)
140 # target produce the same output on successive runs.
144 $(LINTLIB32): $(SRCS)
145 $(LINT.c) -o $(LIBNAME32) $(SRCS)
147 $(LINTLIB64): $(SRCS)
148 $(LINT.c) -D_ELF64 -o $(LIBNAME64) $(SRCS)
150 $(LINTOUT32): $(LINTSRCS) $(LINTSRCS32)
151 $(LINT.c) $(LINTSRCS) $(LINTSRCS32) $(LDLIBS) > $(LINTOUT32) 2>&1
153 $(LINTOUT64): $(LINTSRCS) $(LINTSRCS64)
154 $(LINT.c) -D_ELF64 $(LINTSRCS) $(LINTSRCS64) \
155 $(LDLIBS) > $(LINTOUT64) 2>&1
158 # A couple of macros used in the SGSLINTOUT rule below
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.
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.
174 LINT_HDR= perl $(SGSTOOLS)/lint_hdr.pl
175 LINT_TEE= tee -a $(SGSLINTOUT)
178 @ rm -f $(SGSLINTOUT)
179 @ if [ -r $(LINTOUT1) ]; then \
180 $(LINT_HDR) $(LINTLIB) | $(LINT_TEE); \
181 cat $(LINTOUT1) | $(LINT_TEE); \
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); \
189 if [ -r $(LINTOUT64) ]; then \
190 $(LINT_HDR) $(PROG) 32 | $(LINT_TEE); \
192 $(LINT_HDR) $(PROG) 32 >> $(SGSLINTOUT); \
195 cat $(LINTOUT32) | $(LINT_TEE); \
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); \
202 $(LINT_HDR) $(DYNLIB) 64 | $(LINT_TEE); \
204 elif [ -n "$(RTLD)" ] ; then \
205 $(LINT_HDR) $(RTLD) 64 | $(LINT_TEE); \
207 if [ -r $(LINTOUT32) ]; then \
208 $(LINT_HDR) $(PROG) 64 | $(LINT_TEE); \
210 $(LINT_HDR) $(PROG) 64 >> $(SGSLINTOUT); \
213 cat $(LINTOUT64) | $(LINT_TEE); \
215 @ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64)
218 # For those that install the lint library source file.
220 $(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
221 $(INS.file) ../common/$(LINTLIBSRC)
223 $(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
226 $(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
229 $(ROOTFS_LIBDIR)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS)
232 $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS)
236 # For those that install into the SGSPROTO directory.
241 $(SGSBINDIR): $(SGSPROTO)
244 $(SGSPREFIX): $(SGSPROTO)
247 $(SGSLIBDIR): $(SGSPREFIX)