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 (c) 2012 Joyent, Inc. All rights reserved.
  30 # Copyright 2018 Jason King
  31 #
  32 
  33 .KEEP_STATE:
  34 .SUFFIXES:
  35 
  36 SRCS += \
  37         ffs.c \
  38         mdb.c \
  39         mdb_addrvec.c \
  40         mdb_argvec.c \
  41         mdb_callb.c \
  42         mdb_cmdbuf.c \
  43         mdb_cmds.c \
  44         mdb_conf.c \
  45         mdb_context.c \
  46         mdb_create.c \
  47         mdb_ctf.c \
  48         mdb_ctf_open.c \
  49         mdb_debug.c \
  50         mdb_demangle.c \
  51         mdb_disasm.c \
  52         mdb_dump.c \
  53         mdb_err.c \
  54         mdb_evset.c \
  55         mdb_fdio.c \
  56         mdb_fmt.c \
  57         mdb_frame.c \
  58         mdb_gelf.c \
  59         mdb_help.c \
  60         mdb_io.c \
  61         mdb_kb_kvm.c \
  62         mdb_kproc.c \
  63         mdb_kvm.c \
  64         mdb_logio.c \
  65         mdb_list.c \
  66         mdb_macalias.c \
  67         mdb_main.c \
  68         mdb_memio.c \
  69         mdb_modapi.c \
  70         mdb_module.c \
  71         mdb_module_load.c \
  72         mdb_nm.c \
  73         mdb_nv.c \
  74         mdb_pipeio.c \
  75         mdb_print.c \
  76         mdb_proc.c \
  77         mdb_pservice.c \
  78         mdb_rawfile.c \
  79         mdb_set.c \
  80         mdb_shell.c \
  81         mdb_signal.c \
  82         mdb_stdlib.c \
  83         mdb_string.c \
  84         mdb_strio.c \
  85         mdb_tab.c \
  86         mdb_target.c \
  87         mdb_tdb.c \
  88         mdb_termio.c \
  89         mdb_typedef.c \
  90         mdb_umem.c \
  91         mdb_value.c \
  92         mdb_vcb.c \
  93         mdb_wcb.c \
  94         mdb_whatis.c
  95 
  96 $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
  97 CPPFLAGS += -D_MDB -I. -I../.. -I../../../common
  98 
  99 CSTD=   $(CSTD_GNU99)
 100 C99LMODE=       -Xc99=%all
 101 
 102 LDLIBS += -lcurses -lkvm -lproc -lrtld_db -lctf -lumem -ldisasm -lscf
 103 LDLIBS += -ldemangle-sys
 104 
 105 CERRWARN += -_gcc=-Wno-uninitialized
 106 CERRWARN += -_gcc=-Wno-char-subscripts
 107 CERRWARN += -_gcc=-Wno-clobbered
 108 CERRWARN += -_gcc=-Wno-parentheses
 109 CERRWARN += -_gcc=-Wno-unused-label
 110 CERRWARN += -_gcc=-Wno-unused-variable
 111 
 112 SMOFF += all_func_returns
 113 
 114 #
 115 # -erroff=E_INCONS_ARG_DECL2 works around a problem where lint gets confused
 116 # about how struct mdb_tgt_gregset is used in mdb_tgt_stack_f() and
 117 # mdb_tgt_stack_iter_f(). Will be resolved as part of fix for CR 6749868.
 118 #
 119 LINTFLAGS += -n -errtags=yes -erroff=E_INCONS_ARG_DECL2
 120 LINTFILES = $(SRCS:%.c=%.ln)
 121 
 122 PROG = mdb
 123 OBJS = $(SRCS:%.c=%.o) mdb_lex.o mdb_grammar.o
 124 
 125 LINK = adb
 126 ROOTLINK = $(ROOTBIN)/$(LINK)
 127 ROOTLINK32 = $(LINK:%=$(ROOTBIN32)/%)
 128 ROOTLINK64 = $(LINK:%=$(ROOTBIN64)/%)
 129 
 130 .NO_PARALLEL:
 131 .PARALLEL: $(OBJS) $(LINTFILES)
 132 
 133 all: $(PROG)
 134 
 135 $(PROG): $(OBJS)
 136         $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
 137         $(CTFMERGE) -L VERSION -o $@ $(OBJS)
 138         $(POST_PROCESS)
 139 
 140 $(ROOTLINK32): $(ROOTPROG32)
 141         $(RM) $@
 142         $(LN) $(ROOTPROG32) $@
 143 
 144 $(ROOTLINK64): $(ROOTPROG64)
 145         $(RM) $@
 146         $(LN) $(ROOTPROG64) $@
 147 
 148 mdb_lex.c: ../../../common/mdb/mdb_lex.l mdb_grammar.h
 149         $(LEX) $(LFLAGS) ../../../common/mdb/mdb_lex.l > $@
 150 
 151 mdb_grammar.h mdb_grammar.c: ../../../common/mdb/mdb_grammar.y
 152         $(YACC) $(YFLAGS) ../../../common/mdb/mdb_grammar.y
 153         @$(MV) y.tab.h mdb_grammar.h
 154         @$(MV) y.tab.c mdb_grammar.c
 155 
 156 mdb_lex.o mdb_grammar.o := CCVERBOSE =
 157 
 158 mdb_conf.o := CPPFLAGS += -DMDB_VERSION='$(MDB_VERSION)'
 159 
 160 inet_ntop.o := CPPFLAGS += -Dsnprintf=mdb_snprintf
 161 
 162 ffs.o ffs.ln := CPPFLAGS += -Dffs=mdb_ffs
 163 
 164 %.o: ../../../common/mdb/%.c
 165         $(COMPILE.c) $<
 166         $(CTFCONVERT_O)
 167 
 168 %.o: ../../mdb/%.c
 169         $(COMPILE.c) $<
 170         $(CTFCONVERT_O)
 171 
 172 %.o: %.c
 173         $(COMPILE.c) $<
 174         $(CTFCONVERT_O)
 175 
 176 %.o: $(SRC)/common/net/util/%.c
 177         $(COMPILE.c) $<
 178         $(CTFCONVERT_O)
 179 
 180 %.o: $(SRC)/common/util/%.c
 181         $(COMPILE.c) $<
 182         $(CTFCONVERT_O)
 183 
 184 clean.lint:
 185         $(RM) $(LINTFILES)
 186 
 187 clean:
 188         $(RM) $(OBJS)
 189         $(RM) mdb_lex.c mdb_grammar.c mdb_grammar.h y.tab.h y.tab.c y.output
 190 
 191 clobber: clean clean.lint
 192         $(RM) $(PROG)
 193 
 194 %.ln: ../../../common/mdb/%.c
 195         $(LINT.c) -c $<
 196 
 197 %.ln: ../../mdb/%.c
 198         $(LINT.c) -c $<
 199 
 200 %.ln: %.c
 201         $(LINT.c) -c $<
 202 
 203 %.ln: $(SRC)/common/net/util/%.c
 204         $(LINT.c) -c $<
 205 
 206 %.ln: $(SRC)/common/util/%.c
 207         $(LINT.c) -c $<
 208 
 209 lint: $(LINTFILES)
 210         $(LINT) $(LINTFLAGS) $(LINTFILES)
 211 
 212 dmods: