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