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