xref: /illumos-gate/usr/src/lib/libdtrace/Makefile.com (revision 2a1fd0ffe121888d44fdec321c25b53dcfaa9118)
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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23# Copyright (c) 2011, 2016 by Delphix. All rights reserved.
24#
25# Copyright (c) 2018, Joyent, Inc.
26
27LIBRARY = libdtrace.a
28VERS = .1
29
30LIBSRCS = \
31	dt_aggregate.c \
32	dt_as.c \
33	dt_buf.c \
34	dt_cc.c \
35	dt_cg.c \
36	dt_consume.c \
37	dt_decl.c \
38	dt_dis.c \
39	dt_dof.c \
40	dt_error.c \
41	dt_errtags.c \
42	dt_sugar.c \
43	dt_handle.c \
44	dt_ident.c \
45	dt_inttab.c \
46	dt_link.c \
47	dt_list.c \
48	dt_open.c \
49	dt_options.c \
50	dt_program.c \
51	dt_map.c \
52	dt_module.c \
53	dt_names.c \
54	dt_parser.c \
55	dt_pcb.c \
56	dt_pid.c \
57	dt_pq.c \
58	dt_pragma.c \
59	dt_print.c \
60	dt_printf.c \
61	dt_proc.c \
62	dt_provider.c \
63	dt_regset.c \
64        dt_string.c \
65	dt_strtab.c \
66	dt_subr.c \
67	dt_work.c \
68	dt_xlator.c
69
70LIBISASRCS = \
71	dt_isadep.c
72
73OBJECTS = dt_lex.o dt_grammar.o $(MACHOBJS) $(LIBSRCS:%.c=%.o) $(LIBISASRCS:%.c=%.o)
74
75DRTISRCS = dlink_init.c dlink_common.c
76DRTIOBJS = $(DRTISRCS:%.c=pics/%.o)
77DRTIOBJ = drti.o
78
79LIBDAUDITSRCS = dlink_audit.c dlink_common.c
80LIBDAUDITOBJS = $(LIBDAUDITSRCS:%.c=pics/%.o)
81LIBDAUDIT = libdtrace_forceload.so
82
83DLINKSRCS = dlink_common.c dlink_init.c dlink_audit.c
84
85DLIBSRCS += \
86	errno.d \
87	fc.d \
88	io.d \
89	ip.d \
90	iscsit.d \
91	net.d \
92	nfs.d \
93	nfssrv.d \
94	procfs.d \
95	regs.d \
96	sched.d \
97	signal.d \
98	scsi.d \
99	srp.d \
100	sysevent.d \
101	tcp.d \
102	udp.d \
103	unistd.d
104
105include ../../Makefile.lib
106
107SRCS = $(LIBSRCS:%.c=../common/%.c) $(LIBISASRCS:%.c=../$(MACH)/%.c)
108LIBS = $(DYNLIB) $(LINTLIB)
109
110SRCDIR = ../common
111
112CLEANFILES += dt_lex.c dt_grammar.c dt_grammar.h y.output
113CLEANFILES += ../common/procfs.sed ../common/procfs.d
114CLEANFILES += ../common/io.sed ../common/io.d
115CLEANFILES += ../common/ip.sed ../common/ip.d
116CLEANFILES += ../common/net.sed ../common/net.d
117CLEANFILES += ../common/errno.d ../common/signal.d
118CLEANFILES += ../common/dt_errtags.c ../common/dt_names.c
119CLEANFILES += ../common/sysevent.sed ../common/sysevent.d
120CLEANFILES += ../common/tcp.sed ../common/tcp.d
121CLEANFILES += ../common/udp.sed ../common/udp.d
122CLEANFILES += $(LIBDAUDITOBJS) $(DRTIOBJS)
123
124CLOBBERFILES += $(LIBDAUDIT) drti.o
125
126CPPFLAGS += -I../common -I.
127CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
128CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS)
129
130CERRWARN += -_gcc=-Wno-unused-label
131CERRWARN += -_gcc=-Wno-unused-variable
132CERRWARN += -_gcc=-Wno-parentheses
133CERRWARN += -_gcc=-Wno-uninitialized
134CERRWARN += -_gcc=-Wno-switch
135
136# not linted
137SMATCH=off
138
139YYCFLAGS =
140LDLIBS += -lgen -lproc -lrtld_db -lnsl -lsocket -lctf -lelf -lc
141DRTILDLIBS = $(LDLIBS.lib) -lc
142LIBDAUDITLIBS = $(LDLIBS.lib) -lmapmalloc -lc -lproc
143
144yydebug := YYCFLAGS += -DYYDEBUG
145
146$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
147
148LFLAGS = -t -v
149YFLAGS = -d -v
150
151ROOTDLIBDIR = $(ROOT)/usr/lib/dtrace
152ROOTDLIBDIR64 = $(ROOT)/usr/lib/dtrace/64
153
154ROOTDLIBS = $(DLIBSRCS:%=$(ROOTDLIBDIR)/%)
155ROOTDOBJS = $(ROOTDLIBDIR)/$(DRTIOBJ) $(ROOTDLIBDIR)/$(LIBDAUDIT)
156ROOTDOBJS64 = $(ROOTDLIBDIR64)/$(DRTIOBJ) $(ROOTDLIBDIR64)/$(LIBDAUDIT)
157
158$(ROOTDLIBDIR)/%.d := FILEMODE=444
159$(ROOTDLIBDIR)/%.o := FILEMODE=444
160$(ROOTDLIBDIR64)/%.o :=	FILEMODE=444
161$(ROOTDLIBDIR)/%.so := FILEMODE=555
162$(ROOTDLIBDIR64)/%.so := FILEMODE=555
163
164.KEEP_STATE:
165
166all: $(LIBS) $(DRTIOBJ) $(LIBDAUDIT)
167
168lint: lintdlink lintcheck
169
170lintdlink: $(DLINKSRCS:%.c=../common/%.c)
171	$(LINT.c) $(DLINKSRCS:%.c=../common/%.c) $(DRTILDLIBS)
172
173dt_lex.c: $(SRCDIR)/dt_lex.l dt_grammar.h
174	$(LEX) $(LFLAGS) $(SRCDIR)/dt_lex.l > $@
175
176dt_grammar.c dt_grammar.h: $(SRCDIR)/dt_grammar.y
177	$(YACC) $(YFLAGS) $(SRCDIR)/dt_grammar.y
178	@mv y.tab.h dt_grammar.h
179	@mv y.tab.c dt_grammar.c
180
181pics/dt_lex.o pics/dt_grammar.o := CFLAGS += $(YYCFLAGS)
182pics/dt_lex.o pics/dt_grammar.o := CFLAGS64 += $(YYCFLAGS)
183
184pics/dt_lex.o pics/dt_grammar.o := CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
185pics/dt_lex.o pics/dt_grammar.o := CCVERBOSE =
186
187../common/dt_errtags.c: ../common/mkerrtags.sh ../common/dt_errtags.h
188	sh ../common/mkerrtags.sh < ../common/dt_errtags.h > $@
189
190../common/dt_names.c: ../common/mknames.sh $(SRC)/uts/common/sys/dtrace.h
191	sh ../common/mknames.sh < $(SRC)/uts/common/sys/dtrace.h > $@
192
193../common/errno.d: ../common/mkerrno.sh $(SRC)/uts/common/sys/errno.h
194	sh ../common/mkerrno.sh < $(SRC)/uts/common/sys/errno.h > $@
195
196../common/signal.d: ../common/mksignal.sh $(SRC)/uts/common/sys/iso/signal_iso.h
197	sh ../common/mksignal.sh < $(SRC)/uts/common/sys/iso/signal_iso.h > $@
198
199../common/%.sed: ../common/%.sed.in
200	$(COMPILE.cpp) -D_KERNEL $< | tr -d ' ' | tr '"' '@' | \
201	    sed 's/\&/\\\&/g' | grep '^s/' > $@
202
203../common/procfs.d: ../common/procfs.sed ../common/procfs.d.in
204	sed -f ../common/procfs.sed < ../common/procfs.d.in > $@
205
206../common/io.d: ../common/io.sed ../common/io.d.in
207	sed -f ../common/io.sed < ../common/io.d.in > $@
208
209../common/ip.d: ../common/ip.sed ../common/ip.d.in
210	sed -f ../common/ip.sed < ../common/ip.d.in > $@
211
212../common/net.d: ../common/net.sed ../common/net.d.in
213	sed -f ../common/net.sed < ../common/net.d.in > $@
214
215../common/sysevent.d: ../common/sysevent.sed ../common/sysevent.d.in
216	sed -f ../common/sysevent.sed < ../common/sysevent.d.in > $@
217
218../common/tcp.d: ..//common/tcp.sed ../common/tcp.d.in
219	sed -f ../common/tcp.sed < ../common/tcp.d.in > $@
220
221../common/udp.d: ../common/udp.sed ../common/udp.d.in
222	sed -f ../common/udp.sed < ../common/udp.d.in > $@
223
224pics/%.o: ../$(MACH)/%.c
225	$(COMPILE.c) -o $@ $<
226	$(POST_PROCESS_O)
227
228pics/%.o: ../$(MACH)/%.s
229	$(COMPILE.s) -o $@ $<
230	$(POST_PROCESS_O)
231
232$(DRTIOBJ): $(DRTIOBJS)
233	$(LD) -o $@ -r -Blocal -Breduce $(DRTIOBJS)
234	$(POST_PROCESS_O)
235
236$(LIBDAUDIT): $(LIBDAUDITOBJS)
237	$(LINK.c) -o $@ $(GSHARED) -h$(LIBDAUDIT) $(ZTEXT) $(ZDEFS) $(BDIRECT) \
238	    $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) $(LIBDAUDITOBJS) \
239	    $(LIBDAUDITLIBS)
240	$(POST_PROCESS_SO)
241
242$(ROOTDLIBDIR):
243	$(INS.dir)
244
245$(ROOTDLIBDIR64): $(ROOTDLIBDIR)
246	$(INS.dir)
247
248$(ROOTDLIBDIR)/%.d: ../common/%.d
249	$(INS.file)
250
251$(ROOTDLIBDIR)/%.d: ../$(MACH)/%.d
252	$(INS.file)
253
254$(ROOTDLIBDIR)/%.d: %.d
255	$(INS.file)
256
257$(ROOTDLIBDIR)/%.o: %.o
258	$(INS.file)
259
260$(ROOTDLIBDIR64)/%.o: %.o
261	$(INS.file)
262
263$(ROOTDLIBDIR)/%.so: %.so
264	$(INS.file)
265
266$(ROOTDLIBDIR64)/%.so: %.so
267	$(INS.file)
268
269$(ROOTDLIBS): $(ROOTDLIBDIR)
270
271$(ROOTDOBJS): $(ROOTDLIBDIR)
272
273$(ROOTDOBJS64): $(ROOTDLIBDIR64)
274
275include ../../Makefile.targ
276