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