summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdtrace/Makefile.com
blob: 9a68e6729d04d830bbb9a8d0b9c16971fae01686 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2016 by Delphix. All rights reserved.
#
# Copyright (c) 2018, Joyent, Inc.

LIBRARY = libdtrace.a
VERS = .1

LIBSRCS = \
	dt_aggregate.c \
	dt_as.c \
	dt_buf.c \
	dt_cc.c \
	dt_cg.c \
	dt_consume.c \
	dt_decl.c \
	dt_dis.c \
	dt_dof.c \
	dt_error.c \
	dt_errtags.c \
	dt_sugar.c \
	dt_handle.c \
	dt_ident.c \
	dt_inttab.c \
	dt_link.c \
	dt_list.c \
	dt_open.c \
	dt_options.c \
	dt_program.c \
	dt_map.c \
	dt_module.c \
	dt_names.c \
	dt_parser.c \
	dt_pcb.c \
	dt_pid.c \
	dt_pq.c \
	dt_pragma.c \
	dt_print.c \
	dt_printf.c \
	dt_proc.c \
	dt_provider.c \
	dt_regset.c \
        dt_string.c \
	dt_strtab.c \
	dt_subr.c \
	dt_work.c \
	dt_xlator.c

LIBISASRCS = \
	dt_isadep.c

OBJECTS = dt_lex.o dt_grammar.o $(MACHOBJS) $(LIBSRCS:%.c=%.o) $(LIBISASRCS:%.c=%.o)

DRTISRCS = dlink_init.c dlink_common.c
DRTIOBJS = $(DRTISRCS:%.c=pics/%.o)
DRTIOBJ = drti.o

LIBDAUDITSRCS = dlink_audit.c dlink_common.c
LIBDAUDITOBJS = $(LIBDAUDITSRCS:%.c=pics/%.o)
LIBDAUDIT = libdtrace_forceload.so

DLINKSRCS = dlink_common.c dlink_init.c dlink_audit.c

DLIBSRCS += \
	errno.d \
	fc.d \
	io.d \
	ip.d \
	iscsit.d \
	mac.d \
	net.d \
	nfs.d \
	nfssrv.d \
	procfs.d \
	regs.d \
	sched.d \
	signal.d \
	scsi.d \
	smb.d \
	srp.d \
	sysevent.d \
	tcp.d \
	udp.d \
	unistd.d \
	vnd.d

include ../../Makefile.lib

SRCS = $(LIBSRCS:%.c=../common/%.c) $(LIBISASRCS:%.c=../$(MACH)/%.c)
LIBS = $(DYNLIB)

SRCDIR = ../common

CLEANFILES += dt_lex.c dt_grammar.c dt_grammar.h y.output
CLEANFILES += ../common/procfs.sed ../common/procfs.d
CLEANFILES += ../common/io.sed ../common/io.d
CLEANFILES += ../common/ip.sed ../common/ip.d
CLEANFILES += ../common/mac.sed ../common/mac.d
CLEANFILES += ../common/net.sed ../common/net.d
CLEANFILES += ../common/errno.d ../common/signal.d
CLEANFILES += ../common/dt_errtags.c ../common/dt_names.c
CLEANFILES += ../common/sysevent.sed ../common/sysevent.d
CLEANFILES += ../common/tcp.sed ../common/tcp.d
CLEANFILES += ../common/udp.sed ../common/udp.d
CLEANFILES += $(LIBDAUDITOBJS) $(DRTIOBJS)

CLOBBERFILES += $(LIBDAUDIT) drti.o

CPPFLAGS += -I../common -I.
CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS)

CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch

# not linted
SMATCH=off

YYCFLAGS =
LDLIBS += -lgen -lproc -lrtld_db -lnsl -lsocket -lctf -lelf -lc -lzonecfg
DRTILDLIBS = $(LDLIBS.lib) -lc
LIBDAUDITLIBS = $(LDLIBS.lib) -lmapmalloc -lc -lproc $(LDSTACKPROTECT)

yydebug := YYCFLAGS += -DYYDEBUG

LFLAGS = -t -v
YFLAGS = -d -v

ROOTDLIBDIR = $(ROOT)/usr/lib/dtrace
ROOTDLIBDIR64 = $(ROOT)/usr/lib/dtrace/64

ROOTDLIBS = $(DLIBSRCS:%=$(ROOTDLIBDIR)/%)
ROOTDOBJS = $(ROOTDLIBDIR)/$(DRTIOBJ) $(ROOTDLIBDIR)/$(LIBDAUDIT)
ROOTDOBJS64 = $(ROOTDLIBDIR64)/$(DRTIOBJ) $(ROOTDLIBDIR64)/$(LIBDAUDIT)

#
# We do not build drti.o with the stack protector as otherwise
# everything that uses dtrace -G may have a surprise stack protector
# requirement right now. While in theory this could be handled by libc,
# this will make the overall default transition smoother.
#
$(DRTIOBJ) := STACKPROTECT = none

