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