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