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