forked from strange/erlang_v8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (72 loc) · 2.06 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
SHELL = /bin/bash
PROJECT = erlang_v8
DEPS = jsx poolboy
dep_jsx = pkg://jsx master
dep_poolboy = https://github.com/devinus/poolboy.git master
TEST_DEPS = ct_helper
dep_ct_helper = https://github.com/extend/ct_helper.git master
CT_SUITES = port
ARCH := $(shell getconf LONG_BIT)
OS := $(shell uname)
CUR_DIR := $(shell pwd)
BUILD_ARCH_32 := ia32
BUILD_ARCH_64 := x64
BUILD_ARCH := $(BUILD_ARCH_$(ARCH))
V8_REF := 49744859536225e7ac3b726e5b019dd99e127e6f
V8_DIR := $(CUR_DIR)/lib/v8-$(V8_REF)
V8_LIB := $(V8_DIR)/out/$(BUILD_ARCH).release
V8_URL := https://github.com/v8/v8/archive/$(V8_REF).tar.gz
TARGET_BIN := $(CUR_DIR)/priv/erlang_v8
TARGET_SRC := $(CUR_DIR)/c_src/erlang_v8.cc
include erlang.mk
.PHONY: v8 local-clean local-clean-all
app: v8
run:
erl -pa deps/*/ebin -pa ./ebin
clean: local-clean
clean-all: local-clean-all
local-clean:
rm -rf $(TARGET_BIN)
local-clean-all::
rm -rf $(V8_DIR)
v8: $(TARGET_BIN)
lib:
mkdir -p lib
$(V8_DIR): lib
curl -L $(V8_URL) | tar xvz -C lib
$(V8_DIR)/build/gyp: $(V8_DIR)
@cd $(V8_DIR) && make dependencies
@touch $@
$(V8_LIB)/libv8_base.$(BUILD_ARCH).a: $(V8_DIR)/build/gyp
@cd $(V8_DIR) && make $(BUILD_ARCH).release werror=no
@touch $@
@cp $(V8_LIB)/obj.target/tools/gyp/*.a $(V8_LIB) 2> /dev/null || :
@cp $(V8_LIB)/obj.target/third_party/icu/*.a $(V8_LIB) 2> /dev/null || :
$(TARGET_SRC): $(V8_LIB)/libv8_base.$(BUILD_ARCH).a
@:
$(TARGET_BIN): $(TARGET_SRC)
@mkdir -p priv
ifeq ($(OS),Darwin)
# We need to link libstdc++ as XCode defaults to libc++, and use slightly
# different flags, on OS X. The following assumes Mavericks, XCode and
# default compiler (clang).
g++ -Iinclude $(TARGET_SRC) \
-stdlib=libstdc++ \
-o $(TARGET_BIN) \
$(V8_LIB)/libv8_{base.$(BUILD_ARCH),snapshot}.a \
$(V8_LIB)/libicu{uc,i18n,data}.a \
-I $(V8_DIR)/include \
-lpthread \
-v
else
g++ -Iinclude $(TARGET_SRC) \
-o $(TARGET_BIN) \
-Wl,--start-group \
$(V8_LIB)/libv8_{base.$(BUILD_ARCH),snapshot}.a \
$(V8_LIB)/libicu{uc,i18n,data}.a \
-Wl,--end-group \
-I $(V8_DIR)/include \
-lrt \
-lpthread \
-v
endif