xref: /illumos-gate/usr/src/cmd/ptools/Makefile.bld (revision 74079a53e205d2eeb75b215833ddc684a1db3088)
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
109INSTALL_NEW=
110INSTALL_LEGACY=$(RM) $(ROOTPROCBINSYMLINK) ; \
111	$(LN) -s ../../bin/$(PROG) $(ROOTPROCBINSYMLINK)
112
113.KEEP_STATE:
114
115elfcap.o:	$(ELFCAP)/elfcap.c
116		$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
117		$(POST_PROCESS_O)
118
119pmap_common.o:	$(PMAP)/pmap_common.c
120		$(COMPILE.c) -o $@ $(PMAP)/pmap_common.c
121		$(POST_PROCESS_O)
122
123%.o:	../%.c
124	$(COMPILE.c) $<
125	$(POST_PROCESS_O)
126
127all:	$(PROG) $(LN_$(PROG))
128
129ROOTBINLN=$(LN_$(PROG):%=$(ROOTBIN)/%)
130ROOTBINPROG=$(ROOTBIN)/$(PROG)
131ROOTPROCBINSYMLINK=$(ROOT)/usr/proc/bin/$(PROG)
132
133$(PROG): $$(OBJS)
134	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
135	$(POST_PROCESS)
136
137#
138# Install the ptool, symlinking it into /usr/proc/bin if PTOOL_TYPE is set
139# to LEGACY.
140#
141install: all $(ROOTISAPROG) $(ROOTISALN) $(ROOTBINLN)
142	-$(RM) $(ROOTBINPROG)
143	-$(LN) $(ISAEXEC) $(ROOTBINPROG)
144	-$(INSTALL_$(PTOOL_TYPE))
145
146$(ROOTBINLN): $(ROOTISAPROG)
147	-$(RM) $@
148	-$(LN) $(ISAEXEC) $@
149
150$(ROOTISALN): $(ROOTISAPROG)
151	-$(RM) $@
152	-$(LN) $(ROOTISAPROG) $@
153
154$(LN_$(PROG)): $(PROG)
155	-$(RM) $@
156	-$(LN) $(PROG) $@
157
158clean:
159	$(RM) $(OBJS)
160
161lint:
162	$(LINT.c) $(SRCS) $(LDLIBS)
163