xref: /titanic_44/usr/src/cmd/sgs/Makefile.targ (revision ee5416c9d7e449233197d5d20bc6b81e4ff091b2)
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 2007 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$(SGSLINTOUT): FRC
160	@ rm -f $(SGSLINTOUT)
161	@ if [ -r $(LINTOUT1) ]; then			\
162		echo "\n"$(LINTLIB) >> $(SGSLINTOUT);	\
163		echo $(DASHES) >> $(SGSLINTOUT);	\
164		cat $(LINTOUT1) >> $(SGSLINTOUT);	\
165	fi
166	@ if [ -r $(LINTOUT32) ]; then			\
167		if [ -n "$(DYNLIB)" ] ; then		\
168			echo "\nElf32 - $(DYNLIB)" >> $(SGSLINTOUT);	\
169		elif [ -n "$(RTLD)" ] ; then		\
170			echo "\nElf32 - $(RTLD)" >> $(SGSLINTOUT);	\
171		else echo "\nElf32 - $(PROG)" >> $(SGSLINTOUT);	\
172		fi; \
173		echo $(DASHES) >> $(SGSLINTOUT);	\
174		cat $(LINTOUT32) >> $(SGSLINTOUT);	\
175	fi
176	@ if [ -r $(LINTOUT64) ]; then			\
177		if [ -n "$(DYNLIB)" ] ; then		\
178			if [ $(DYNLIB) = "libld.so.2" ] ; then \
179				echo "\nElf64 - libld.so.3" >> $(SGSLINTOUT);	\
180			else \
181				echo "\nElf64 - $(DYNLIB)" >> $(SGSLINTOUT);	\
182			fi; \
183		elif [ -n "$(RTLD)" ] ; then		\
184			echo "\nElf64 - $(RTLD)" >> $(SGSLINTOUT);	\
185		else echo "\nElf64 - $(PROG)" >> $(SGSLINTOUT);	\
186		fi; \
187		echo $(DASHES) >> $(SGSLINTOUT);	\
188		cat $(LINTOUT64) >> $(SGSLINTOUT);	\
189	fi
190	@ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64)
191
192#
193# For those that install the lint library source file.
194#
195$(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
196	$(INS.file) ../common/$(LINTLIBSRC)
197
198$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKS): \
199	$(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
200$(VAR_POUND_1)	$(INS.liblink)
201
202$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKS): \
203	$(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
204$(VAR_POUND_1)	$(INS.liblink64)
205
206$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): \
207	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS)
208$(VAR_POUND_1)	$(INS.liblinkccc)
209
210$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): \
211	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS)
212$(VAR_POUND_1)	$(INS.liblinkccc64)
213
214FRC:
215