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 (the "License"). 6# You may not use this file except in compliance with the License. 7# 8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9# or http://www.opensolaris.org/os/licensing. 10# See the License for the specific language governing permissions 11# and limitations under the License. 12# 13# When distributing Covered Code, include this CDDL HEADER in each 14# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15# If applicable, add the following below this CDDL HEADER, with the 16# fields enclosed by brackets "[]" replaced with your own identifying 17# information: Portions Copyright [yyyy] [name of copyright owner] 18# 19# CDDL HEADER END 20# 21 22# 23# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26# Copyright 2019 Joyent, Inc. 27 28PROG:sh = basename `cd ..; pwd` 29 30include ../../../Makefile.ctf 31 32OBJS = $(PROG).o 33 34SRCS = ../$(PROG).c 35 36FILEMODE = 0555 37 38# libproc is added individually as pwait doesn't need it. 39# These are defined this way so lint can use them 40LDLIBS_pargs = -lproc 41LDLIBS_pcred = -lproc 42LDLIBS_pfiles = -lproc -lnsl 43LDLIBS_pflags = -lproc 44LDLIBS_pldd = -lproc 45LDLIBS_plgrp = -lproc -llgrp 46LDLIBS_pmap = -lproc 47LDLIBS_pmadvise = -lproc 48LDLIBS_ppriv = -lproc 49LDLIBS_preap = -lproc 50LDLIBS_prun = -lproc 51LDLIBS_psecflags = -lproc -lproject 52LDLIBS_psig = -lproc 53LDLIBS_pstack = -lproc -lc_db 54LDLIBS_pstop = -lproc 55LDLIBS_ptime = -lproc 56LDLIBS_ptree = -lproc -lcontract 57LDLIBS_pwdx = -lproc 58 59LDLIBS += $(LDLIBS_$(PROG)) 60 61CERRWARN_plgrp += -_gcc=-Wno-parentheses 62CERRWARN_plgrp += -_smatch=off 63 64CERRWARN_pmadvise += -_smatch=off 65 66CERRWARN_ppriv += -_gcc=-Wno-parentheses 67CERRWARN_ppriv += $(CNOWARN_UNINIT) 68 69CERRWARN_ptree += -_gcc=-Wno-parentheses 70CERRWARN_ptree += -_smatch=off 71 72CERRWARN_pstack += $(CNOWARN_UNINIT) 73CERRWARN_pstack += -_gcc=-Wno-clobbered 74 75CERRWARN_pargs += -_gcc=-Wno-clobbered 76CERRWARN_pargs += -_gcc=-Wno-type-limits 77 78CERRWARN_pwait += -_smatch=off 79 80CERRWARN += $(CERRWARN_$(PROG)) 81 82# pargs depends on ../../common/elfcap components 83# pmadvise depends on pmap components 84 85ELFCAP = $(SRC)/common/elfcap 86PMAP = $(SRC)/cmd/ptools/pmap 87 88CPPFLAGS_pargs = -I$(ELFCAP) 89OBJS_pargs = elfcap.o 90SRCS_pargs = $(ELFCAP)/elfcap.c 91 92CPPFLAGS_pmap = -I$(PMAP) 93OBJS_pmap = pmap_common.o 94SRCS_pmap = $(PMAP)/pmap_common.c 95 96CPPFLAGS_pmadvise = -I$(PMAP) 97OBJS_pmadvise = pmap_common.o 98SRCS_pmadvise = $(PMAP)/pmap_common.c 99 100LN_pargs = penv pauxv 101 102CPPFLAGS += $(CPPFLAGS_$(PROG)) 103OBJS += $(OBJS_$(PROG)) 104SRCS += $(SRCS_$(PROG)) 105 106$(OBJS_ptree) := CSTD = $(CSTD_GNU99) 107ptree := CSTD = $(CSTD_GNU99) 108 109pwdx := CSTD = $(CSTD_GNU99) 110 111INSTALL_NEW= 112INSTALL_LEGACY=$(RM) $(ROOTPROCBINSYMLINK) ; \ 113 $(SYMLINK) ../../bin/$(PROG) $(ROOTPROCBINSYMLINK) 114 115.KEEP_STATE: 116 117elfcap.o: $(ELFCAP)/elfcap.c 118 $(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c 119 $(POST_PROCESS_O) 120 121pmap_common.o: $(PMAP)/pmap_common.c 122 $(COMPILE.c) -o $@ $(PMAP)/pmap_common.c 123 $(POST_PROCESS_O) 124 125%.o: ../%.c 126 $(COMPILE.c) $< 127 $(POST_PROCESS_O) 128 129all: $(PROG) 130 131ROOTBINLN=$(LN_$(PROG):%=$(ROOTBIN)/%) 132ROOTBINPROG=$(ROOTBIN)/$(PROG) 133ROOTPROCBINSYMLINK=$(ROOT)/usr/proc/bin/$(PROG) 134 135$(PROG): $$(OBJS) 136 $(LINK.c) $(OBJS) -o $@ $(LDLIBS) 137 $(POST_PROCESS) 138 139# 140# Install the ptool, symlinking it into /usr/proc/bin if PTOOL_TYPE is set 141# to LEGACY. 142# 143install: all $(ROOTPROG) $(ROOTISAPROG) $(ROOTISALN) $(ROOTBINLN) 144 -$(INSTALL_$(PTOOL_TYPE)) 145 146$(ROOTISAPROG): 147 $(RM) $@; $(SYMLINK) ../../bin/$(@F) $@ 148 149$(ROOTISALN): 150 $(RM) $@ 151 $(SYMLINK) ../../bin/$(@F) $@ 152 153$(ROOTBINLN): $(ROOTPROG) 154 $(RM) $@; $(LN) $(ROOTPROG) $@ 155 156clean: 157 $(RM) $(OBJS) 158