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