-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
63 lines (45 loc) · 1.23 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
SRC_DIR = c_src
CXXFLAGS = -O3 -std=c++11
HEADERS_DIRS = $(sort $(dir $(shell find $(SRC_DIR)/* | grep .h)))
CXXFLAGS += -I"$(ERTS_INCLUDE_DIR)"
CXXFLAGS += $(foreach header, $(HEADERS_DIRS), -I"$(header)")
CXXFLAGS += -DNDEBUG=1
KERNEL_NAME := $(shell uname -s)
PRIV_DIR = $(MIX_APP_PATH)/priv
LIB_NAME = $(PRIV_DIR)/duckdb_nif.so
ifneq ($(CROSSCOMPILE),)
CXXFLAGS += -fPIC -fvisibility=hidden
LDFLAGS += -fPIC -shared
else
ifeq ($(KERNEL_NAME), Linux)
CXXFLAGS += -fPIC -fvisibility=hidden
LDFLAGS += -fPIC -shared
endif
ifeq ($(KERNEL_NAME), Darwin)
CXXFLAGS += -fPIC
LDFLAGS += -dynamiclib -undefined dynamic_lookup
endif
ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),OpenBSD FreeBSD NetBSD))
CXXFLAGS += -fPIC
LDFLAGS += -fPIC -shared
endif
endif
SRC = $(shell find $(SRC_DIR) -name "*.cpp")
OBJ=$(subst $(SRC_DIR), $(PRIV_DIR), $(SRC:.cpp=.o))
.PRECIOUS: $(PRIV_DIR)/. $(PRIV_DIR)%/.
$(PRIV_DIR):
mkdir -p $@
$(PRIV_DIR)/.:
mkdir -p $@
$(PRIV_DIR)%/.:
mkdir -p $@
.SECONDEXPANSION:
$(PRIV_DIR)/%.o: $(SRC_DIR)/%.cpp | $$(@D)/.
$(CXX) $(CXXFLAGS) -c $< -o $@
$(LIB_NAME): $(OBJ)
$(CXX) $(LDFLAGS) $^ -o $@
all: $(PRIV_DIR) $(SRC) $(LIB_NAME)
clean:
$(RM) -rf run $(OBJ)
$(RM) -f $(LIB_NAME)
.PHONY: all clean