xref: /titanic_51/usr/src/cmd/sgs/Makefile.targ (revision 20c1c3551cb3b3117591ae38463d16aada597c48)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
55aefb655Srie# Common Development and Distribution License (the "License").
65aefb655Srie# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
215aefb655Srie
227c478bd9Sstevel@tonic-gate#
23*20c1c355SRod Evans# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate#
257c478bd9Sstevel@tonic-gate
2667298654Sdamico# Standard install rules
2767298654Sdamico# The VAR_SGSBIN and VAR_SGSBIN64 install rules included here are applicable
2867298654Sdamico# to Solaris 10 and earlier releases. For post Solaris 10 releases, the
2967298654Sdamico# standard ROOTBIN and ROOTBIN64 rules defined in ../Makefile.cmd are used.
3067298654Sdamico# The new rules here are included to allow for easier backporting. Making
3167298654Sdamico# the appropriate updates in ./Makefile.var, will allow the SGS components
3267298654Sdamico# to be installed in /usr/ccs/bin rather than the current /usr/bin.
3367298654Sdamico#
3467298654Sdamico$(VAR_SGSBIN)/%: %
3567298654Sdamico	$(INS.file)
3667298654Sdamico
3767298654Sdamico$(VAR_SGSBIN64)/%: %
3867298654Sdamico	$(INS.file)
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate################################################################################
417c478bd9Sstevel@tonic-gate#
427c478bd9Sstevel@tonic-gate# Linting the Linker Libraries
437c478bd9Sstevel@tonic-gate#
445aefb655Srie#  Several of the linker's libraries are, in whole or in part, built in two
455aefb655Srie#  passes, once as Elf32 and once as Elf64 (i.e. with -D_ELF64 defined).  Lint
465aefb655Srie#  needs to be able to do both passes, but combining the two is problematic for
475aefb655Srie#  the 2nd pass of lint, as it sees many interfaces as being defined both ways
485aefb655Srie#  and considers them to be incompatible.  The targets defined here allow for
495aefb655Srie#  both passes to live independently.  This means that both the lint.out, and
505aefb655Srie#  the lint library itself get generated separately, to different output files.
515aefb655Srie#  The lint.out's get combined into a single lint.out report, and the lint
525aefb655Srie#  libraries get generated with a 32/64 suffix.  The dependents on these lint
535aefb655Srie#  libraries, then, choose which version they need to use.  Substitutions can
545aefb655Srie#  be made automatically if the macro's defined in ./Makefile.com are used to
555aefb655Srie#  specify the dependency, for those libs that need them.
567c478bd9Sstevel@tonic-gate#
577c478bd9Sstevel@tonic-gate# Don't
587c478bd9Sstevel@tonic-gate#
595aefb655Srie#  Don't use the /*LINTLIBRARY*/ directive in linker libraries, this disables
605aefb655Srie#  some important checks, including the ability to test format strings from the
615aefb655Srie#  msg.h files.
627c478bd9Sstevel@tonic-gate#
635aefb655Srie#  Don't use the `-x' option to lint when linting linker libraries.  This masks
645aefb655Srie#  all the dead wood in our own header files.  Instead, there has been added to
655aefb655Srie#  the relevant common directories a file called `lintsup.c' which is used to
665aefb655Srie#  mask out the headers that we aren't interested in.  This method is used for
675aefb655Srie#  libraries, like libld, which have their own header files, but is irrelevant
685aefb655Srie#  to libraries like libldstab which exports no interface of it's own.
697c478bd9Sstevel@tonic-gate#
705aefb655Srie#  The `lintsup.c' file can also be used, in some cases, to mask out other
715aefb655Srie#  issues that lint won't otherwise shut up about.
727c478bd9Sstevel@tonic-gate#
737c478bd9Sstevel@tonic-gate# Other Lint Options
747c478bd9Sstevel@tonic-gate#
755aefb655Srie#  `-m' has been added to the LINTFLAGS.  Warnings about globals that could be
765aefb655Srie#  static are irrelevant as we use mapfiles to scope down unnecessary globals.
777c478bd9Sstevel@tonic-gate#
785aefb655Srie#  `-u' is used in the LINTFLAGS for libraries, otherwise lint tends to be very
795aefb655Srie#  noisy.
807c478bd9Sstevel@tonic-gate#
815aefb655Srie#  `-x' is avoided for libraries, but is used for executables because all we
825aefb655Srie#  care about is that what we use is defined, not about declarations in public
835aefb655Srie#  headers that we don't use.
847c478bd9Sstevel@tonic-gate#
857c478bd9Sstevel@tonic-gate# Relevant variables:
867c478bd9Sstevel@tonic-gate#
877c478bd9Sstevel@tonic-gate# */Makefile.com
887c478bd9Sstevel@tonic-gate#	SRCS=		../common/llib-l<libname>
897c478bd9Sstevel@tonic-gate#	LINTSRCS=	<source files>
907c478bd9Sstevel@tonic-gate#	LDLIBS=		... [$(LDDBG_LIB) $(LD_LIB)]
917c478bd9Sstevel@tonic-gate#	LINTFLAGS=	...
927c478bd9Sstevel@tonic-gate#	LINTFLAGS64=	...
937c478bd9Sstevel@tonic-gate#	CLEANFILES +=	... $(LINTOUTS)
947c478bd9Sstevel@tonic-gate#	CLOBBERFILES +=	... $(LINTLIBS)
957c478bd9Sstevel@tonic-gate#
967c478bd9Sstevel@tonic-gate# Relevant targets:
977c478bd9Sstevel@tonic-gate#
987c478bd9Sstevel@tonic-gate# */Makefile.targ
997c478bd9Sstevel@tonic-gate#	# this file for SGS lint targets.
1007c478bd9Sstevel@tonic-gate#	include		$(SRC)/cmd/sgs/Makefile.targ
1017c478bd9Sstevel@tonic-gate#
1027c478bd9Sstevel@tonic-gate#	lint:		<choose the desired functionality> $(SGSLINTOUT)
1037c478bd9Sstevel@tonic-gate#
1047c478bd9Sstevel@tonic-gate#		$(LINTLIB32),
1057c478bd9Sstevel@tonic-gate#		$(LINTLIB64)	Create an Elf32 or Elf64 lint library from
1067c478bd9Sstevel@tonic-gate#				a proto file indicated by the $(SRCS) variable.
1077c478bd9Sstevel@tonic-gate#
1087c478bd9Sstevel@tonic-gate#		$(LINTOUT32),
1097c478bd9Sstevel@tonic-gate#		$(LINTOUT64)	Run lint on the sources indicated by the
1107c478bd9Sstevel@tonic-gate#				$(LINTSRCS) variable with respect to Elf32
1117c478bd9Sstevel@tonic-gate#				or Elf64.  Dependencies are gathered from
1127c478bd9Sstevel@tonic-gate#				the $(LDLIBS) variable.
1137c478bd9Sstevel@tonic-gate#
1147c478bd9Sstevel@tonic-gate#		$(SGSLINTOUT)	Create a `lint.out' file as the concatination
1157c478bd9Sstevel@tonic-gate#				of the lint output from the previous targets.
1167c478bd9Sstevel@tonic-gate#				This should be specified *last* in the list.
1177c478bd9Sstevel@tonic-gate#
1187c478bd9Sstevel@tonic-gate################################################################################
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gate#
1217c478bd9Sstevel@tonic-gate# Override the OS's $(LINTOUT) target to avoid confusion.
1227c478bd9Sstevel@tonic-gate#
1237c478bd9Sstevel@tonic-gateLINTOUT =	$(LINTOUT1)
1247c478bd9Sstevel@tonic-gate
1257c478bd9Sstevel@tonic-gate#
1265aefb655Srie# If LD_LIB, LDDBG_LIB, or CONV_LIB is added to LDLIBS, then the right lint
1275aefb655Srie# library should be picked up automatically.
1287c478bd9Sstevel@tonic-gate#
1297c478bd9Sstevel@tonic-gate$(LINTOUT32) :=	LD_LIB=$(LD_LIB32)
1307c478bd9Sstevel@tonic-gate$(LINTOUT32) :=	LDDBG_LIB=$(LDDBG_LIB32)
1315aefb655Srie$(LINTOUT32) :=	CONV_LIB=$(CONV_LIB32)
1325aefb655Srie
1337c478bd9Sstevel@tonic-gate$(LINTOUT64) :=	LD_LIB=$(LD_LIB64)
1347c478bd9Sstevel@tonic-gate$(LINTOUT64) :=	LDDBG_LIB=$(LDDBG_LIB64)
1355aefb655Srie$(LINTOUT64) :=	CONV_LIB=$(CONV_LIB64)
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate#
1387c478bd9Sstevel@tonic-gate# Force $(LINTLIB) in order to help the $(SGSLINTOUT)
1397c478bd9Sstevel@tonic-gate# target produce the same output on successive runs.
1407c478bd9Sstevel@tonic-gate#
1417c478bd9Sstevel@tonic-gate$(LINTLIB):	FRC
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate$(LINTLIB32):	$(SRCS)
1447c478bd9Sstevel@tonic-gate	$(LINT.c) -o $(LIBNAME32) $(SRCS)
1457c478bd9Sstevel@tonic-gate
1467c478bd9Sstevel@tonic-gate$(LINTLIB64):	$(SRCS)
1477c478bd9Sstevel@tonic-gate	$(LINT.c) -D_ELF64 -o $(LIBNAME64) $(SRCS)
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate$(LINTOUT32):	$(LINTSRCS) $(LINTSRCS32)
1507c478bd9Sstevel@tonic-gate	$(LINT.c) $(LINTSRCS) $(LINTSRCS32) $(LDLIBS) > $(LINTOUT32) 2>&1
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate$(LINTOUT64):	$(LINTSRCS) $(LINTSRCS64)
1537c478bd9Sstevel@tonic-gate	$(LINT.c) -D_ELF64 $(LINTSRCS) $(LINTSRCS64) \
1547c478bd9Sstevel@tonic-gate	    $(LDLIBS) > $(LINTOUT64) 2>&1
1557c478bd9Sstevel@tonic-gate
1561dd08564Sab196087#
1571dd08564Sab196087# A couple of macros used in the SGSLINTOUT rule below
1581dd08564Sab196087#
1591dd08564Sab196087#	LINT_HDR - Use sgs/tools/lint_hdr.pl to generate lint output headers
1601dd08564Sab196087#	LINT_TEE - Use tee to write output to stdout and also capture it
1611dd08564Sab196087#		in the SGSLINT output file.
1621dd08564Sab196087#
1631dd08564Sab196087# An additional complexity: We produce headers for all the lint
1641dd08564Sab196087# output so that we can tell what came from where when we look
1651dd08564Sab196087# at the resulting file. We also cat these headers to stdout so that
1661dd08564Sab196087# the user of make will see them. However, we don't want the headers
1671dd08564Sab196087# to go to stdout if there is only one of LINTOUT32 and LINTOUT64. To
1681dd08564Sab196087# the interactive user, the headers are only interesting as a way to
1691dd08564Sab196087# separate the two ELF classes. We only bother with this for the
1701dd08564Sab196087# non-DYNLIB and non-RTLD case, because at the current time, both of these
1711dd08564Sab196087# cases always have both 32 and 64-bit ELFCLASS support.
1721dd08564Sab196087#
1731dd08564Sab196087LINT_HDR=	perl $(SGSTOOLS)/lint_hdr.pl
1741dd08564Sab196087LINT_TEE=	tee -a $(SGSLINTOUT)
1751dd08564Sab196087
1767c478bd9Sstevel@tonic-gate$(SGSLINTOUT): FRC
1777c478bd9Sstevel@tonic-gate	@ rm -f $(SGSLINTOUT)
1787c478bd9Sstevel@tonic-gate	@ if [ -r $(LINTOUT1) ]; then			\
1791dd08564Sab196087		$(LINT_HDR) $(LINTLIB) | $(LINT_TEE);	\
1801dd08564Sab196087		cat $(LINTOUT1) | $(LINT_TEE);	\
1817c478bd9Sstevel@tonic-gate	fi
1827c478bd9Sstevel@tonic-gate	@ if [ -r $(LINTOUT32) ]; then			\
1837c478bd9Sstevel@tonic-gate		if [ -n "$(DYNLIB)" ] ; then		\
1841dd08564Sab196087			$(LINT_HDR) $(DYNLIB) 32 | $(LINT_TEE); \
1857c478bd9Sstevel@tonic-gate		elif [ -n "$(RTLD)" ] ; then		\
1861dd08564Sab196087			$(LINT_HDR) $(RTLD) 32 | $(LINT_TEE); \
1871dd08564Sab196087		else \
1881dd08564Sab196087			if [ -r $(LINTOUT64) ]; then \
1891dd08564Sab196087				$(LINT_HDR) $(PROG) 32 | $(LINT_TEE);	\
1901dd08564Sab196087			else \
1911dd08564Sab196087				$(LINT_HDR) $(PROG) 32 >> $(SGSLINTOUT); \
1927c478bd9Sstevel@tonic-gate			fi; \
1931dd08564Sab196087		fi; \
1941dd08564Sab196087		cat $(LINTOUT32) | $(LINT_TEE);	\
1957c478bd9Sstevel@tonic-gate	fi
1967c478bd9Sstevel@tonic-gate	@ if [ -r $(LINTOUT64) ]; then			\
1977c478bd9Sstevel@tonic-gate		if [ -n "$(DYNLIB)" ] ; then		\
1987c478bd9Sstevel@tonic-gate			if [ $(DYNLIB) = "libld.so.2" ] ; then \
1991dd08564Sab196087				$(LINT_HDR) libld.so.3 64 | $(LINT_TEE); \
2007c478bd9Sstevel@tonic-gate			else \
2011dd08564Sab196087				$(LINT_HDR) $(DYNLIB) 64 | $(LINT_TEE); \
2027c478bd9Sstevel@tonic-gate			fi; \
2037c478bd9Sstevel@tonic-gate		elif [ -n "$(RTLD)" ] ; then		\
2041dd08564Sab196087			$(LINT_HDR) $(RTLD) 64 | $(LINT_TEE); \
2051dd08564Sab196087		else \
2061dd08564Sab196087			if [ -r $(LINTOUT32) ]; then \
2071dd08564Sab196087				$(LINT_HDR) $(PROG) 64 | $(LINT_TEE); \
2081dd08564Sab196087			else \
2091dd08564Sab196087				$(LINT_HDR) $(PROG) 64 >> $(SGSLINTOUT); \
2107c478bd9Sstevel@tonic-gate			fi; \
2111dd08564Sab196087		fi; \
2121dd08564Sab196087		cat $(LINTOUT64) | $(LINT_TEE);	\
2137c478bd9Sstevel@tonic-gate	fi
2147c478bd9Sstevel@tonic-gate	@ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64)
2157c478bd9Sstevel@tonic-gate
2167c478bd9Sstevel@tonic-gate#
2177c478bd9Sstevel@tonic-gate# For those that install the lint library source file.
2187c478bd9Sstevel@tonic-gate#
2197c478bd9Sstevel@tonic-gate$(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
2207c478bd9Sstevel@tonic-gate	$(INS.file) ../common/$(LINTLIBSRC)
2217c478bd9Sstevel@tonic-gate
222*20c1c355SRod Evans$(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
223*20c1c355SRod Evans	$(INS.liblink)
2247c478bd9Sstevel@tonic-gate
225*20c1c355SRod Evans$(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
226*20c1c355SRod Evans	$(INS.liblink64)
2277c478bd9Sstevel@tonic-gate
228*20c1c355SRod Evans$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS)
229*20c1c355SRod Evans	$(INS.liblinkccc)
2307c478bd9Sstevel@tonic-gate
231*20c1c355SRod Evans$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS)
232*20c1c355SRod Evans	$(INS.liblinkccc64)
2337c478bd9Sstevel@tonic-gate
2347c478bd9Sstevel@tonic-gateFRC:
235