xref: /illumos-gate/usr/src/cmd/ptools/Makefile.bld (revision f52943a93040563107b95bccb9db87d9971ef47d)
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
30OBJS = $(PROG).o
31
32SRCS = ../$(PROG).c
33
34FILEMODE = 0555
35
36# libproc is added individually as pwait doesn't need it.
37# These are defined this way so lint can use them
38LDLIBS_pargs		= -lproc
39LDLIBS_pcred		= -lproc
40LDLIBS_pfiles		= -lproc -lnsl
41LDLIBS_pflags		= -lproc
42LDLIBS_pldd		= -lproc
43LDLIBS_plgrp		= -lproc -llgrp
44LDLIBS_pmap		= -lproc
45LDLIBS_pmadvise		= -lproc
46LDLIBS_ppriv		= -lproc
47LDLIBS_preap		= -lproc
48LDLIBS_prun		= -lproc
49LDLIBS_psecflags	= -lproc -lproject
50LDLIBS_psig		= -lproc
51LDLIBS_pstack		= -lproc -lc_db
52LDLIBS_pstop		= -lproc
53LDLIBS_ptime		= -lproc
54LDLIBS_ptree		= -lproc -lcontract
55LDLIBS_pwdx		= -lproc
56
57LDLIBS += $(LDLIBS_$(PROG))
58
59CERRWARN_plgrp	+= -_gcc=-Wno-parentheses
60CERRWARN_plgrp	+= -_smatch=off
61
62CERRWARN_pmadvise += -_smatch=off
63
64CERRWARN_ppriv	+= -_gcc=-Wno-parentheses
65CERRWARN_ppriv	+= $(CNOWARN_UNINIT)
66
67CERRWARN_ptree	+= -_gcc=-Wno-parentheses
68CERRWARN_ptree	+= -_smatch=off
69
70CERRWARN_pstack	+= $(CNOWARN_UNINIT)
71CERRWARN_pstack	+= -_gcc=-Wno-clobbered
72
73CERRWARN_pargs	+= -_gcc=-Wno-clobbered
74CERRWARN_pargs	+= -_gcc=-Wno-type-limits
75
76CERRWARN_pwait	+= -_smatch=off
77
78CERRWARN += $(CERRWARN_$(PROG))
79
80# pargs depends on ../../common/elfcap components
81# pmadvise depends on pmap components
82
83ELFCAP =	$(SRC)/common/elfcap
84PMAP =		$(SRC)/cmd/ptools/pmap
85
86CPPFLAGS_pargs =	-I$(ELFCAP)
87OBJS_pargs =		elfcap.o
88SRCS_pargs =		$(ELFCAP)/elfcap.c
89
90CPPFLAGS_pmap =		-I$(PMAP)
91OBJS_pmap =		pmap_common.o
92SRCS_pmap =		$(PMAP)/pmap_common.c
93
94CPPFLAGS_pmadvise =	-I$(PMAP)
95OBJS_pmadvise =		pmap_common.o
96SRCS_pmadvise =		$(PMAP)/pmap_common.c
97
98LN_pargs =		penv pauxv
99
100CPPFLAGS +=	$(CPPFLAGS_$(PROG))
101OBJS +=		$(OBJS_$(PROG))
102SRCS +=		$(SRCS_$(PROG))
103
104$(OBJS_ptree) :=	CSTD = $(CSTD_GNU99)
105ptree :=		CSTD = $(CSTD_GNU99)
106
107INSTALL_NEW=
108INSTALL_LEGACY=$(RM) $(ROOTPROCBINSYMLINK) ; \
109	$(LN) -s ../../bin/$(PROG) $(ROOTPROCBINSYMLINK)
110
111.KEEP_STATE:
112
113elfcap.o:	$(ELFCAP)/elfcap.c
114		$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
115
116pmap_common.o:	$(PMAP)/pmap_common.c
117		$(COMPILE.c) -o $@ $(PMAP)/pmap_common.c
118
119%.o:	../%.c
120	$(COMPILE.c) $<
121
122all:	$(PROG) $(LN_$(PROG))
123
124ROOTBINLN=$(LN_$(PROG):%=$(ROOTBIN)/%)
125ROOTBINPROG=$(ROOTBIN)/$(PROG)
126ROOTPROCBINSYMLINK=$(ROOT)/usr/proc/bin/$(PROG)
127
128$(PROG): $$(OBJS)
129	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
130	$(POST_PROCESS)
131
132#
133# Install the ptool, symlinking it into /usr/proc/bin if PTOOL_TYPE is set
134# to LEGACY.
135#
136install: all $(ROOTISAPROG) $(ROOTISALN) $(ROOTBINLN)
137	-$(RM) $(ROOTBINPROG)
138	-$(LN) $(ISAEXEC) $(ROOTBINPROG)
139	-$(INSTALL_$(PTOOL_TYPE))
140
141$(ROOTBINLN): $(ROOTISAPROG)
142	-$(RM) $@
143	-$(LN) $(ISAEXEC) $@
144
145$(ROOTISALN): $(ROOTISAPROG)
146	-$(RM) $@
147	-$(LN) $(ROOTISAPROG) $@
148
149$(LN_$(PROG)): $(PROG)
150	-$(RM) $@
151	-$(LN) $(PROG) $@
152
153clean:
154	$(RM) $(OBJS)
155
156lint:
157	$(LINT.c) $(SRCS) $(LDLIBS)
158