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*67298654Sdamico# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate# 287c478bd9Sstevel@tonic-gate 29*67298654Sdamico# Standard install rules 30*67298654Sdamico# The VAR_SGSBIN and VAR_SGSBIN64 install rules included here are applicable 31*67298654Sdamico# to Solaris 10 and earlier releases. For post Solaris 10 releases, the 32*67298654Sdamico# standard ROOTBIN and ROOTBIN64 rules defined in ../Makefile.cmd are used. 33*67298654Sdamico# The new rules here are included to allow for easier backporting. Making 34*67298654Sdamico# the appropriate updates in ./Makefile.var, will allow the SGS components 35*67298654Sdamico# to be installed in /usr/ccs/bin rather than the current /usr/bin. 36*67298654Sdamico# 37*67298654Sdamico$(VAR_SGSBIN)/%: % 38*67298654Sdamico $(INS.file) 39*67298654Sdamico 40*67298654Sdamico$(VAR_SGSBIN64)/%: % 41*67298654Sdamico $(INS.file) 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate################################################################################ 447c478bd9Sstevel@tonic-gate# 457c478bd9Sstevel@tonic-gate# Linting the Linker Libraries 467c478bd9Sstevel@tonic-gate# 475aefb655Srie# Several of the linker's libraries are, in whole or in part, built in two 485aefb655Srie# passes, once as Elf32 and once as Elf64 (i.e. with -D_ELF64 defined). Lint 495aefb655Srie# needs to be able to do both passes, but combining the two is problematic for 505aefb655Srie# the 2nd pass of lint, as it sees many interfaces as being defined both ways 515aefb655Srie# and considers them to be incompatible. The targets defined here allow for 525aefb655Srie# both passes to live independently. This means that both the lint.out, and 535aefb655Srie# the lint library itself get generated separately, to different output files. 545aefb655Srie# The lint.out's get combined into a single lint.out report, and the lint 555aefb655Srie# libraries get generated with a 32/64 suffix. The dependents on these lint 565aefb655Srie# libraries, then, choose which version they need to use. Substitutions can 575aefb655Srie# be made automatically if the macro's defined in ./Makefile.com are used to 585aefb655Srie# specify the dependency, for those libs that need them. 597c478bd9Sstevel@tonic-gate# 607c478bd9Sstevel@tonic-gate# Don't 617c478bd9Sstevel@tonic-gate# 625aefb655Srie# Don't use the /*LINTLIBRARY*/ directive in linker libraries, this disables 635aefb655Srie# some important checks, including the ability to test format strings from the 645aefb655Srie# msg.h files. 657c478bd9Sstevel@tonic-gate# 665aefb655Srie# Don't use the `-x' option to lint when linting linker libraries. This masks 675aefb655Srie# all the dead wood in our own header files. Instead, there has been added to 685aefb655Srie# the relevant common directories a file called `lintsup.c' which is used to 695aefb655Srie# mask out the headers that we aren't interested in. This method is used for 705aefb655Srie# libraries, like libld, which have their own header files, but is irrelevant 715aefb655Srie# to libraries like libldstab which exports no interface of it's own. 727c478bd9Sstevel@tonic-gate# 735aefb655Srie# The `lintsup.c' file can also be used, in some cases, to mask out other 745aefb655Srie# issues that lint won't otherwise shut up about. 757c478bd9Sstevel@tonic-gate# 767c478bd9Sstevel@tonic-gate# Other Lint Options 777c478bd9Sstevel@tonic-gate# 785aefb655Srie# `-m' has been added to the LINTFLAGS. Warnings about globals that could be 795aefb655Srie# static are irrelevant as we use mapfiles to scope down unnecessary globals. 807c478bd9Sstevel@tonic-gate# 815aefb655Srie# `-u' is used in the LINTFLAGS for libraries, otherwise lint tends to be very 825aefb655Srie# noisy. 837c478bd9Sstevel@tonic-gate# 845aefb655Srie# `-x' is avoided for libraries, but is used for executables because all we 855aefb655Srie# care about is that what we use is defined, not about declarations in public 865aefb655Srie# headers that we don't use. 877c478bd9Sstevel@tonic-gate# 887c478bd9Sstevel@tonic-gate# Relevant variables: 897c478bd9Sstevel@tonic-gate# 907c478bd9Sstevel@tonic-gate# */Makefile.com 917c478bd9Sstevel@tonic-gate# SRCS= ../common/llib-l<libname> 927c478bd9Sstevel@tonic-gate# LINTSRCS= <source files> 937c478bd9Sstevel@tonic-gate# LDLIBS= ... [$(LDDBG_LIB) $(LD_LIB)] 947c478bd9Sstevel@tonic-gate# LINTFLAGS= ... 957c478bd9Sstevel@tonic-gate# LINTFLAGS64= ... 967c478bd9Sstevel@tonic-gate# CLEANFILES += ... $(LINTOUTS) 977c478bd9Sstevel@tonic-gate# CLOBBERFILES += ... $(LINTLIBS) 987c478bd9Sstevel@tonic-gate# 997c478bd9Sstevel@tonic-gate# Relevant targets: 1007c478bd9Sstevel@tonic-gate# 1017c478bd9Sstevel@tonic-gate# */Makefile.targ 1027c478bd9Sstevel@tonic-gate# # this file for SGS lint targets. 1037c478bd9Sstevel@tonic-gate# include $(SRC)/cmd/sgs/Makefile.targ 1047c478bd9Sstevel@tonic-gate# 1057c478bd9Sstevel@tonic-gate# lint: <choose the desired functionality> $(SGSLINTOUT) 1067c478bd9Sstevel@tonic-gate# 1077c478bd9Sstevel@tonic-gate# $(LINTLIB32), 1087c478bd9Sstevel@tonic-gate# $(LINTLIB64) Create an Elf32 or Elf64 lint library from 1097c478bd9Sstevel@tonic-gate# a proto file indicated by the $(SRCS) variable. 1107c478bd9Sstevel@tonic-gate# 1117c478bd9Sstevel@tonic-gate# $(LINTOUT32), 1127c478bd9Sstevel@tonic-gate# $(LINTOUT64) Run lint on the sources indicated by the 1137c478bd9Sstevel@tonic-gate# $(LINTSRCS) variable with respect to Elf32 1147c478bd9Sstevel@tonic-gate# or Elf64. Dependencies are gathered from 1157c478bd9Sstevel@tonic-gate# the $(LDLIBS) variable. 1167c478bd9Sstevel@tonic-gate# 1177c478bd9Sstevel@tonic-gate# $(SGSLINTOUT) Create a `lint.out' file as the concatination 1187c478bd9Sstevel@tonic-gate# of the lint output from the previous targets. 1197c478bd9Sstevel@tonic-gate# This should be specified *last* in the list. 1207c478bd9Sstevel@tonic-gate# 1217c478bd9Sstevel@tonic-gate################################################################################ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate# 1247c478bd9Sstevel@tonic-gate# Override the OS's $(LINTOUT) target to avoid confusion. 1257c478bd9Sstevel@tonic-gate# 1267c478bd9Sstevel@tonic-gateLINTOUT = $(LINTOUT1) 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate# 1295aefb655Srie# If LD_LIB, LDDBG_LIB, or CONV_LIB is added to LDLIBS, then the right lint 1305aefb655Srie# library should be picked up automatically. 1317c478bd9Sstevel@tonic-gate# 1327c478bd9Sstevel@tonic-gate$(LINTOUT32) := LD_LIB=$(LD_LIB32) 1337c478bd9Sstevel@tonic-gate$(LINTOUT32) := LDDBG_LIB=$(LDDBG_LIB32) 1345aefb655Srie$(LINTOUT32) := CONV_LIB=$(CONV_LIB32) 1355aefb655Srie 1367c478bd9Sstevel@tonic-gate$(LINTOUT64) := LD_LIB=$(LD_LIB64) 1377c478bd9Sstevel@tonic-gate$(LINTOUT64) := LDDBG_LIB=$(LDDBG_LIB64) 1385aefb655Srie$(LINTOUT64) := CONV_LIB=$(CONV_LIB64) 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate# 1417c478bd9Sstevel@tonic-gate# Force $(LINTLIB) in order to help the $(SGSLINTOUT) 1427c478bd9Sstevel@tonic-gate# target produce the same output on successive runs. 1437c478bd9Sstevel@tonic-gate# 1447c478bd9Sstevel@tonic-gate$(LINTLIB): FRC 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate$(LINTLIB32): $(SRCS) 1477c478bd9Sstevel@tonic-gate $(LINT.c) -o $(LIBNAME32) $(SRCS) 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate$(LINTLIB64): $(SRCS) 1507c478bd9Sstevel@tonic-gate $(LINT.c) -D_ELF64 -o $(LIBNAME64) $(SRCS) 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate$(LINTOUT32): $(LINTSRCS) $(LINTSRCS32) 1537c478bd9Sstevel@tonic-gate $(LINT.c) $(LINTSRCS) $(LINTSRCS32) $(LDLIBS) > $(LINTOUT32) 2>&1 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate$(LINTOUT64): $(LINTSRCS) $(LINTSRCS64) 1567c478bd9Sstevel@tonic-gate $(LINT.c) -D_ELF64 $(LINTSRCS) $(LINTSRCS64) \ 1577c478bd9Sstevel@tonic-gate $(LDLIBS) > $(LINTOUT64) 2>&1 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate$(SGSLINTOUT): FRC 1607c478bd9Sstevel@tonic-gate @ rm -f $(SGSLINTOUT) 1617c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT1) ]; then \ 1627c478bd9Sstevel@tonic-gate echo "\n"$(LINTLIB) >> $(SGSLINTOUT); \ 1637c478bd9Sstevel@tonic-gate echo $(DASHES) >> $(SGSLINTOUT); \ 1647c478bd9Sstevel@tonic-gate cat $(LINTOUT1) >> $(SGSLINTOUT); \ 1657c478bd9Sstevel@tonic-gate fi 1667c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT32) ]; then \ 1677c478bd9Sstevel@tonic-gate if [ -n "$(DYNLIB)" ] ; then \ 1687c478bd9Sstevel@tonic-gate echo "\nElf32 - $(DYNLIB)" >> $(SGSLINTOUT); \ 1697c478bd9Sstevel@tonic-gate elif [ -n "$(RTLD)" ] ; then \ 1707c478bd9Sstevel@tonic-gate echo "\nElf32 - $(RTLD)" >> $(SGSLINTOUT); \ 1717c478bd9Sstevel@tonic-gate else echo "\nElf32 - $(PROG)" >> $(SGSLINTOUT); \ 1727c478bd9Sstevel@tonic-gate fi; \ 1737c478bd9Sstevel@tonic-gate echo $(DASHES) >> $(SGSLINTOUT); \ 1747c478bd9Sstevel@tonic-gate cat $(LINTOUT32) >> $(SGSLINTOUT); \ 1757c478bd9Sstevel@tonic-gate fi 1767c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT64) ]; then \ 1777c478bd9Sstevel@tonic-gate if [ -n "$(DYNLIB)" ] ; then \ 1787c478bd9Sstevel@tonic-gate if [ $(DYNLIB) = "libld.so.2" ] ; then \ 1797c478bd9Sstevel@tonic-gate echo "\nElf64 - libld.so.3" >> $(SGSLINTOUT); \ 1807c478bd9Sstevel@tonic-gate else \ 1817c478bd9Sstevel@tonic-gate echo "\nElf64 - $(DYNLIB)" >> $(SGSLINTOUT); \ 1827c478bd9Sstevel@tonic-gate fi; \ 1837c478bd9Sstevel@tonic-gate elif [ -n "$(RTLD)" ] ; then \ 1847c478bd9Sstevel@tonic-gate echo "\nElf64 - $(RTLD)" >> $(SGSLINTOUT); \ 1857c478bd9Sstevel@tonic-gate else echo "\nElf64 - $(PROG)" >> $(SGSLINTOUT); \ 1867c478bd9Sstevel@tonic-gate fi; \ 1877c478bd9Sstevel@tonic-gate echo $(DASHES) >> $(SGSLINTOUT); \ 1887c478bd9Sstevel@tonic-gate cat $(LINTOUT64) >> $(SGSLINTOUT); \ 1897c478bd9Sstevel@tonic-gate fi 1907c478bd9Sstevel@tonic-gate @ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64) 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate# 1937c478bd9Sstevel@tonic-gate# For those that install the lint library source file. 1947c478bd9Sstevel@tonic-gate# 1957c478bd9Sstevel@tonic-gate$(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC) 1967c478bd9Sstevel@tonic-gate $(INS.file) ../common/$(LINTLIBSRC) 1977c478bd9Sstevel@tonic-gate 1985aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKS): \ 1995aefb655Srie $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS) 2007c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblink) 2017c478bd9Sstevel@tonic-gate 2025aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKS): \ 2035aefb655Srie $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS) 2047c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblink64) 2057c478bd9Sstevel@tonic-gate 2065aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): \ 2075aefb655Srie $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS) 2087c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblinkccc) 2097c478bd9Sstevel@tonic-gate 2105aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): \ 2115aefb655Srie $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS) 2127c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblinkccc64) 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gateFRC: 215