Skip to content

Commit b45c25c

Browse files
authored
Adding ERL_CFLAGS (#198)
* Add ERL_FLAGS option - Give priority in front on CFLAGS incase cross-compile is attempted - Set to '-I$(ERL_EI_INCLUDE_DIR)' if not set already
1 parent 4e86e3d commit b45c25c

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# CROSSCOMPILE crosscompiler prefix, if any
1515
# CFLAGS compiler flags for compiling all C files
1616
# LDFLAGS linker flags for linking all binaries
17+
# ERL_CFLAGS additional compiler flags for files using Erlang header files
18+
# ERL_EI_INCLUDE_DIR include path to header files (Possibly required for crosscompile)
1719
#
1820

1921
SRC = c_src/sqlite3_nif.c
@@ -111,6 +113,10 @@ CFLAGS += -DSQLITE_ENABLE_MATH_FUNCTIONS=1
111113
CFLAGS += -DSQLITE_ENABLE_RBU=1
112114
CFLAGS += -DSQLITE_ENABLE_RTREE=1
113115
CFLAGS += -DSQLITE_OMIT_DEPRECATED=1
116+
117+
# Set Erlang-specific compile flags
118+
ERL_CFLAGS ?= -I$(ERL_EI_INCLUDE_DIR)
119+
114120
ifneq ($(STATIC_ERLANG_NIF),)
115121
CFLAGS += -DSTATIC_ERLANG_NIF=1
116122
endif
@@ -123,7 +129,7 @@ endif
123129

124130
$(BUILD)/%.o: c_src/%.c
125131
@echo " CC $(notdir $@)"
126-
$(CC) -c $(CFLAGS) -o $@ $<
132+
$(CC) -c $(ERL_CFLAGS) $(CFLAGS) -o $@ $<
127133

128134
$(LIB_NAME): $(OBJ)
129135
@echo " LD $(notdir $@)"

Makefile.win

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ CFLAGS = -DSQLITE_OMIT_DEPRECATED=1 $(CFLAGS)
4747
# TODO: We should allow the person building to be able to specify this
4848
CFLAGS = -DNDEBUG=1 $(CFLAGS)
4949

50+
# Set Erlang-specific compile flags
51+
!IFNDEF ERL_CFLAGS
52+
ERL_CFLAGS = -I"$(ERL_EI_INCLUDE_DIR)"
53+
!ENDIF
5054

5155
all: clean priv\sqlite3_nif.dll
5256

@@ -59,7 +63,7 @@ Makefile.auto.win:
5963
!IFDEF ERTS_INCLUDE_PATH
6064
priv\sqlite3_nif.dll:
6165
if NOT EXIST "priv" mkdir "priv"
62-
$(CC) $(CFLAGS) -I"$(ERTS_INCLUDE_PATH)" -LD -MD -Fe$@ $(SRC)
66+
$(CC) $(ERL_CFLAGS) $(CFLAGS) -I"$(ERTS_INCLUDE_PATH)" -LD -MD -Fe$@ $(SRC)
6367
!ELSE
6468
priv\sqlite3_nif.dll: Makefile.auto.win
6569
$(NMAKE) -F Makefile.win priv\sqlite3_nif.dll

0 commit comments

Comments
 (0)