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