xref: /illumos-gate/usr/src/lib/libsqlite/Makefile.com (revision 002c70ff32f5df6f93c15f88d351ce26443e6ee7)
1#
2# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
3# Use is subject to license terms.
4#
5#ident	"%Z%%M%	%I%	%E% SMI"
6#
7
8SQLITE_VERSION = 2.8.15-repcached
9
10LIBRARY = libsqlite.a
11RELOC = $(LIBRARY:%.a=%.o)
12
13VERS = .1
14OBJECTS = \
15	attach.o	\
16	auth.o		\
17	btree.o		\
18	btree_rb.o	\
19	build.o		\
20	copy.o		\
21	date.o		\
22	delete.o	\
23	encode.o	\
24	expr.o		\
25	func.o		\
26	hash.o		\
27	insert.o	\
28	main.o		\
29	opcodes.o	\
30	os.o		\
31	pager.o		\
32	parse.o		\
33	pragma.o	\
34	printf.o	\
35	random.o	\
36	select.o	\
37	table.o		\
38	tokenize.o	\
39	trigger.o	\
40	update.o	\
41	util.o		\
42	vacuum.o	\
43	vdbe.o		\
44	vdbeaux.o	\
45	where.o
46
47include $(SRC)/lib/Makefile.lib
48
49SRCDIR = ../src
50TOOLDIR = ../tool
51LIBS = $(RELOC) $(LINTLIB)
52
53$(LINTLIB) :=	SRCS = $(LINTSRC)
54
55SRCS = \
56	$(SRCDIR)/attach.c	\
57	$(SRCDIR)/auth.c	\
58	$(SRCDIR)/btree.c	\
59	$(SRCDIR)/btree_rb.c	\
60	$(SRCDIR)/build.c	\
61	$(SRCDIR)/copy.c	\
62	$(SRCDIR)/date.c	\
63	$(SRCDIR)/delete.c	\
64	$(SRCDIR)/encode.c	\
65	$(SRCDIR)/expr.c	\
66	$(SRCDIR)/func.c	\
67	$(SRCDIR)/hash.c	\
68	$(SRCDIR)/insert.c	\
69	$(SRCDIR)/main.c	\
70	opcodes.c		\
71	$(SRCDIR)/os.c		\
72	$(SRCDIR)/pager.c	\
73	parse.c			\
74	$(SRCDIR)/pragma.c	\
75	$(SRCDIR)/printf.c	\
76	$(SRCDIR)/random.c	\
77	$(SRCDIR)/select.c	\
78	$(SRCDIR)/table.c	\
79	$(SRCDIR)/tokenize.c	\
80	$(SRCDIR)/update.c	\
81	$(SRCDIR)/util.c	\
82	$(SRCDIR)/vacuum.c	\
83	$(SRCDIR)/vdbe.c	\
84	$(SRCDIR)/vdbeaux.c	\
85	$(SRCDIR)/where.c	\
86	$(SRCDIR)/trigger.c
87
88MYCPPFLAGS = -D_REENTRANT -DTHREADSAFE=1 -DHAVE_USLEEP=1 -I. -I.. -I$(SRCDIR)
89CPPFLAGS += $(MYCPPFLAGS)
90
91MAPFILE = ../mapfile-sqlite
92
93# Header files used by all library source files.
94#
95HDR = \
96	$(SRCDIR)/btree.h	\
97	$(SRCDIR)/config.h	\
98	$(SRCDIR)/hash.h	\
99	opcodes.h		\
100	$(SRCDIR)/os.h		\
101	parse.h			\
102	../sqlite.h		\
103	$(SRCDIR)/sqliteInt.h	\
104	$(SRCDIR)/vdbe.h	\
105	$(SRCDIR)/vdbeInt.h
106
107#
108# Sources used for test harness
109#
110TESTSRC = \
111	$(SRCDIR)/tclsqlite.c	\
112	$(SRCDIR)/btree.c	\
113	$(SRCDIR)/func.c	\
114	$(SRCDIR)/os.c		\
115	$(SRCDIR)/pager.c	\
116	$(SRCDIR)/test1.c	\
117	$(SRCDIR)/test2.c	\
118	$(SRCDIR)/test3.c	\
119	$(SRCDIR)/md5.c
120
121TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
122
123TESTCLEAN = $(TESTOBJS) test.db test.tcl test1.bt test2.db testdb
124
125#
126# Native variants
127#
128NATIVERELOC = $(RELOC:%.o=%-native.o)
129NATIVEPROGS = lemon-build testfixture
130NATIVEOBJS = lemon.o $(OBJS:%.o=%-native.o)
131
132NATIVETARGETS = $(NATIVEPROGS) $(NATIVEOBJS) $(NATIVERELOC)
133
134$(NATIVETARGETS) :=	CC = $(NATIVECC)
135$(NATIVETARGETS) :=	LD = $(NATIVELD)
136$(NATIVETARGETS) :=	CFLAGS = $(NATIVE_CFLAGS)
137$(NATIVETARGETS) :=	CPPFLAGS = $(MYCPPFLAGS)
138$(NATIVETARGETS) :=	LDFLAGS =
139$(NATIVETARGETS) :=	LDLIBS = -lc
140
141$(OBJS) :=		CFLAGS += $(CTF_FLAGS)
142$(OBJS) :=		CTFCONVERT_POST = $(CTFCONVERT_O)
143
144TCLBASE = /usr/sfw
145TCLVERS = tcl8.3
146
147testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1
148#
149# work around compiler issues
150#
151testfixture := CFLAGS += \
152	-erroff=E_ARRAY_OF_INCOMPLETE \
153	-erroff=E_ARG_INCOMPATIBLE_WITH_ARG
154
155testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl
156
157CLEANFILES += \
158	$(RELOC)	\
159	$(LINTLIB)	\
160	$(NATIVETARGETS) \
161	$(TESTCLEAN)	\
162	lemon		\
163	lemon.o		\
164	lempar.c	\
165	opcodes.c	\
166	opcodes.h	\
167	parse_tmp.c	\
168	parse_tmp.h	\
169	parse_tmp.out	\
170	parse_tmp.y	\
171	parse.c		\
172	parse.h
173
174ENCODING  = ISO8859
175
176LINTSRC=    ../llib-lsqlite
177
178
179.PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o)
180.KEEP_STATE:
181
182# This is the default Makefile target.  The objects listed here
183# are what get build when you type just "make" with no arguments.
184#
185all:		$(LIBS)
186install:	all $(ROOTLIBDIR)/$(RELOC) $(ROOTLIBDIR)/$(NATIVERELOC) \
187		$(ROOTLIBDIR)/llib-lsqlite.ln
188
189$(ROOTLIBDIR)/$(RELOC)		:= FILEMODE= 644
190$(ROOTLIBDIR)/$(NATIVERELOC)	:= FILEMODE= 644
191$(ROOTLIBDIR)/llib-lsqlite.ln	:= FILEMODE= 644
192
193$(ROOTLIBDIR)/%: %
194	$(INS.file)
195
196$(OBJS) $(OBJS:%.o=%-native.o): $(HDR)
197
198native: $(NATIVERELOC)
199
200$(RELOC): objs .WAIT $(OBJS)
201	$(LD) -r $(MAPFILE:%=-M%) -o $(RELOC) $(OBJS)
202	$(CTFMERGE) -t -f -L VERSION -o $(RELOC) $(OBJS)
203
204$(NATIVERELOC):	objs .WAIT $(OBJS:%.o=%-native.o)
205	$(LD) -r $(MAPFILE:%=-M%) -o $(NATIVERELOC) $(OBJS:%.o=%-native.o)
206
207opcodes.h: $(SRCDIR)/vdbe.c
208	@echo "Generating $@"; \
209	 $(RM) -f $@ ; \
210	 echo '/* Automatically generated file.  Do not edit */' > $@ ; \
211	 grep '^case OP_' $(SRCDIR)/vdbe.c | \
212	    sed -e 's/://' | \
213	    awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
214
215opcodes.c: $(SRCDIR)/vdbe.c
216	@echo "Generating $@"; \
217	 $(RM) -f $@ ; \
218	 echo '/* Automatically generated file.  Do not edit */' > $@ ; \
219	 echo 'char *sqliteOpcodeNames[] = { "???", ' >> $@ ; \
220	 grep '^case OP_' $(SRCDIR)/vdbe.c | \
221	    sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >> $@ ; \
222	 echo '};' >> $@
223
224#
225# We use a recursive invocation because otherwise pmake always rebuilds
226# everything, due to multiple expansions of "foo := A += B".
227#
228lemon:	FRC
229	$(MAKE) lemon-build
230
231lemon-build:	lemon.o $(TOOLDIR)/lempar.c
232	$(LINK.c) -o lemon lemon.o
233	$(RM) lempar.c
234	$(LN) -s $(TOOLDIR)/lempar.c lempar.c
235	$(RM) lemon-build
236	$(CP) lemon lemon-build
237
238testfixture: FRC
239	@if [ -f $(TCLBASE)/include/tcl.h ]; then \
240		unset SUNPRO_DEPENDENCIES; \
241		echo $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
242		exec $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
243	else \
244		echo "$(TCLBASE)/include/tcl.h: not found."; \
245		exit 1; \
246	fi
247
248parse_tmp.out: $(SRCDIR)/parse.y lemon
249	$(RM) parse_tmp.y
250	$(CP) $(SRCDIR)/parse.y parse_tmp.y
251	./lemon parse_tmp.y
252
253parse.h: parse_tmp.out
254	$(CP) parse_tmp.h parse.h
255
256parse.c: parse_tmp.out
257	$(CP) parse_tmp.c parse.c
258
259objs/%-native.o: $(SRCDIR)/%.c
260	$(COMPILE.c) -o $@ $<
261	$(POST_PROCESS_O)
262
263objs/%-native.o: %.c
264	$(COMPILE.c) -o $@ $<
265	$(POST_PROCESS_O)
266
267objs/parse-native.o: parse.c
268	$(COMPILE.c) -o $@ parse.c
269	$(POST_PROCESS_O)
270
271objs/%.o: %.c
272	$(COMPILE.c) -o $@ $<
273	$(POST_PROCESS_O)
274
275%.o: $(SRCDIR)/%.c
276	$(COMPILE.c) -o $@ $<
277	$(POST_PROCESS_O)
278
279%.o: $(TOOLDIR)/%.c
280	$(COMPILE.c) -o $@ $<
281	$(POST_PROCESS_O)
282
283include $(SRC)/lib/Makefile.targ
284
285FRC:
286