xref: /illumos-gate/usr/src/cmd/mdb/Makefile.mdb (revision 7f3d7c9289dee6488b3cd2848a68c0b8580d750c)
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# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25
26#
27# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
28# Copyright (c) 2012 by Delphix. All rights reserved.
29# Copyright 2021 Joyent, Inc.
30# Copyright 2018 Jason King
31# Copyright 2025 Oxide Computer Company
32#
33
34.KEEP_STATE:
35.SUFFIXES:
36
37SRCS += \
38	ffs.c \
39	mdb.c \
40	mdb_addrvec.c \
41	mdb_argvec.c \
42	mdb_callb.c \
43	mdb_cmdbuf.c \
44	mdb_cmds.c \
45	mdb_conf.c \
46	mdb_context.c \
47	mdb_create.c \
48	mdb_ctf.c \
49	mdb_ctf_open.c \
50	mdb_debug.c \
51	mdb_demangle.c \
52	mdb_disasm.c \
53	mdb_dump.c \
54	mdb_err.c \
55	mdb_evset.c \
56	mdb_fdio.c \
57	mdb_fmt.c \
58	mdb_frame.c \
59	mdb_gelf.c \
60	mdb_help.c \
61	mdb_io.c \
62	mdb_kb_kvm.c \
63	mdb_kproc.c \
64	mdb_kvm.c \
65	mdb_linkerset.c \
66	mdb_logio.c \
67	mdb_list.c \
68	mdb_macalias.c \
69	mdb_main.c \
70	mdb_memio.c \
71	mdb_modapi.c \
72	mdb_module.c \
73	mdb_module_load.c \
74	mdb_nm.c \
75	mdb_nv.c \
76	mdb_pipeio.c \
77	mdb_print.c \
78	mdb_proc.c \
79	mdb_pservice.c \
80	mdb_rawfile.c \
81	mdb_set.c \
82	mdb_shell.c \
83	mdb_signal.c \
84	mdb_stack.c \
85	mdb_stdlib.c \
86	mdb_string.c \
87	mdb_strio.c \
88	mdb_tab.c \
89	mdb_target.c \
90	mdb_tdb.c \
91	mdb_termio.c \
92	mdb_typedef.c \
93	mdb_umem.c \
94	mdb_value.c \
95	mdb_vcb.c \
96	mdb_walkers.c \
97	mdb_wcb.c \
98	mdb_whatis.c
99
100$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
101CPPFLAGS += -D_MDB -I. -I../.. -I../../../common
102
103CSTD=	$(CSTD_GNU99)
104
105LDLIBS += -lcurses -lkvm -lproc -lrtld_db -lctf -lumem -ldisasm -lscf
106LDLIBS += -ldemangle-sys
107
108CERRWARN += $(CNOWARN_UNINIT)
109CERRWARN += -_gcc=-Wno-char-subscripts
110CERRWARN += -_gcc=-Wno-clobbered
111CERRWARN += -_gcc=-Wno-parentheses
112CERRWARN += -_gcc=-Wno-unused-label
113CERRWARN += -_gcc=-Wno-unused-variable
114
115PROG = mdb
116OBJS = $(SRCS:%.c=%.o) mdb_lex.o mdb_grammar.o
117
118LINK = adb
119ROOTLINK = $(ROOTBIN)/$(LINK)
120ROOTLINK32 = $(LINK:%=$(ROOTBIN32)/%)
121ROOTLINK64 = $(LINK:%=$(ROOTBIN64)/%)
122
123.NO_PARALLEL:
124.PARALLEL: $(OBJS)
125
126all: $(PROG)
127
128$(PROG): $(OBJS)
129	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
130	$(CTFMERGE) -L VERSION -o $@ $(OBJS)
131	$(POST_PROCESS)
132
133$(ROOTLINK32): $(ROOTPROG32)
134	$(RM) $@
135	$(LN) $(ROOTPROG32) $@
136
137$(ROOTLINK64): $(ROOTPROG64)
138	$(RM) $@
139	$(LN) $(ROOTPROG64) $@
140
141mdb_lex.c: ../../../common/mdb/mdb_lex.l mdb_grammar.h
142	$(LEX) $(LFLAGS) ../../../common/mdb/mdb_lex.l > $@
143
144mdb_grammar.h mdb_grammar.c: ../../../common/mdb/mdb_grammar.y
145	$(YACC) $(YFLAGS) ../../../common/mdb/mdb_grammar.y
146	@$(MV) y.tab.h mdb_grammar.h
147	@$(MV) y.tab.c mdb_grammar.c
148
149mdb_lex.o mdb_grammar.o := CCVERBOSE =
150
151mdb_conf.o := CPPFLAGS += -DMDB_VERSION='$(MDB_VERSION)'
152
153inet_ntop.o := CPPFLAGS += -Dsnprintf=mdb_snprintf
154
155ffs.o ffs.ln := CPPFLAGS += -Dffs=mdb_ffs
156
157%.o: ../../../common/mdb/%.c
158	$(COMPILE.c) $<
159	$(CTFCONVERT_O)
160
161%.o: ../../mdb/%.c
162	$(COMPILE.c) $<
163	$(CTFCONVERT_O)
164
165%.o: %.c
166	$(COMPILE.c) $<
167	$(CTFCONVERT_O)
168
169%.o: $(SRC)/common/net/util/%.c
170	$(COMPILE.c) $<
171	$(CTFCONVERT_O)
172
173%.o: $(SRC)/common/util/%.c
174	$(COMPILE.c) $<
175	$(CTFCONVERT_O)
176
177clean:
178	$(RM) $(OBJS)
179	$(RM) mdb_lex.c mdb_grammar.c mdb_grammar.h y.tab.h y.tab.c y.output
180
181clobber: clean
182	$(RM) $(PROG)
183
184dmods:
185