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.
8 # Make the SO name unlikely to conflict with any other
9 # libsqlite that might also be found on the system.
10 LIBRARY = libsqlite-sys.a
46 include $(SRC)/lib/Makefile.lib
48 # install this library in the root filesystem
49 include $(SRC)/lib/Makefile.rootfs
53 $(DYNLIB) := LDLIBS += -lc
54 LIBS = $(DYNLIB) $(NATIVERELOC)
57 GENSRC = opcodes.c parse.c
65 $(SRCDIR)/btree_rb.c \
83 $(SRCDIR)/tokenize.c \
92 MYCPPFLAGS = -DTHREADSAFE=1 -DHAVE_USLEEP=1 -I. -I.. -I$(SRCDIR)
93 CPPFLAGS += $(MYCPPFLAGS)
95 CERRWARN += -Wno-implicit-function-declaration
96 CERRWARN += -Wno-uninitialized
97 CERRWARN += -Wno-unused-function
98 CERRWARN += -Wno-unused-label
100 MAPFILES = ../mapfile-sqlite
102 # headers generated here
103 GENHDR = opcodes.h parse.h
105 # Header files used by all library source files.
114 $(SRCDIR)/sqliteInt.h \
119 # Sources used for test harness
122 $(SRCDIR)/tclsqlite.c \
132 TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
134 TESTCLEAN = $(TESTOBJS) test.db test.tcl test1.bt test2.db testdb
137 # Native variant (needed by cmd/configd)
139 NATIVERELOC = libsqlite-native.o
140 NATIVEPROGS = testfixture
141 NATIVEOBJS = $(OBJS:%.o=%-native.o)
143 NATIVETARGETS = $(NATIVEPROGS) $(NATIVEOBJS) $(NATIVERELOC)
145 $(NATIVETARGETS) := CC = $(NATIVECC)
146 $(NATIVETARGETS) := LD = $(NATIVELD)
147 $(NATIVETARGETS) := CFLAGS = $(NATIVE_CFLAGS)
148 $(NATIVETARGETS) := CPPFLAGS = $(MYCPPFLAGS)
149 $(NATIVETARGETS) := LDFLAGS =
150 $(NATIVETARGETS) := LDLIBS = -lc
152 $(OBJS) := CFLAGS += $(CTF_FLAGS)
153 $(OBJS) := CTFCONVERT_POST = $(CTFCONVERT_O)
158 testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1
159 testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl
179 .PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o)
182 # This is the default Makefile target. The objects listed here
183 # are what get build when you type just "make" with no arguments.
187 $(ROOTLIBDIR)/$(DYNLIB) \
188 $(ROOTLIBDIR)/$(NATIVERELOC)
192 $(ROOTLIBDIR)/$(NATIVERELOC) := FILEMODE= 644
194 $(ROOTLINK): $(ROOTLIBDIR) $(ROOTLIBDIR)/$(DYNLIB)
197 native: $(NATIVERELOC)
199 $(NATIVERELOC): objs .WAIT $(OBJS:%.o=%-native.o)
200 $(LD) -r -o $(NATIVERELOC) $(OBJS:%.o=%-native.o)
202 opcodes.h: $(SRCDIR)/vdbe.c
203 @echo "Generating $@"; \
205 echo '/* Automatically generated file. Do not edit */' > $@ ; \
206 grep '^case OP_' $(SRCDIR)/vdbe.c | \
208 $(AWK) '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
210 opcodes.c: $(SRCDIR)/vdbe.c
211 @echo "Generating $@"; \
213 echo '/* Automatically generated file. Do not edit */' > $@ ; \
214 echo 'char *sqliteOpcodeNames[] = { "???", ' >> $@ ; \
215 grep '^case OP_' $(SRCDIR)/vdbe.c | \
216 sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >> $@ ; \
220 @if [ -f $(TCLBASE)/include/tcl.h ]; then \
221 unset SUNPRO_DEPENDENCIES; \
222 echo $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
223 exec $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
225 echo "$(TCLBASE)/include/tcl.h: not found."; \
229 # Prevent Makefile.lib $(PICS) := from adding PICFLAGS
230 # by building lemon in a recursive make invocation.
231 # Otherwise, this target causes a rebuild every time after
232 # the PICS target builds this one way, then lint the other.
233 parse.h parse.c : $(SRCDIR)/parse.y $(TOOLDIR)/lemon.c $(TOOLDIR)/lempar.c
234 -$(RM) parse_tmp.y lempar.c
235 $(CP) $(SRCDIR)/parse.y parse_tmp.y
236 $(CP) $(TOOLDIR)/lempar.c lempar.c
239 -$(RM) parse.c parse.h
240 $(CP) parse_tmp.h parse.h
241 $(CP) parse_tmp.c parse.c
243 lemon: $(TOOLDIR)/lemon.c
244 $(NATIVECC) $(NATIVE_CFLAGS) -o $@ $(TOOLDIR)/lemon.c
246 objs/%-native.o: $(SRCDIR)/%.c $(GENHDR)
247 $(COMPILE.c) -o $@ $<
250 objs/%-native.o: %.c $(GENHDR)
251 $(COMPILE.c) -o $@ $<
254 objs/parse-native.o: parse.c $(GENHDR)
255 $(COMPILE.c) -o $@ parse.c
258 objs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR)
259 $(COMPILE.c) -o $@ $<
262 objs/%.o pics/%.o: %.c $(GENHDR)
263 $(COMPILE.c) -o $@ $<
266 # need direct rules for generated files
267 objs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR)
268 $(COMPILE.c) -o $@ opcodes.c
271 objs/parse.o pics/parse.o: parse.c $(GENHDR)
272 $(COMPILE.c) -o $@ parse.c
275 include $(SRC)/lib/Makefile.targ