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# 8 9# Make the SO name unlikely to conflict with any other 10# libsqlite that might also be found on the system. 11LIBRARY = libsqlite-sys.a 12 13VERS = .2.8.15 14OBJECTS = \ 15 attach.o \ 16 auth.o \ 17 btree.o \ 18 btree_rb.o \ 19 build.o \ 20 copy.o \ 21 date.o \ 22 delete.o \ 23 encode.o \ 24 expr.o \ 25 func.o \ 26 hash.o \ 27 insert.o \ 28 main.o \ 29 opcodes.o \ 30 os.o \ 31 pager.o \ 32 parse.o \ 33 pragma.o \ 34 printf.o \ 35 random.o \ 36 select.o \ 37 table.o \ 38 tokenize.o \ 39 trigger.o \ 40 update.o \ 41 util.o \ 42 vacuum.o \ 43 vdbe.o \ 44 vdbeaux.o \ 45 where.o 46 47include $(SRC)/lib/Makefile.lib 48 49# install this library in the root filesystem 50include $(SRC)/lib/Makefile.rootfs 51 52SRCDIR = ../src 53TOOLDIR = ../tool 54$(DYNLIB) := LDLIBS += -lc 55LIBS = $(DYNLIB) $(LINTLIB) $(NATIVERELOC) 56 57$(LINTLIB) := SRCS = ../$(LINTSRC) 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 += -_gcc=-Wno-uninitialized 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 161TCLBASE = /usr/sfw 162TCLVERS = tcl8.3 163 164testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1 165# 166# work around compiler issues 167# 168testfixture := CFLAGS += \ 169 -erroff=E_ARRAY_OF_INCOMPLETE \ 170 -erroff=E_ARG_INCOMPATIBLE_WITH_ARG 171 172testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl 173 174CLEANFILES += \ 175 $(NATIVETARGETS) \ 176 $(TESTCLEAN) \ 177 lemon \ 178 lemon.o \ 179 lempar.c \ 180 opcodes.c \ 181 opcodes.h \ 182 parse_tmp.c \ 183 parse_tmp.h \ 184 parse_tmp.out \ 185 parse_tmp.y \ 186 parse.c \ 187 parse.h 188 189ENCODING = ISO8859 190 191 192.PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o) 193.KEEP_STATE: 194 195# This is the default Makefile target. The objects listed here 196# are what get build when you type just "make" with no arguments. 197# 198all: $(LIBS) 199install: all \ 200 $(ROOTLIBDIR)/$(DYNLIB) \ 201 $(ROOTLIBDIR)/$(LINTLIB) \ 202 $(ROOTLIBDIR)/$(NATIVERELOC) 203 204lint: 205 206all_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 217native: $(NATIVERELOC) 218 219$(NATIVERELOC): objs .WAIT $(OBJS:%.o=%-native.o) 220 $(LD) -r -o $(NATIVERELOC) $(OBJS:%.o=%-native.o) 221 222opcodes.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 230opcodes.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 239testfixture: 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. 253parse.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 263lemon: $(TOOLDIR)/lemon.c 264 $(NATIVECC) $(NATIVE_CFLAGS) -o $@ $(TOOLDIR)/lemon.c 265 266objs/%-native.o: $(SRCDIR)/%.c $(GENHDR) 267 $(COMPILE.c) -o $@ $< 268 $(POST_PROCESS_O) 269 270objs/%-native.o: %.c $(GENHDR) 271 $(COMPILE.c) -o $@ $< 272 $(POST_PROCESS_O) 273 274objs/parse-native.o: parse.c $(GENHDR) 275 $(COMPILE.c) -o $@ parse.c 276 $(POST_PROCESS_O) 277 278objs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR) 279 $(COMPILE.c) -o $@ $< 280 $(POST_PROCESS_O) 281 282objs/%.o pics/%.o: %.c $(GENHDR) 283 $(COMPILE.c) -o $@ $< 284 $(POST_PROCESS_O) 285 286# need direct rules for generated files 287objs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR) 288 $(COMPILE.c) -o $@ opcodes.c 289 $(POST_PROCESS_O) 290 291objs/parse.o pics/parse.o: parse.c $(GENHDR) 292 $(COMPILE.c) -o $@ parse.c 293 $(POST_PROCESS_O) 294 295include $(SRC)/lib/Makefile.targ 296 297FRC: 298