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