-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (46 loc) · 1.58 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
PRIV_DIR = $(MIX_APP_PATH)/priv
NIF_SO = $(PRIV_DIR)/expty.so
SPAWN_HELPER = $(PRIV_DIR)/spawn-helper
C_SRC = $(shell pwd)/c_src
LIB_SRC = $(shell pwd)/lib
LIBUV_SRC = $(shell pwd)/3rd_party/libuv-1.44.2
LIBUV_BUILD_DIR = $(MIX_APP_PATH)/cmake_libuv-1.44.2
LIBUV_INSTALL_DIR = $(MIX_APP_PATH)/libuv
LIBUV_A = $(LIBUV_INSTALL_DIR)/lib/libuv_a.a
NIF_BUILD_DIR = $(MIX_APP_PATH)/cmake_expty
DEFAULT_JOBS ?= 1
MAKE_BUILD_FLAGS ?= -j$(DEFAULT_JOBS)
.DEFAULT_GLOBAL := build
build: $(NIF_SO)
@ echo > /dev/null
$(PRIV_DIR):
@ mkdir -p "$(PRIV_DIR)"
$(LIBUV_A): $(PRIV_DIR)
@ if [ ! -e "$(LIBUV_A)" ]; then \
mkdir -p "$(LIBUV_BUILD_DIR)" && \
mkdir -p "$(NIF_BUILD_DIR)" && \
cd "$(LIBUV_BUILD_DIR)" && \
cmake "$(LIBUV_SRC)" -D CMAKE_INSTALL_PREFIX="$(LIBUV_INSTALL_DIR)" -D CMAKE_C_FLAGS="-fPIC" -D CMAKE_CXX_FLAGS="-fPIC" && \
cmake --build . $(MAKE_BUILD_FLAGS) && \
cmake --install . ; \
fi
$(NIF_SO): $(PRIV_DIR) $(LIBUV_A)
@ if [ ! -e "$(NIF_SO)" ]; then \
mkdir -p "$(NIF_BUILD_DIR)" && \
cd "$(NIF_BUILD_DIR)" && \
cmake "$(shell pwd)" -D CMAKE_INSTALL_PREFIX="$(PRIV_DIR)" \
-D LIBUV_INCLUDE_DIR="$(LIBUV_INSTALL_DIR)/include" \
-D LIBUV_LIBRARIES_DIR="$(LIBUV_INSTALL_DIR)/lib" \
-D C_SRC="$(C_SRC)" \
-D CMAKE_TOOLCHAIN_FILE="$(TOOLCHAIN_FILE)" \
-D MIX_APP_PATH="$(MIX_APP_PATH)" \
-D PRIV_DIR="$(PRIV_DIR)" \
-D ERTS_INCLUDE_DIR="$(ERTS_INCLUDE_DIR)" && \
cmake --build . $(MAKE_BUILD_FLAGS) && \
cmake --install . ; \
fi
cleanup:
@ rm -rf "$(PRIV_DIR)"
@ rm -rf "$(LIBUV_BUILD_DIR)"
@ rm -rf "$(LIBUV_INSTALL_DIR)"
@ rm -rf "$(NIF_BUILD_DIR)"