Makefile.targ revision 4538:844098db2e81
118334Speter#
272562Sobrien# CDDL HEADER START
3169689Skan#
4169689Skan# The contents of this file are subject to the terms of the
518334Speter# Common Development and Distribution License (the "License").
690075Sobrien# You may not use this file except in compliance with the License.
718334Speter#
890075Sobrien# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
990075Sobrien# or http://www.opensolaris.org/os/licensing.
1090075Sobrien# See the License for the specific language governing permissions
1190075Sobrien# and limitations under the License.
1218334Speter#
1390075Sobrien# When distributing Covered Code, include this CDDL HEADER in each
1490075Sobrien# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1590075Sobrien# If applicable, add the following below this CDDL HEADER, with the
1690075Sobrien# fields enclosed by brackets "[]" replaced with your own identifying
1718334Speter# information: Portions Copyright [yyyy] [name of copyright owner]
1818334Speter#
1990075Sobrien# CDDL HEADER END
20169689Skan#
21169689Skan
2218334Speter#
2318334Speter# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
2450397Sobrien# Use is subject to license terms.
25132718Skan#
26132718Skan# ident	"%Z%%M%	%I%	%E% SMI"
2718334Speter#
28117395Skan
2918334Speter# Standard install rules
3018334Speter# The VAR_SGSBIN and VAR_SGSBIN64 install rules included here are applicable
3118334Speter# to Solaris 10 and earlier releases. For post Solaris 10 releases, the 
3218334Speter# standard ROOTBIN and ROOTBIN64 rules defined in ../Makefile.cmd are used.
3350397Sobrien# The new rules here are included to allow for easier backporting. Making
3450397Sobrien# the appropriate updates in ./Makefile.var, will allow the SGS components
3518334Speter# to be installed in /usr/ccs/bin rather than the current /usr/bin.
3650397Sobrien#
3790075Sobrien$(VAR_SGSBIN)/%: %
3890075Sobrien	$(INS.file)
3918334Speter
4090075Sobrien$(VAR_SGSBIN64)/%: %
4190075Sobrien	$(INS.file)
4218334Speter
4390075Sobrien################################################################################
4418334Speter#
4518334Speter# Linting the Linker Libraries
4650397Sobrien#
4790075Sobrien#  Several of the linker's libraries are, in whole or in part, built in two
4890075Sobrien#  passes, once as Elf32 and once as Elf64 (i.e. with -D_ELF64 defined).  Lint
4990075Sobrien#  needs to be able to do both passes, but combining the two is problematic for
5090075Sobrien#  the 2nd pass of lint, as it sees many interfaces as being defined both ways
51169689Skan#  and considers them to be incompatible.  The targets defined here allow for
52169689Skan#  both passes to live independently.  This means that both the lint.out, and
53169689Skan#  the lint library itself get generated separately, to different output files.
54132718Skan#  The lint.out's get combined into a single lint.out report, and the lint
55169689Skan#  libraries get generated with a 32/64 suffix.  The dependents on these lint
5618334Speter#  libraries, then, choose which version they need to use.  Substitutions can
5718334Speter#  be made automatically if the macro's defined in ./Makefile.com are used to
5818334Speter#  specify the dependency, for those libs that need them.
5918334Speter#
6018334Speter# Don't
6118334Speter#
6218334Speter#  Don't use the /*LINTLIBRARY*/ directive in linker libraries, this disables
6318334Speter#  some important checks, including the ability to test format strings from the
6418334Speter#  msg.h files.
65107590Sobrien#
6618334Speter#  Don't use the `-x' option to lint when linting linker libraries.  This masks
6790075Sobrien#  all the dead wood in our own header files.  Instead, there has been added to
6818334Speter#  the relevant common directories a file called `lintsup.c' which is used to
69107590Sobrien#  mask out the headers that we aren't interested in.  This method is used for
7018334Speter#  libraries, like libld, which have their own header files, but is irrelevant
7118334Speter#  to libraries like libldstab which exports no interface of it's own.
7218334Speter#
7318334Speter#  The `lintsup.c' file can also be used, in some cases, to mask out other
7418334Speter#  issues that lint won't otherwise shut up about.
7518334Speter#
7618334Speter# Other Lint Options
7718334Speter#
7818334Speter#  `-m' has been added to the LINTFLAGS.  Warnings about globals that could be
7918334Speter#  static are irrelevant as we use mapfiles to scope down unnecessary globals.
8018334Speter#
8150397Sobrien#  `-u' is used in the LINTFLAGS for libraries, otherwise lint tends to be very
8218334Speter#  noisy.
8318334Speter#
8418334Speter#  `-x' is avoided for libraries, but is used for executables because all we
8518334Speter#  care about is that what we use is defined, not about declarations in public
8618334Speter#  headers that we don't use.
8718334Speter#
8818334Speter# Relevant variables:
8918334Speter#
9018334Speter# */Makefile.com
9118334Speter#	SRCS=		../common/llib-l<libname>
9218334Speter#	LINTSRCS=	<source files>
9318334Speter#	LDLIBS=		... [$(LDDBG_LIB) $(LD_LIB)]
9418334Speter#	LINTFLAGS=	...
9518334Speter#	LINTFLAGS64=	...
9618334Speter#	CLEANFILES +=	... $(LINTOUTS)
9718334Speter#	CLOBBERFILES +=	... $(LINTLIBS)
9818334Speter#
9918334Speter# Relevant targets:
10018334Speter#
10118334Speter# */Makefile.targ
10290075Sobrien#	# this file for SGS lint targets.
10390075Sobrien#	include		$(SRC)/cmd/sgs/Makefile.targ
10418334Speter#
10518334Speter#	lint:		<choose the desired functionality> $(SGSLINTOUT)
10618334Speter#
10790075Sobrien#		$(LINTLIB32),
10850397Sobrien#		$(LINTLIB64)	Create an Elf32 or Elf64 lint library from
10918334Speter#				a proto file indicated by the $(SRCS) variable.
11090075Sobrien#
11150397Sobrien#		$(LINTOUT32),
11250397Sobrien#		$(LINTOUT64)	Run lint on the sources indicated by the
11350397Sobrien#				$(LINTSRCS) variable with respect to Elf32
11450397Sobrien#				or Elf64.  Dependencies are gathered from
11550397Sobrien#				the $(LDLIBS) variable.
11690075Sobrien#
11790075Sobrien#		$(SGSLINTOUT)	Create a `lint.out' file as the concatination
118132718Skan#				of the lint output from the previous targets.
119132718Skan#				This should be specified *last* in the list.
12050397Sobrien#
12150397Sobrien################################################################################
12250397Sobrien
123132718Skan#
124169689Skan# Override the OS's $(LINTOUT) target to avoid confusion.
125132718Skan#
126132718SkanLINTOUT =	$(LINTOUT1)
127132718Skan
128132718Skan#
129169689Skan# If LD_LIB, LDDBG_LIB, or CONV_LIB is added to LDLIBS, then the right lint
130169689Skan# library should be picked up automatically.
131132718Skan#
132132718Skan$(LINTOUT32) :=	LD_LIB=$(LD_LIB32)
133132718Skan$(LINTOUT32) :=	LDDBG_LIB=$(LDDBG_LIB32)
134132718Skan$(LINTOUT32) :=	CONV_LIB=$(CONV_LIB32)
135132718Skan
136132718Skan$(LINTOUT64) :=	LD_LIB=$(LD_LIB64)
137132718Skan$(LINTOUT64) :=	LDDBG_LIB=$(LDDBG_LIB64)
138169689Skan$(LINTOUT64) :=	CONV_LIB=$(CONV_LIB64)
139132718Skan
140132718Skan#
141132718Skan# Force $(LINTLIB) in order to help the $(SGSLINTOUT)
142132718Skan# target produce the same output on successive runs.
143132718Skan#
144132718Skan$(LINTLIB):	FRC
145132718Skan
146132718Skan$(LINTLIB32):	$(SRCS)
147169689Skan	$(LINT.c) -o $(LIBNAME32) $(SRCS)
148132718Skan
149132718Skan$(LINTLIB64):	$(SRCS)
150132718Skan	$(LINT.c) -D_ELF64 -o $(LIBNAME64) $(SRCS)
151132718Skan
152132718Skan$(LINTOUT32):	$(LINTSRCS) $(LINTSRCS32)
153132718Skan	$(LINT.c) $(LINTSRCS) $(LINTSRCS32) $(LDLIBS) > $(LINTOUT32) 2>&1
154169689Skan
155132718Skan$(LINTOUT64):	$(LINTSRCS) $(LINTSRCS64)
15690075Sobrien	$(LINT.c) -D_ELF64 $(LINTSRCS) $(LINTSRCS64) \
157132718Skan	    $(LDLIBS) > $(LINTOUT64) 2>&1
15890075Sobrien
159132718Skan$(SGSLINTOUT): FRC
160132718Skan	@ rm -f $(SGSLINTOUT)
161169689Skan	@ if [ -r $(LINTOUT1) ]; then			\
16218334Speter		echo "\n"$(LINTLIB) >> $(SGSLINTOUT);	\
16318334Speter		echo $(DASHES) >> $(SGSLINTOUT);	\
16418334Speter		cat $(LINTOUT1) >> $(SGSLINTOUT);	\
16518334Speter	fi
16618334Speter	@ if [ -r $(LINTOUT32) ]; then			\
16718334Speter		if [ -n "$(DYNLIB)" ] ; then		\
16818334Speter			echo "\nElf32 - $(DYNLIB)" >> $(SGSLINTOUT);	\
16918334Speter		elif [ -n "$(RTLD)" ] ; then		\
170117395Skan			echo "\nElf32 - $(RTLD)" >> $(SGSLINTOUT);	\
171117395Skan		else echo "\nElf32 - $(PROG)" >> $(SGSLINTOUT);	\
172117395Skan		fi; \
173117395Skan		echo $(DASHES) >> $(SGSLINTOUT);	\
17452284Sobrien		cat $(LINTOUT32) >> $(SGSLINTOUT);	\
17590075Sobrien	fi
17652284Sobrien	@ if [ -r $(LINTOUT64) ]; then			\
17790075Sobrien		if [ -n "$(DYNLIB)" ] ; then		\
178169689Skan			if [ $(DYNLIB) = "libld.so.2" ] ; then \
179169689Skan				echo "\nElf64 - libld.so.3" >> $(SGSLINTOUT);	\
18052284Sobrien			else \
18152284Sobrien				echo "\nElf64 - $(DYNLIB)" >> $(SGSLINTOUT);	\
182117395Skan			fi; \
183117395Skan		elif [ -n "$(RTLD)" ] ; then		\
184117395Skan			echo "\nElf64 - $(RTLD)" >> $(SGSLINTOUT);	\
185117395Skan		else echo "\nElf64 - $(PROG)" >> $(SGSLINTOUT);	\
186169689Skan		fi; \
187169689Skan		echo $(DASHES) >> $(SGSLINTOUT);	\
188117395Skan		cat $(LINTOUT64) >> $(SGSLINTOUT);	\
189117395Skan	fi
190132718Skan	@ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64)
191132718Skan
192132718Skan#
193132718Skan# For those that install the lint library source file.
194169689Skan#
195169689Skan$(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
196169689Skan	$(INS.file) ../common/$(LINTLIBSRC)
197132718Skan
198132718Skan$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKS): \
19918334Speter	$(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
200169689Skan$(VAR_POUND_1)	$(INS.liblink)
20118334Speter
202169689Skan$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKS): \
203169689Skan	$(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
20418334Speter$(VAR_POUND_1)	$(INS.liblink64)
205169689Skan
206132718Skan$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): \
207132718Skan	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS)
208169689Skan$(VAR_POUND_1)	$(INS.liblinkccc)
209132718Skan
210132718Skan$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): \
211169689Skan	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS)
212169689Skan$(VAR_POUND_1)	$(INS.liblinkccc64)
213169689Skan
214169689SkanFRC:
215169689Skan