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