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 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26#
27
28LIBRARY = libdtrace.a
29VERS = .1
30
31LIBSRCS = \
32	dt_aggregate.c \
33	dt_as.c \
34	dt_buf.c \
35	dt_cc.c \
36	dt_cg.c \
37	dt_consume.c \
38	dt_decl.c \
39	dt_dis.c \
40	dt_dof.c \
41	dt_error.c \
42	dt_errtags.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_pragma.c \
58	dt_printf.c \
59	dt_proc.c \
60	dt_provider.c \
61	dt_regset.c \
62        dt_string.c \
63	dt_strtab.c \
64	dt_subr.c \
65	dt_work.c \
66	dt_xlator.c
67
68LIBISASRCS = \
69	dt_isadep.c
70
71OBJECTS = dt_lex.o dt_grammar.o $(MACHOBJS) $(LIBSRCS:%.c=%.o) $(LIBISASRCS:%.c=%.o)
72
73DRTISRC = drti.c
74DRTIOBJ = $(DRTISRC:%.c=%.o)
75
76DLIBSRCS += \
77	errno.d \
78	io.d \
79	ip.d \
80	procfs.d \
81	regs.d \
82	sched.d \
83	signal.d \
84	sysevent.d \
85	unistd.d
86
87include ../../Makefile.lib
88
89SRCS = $(LIBSRCS:%.c=../common/%.c) $(LIBISASRCS:%.c=../$(MACH)/%.c)
90LIBS = $(DYNLIB) $(LINTLIB)
91
92SRCDIR = ../common
93
94CLEANFILES += dt_lex.c dt_grammar.c dt_grammar.h y.output
95CLEANFILES += ../common/procfs.sed ../common/procfs.d
96CLEANFILES += ../common/io.sed ../common/io.d
97CLEANFILES += ../common/ip.sed ../common/ip.d
98CLEANFILES += ../common/errno.d ../common/signal.d
99CLEANFILES += ../common/dt_errtags.c ../common/dt_names.c
100CLEANFILES += ../common/sysevent.sed ../common/sysevent.d
101
102CLOBBERFILES += drti.o
103
104CPPFLAGS += -I../common -I.
105CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
106CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS)
107YYCFLAGS =
108LDLIBS += -lgen -lproc -lrtld_db -lctf -lelf -lc
109DRTILDLIBS = $(LDLIBS.lib) -lc
110
111yydebug := YYCFLAGS += -DYYDEBUG
112
113$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
114
115LFLAGS = -t -v
116YFLAGS = -d -v
117
118ROOTDLIBDIR = $(ROOT)/usr/lib/dtrace
119ROOTDLIBDIR64 = $(ROOT)/usr/lib/dtrace/64
120
121ROOTDLIBS = $(DLIBSRCS:%=$(ROOTDLIBDIR)/%)
122ROOTDOBJS = $(ROOTDLIBDIR)/$(DRTIOBJ)
123ROOTDOBJS64 = $(ROOTDLIBDIR64)/$(DRTIOBJ)
124
125.KEEP_STATE:
126
127all: $(LIBS) $(DRTIOBJ)
128
129lint: lintdrti lintcheck
130
131lintdrti: ../common/$(DRTISRC)
132	$(LINT.c) ../common/$(DRTISRC) $(DRTILDLIBS)
133
134dt_lex.c: $(SRCDIR)/dt_lex.l dt_grammar.h
135	$(LEX) $(LFLAGS) $(SRCDIR)/dt_lex.l > $@
136
137dt_grammar.c dt_grammar.h: $(SRCDIR)/dt_grammar.y
138	$(YACC) $(YFLAGS) $(SRCDIR)/dt_grammar.y
139	@mv y.tab.h dt_grammar.h
140	@mv y.tab.c dt_grammar.c
141
142pics/dt_lex.o pics/dt_grammar.o := CFLAGS += $(YYCFLAGS)
143pics/dt_lex.o pics/dt_grammar.o := CFLAGS64 += $(YYCFLAGS)
144
145pics/dt_lex.o pics/dt_grammar.o := CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
146pics/dt_lex.o pics/dt_grammar.o := CCVERBOSE =
147
148../common/dt_errtags.c: ../common/mkerrtags.sh ../common/dt_errtags.h
149	sh ../common/mkerrtags.sh < ../common/dt_errtags.h > $@
150
151../common/dt_names.c: ../common/mknames.sh $(SRC)/uts/common/sys/dtrace.h
152	sh ../common/mknames.sh < $(SRC)/uts/common/sys/dtrace.h > $@
153
154../common/errno.d: ../common/mkerrno.sh $(SRC)/uts/common/sys/errno.h
155	sh ../common/mkerrno.sh < $(SRC)/uts/common/sys/errno.h > $@
156
157../common/signal.d: ../common/mksignal.sh $(SRC)/uts/common/sys/iso/signal_iso.h
158	sh ../common/mksignal.sh < $(SRC)/uts/common/sys/iso/signal_iso.h > $@
159
160../common/%.sed: ../common/%.sed.in
161	$(COMPILE.cpp) -D_KERNEL $< | tr -d ' ' | tr '"' '@' | \
162	    sed 's/\&/\\\&/g' | grep '^s/' > $@
163
164../common/procfs.d: ../common/procfs.sed ../common/procfs.d.in
165	sed -f ../common/procfs.sed < ../common/procfs.d.in > $@
166
167../common/io.d: ../common/io.sed ../common/io.d.in
168	sed -f ../common/io.sed < ../common/io.d.in > $@
169
170../common/ip.d: ../common/ip.sed ../common/ip.d.in
171	sed -f ../common/ip.sed < ../common/ip.d.in > $@
172
173../common/sysevent.d: ../common/sysevent.sed ../common/sysevent.d.in
174	sed -f ../common/sysevent.sed < ../common/sysevent.d.in > $@
175
176pics/%.o: ../$(MACH)/%.c
177	$(COMPILE.c) -o $@ $<
178	$(POST_PROCESS_O)
179
180pics/%.o: ../$(MACH)/%.s
181	$(COMPILE.s) -o $@ $<
182	$(POST_PROCESS_O)
183
184%.o: ../common/%.c
185	$(COMPILE.c) -o $@ $<
186	$(POST_PROCESS_O)
187
188$(ROOTDLIBDIR):
189	$(INS.dir)
190
191$(ROOTDLIBDIR64): $(ROOTDLIBDIR)
192	$(INS.dir)
193
194$(ROOTDLIBDIR)/%.d: ../common/%.d
195	$(INS.file)
196
197$(ROOTDLIBDIR)/%.d: ../$(MACH)/%.d
198	$(INS.file)
199
200$(ROOTDLIBDIR)/%.d: %.d
201	$(INS.file)
202
203$(ROOTDLIBDIR)/%.o: %.o
204	$(INS.file)
205
206$(ROOTDLIBDIR64)/%.o: %.o
207	$(INS.file)
208
209$(ROOTDLIBS): $(ROOTDLIBDIR)
210
211$(ROOTDOBJS): $(ROOTDLIBDIR)
212
213$(ROOTDOBJS64): $(ROOTDLIBDIR64)
214
215include ../../Makefile.targ
216