Skip to content

Commit 00b126b

Browse files
authored
Allow using system-wide or custom sqlite3 installation (#186)
This allows using engines built by other projects. For example with https://www.zetetic.net/sqlcipher or https://www.sqlite.org/see/doc/trunk/www/readme.wiki
1 parent 8dbf88b commit 00b126b

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

Makefile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,32 @@
1616
# LDFLAGS linker flags for linking all binaries
1717
#
1818

19-
SRC = $(wildcard c_src/*.c)
20-
HEADERS = $(wildcard c_src/*.h)
19+
SRC = c_src/sqlite3_nif.c
20+
HEADERS = c_src/utf8.h
21+
22+
ifeq ($(EXQLITE_USE_SYSTEM),)
23+
SRC += c_src/sqlite3.c
24+
HEADERS += c_src/sqlite3.h c_src/sqlite3ext.h
25+
CFLAGS += -Ic_src
26+
else
27+
ifneq ($(EXQLITE_SYSTEM_CFLAGS),)
28+
CFLAGS += $(EXQLITE_SYSTEM_CFLAGS)
29+
endif
30+
31+
ifneq ($(EXQLITE_SYSTEM_LDFLAGS),)
32+
LDFLAGS += $(EXQLITE_SYSTEM_CFLAGS)
33+
else
34+
# best attempt to link the system library
35+
# if the user didn't supply it in the environment
36+
LDFLAGS += -lsqlite3
37+
endif
38+
endif
2139

2240
CFLAGS ?= -O2 -Wall
2341
ifneq ($(DEBUG),)
2442
CFLAGS += -g
2543
endif
2644
CFLAGS += -I"$(ERTS_INCLUDE_DIR)"
27-
CFLAGS += -Ic_src
2845

2946
KERNEL_NAME := $(shell uname -s)
3047

@@ -35,6 +52,9 @@ ARCHIVE_NAME = $(PREFIX)/sqlite3_nif.a
3552

3653
OBJ = $(SRC:c_src/%.c=$(BUILD)/%.o)
3754

55+
$(info ${SRC} == ${OBJ} == ${wildcard c_src/*.c})
56+
$(info ${LDFLAGS})
57+
3858
ifneq ($(CROSSCOMPILE),)
3959
ifeq ($(CROSSCOMPILE), Android)
4060
CFLAGS += -fPIC -Os -z global
@@ -112,7 +132,7 @@ $(BUILD)/%.o: c_src/%.c
112132

113133
$(LIB_NAME): $(OBJ)
114134
@echo " LD $(notdir $@)"
115-
$(CC) -o $@ $(LDFLAGS) $^
135+
$(CC) -o $@ $^ $(LDFLAGS)
116136

117137
$(ARCHIVE_NAME): $(OBJ)
118138
@echo " AR $(notdir $@)"

0 commit comments

Comments
 (0)