1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12#
13# Copyright 2019, Joyent, Inc.
14#
15
16include $(SRC)/Makefile.master
17
18ROOTOPTPKG = $(ROOT)/opt/util-tests
19TESTDIR = $(ROOTOPTPKG)/tests/ctf
20
21SCRIPTS =	precheck.ksh \
22		ctftest.ksh \
23		ctftest-convert-non-c.ksh \
24		ctftest-convert-no-dwarf.ksh \
25		ctftest-merge-no-ctf.ksh \
26
27TESTS =		test-float.c \
28		test-reference.c \
29		test-int.c \
30		test-array.c \
31		test-enum.c \
32		test-forward.c \
33		test-sou.c \
34		test-function.c \
35		test-qualifiers.c \
36		test-merge-static/Makefile.ctftest \
37		test-merge-static/test-a.c \
38		test-merge-static/test-b.c \
39		test-merge-static/test-c.c \
40		test-merge-static/test-d.c \
41		test-merge-static/test-main.c \
42		test-merge-forward/Makefile.ctftest \
43		test-merge-forward/test-impl.c \
44		test-merge-forward/test-merge.c \
45		test-merge-dedup/Makefile.ctftest \
46		test-merge-dedup/test-merge-1.c \
47		test-merge-dedup/test-merge-2.c \
48		test-merge-dedup/test-merge-3.c \
49		test-merge-dedup/test-merge-dedup.c \
50		test-merge-reduction/Makefile.ctftest \
51		test-merge-reduction/mapfile-vers \
52		test-merge-reduction/test-global.c \
53		test-merge-reduction/test-scoped.c \
54		test-merge-weak/Makefile.ctftest \
55		test-merge-weak/test-merge-weak.c \
56		test-weak.c \
57		Makefile.ctftest.com
58
59MAKEDIRS =	test-merge-static \
60		test-merge-forward \
61		test-merge-dedup \
62		test-merge-reduction \
63		test-merge-weak
64
65CHECKS =	check-float-32 \
66		check-float-64 \
67		check-int-32 \
68		check-int-64 \
69		check-reference \
70		check-array \
71		check-enum \
72		check-sou-32 \
73		check-sou-64 \
74		check-forward-32 \
75		check-forward-64 \
76		check-function \
77		check-qualifiers \
78		check-merge-static \
79		check-merge-forward-32 \
80		check-merge-forward-64 \
81		check-merge-dedup \
82		check-merge-reduction \
83		check-merge-weak \
84		check-weak
85
86COMMON_OBJS =	check-common.o
87ALL_OBJS =	$(CHECKS:%=%.o) $(CHECKS:%-32=%.32.o) $(CHECKS:%-64=%.64.o) $(COMMON_OBJS)
88
89ROOTTESTS =	$(TESTS:%=$(TESTDIR)/%)
90ROOTMAKEDIRS =	$(MAKEDIRS:%=$(TESTDIR)/%)
91ROOTCHECKS =	$(CHECKS:%=$(TESTDIR)/%)
92ROOTSCRIPTS =	$(SCRIPTS:%.ksh=$(TESTDIR)/%)
93
94ROOTTESTS	:= FILEMODE =	0444
95ROOTCHECKS	:= FILEMODE =	0555
96ROOTSCRIPTS	:= FILEMODE =	0555
97
98include $(SRC)/cmd/Makefile.cmd
99include $(SRC)/test/Makefile.com
100
101CSTD = $(CSTD_GNU99)
102
103LDLIBS +=	-lctf
104
105check-merge-static :=	LDLIBS += -lelf
106
107all: $(CHECKS)
108
109install: all $(ROOTTESTS) $(ROOTCHECKS) $(ROOTSCRIPTS)
110
111$(CHECKS): $(COMMON_OBJS)
112
113clean:
114	$(RM) $(ALL_OBJS)
115
116clobber: clean
117	$(RM) $(CHECKS)
118
119$(ROOTTESTS): $(TESTDIR) $(ROOTMAKEDIRS) $(TESTS)
120$(ROOTCHECKS): $(TESTDIR) $(CHECKS)
121$(ROOTSCRIPTS): $(TESTDIR) $(SCRIPTS)
122
123$(TESTDIR):
124	$(INS.dir)
125
126$(ROOTMAKEDIRS):
127	$(INS.dir)
128
129$(TESTDIR)/%: %
130	$(INS.file)
131
132$(TESTDIR)/%: %.ksh
133	$(INS.rename)
134
135%.o: %.c
136	$(COMPILE.c) -o $@ $<
137	$(POST_PROCESS_O)
138
139%.32.o: %.c
140	$(COMPILE.c) -o $@ $<
141	$(POST_PROCESS_O)
142
143%.64.o: %.c
144	$(COMPILE.c) -DTARGET_LP64 -o $@ $<
145	$(POST_PROCESS_O)
146
147%-32: %.32.o
148	$(LINK.c) -o $@ $< $(COMMON_OBJS) $(LDLIBS)
149	$(POST_PROCESS)
150
151%-64: %.64.o
152	$(LINK.c) -o $@ $< $(COMMON_OBJS) $(LDLIBS)
153	$(POST_PROCESS)
154
155%: %.o
156	$(LINK.c) -o $@ $< $(COMMON_OBJS) $(LDLIBS)
157	$(POST_PROCESS)
158