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