1 #emcc has lots of bash'isms
4 EMSCRIPTEN_VERSION
=1.38.28
5 EMSCRIPTEN_SDK_DIR
=$(TOP
)/sdks
/builds
/toolchains
/emsdk
7 $(TOP
)/sdks
/builds
/toolchains
/emsdk
:
8 git clone https
://github.com
/juj
/emsdk.git
$(EMSCRIPTEN_SDK_DIR
)
10 .stamp-wasm-checkout-and-update-emsdk
: |
$(EMSCRIPTEN_SDK_DIR
)
11 cd
$(TOP
)/sdks
/builds
/toolchains
/emsdk
&& git reset
--hard
&& git
clean -xdff
&& git pull
14 #This is a weird rule to workaround the circularity of the next rule.
15 #.stamp-wasm-install-and-select-$(EMSCRIPTEN_VERSION) depends on .emscripten and, at the same time, it updates it.
16 #This is designed to force the .stamp target to rerun when a different emscripten version is selected, which causes .emscripten to be updated
17 $(EMSCRIPTEN_SDK_DIR
)/.emscripten
: |
$(EMSCRIPTEN_SDK_DIR
)
20 .stamp-wasm-install-and-select-
$(EMSCRIPTEN_VERSION
): .stamp-wasm-checkout-and-update-emsdk
$(EMSCRIPTEN_SDK_DIR
)/.emscripten
21 cd
$(TOP
)/sdks
/builds
/toolchains
/emsdk
&& .
/emsdk
install sdk-
$(EMSCRIPTEN_VERSION
)-64bit
22 cd
$(TOP
)/sdks
/builds
/toolchains
/emsdk
&& .
/emsdk activate
--embedded sdk-
$(EMSCRIPTEN_VERSION
)-64bit
23 #cd $(TOP)/sdks/builds/toolchains/emsdk/emscripten/$(EMSCRIPTEN_VERSION) && (patch -N -p1 < $(TOP)/sdks/builds/fix-emscripten-7399.diff; exit 0)
26 .PHONY
: provision-wasm
27 provision-wasm
: .stamp-wasm-install-and-select-
$(EMSCRIPTEN_VERSION
)
29 WASM_RUNTIME_AC_VARS
= \
30 ac_cv_func_shm_open_working_with_mmap
=no
32 WASM_RUNTIME_CFLAGS
=-fexceptions
$(if
$(RELEASE
),-Os
-g
,-O0
-ggdb3
-fno-omit-frame-pointer
)
34 WASM_RUNTIME_CONFIGURE_FLAGS
= \
35 --cache-file
=$(TOP
)/sdks
/builds
/wasm-runtime-
$(CONFIGURATION
).config.cache \
36 --prefix=$(TOP
)/sdks
/out
/wasm-runtime-
$(CONFIGURATION
) \
41 --with-lazy-gc-thread-creation
=yes \
43 --disable-executables \
44 --disable-support-build \
45 --disable-visibility-hidden \
46 --enable-maintainer-mode \
47 --enable-minimal
=ssa
,com
,jit
,reflection_emit_save
,portability
,assembly_remapping
,attach
,verifier
,full_messages
,appdomains
,security
,sgen_marksweep_conc
,sgen_split_nursery
,sgen_gc_bridge
,logging
,remoting
,shared_perfcounters
,sgen_debug_helpers
,soft_debug
,interpreter
,assert_messages
,cleanup
,mdb \
49 --enable-llvm-runtime \
50 --enable-icall-export \
51 --disable-icall-tables \
52 --disable-crash-reporting \
54 $(if
$(ENABLE_CXX
),--enable-cxx
) \
55 CFLAGS
="$(WASM_RUNTIME_CFLAGS)"
57 .stamp-wasm-runtime-toolchain
:
60 .stamp-wasm-runtime-
$(CONFIGURATION
)-configure
: $(TOP
)/configure |
$(if
$(IGNORE_PROVISION_WASM
),,provision-wasm
)
61 mkdir
-p
$(TOP
)/sdks
/builds
/wasm-runtime-
$(CONFIGURATION
)
62 cd
$(TOP
)/sdks
/builds
/wasm-runtime-
$(CONFIGURATION
) && source
$(TOP
)/sdks
/builds
/toolchains
/emsdk
/emsdk_env.sh
&& emconfigure
$(TOP
)/configure
$(WASM_RUNTIME_AC_VARS
) $(WASM_RUNTIME_CONFIGURE_FLAGS
)
65 .PHONY
: .stamp-wasm-runtime-configure
66 .stamp-wasm-runtime-configure
: .stamp-wasm-runtime-
$(CONFIGURATION
)-configure
68 .PHONY
: build-custom-wasm-runtime
69 build-custom-wasm-runtime
:
70 source
$(TOP
)/sdks
/builds
/toolchains
/emsdk
/emsdk_env.sh
&& $(MAKE
) -C wasm-runtime-
$(CONFIGURATION
)
72 .PHONY
: setup-custom-wasm-runtime
73 setup-custom-wasm-runtime
:
74 mkdir
-p
$(TOP
)/sdks
/out
/wasm-runtime-
$(CONFIGURATION
)
76 .PHONY
: package-wasm-runtime
78 $(MAKE
) -C
$(TOP
)/sdks
/builds
/wasm-runtime-
$(CONFIGURATION
)/mono
install
80 .PHONY
: clean-wasm-runtime
82 rm -rf .stamp-wasm-runtime-toolchain .stamp-wasm-runtime-
$(CONFIGURATION
)-configure
$(TOP
)/sdks
/builds
/wasm-runtime-
$(CONFIGURATION
) $(TOP
)/sdks
/builds
/wasm-runtime-
$(CONFIGURATION
).config.cache
$(TOP
)/sdks
/out
/wasm-runtime-
$(CONFIGURATION
)
84 $(eval
$(call TargetTemplate
,wasm
,runtime
))
86 .PHONY
: configure-wasm
87 configure-wasm
: configure-wasm-runtime
90 build-wasm
: build-wasm-runtime
93 archive-wasm
: package-wasm-runtime
95 wasm_ARCHIVE
+= wasm-runtime-
$(CONFIGURATION
)
102 # $(4): device target
104 # $(6): offsets dumper abi
105 define WasmCrossTemplate
107 _wasm-
$(1)_OFFSETS_DUMPER_ARGS
=--emscripten-sdk
="$$(EMSCRIPTEN_SDK_DIR)/emscripten/$$(EMSCRIPTEN_VERSION)"
109 _wasm-
$(1)_CONFIGURE_FLAGS
= \
112 --disable-mcs-build \
114 --disable-support-build \
115 --enable-maintainer-mode \
116 --enable-minimal
=appdomains
,com
,remoting \
117 --enable-icall-symbol-map \
118 --with-cooperative-gc
=no \
119 --enable-hybrid-suspend
=no \
120 --with-cross-offsets
=wasm32-unknown-none.h
122 $$(eval
$$(call CrossRuntimeTemplate
,wasm
,$(1),$$(if
$$(filter $$(UNAME
),Darwin
),$(2)-apple-darwin10
,$$(if
$$(filter $$(UNAME
),Linux
),$(2)-linux-gnu
,$$(error
"Unknown UNAME='$$(UNAME)'"))),$(3)-unknown-none
,$(4),$(5),$(6)))
126 # 64 bit cross compiler
127 $(eval
$(call WasmCrossTemplate
,cross
,x86_64
,wasm32
,runtime
,llvm-llvm64
,wasm32-unknown-unknown
))
134 # $(4): device target
136 # $(6): offsets dumper abi
137 define WasmCrossMXETemplate
139 _wasm-
$(1)_OFFSETS_DUMPER_ARGS
=--emscripten-sdk
="$(EMSCRIPTEN_SDK_DIR)/emscripten/$(EMSCRIPTEN_VERSION)"
141 _wasm-
$(1)_PATH
=$$(MXE_PREFIX
)/bin
143 _wasm-
$(1)_AR
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-ar
144 _wasm-
$(1)_AS
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-as
145 _wasm-
$(1)_CC
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-gcc
146 _wasm-
$(1)_CXX
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-g
++
147 _wasm-
$(1)_DLLTOOL
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-dlltool
148 _wasm-
$(1)_LD
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-ld
149 _wasm-
$(1)_OBJDUMP
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-objdump
150 _wasm-
$(1)_RANLIB
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-ranlib
151 _wasm-
$(1)_STRIP
=$$(MXE_PREFIX
)/bin
/$(2)-w64-mingw32
$$(if
$$(filter $$(UNAME
),Darwin
),.static
)-strip
154 $$(if
$$(RELEASE
),,-DDEBUG_CROSS
) \
158 _wasm-
$(1)_CXXFLAGS
= \
159 $$(if
$$(RELEASE
),,-DDEBUG_CROSS
) \
164 _wasm-
$(1)_LDFLAGS
= \
168 _wasm-
$(1)_CONFIGURE_FLAGS
= \
171 --disable-mcs-build \
174 --disable-support-build \
175 --enable-maintainer-mode \
176 --enable-minimal
=appdomains
,com
,remoting \
178 --enable-icall-symbol-map \
179 --with-cross-offsets
=wasm32-unknown-none.h
181 .stamp-wasm-
$(1)-$$(CONFIGURATION
)-configure
: |
$$(if
$$(IGNORE_PROVISION_MXE
),,provision-mxe
)
183 $$(eval
$$(call CrossRuntimeTemplate
,wasm
,$(1),$(2)-w64-mingw32
$$(if
$$(filter $(UNAME
),Darwin
),.static
),$(3)-unknown-none
,$(4),$(5),$(6)))
187 $(eval
$(call WasmCrossMXETemplate
,cross-win
,i686
,wasm32
,runtime
,llvm-llvmwin32
,wasm32-unknown-unknown
))
189 $(eval
$(call BclTemplate
,wasm
,wasm wasm_tools
,wasm
))