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