Makefile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ## Copyright (c) 2018 David Crawshaw <david@zentus.com>
  2. ##
  3. ## Permission to use, copy, modify, and distribute this software for any
  4. ## purpose with or without fee is hereby granted, provided that the above
  5. ## copyright notice and this permission notice appear in all copies.
  6. ##
  7. ## THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. ## WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. ## MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. ## ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. ## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. ## ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. ## OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. # This Makefile is simply for development purposes. Normally, when this package
  15. # is imported, Go will build the ./c/sqlite.c file that is included directly by
  16. # static.go. However this is pretty slow ~30s. When developing this is very
  17. # annoying. Use this Makefile to pre-build the sqlite3.o object and then build
  18. # the package with the build tag linksqlite3, which will ignore static.go and
  19. # use link.go instead to link against sqlite.o. This reduces compilation times
  20. # down to <3 sec!
  21. #
  22. # If you are using an editor that builds the project as you work on it, you'll
  23. # want to build the sqlite3.o object and tell your editor to use the
  24. # linksqlite3 go build tag when working on this project.
  25. # For vim-go, use the command `GoBuildTags linksqlite3` or
  26. # `let g:go_build_tags = # 'linksqlite3'`
  27. export GOFLAGS=-tags=linksqlite3
  28. .PHONY: clean all env test release
  29. all: sqlite3.o
  30. go build ./...
  31. test: sqlite3.o
  32. go test ./...
  33. test-race: sqlite3.o
  34. go test -race ./...
  35. env:
  36. go env
  37. ## This builds the package statically.
  38. release:
  39. go build -tags=!linksqlite3
  40. VPATH = ./c # Look in ./c for source files
  41. # !!! THESE DEFINES SHOULD MATCH sqlite.go for linux !!!
  42. CFLAGS += -std=c99
  43. CFLAGS += -DSQLITE_THREADSAFE=2
  44. CFLAGS += -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1
  45. CFLAGS += -DSQLITE_ENABLE_UNLOCK_NOTIFY
  46. CFLAGS += -DSQLITE_ENABLE_FTS5
  47. CFLAGS += -DSQLITE_ENABLE_RTREE
  48. CFLAGS += -DSQLITE_LIKE_DOESNT_MATCH_BLOBS
  49. CFLAGS += -DSQLITE_OMIT_DEPRECATED
  50. CFLAGS += -DSQLITE_ENABLE_JSON1
  51. CFLAGS += -DSQLITE_ENABLE_SESSION
  52. CFLAGS += -DSQLITE_ENABLE_SNAPSHOT
  53. CFLAGS += -DSQLITE_ENABLE_PREUPDATE_HOOK
  54. CFLAGS += -DSQLITE_USE_ALLOCA
  55. CFLAGS += -DSQLITE_ENABLE_COLUMN_METADATA
  56. CFLAGS += -DHAVE_USLEEP=1
  57. CFLAGS += -DSQLITE_DQS=0
  58. CFLAGS += -DSQLITE_ENABLE_GEOPOLY
  59. LDFLAGS = -ldl -lm
  60. # !!! THESE DEFINES SHOULD MATCH sqlite.go !!!
  61. sqlite3.o: sqlite3.c sqlite3.h sqlite3ext.h
  62. clean:
  63. rm -f sqlite3.o