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