forked from r-wasm/webr-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webr-vars.mk
108 lines (83 loc) · 2.75 KB
/
webr-vars.mk
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
96
97
98
99
100
101
102
103
104
105
106
107
108
# Configure your local environment in this file. Make sure to set
# `WEBR_ROOT` to the root directory of the webR repo
-include ~/.webr-vars.mk
# Select emfc implementation
-include $(WEBR_ROOT)/tools/fortran.mk
R_VERSION = $(shell cat $(WEBR_ROOT)/R/R-VERSION)
R_SOURCE = $(WEBR_ROOT)/R/build/R-$(R_VERSION)
R_HOME = $(WEBR_ROOT)/wasm/R-$(R_VERSION)/lib/R
WASM = $(WEBR_ROOT)/wasm
EM_LIBS := -s USE_BZIP2=1
EM_LIBS += -s USE_ZLIB=1
WASM_OPT := $(WASM_OPT)
WASM_OPT += -Oz
WASM_COMMON_FLAGS := $(WASM_OPT)
WASM_COMMON_FLAGS += -fPIC
WASM_COMMON_FLAGS += -fwasm-exceptions
WASM_COMMON_FLAGS += -s SUPPORT_LONGJMP=wasm
WASM_CFLAGS := $(WASM_CFLAGS)
WASM_CFLAGS += $(WASM_COMMON_FLAGS)
WASM_CFLAGS += -std=gnu11
WASM_CXXFLAGS := $(WASM_CXXFLAGS)
WASM_CXXFLAGS += $(WASM_COMMON_FLAGS)
WASM_CXXFLAGS += -DRCPP_DEMANGLER_ENABLED=0
WASM_CXXFLAGS += -D__STRICT_ANSI__
WASM_CPPFLAGS := $(WASM_CPPFLAGS)
WASM_CPPFLAGS += -I$(WASM)/include
WASM_CPPFLAGS += -I$(R_SOURCE)/build/include
WASM_CPPFLAGS += -I$(R_SOURCE)/src/include
WASM_CPPFLAGS += $(EM_LIBS)
WASM_LDFLAGS := $(WASM_LDFLAGS)
WASM_LDFLAGS += -s SIDE_MODULE=1
WASM_LDFLAGS += -s WASM_BIGINT
WASM_LDFLAGS += -s ASSERTIONS=1
WASM_LDFLAGS += -L$(WASM)/lib
WASM_LDFLAGS += -L$(WASM)/R-$(R_VERSION)/lib/R/lib
WASM_LDFLAGS += $(EM_LIBS)
WASM_LDFLAGS += -fwasm-exceptions
WASM_LDFLAGS += -s SUPPORT_LONGJMP=wasm
WASM_LDFLAGS += $(WASM_OPT)
# Needed because Emscripten's `dlopen()` calls seem to ignore the
# `local` flag?
C_VISIBILITY = -fvisibility=hidden
CXX_VISIBILITY = -fvisibility=hidden
CXX98 = em++
CXX11 = em++
CXX14 = em++
CXX17 = em++
CXX20 = em++
CC = emcc
CXX = em++
FC = $(EMFC)
CFLAGS = $(WASM_CFLAGS)
CPPFLAGS = $(WASM_CPPFLAGS)
CXXFLAGS = -std=gnu++11 $(WASM_CXXFLAGS)
CXX98FLAGS = -std=gnu++98 $(WASM_CXXFLAGS)
CXX11FLAGS = -std=gnu++11 $(WASM_CXXFLAGS)
CXX14FLAGS = -std=gnu++14 $(WASM_CXXFLAGS)
CXX17FLAGS = -std=gnu++17 $(WASM_CXXFLAGS)
CXX20FLAGS = -std=gnu++20 $(WASM_CXXFLAGS)
LDFLAGS = $(WASM_LDFLAGS)
FLIBS = $(FORTRAN_WASM_LDADD)
AR = emar
# Uncomment to show emscripten calls to clang for debugging
# CFLAGS += -v
# LDFLAGS += -v
# Clear up flags from $(R_HOME)/etc/Makeconf
override DYLIB_LD = $(CC)
override DYLIB_LDFLAGS = $(CFLAGS)
override DYLIB_LINK = $(DYLIB_LD) $(DYLIB_LDFLAGS) $(LDFLAGS)
override SHLIB_LDFLAGS =
override SHLIB_LINK = $(SHLIB_LD) $(SHLIB_LDFLAGS) $(LDFLAGS)
override FOUNDATION_LIBS =
override LIBINTL =
override LIBR =
override ALL_LIBS = $(PKG_LIBS) $(SHLIB_LIBADD) $(LIBR) $(LIBINTL)
override BLAS_LIBS = -L$(WEBR_LOCAL)/lib/R/lib -lRblas
override LAPACK_LIBS = -L$(WEBR_LOCAL)/lib/R/lib -lRlapack
override ALL_CPPFLAGS = -DNDEBUG $(PKG_CPPFLAGS) $(CLINK_CPPFLAGS) $(CPPFLAGS)
override ALL_FFLAGS =
override ALL_FCFLAGS =
# Print Makefile variable
.PHONY: print-%
print-% : ; @echo $* = $($*)