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) 2018, Joyent, Inc.
9 # Make the SO name unlikely to conflict with any other
10 # libsqlite that might also be found on the system.
11 LIBRARY = libsqlite-sys.a
47 include $(SRC)/lib/Makefile.lib
49 # install this library in the root filesystem
50 include $(SRC)/lib/Makefile.rootfs
54 $(DYNLIB) := LDLIBS += -lc
55 LIBS = $(DYNLIB) $(NATIVERELOC)
58 GENSRC = opcodes.c parse.c
66 $(SRCDIR)/btree_rb.c \
84 $(SRCDIR)/tokenize.c \
93 MYCPPFLAGS = -DTHREADSAFE=1 -DHAVE_USLEEP=1 -I. -I.. -I$(SRCDIR)
94 CPPFLAGS += $(MYCPPFLAGS)
96 CERRWARN += -Wno-implicit-function-declaration
97 CERRWARN += -Wno-uninitialized
98 CERRWARN += -Wno-unused-function
99 CERRWARN += -Wno-unused-label
104 MAPFILES = ../mapfile-sqlite
106 # headers generated here
107 GENHDR = opcodes.h parse.h
109 # Header files used by all library source files.
118 $(SRCDIR)/sqliteInt.h \
123 # Sources used for test harness
126 $(SRCDIR)/tclsqlite.c \
136 TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
138 TESTCLEAN = $(TESTOBJS) test.db test.tcl test1.bt test2.db testdb
141 # Native variant (needed by cmd/configd)
143 NATIVERELOC = libsqlite-native.o
144 NATIVEPROGS = testfixture
145 NATIVEOBJS = $(OBJS:%.o=%-native.o)
147 NATIVETARGETS = $(NATIVEPROGS) $(NATIVEOBJS) $(NATIVERELOC)
149 $(NATIVETARGETS) := CC = $(NATIVECC)
150 $(NATIVETARGETS) := LD = $(NATIVELD)
151 $(NATIVETARGETS) := CFLAGS = $(NATIVE_CFLAGS)
152 $(NATIVETARGETS) := CPPFLAGS = $(MYCPPFLAGS)
153 $(NATIVETARGETS) := LDFLAGS =
154 $(NATIVETARGETS) := LDLIBS = -lc
156 $(OBJS) := CFLAGS += $(CTF_FLAGS)
157 $(OBJS) := CTFCONVERT_POST = $(CTFCONVERT_O)
162 testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1
163 testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl
183 .PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o)
186 # This is the default Makefile target. The objects listed here
187 # are what get build when you type just "make" with no arguments.
191 $(ROOTLIBDIR)/$(DYNLIB) \
192 $(ROOTLIBDIR)/$(NATIVERELOC)
196 $(ROOTLIBDIR)/$(NATIVERELOC) := FILEMODE= 644
198 $(ROOTLINK): $(ROOTLIBDIR) $(ROOTLIBDIR)/$(DYNLIB)
201 native: $(NATIVERELOC)
203 $(NATIVERELOC): objs .WAIT $(OBJS:%.o=%-native.o)
204 $(LD) -r -o $(NATIVERELOC) $(OBJS:%.o=%-native.o)
206 opcodes.h: $(SRCDIR)/vdbe.c
207 @echo "Generating $@"; \
209 echo '/* Automatically generated file. Do not edit */' > $@ ; \
210 grep '^case OP_' $(SRCDIR)/vdbe.c | \
212 $(AWK) '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
214 opcodes.c: $(SRCDIR)/vdbe.c
215 @echo "Generating $@"; \
217 echo '/* Automatically generated file. Do not edit */' > $@ ; \
218 echo 'char *sqliteOpcodeNames[] = { "???", ' >> $@ ; \
219 grep '^case OP_' $(SRCDIR)/vdbe.c | \
220 sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >> $@ ; \
224 @if [ -f $(TCLBASE)/include/tcl.h ]; then \
225 unset SUNPRO_DEPENDENCIES; \
226 echo $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
227 exec $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
229 echo "$(TCLBASE)/include/tcl.h: not found."; \
233 # Prevent Makefile.lib $(PICS) := from adding PICFLAGS
234 # by building lemon in a recursive make invocation.
235 # Otherwise, this target causes a rebuild every time after
236 # the PICS target builds this one way, then lint the other.
237 parse.h parse.c : $(SRCDIR)/parse.y $(TOOLDIR)/lemon.c $(TOOLDIR)/lempar.c
238 -$(RM) parse_tmp.y lempar.c
239 $(CP) $(SRCDIR)/parse.y parse_tmp.y
240 $(CP) $(TOOLDIR)/lempar.c lempar.c
243 -$(RM) parse.c parse.h
244 $(CP) parse_tmp.h parse.h
245 $(CP) parse_tmp.c parse.c
247 lemon: $(TOOLDIR)/lemon.c
248 $(NATIVECC) $(NATIVE_CFLAGS) -o $@ $(TOOLDIR)/lemon.c
250 objs/%-native.o: $(SRCDIR)/%.c $(GENHDR)
251 $(COMPILE.c) -o $@ $<
254 objs/%-native.o: %.c $(GENHDR)
255 $(COMPILE.c) -o $@ $<
258 objs/parse-native.o: parse.c $(GENHDR)
259 $(COMPILE.c) -o $@ parse.c
262 objs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR)
263 $(COMPILE.c) -o $@ $<
266 objs/%.o pics/%.o: %.c $(GENHDR)
267 $(COMPILE.c) -o $@ $<
270 # need direct rules for generated files
271 objs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR)
272 $(COMPILE.c) -o $@ opcodes.c
275 objs/parse.o pics/parse.o: parse.c $(GENHDR)
276 $(COMPILE.c) -o $@ parse.c
279 include $(SRC)/lib/Makefile.targ