2 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 # Use is subject to license terms.
4 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
7 # Make the SO name unlikely to conflict with any other
8 # libsqlite that might also be found on the system.
9 LIBRARY = libsqlite-sys.a
45 include $(SRC)/lib/Makefile.lib
47 # install this library in the root filesystem
48 include $(SRC)/lib/Makefile.rootfs
52 $(DYNLIB) := LDLIBS += -lc
53 LIBS = $(DYNLIB) $(LINTLIB) $(NATIVERELOC)
55 $(LINTLIB) := SRCS = ../$(LINTSRC)
58 GENSRC = opcodes.c parse.c
66 $(SRCDIR)/btree_rb.c \
84 $(SRCDIR)/tokenize.c \
93 MYCPPFLAGS = -D_REENTRANT -DTHREADSAFE=1 -DHAVE_USLEEP=1 -I. -I.. -I$(SRCDIR)
94 CPPFLAGS += $(MYCPPFLAGS)
96 CERRWARN += -_gcc=-Wno-implicit-function-declaration
97 CERRWARN += -_gcc=-Wno-uninitialized
98 CERRWARN += -_gcc=-Wno-unused-function
99 CERRWARN += -_gcc=-Wno-unused-label
101 MAPFILES = ../mapfile-sqlite
103 # headers generated here
104 GENHDR = opcodes.h parse.h
106 # Header files used by all library source files.
115 $(SRCDIR)/sqliteInt.h \
120 # Sources used for test harness
123 $(SRCDIR)/tclsqlite.c \
133 TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
135 TESTCLEAN = $(TESTOBJS) test.db test.tcl test1.bt test2.db testdb
138 # Native variant (needed by cmd/configd)
140 NATIVERELOC = libsqlite-native.o
141 NATIVEPROGS = testfixture
142 NATIVEOBJS = $(OBJS:%.o=%-native.o)
144 NATIVETARGETS = $(NATIVEPROGS) $(NATIVEOBJS) $(NATIVERELOC)
146 $(NATIVETARGETS) := CC = $(NATIVECC)
147 $(NATIVETARGETS) := LD = $(NATIVELD)
148 $(NATIVETARGETS) := CFLAGS = $(NATIVE_CFLAGS)
149 $(NATIVETARGETS) := CPPFLAGS = $(MYCPPFLAGS)
150 $(NATIVETARGETS) := LDFLAGS =
151 $(NATIVETARGETS) := LDLIBS = -lc
153 $(OBJS) := CFLAGS += $(CTF_FLAGS)
154 $(OBJS) := CTFCONVERT_POST = $(CTFCONVERT_O)
159 testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1
161 # work around compiler issues
163 testfixture := CFLAGS += \
164 -erroff=E_ARRAY_OF_INCOMPLETE \
165 -erroff=E_ARG_INCOMPATIBLE_WITH_ARG
167 testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl
187 .PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o)
190 # This is the default Makefile target. The objects listed here
191 # are what get build when you type just "make" with no arguments.
195 $(ROOTLIBDIR)/$(DYNLIB) \
196 $(ROOTLIBDIR)/$(LINTLIB) \
197 $(ROOTLIBDIR)/$(NATIVERELOC)
203 $(ROOTLIBDIR)/$(NATIVERELOC) := FILEMODE= 644
204 $(ROOTLINTDIR)/$(LINTLIB) := FILEMODE= 644
206 $(ROOTLINK): $(ROOTLIBDIR) $(ROOTLIBDIR)/$(DYNLIB)
209 $(ROOTLINTDIR)/%: ../%
212 native: $(NATIVERELOC)
214 $(NATIVERELOC): objs .WAIT $(OBJS:%.o=%-native.o)
215 $(LD) -r -o $(NATIVERELOC) $(OBJS:%.o=%-native.o)
217 opcodes.h: $(SRCDIR)/vdbe.c
218 @echo "Generating $@"; \
220 echo '/* Automatically generated file. Do not edit */' > $@ ; \
221 grep '^case OP_' $(SRCDIR)/vdbe.c | \
223 $(AWK) '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
225 opcodes.c: $(SRCDIR)/vdbe.c
226 @echo "Generating $@"; \
228 echo '/* Automatically generated file. Do not edit */' > $@ ; \
229 echo 'char *sqliteOpcodeNames[] = { "???", ' >> $@ ; \
230 grep '^case OP_' $(SRCDIR)/vdbe.c | \
231 sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >> $@ ; \
235 @if [ -f $(TCLBASE)/include/tcl.h ]; then \
236 unset SUNPRO_DEPENDENCIES; \
237 echo $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
238 exec $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
240 echo "$(TCLBASE)/include/tcl.h: not found."; \
244 parse.h parse.c : $(SRCDIR)/parse.y $(TOOLDIR)/lemon.c $(TOOLDIR)/lempar.c
245 -$(RM) parse_tmp.y lempar.c
246 $(CP) $(SRCDIR)/parse.y parse_tmp.y
247 $(CP) $(TOOLDIR)/lempar.c lempar.c
248 $(NATIVECC) $(NATIVE_CFLAGS) -o lemon $(TOOLDIR)/lemon.c
250 -$(RM) parse.c parse.h
251 $(CP) parse_tmp.h parse.h
252 $(CP) parse_tmp.c parse.c
254 objs/%-native.o: $(SRCDIR)/%.c $(GENHDR)
255 $(COMPILE.c) -o $@ $<
258 objs/%-native.o: %.c $(GENHDR)
259 $(COMPILE.c) -o $@ $<
262 objs/parse-native.o: parse.c $(GENHDR)
263 $(COMPILE.c) -o $@ parse.c
266 objs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR)
267 $(COMPILE.c) -o $@ $<
270 objs/%.o pics/%.o: %.c $(GENHDR)
271 $(COMPILE.c) -o $@ $<
274 # need direct rules for generated files
275 objs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR)
276 $(COMPILE.c) -o $@ opcodes.c
279 objs/parse.o pics/parse.o: parse.c $(GENHDR)
280 $(COMPILE.c) -o $@ parse.c
283 include $(SRC)/lib/Makefile.targ