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) $(LINTLIB) $(NATIVERELOC)
56 $(LINTLIB) := SRCS = ../$(LINTSRC)
59 GENSRC = opcodes.c parse.c
67 $(SRCDIR)/btree_rb.c \
85 $(SRCDIR)/tokenize.c \
94 MYCPPFLAGS = -D_REENTRANT -DTHREADSAFE=1 -DHAVE_USLEEP=1 -I. -I.. -I$(SRCDIR)
95 CPPFLAGS += $(MYCPPFLAGS)
97 CERRWARN += -_gcc=-Wno-implicit-function-declaration
98 CERRWARN += -_gcc=-Wno-uninitialized
99 CERRWARN += -_gcc=-Wno-unused-function
100 CERRWARN += -_gcc=-Wno-unused-label
102 MAPFILES = ../mapfile-sqlite
104 # headers generated here
105 GENHDR = opcodes.h parse.h
107 # Header files used by all library source files.
116 $(SRCDIR)/sqliteInt.h \
121 # Sources used for test harness
124 $(SRCDIR)/tclsqlite.c \
134 TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
136 TESTCLEAN = $(TESTOBJS) test.db test.tcl test1.bt test2.db testdb
139 # Native variant (needed by cmd/configd)
141 NATIVERELOC = libsqlite-native.o
142 NATIVEPROGS = testfixture
143 NATIVEOBJS = $(OBJS:%.o=%-native.o)
145 NATIVETARGETS = $(NATIVEPROGS) $(NATIVEOBJS) $(NATIVERELOC)
147 $(NATIVETARGETS) := CC = $(NATIVECC)
148 $(NATIVETARGETS) := LD = $(NATIVELD)
149 $(NATIVETARGETS) := CFLAGS = $(NATIVE_CFLAGS)
150 $(NATIVETARGETS) := CPPFLAGS = $(MYCPPFLAGS)
151 $(NATIVETARGETS) := LDFLAGS =
152 $(NATIVETARGETS) := LDLIBS = -lc
154 $(OBJS) := CFLAGS += $(CTF_FLAGS)
155 $(OBJS) := CTFCONVERT_POST = $(CTFCONVERT_O)
160 testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1
162 # work around compiler issues
164 testfixture := CFLAGS += \
165 -erroff=E_ARRAY_OF_INCOMPLETE \
166 -erroff=E_ARG_INCOMPATIBLE_WITH_ARG
168 testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl
188 .PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o)
191 # This is the default Makefile target. The objects listed here
192 # are what get build when you type just "make" with no arguments.
196 $(ROOTLIBDIR)/$(DYNLIB) \
197 $(ROOTLIBDIR)/$(LINTLIB) \
198 $(ROOTLIBDIR)/$(NATIVERELOC)
204 $(ROOTLIBDIR)/$(NATIVERELOC) := FILEMODE= 644
205 $(ROOTLINTDIR)/$(LINTLIB) := FILEMODE= 644
207 $(ROOTLINK): $(ROOTLIBDIR) $(ROOTLIBDIR)/$(DYNLIB)
210 $(ROOTLINTDIR)/%: ../%
213 native: $(NATIVERELOC)
215 $(NATIVERELOC): objs .WAIT $(OBJS:%.o=%-native.o)
216 $(LD) -r -o $(NATIVERELOC) $(OBJS:%.o=%-native.o)
218 opcodes.h: $(SRCDIR)/vdbe.c
219 @echo "Generating $@"; \
221 echo '/* Automatically generated file. Do not edit */' > $@ ; \
222 grep '^case OP_' $(SRCDIR)/vdbe.c | \
224 $(AWK) '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
226 opcodes.c: $(SRCDIR)/vdbe.c
227 @echo "Generating $@"; \
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/:.*$$/", /' >> $@ ; \
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) ;\
241 echo "$(TCLBASE)/include/tcl.h: not found."; \
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.
249 parse.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
255 -$(RM) parse.c parse.h
256 $(CP) parse_tmp.h parse.h
257 $(CP) parse_tmp.c parse.c
259 lemon: $(TOOLDIR)/lemon.c
260 $(NATIVECC) $(NATIVE_CFLAGS) -o $@ $(TOOLDIR)/lemon.c
262 objs/%-native.o: $(SRCDIR)/%.c $(GENHDR)
263 $(COMPILE.c) -o $@ $<
266 objs/%-native.o: %.c $(GENHDR)
267 $(COMPILE.c) -o $@ $<
270 objs/parse-native.o: parse.c $(GENHDR)
271 $(COMPILE.c) -o $@ parse.c
274 objs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR)
275 $(COMPILE.c) -o $@ $<
278 objs/%.o pics/%.o: %.c $(GENHDR)
279 $(COMPILE.c) -o $@ $<
282 # need direct rules for generated files
283 objs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR)
284 $(COMPILE.c) -o $@ opcodes.c
287 objs/parse.o pics/parse.o: parse.c $(GENHDR)
288 $(COMPILE.c) -o $@ parse.c
291 include $(SRC)/lib/Makefile.targ