Skip to content

Allow using system-wide or custom sqlite3 installation #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,32 @@
# LDFLAGS linker flags for linking all binaries
#

SRC = $(wildcard c_src/*.c)
HEADERS = $(wildcard c_src/*.h)
SRC = c_src/sqlite3_nif.c
HEADERS = c_src/utf8.h

ifeq ($(EXQLITE_USE_SYSTEM),)
SRC += c_src/sqlite3.c
HEADERS += c_src/sqlite3.h c_src/sqlite3ext.h
CFLAGS += -Ic_src
else
ifneq ($(EXQLITE_SYSTEM_CFLAGS),)
CFLAGS += $(EXQLITE_SYSTEM_CFLAGS)
endif

ifneq ($(EXQLITE_SYSTEM_LDFLAGS),)
LDFLAGS += $(EXQLITE_SYSTEM_CFLAGS)
else
# best attempt to link the system library
# if the user didn't supply it in the environment
LDFLAGS += -lsqlite3
endif
endif

CFLAGS ?= -O2 -Wall
ifneq ($(DEBUG),)
CFLAGS += -g
endif
CFLAGS += -I"$(ERTS_INCLUDE_DIR)"
CFLAGS += -Ic_src

KERNEL_NAME := $(shell uname -s)

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

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

$(info ${SRC} == ${OBJ} == ${wildcard c_src/*.c})
$(info ${LDFLAGS})

ifneq ($(CROSSCOMPILE),)
ifeq ($(CROSSCOMPILE), Android)
CFLAGS += -fPIC -Os -z global
Expand Down Expand Up @@ -112,7 +132,7 @@ $(BUILD)/%.o: c_src/%.c

$(LIB_NAME): $(OBJ)
@echo " LD $(notdir $@)"
$(CC) -o $@ $(LDFLAGS) $^
$(CC) -o $@ $^ $(LDFLAGS)

$(ARCHIVE_NAME): $(OBJ)
@echo " AR $(notdir $@)"
Expand Down