$(ROOTDLIBDIR)/%.d := FILEMODE=444
$(ROOTDLIBDIR)/%.o := FILEMODE=444
$(ROOTDLIBDIR64)/%.o :=	FILEMODE=444
$(ROOTDLIBDIR)/%.so := FILEMODE=555
$(ROOTDLIBDIR64)/%.so := FILEMODE=555

.KEEP_STATE:

all: $(LIBS) $(DRTIOBJ) $(LIBDAUDIT)


dt_lex.c: $(SRCDIR)/dt_lex.l dt_grammar.h
	$(LEX) $(LFLAGS) $(SRCDIR)/dt_lex.l > $@

dt_grammar.c dt_grammar.h: $(SRCDIR)/dt_grammar.y
	$(YACC) $(YFLAGS) $(SRCDIR)/dt_grammar.y
	@mv y.tab.h dt_grammar.h
	@mv y.tab.c dt_grammar.c

pics/dt_lex.o pics/dt_grammar.o := CFLAGS += $(YYCFLAGS)
pics/dt_lex.o pics/dt_grammar.o := CFLAGS64 += $(YYCFLAGS)

pics/dt_lex.o pics/dt_grammar.o := CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
pics/dt_lex.o pics/dt_grammar.o := CCVERBOSE =

../common/dt_errtags.c: ../common/mkerrtags.sh ../common/dt_errtags.h
	sh ../common/mkerrtags.sh < ../common/dt_errtags.h > $@

../common/dt_names.c: ../common/mknames.sh $(SRC)/uts/common/sys/dtrace.h
	sh ../common/mknames.sh < $(SRC)/uts/common/sys/dtrace.h > $@

../common/errno.d: ../common/mkerrno.sh $(SRC)/uts/common/sys/errno.h
	sh ../common/mkerrno.sh < $(SRC)/uts/common/sys/errno.h > $@

../common/signal.d: ../common/mksignal.sh $(SRC)/uts/common/sys/iso/signal_iso.h
	sh ../common/mksignal.sh < $(SRC)/uts/common/sys/iso/signal_iso.h > $@

../common/%.sed: ../common/%.sed.in
	$(COMPILE.cpp) -D_KERNEL $< | tr -d ' ' | tr '"' '@' | \
	    sed 's/\&/\\\&/g' | grep '^s/' > $@

../common/procfs.d: ../common/procfs.sed ../common/procfs.d.in
	sed -f ../common/procfs.sed < ../common/procfs.d.in > $@

../common/io.d: ../common/io.sed ../common/io.d.in
	sed -f ../common/io.sed < ../common/io.d.in > $@

../common/ip.d: ../common/ip.sed ../common/ip.d.in
	sed -f ../common/ip.sed < ../common/ip.d.in > $@

../common/mac.d: ../common/mac.sed ../common/mac.d.in
	sed -f ../common/mac.sed < ../common/mac.d.in > $@

../common/net.d: ../common/net.sed ../common/net.d.in
	sed -f ../common/net.sed < ../common/net.d.in > $@

../common/sysevent.d: ../common/sysevent.sed ../common/sysevent.d.in
	sed -f ../common/sysevent.sed < ../common/sysevent.d.in > $@

../common/tcp.d: ..//common/tcp.sed ../common/tcp.d.in
	sed -f ../common/tcp.sed < ../common/tcp.d.in > $@

../common/udp.d: ../common/udp.sed ../common/udp.d.in
	sed -f ../common/udp.sed < ../common/udp.d.in > $@

pics/%.o: ../$(MACH)/%.c
	$(COMPILE.c) -o $@ $<
	$(POST_PROCESS_O)

pics/%.o: ../$(MACH)/%.s
	$(COMPILE.s) -o $@ $<
	$(POST_PROCESS_O)

$(DRTIOBJ): $(DRTIOBJS)
	$(LD) -o $@ -r $(BLOCAL) $(BREDUCE) $(DRTIOBJS)
	$(POST_PROCESS_O)

$(LIBDAUDIT): $(LIBDAUDITOBJS)
	$(LINK.c) -o $@ $(GSHARED) -h$(LIBDAUDIT) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
	    $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%) $(LIBDAUDITOBJS) \
	    $(LIBDAUDITLIBS)
	$(POST_PROCESS_SO)

$(ROOTDLIBDIR):
	$(INS.dir)

$(ROOTDLIBDIR64): $(ROOTDLIBDIR)
	$(INS.dir)

$(ROOTDLIBDIR)/%.d: ../common/%.d
	$(INS.file)

$(ROOTDLIBDIR)/%.d: ../$(MACH)/%.d
	$(INS.file)

$(ROOTDLIBDIR)/%.d: %.d
	$(INS.file)

$(ROOTDLIBDIR)/%.o: %.o
	$(INS.file)

$(ROOTDLIBDIR64)/%.o: %.o
	$(INS.file)

$(ROOTDLIBDIR)/%.so: %.so
	$(INS.file)

$(ROOTDLIBDIR64)/%.so: %.so
	$(INS.file)

$(ROOTDLIBS): $(ROOTDLIBDIR)

$(ROOTDOBJS): $(ROOTDLIBDIR)

$(ROOTDOBJS64): $(ROOTDLIBDIR64)

include ../../Makefile.targ