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*1dd08564Sab196087# Copyright 2008 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 2967298654Sdamico# Standard install rules 3067298654Sdamico# The VAR_SGSBIN and VAR_SGSBIN64 install rules included here are applicable 3167298654Sdamico# to Solaris 10 and earlier releases. For post Solaris 10 releases, the 3267298654Sdamico# standard ROOTBIN and ROOTBIN64 rules defined in ../Makefile.cmd are used. 3367298654Sdamico# The new rules here are included to allow for easier backporting. Making 3467298654Sdamico# the appropriate updates in ./Makefile.var, will allow the SGS components 3567298654Sdamico# to be installed in /usr/ccs/bin rather than the current /usr/bin. 3667298654Sdamico# 3767298654Sdamico$(VAR_SGSBIN)/%: % 3867298654Sdamico $(INS.file) 3967298654Sdamico 4067298654Sdamico$(VAR_SGSBIN64)/%: % 4167298654Sdamico $(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 159*1dd08564Sab196087# 160*1dd08564Sab196087# A couple of macros used in the SGSLINTOUT rule below 161*1dd08564Sab196087# 162*1dd08564Sab196087# LINT_HDR - Use sgs/tools/lint_hdr.pl to generate lint output headers 163*1dd08564Sab196087# LINT_TEE - Use tee to write output to stdout and also capture it 164*1dd08564Sab196087# in the SGSLINT output file. 165*1dd08564Sab196087# 166*1dd08564Sab196087# An additional complexity: We produce headers for all the lint 167*1dd08564Sab196087# output so that we can tell what came from where when we look 168*1dd08564Sab196087# at the resulting file. We also cat these headers to stdout so that 169*1dd08564Sab196087# the user of make will see them. However, we don't want the headers 170*1dd08564Sab196087# to go to stdout if there is only one of LINTOUT32 and LINTOUT64. To 171*1dd08564Sab196087# the interactive user, the headers are only interesting as a way to 172*1dd08564Sab196087# separate the two ELF classes. We only bother with this for the 173*1dd08564Sab196087# non-DYNLIB and non-RTLD case, because at the current time, both of these 174*1dd08564Sab196087# cases always have both 32 and 64-bit ELFCLASS support. 175*1dd08564Sab196087# 176*1dd08564Sab196087LINT_HDR= perl $(SGSTOOLS)/lint_hdr.pl 177*1dd08564Sab196087LINT_TEE= tee -a $(SGSLINTOUT) 178*1dd08564Sab196087 1797c478bd9Sstevel@tonic-gate$(SGSLINTOUT): FRC 1807c478bd9Sstevel@tonic-gate @ rm -f $(SGSLINTOUT) 1817c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT1) ]; then \ 182*1dd08564Sab196087 $(LINT_HDR) $(LINTLIB) | $(LINT_TEE); \ 183*1dd08564Sab196087 cat $(LINTOUT1) | $(LINT_TEE); \ 1847c478bd9Sstevel@tonic-gate fi 1857c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT32) ]; then \ 1867c478bd9Sstevel@tonic-gate if [ -n "$(DYNLIB)" ] ; then \ 187*1dd08564Sab196087 $(LINT_HDR) $(DYNLIB) 32 | $(LINT_TEE); \ 1887c478bd9Sstevel@tonic-gate elif [ -n "$(RTLD)" ] ; then \ 189*1dd08564Sab196087 $(LINT_HDR) $(RTLD) 32 | $(LINT_TEE); \ 190*1dd08564Sab196087 else \ 191*1dd08564Sab196087 if [ -r $(LINTOUT64) ]; then \ 192*1dd08564Sab196087 $(LINT_HDR) $(PROG) 32 | $(LINT_TEE); \ 193*1dd08564Sab196087 else \ 194*1dd08564Sab196087 $(LINT_HDR) $(PROG) 32 >> $(SGSLINTOUT); \ 1957c478bd9Sstevel@tonic-gate fi; \ 196*1dd08564Sab196087 fi; \ 197*1dd08564Sab196087 cat $(LINTOUT32) | $(LINT_TEE); \ 1987c478bd9Sstevel@tonic-gate fi 1997c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT64) ]; then \ 2007c478bd9Sstevel@tonic-gate if [ -n "$(DYNLIB)" ] ; then \ 2017c478bd9Sstevel@tonic-gate if [ $(DYNLIB) = "libld.so.2" ] ; then \ 202*1dd08564Sab196087 $(LINT_HDR) libld.so.3 64 | $(LINT_TEE); \ 2037c478bd9Sstevel@tonic-gate else \ 204*1dd08564Sab196087 $(LINT_HDR) $(DYNLIB) 64 | $(LINT_TEE); \ 2057c478bd9Sstevel@tonic-gate fi; \ 2067c478bd9Sstevel@tonic-gate elif [ -n "$(RTLD)" ] ; then \ 207*1dd08564Sab196087 $(LINT_HDR) $(RTLD) 64 | $(LINT_TEE); \ 208*1dd08564Sab196087 else \ 209*1dd08564Sab196087 if [ -r $(LINTOUT32) ]; then \ 210*1dd08564Sab196087 $(LINT_HDR) $(PROG) 64 | $(LINT_TEE); \ 211*1dd08564Sab196087 else \ 212*1dd08564Sab196087 $(LINT_HDR) $(PROG) 64 >> $(SGSLINTOUT); \ 2137c478bd9Sstevel@tonic-gate fi; \ 214*1dd08564Sab196087 fi; \ 215*1dd08564Sab196087 cat $(LINTOUT64) | $(LINT_TEE); \ 2167c478bd9Sstevel@tonic-gate fi 2177c478bd9Sstevel@tonic-gate @ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64) 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate# 2207c478bd9Sstevel@tonic-gate# For those that install the lint library source file. 2217c478bd9Sstevel@tonic-gate# 2227c478bd9Sstevel@tonic-gate$(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC) 2237c478bd9Sstevel@tonic-gate $(INS.file) ../common/$(LINTLIBSRC) 2247c478bd9Sstevel@tonic-gate 2255aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKS): \ 2265aefb655Srie $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS) 2277c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblink) 2287c478bd9Sstevel@tonic-gate 2295aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKS): \ 2305aefb655Srie $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS) 2317c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblink64) 2327c478bd9Sstevel@tonic-gate 2335aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): \ 2345aefb655Srie $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS) 2357c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblinkccc) 2367c478bd9Sstevel@tonic-gate 2375aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): \ 2385aefb655Srie $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS) 2397c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblinkccc64) 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gateFRC: 242