xref: /sqlite-3.40.0/ext/wasm/GNUmakefile (revision 7d24ff29)
171de8e02Sstephan#######################################################################
24bc2f6b4Sstephan# This GNU makefile drives the build of the sqlite3 WASM
34bc2f6b4Sstephan# components. It is not part of the canonical build process.
4b5e2e6fcSstephan#
5b5e2e6fcSstephan# This build assumes a Linux platform and is not intended for
689954fe7Sstephan# general-purpose client-level use, except for creating builds with
789954fe7Sstephan# custom configurations. It is primarily intended for the sqlite
889954fe7Sstephan# project's own development of the JS/WASM components.
9b5e2e6fcSstephan#
10b5e2e6fcSstephan# Primary targets:
11b5e2e6fcSstephan#
12b5e2e6fcSstephan#  default, all = build in dev mode
13b5e2e6fcSstephan#
14b5e2e6fcSstephan#  o0, o1, o2, o3, os, oz = full clean/rebuild with the -Ox level indicated
15b5e2e6fcSstephan#      by the target name. Rebuild is necessary for all components to get
16b5e2e6fcSstephan#      the desired optimization level.
17b5e2e6fcSstephan#
1889954fe7Sstephan#  dist = create end user deliverables. Add dist.build=oX to build
1989954fe7Sstephan#      with a specific optimization level, where oX is one of the
2089954fe7Sstephan#      above-listed o? target names.
21b5e2e6fcSstephan#
22b5e2e6fcSstephan#  clean = clean up
234bc2f6b4Sstephan########################################################################
244bc2f6b4SstephanSHELL := $(shell which bash 2>/dev/null)
254bc2f6b4SstephanMAKEFILE := $(lastword $(MAKEFILE_LIST))
2671de8e02SstephanCLEAN_FILES :=
2771de8e02SstephanDISTCLEAN_FILES := ./--dummy--
28b5e2e6fcSstephandefault: all
2971de8e02Sstephanrelease: oz
303961b263Sstephan
313961b263Sstephan# Emscripten SDK home dir and related binaries...
32ce2d4ae6SstephanEMSDK_HOME ?= $(word 1,$(wildcard $(HOME)/emsdk $(HOME)/src/emsdk))
33ce2d4ae6Sstephanemcc.bin ?= $(word 1,$(wildcard $(EMSDK_HOME)/upstream/emscripten/emcc) $(shell which emcc))
343961b263Sstephanifeq (,$(emcc.bin))
353961b263Sstephan  $(error Cannot find emcc.)
363961b263Sstephanendif
373961b263Sstephan
383961b263Sstephanwasm-strip ?= $(shell which wasm-strip 2>/dev/null)
393961b263Sstephanifeq (,$(filter clean,$(MAKECMDGOALS)))
403961b263Sstephanifeq (,$(wasm-strip))
413961b263Sstephan  $(info WARNING: *******************************************************************)
4228ef9bddSstephan  $(info WARNING: builds using -O2/-O3/-Os/-Oz will minify WASM-exported names,)
433961b263Sstephan  $(info WARNING: breaking _All The Things_. The workaround for that is to build)
443961b263Sstephan  $(info WARNING: with -g3 (which explodes the file size) and then strip the debug)
453961b263Sstephan  $(info WARNING: info after compilation, using wasm-strip, to shrink the wasm file.)
463961b263Sstephan  $(info WARNING: wasm-strip was not found in the PATH so we cannot strip those.)
4728ef9bddSstephan  $(info WARNING: If this build uses any optimization level higher than -O1 then)
48ce2d4ae6Sstephan  $(info WARNING: the ***resulting JS code WILL NOT BE USABLE***.)
493961b263Sstephan  $(info WARNING: wasm-strip is part of the wabt package:)
503961b263Sstephan  $(info WARNING:    https://github.com/WebAssembly/wabt)
513961b263Sstephan  $(info WARNING: on Ubuntu-like systems it can be installed with:)
523961b263Sstephan  $(info WARNING:    sudo apt install wabt)
533961b263Sstephan  $(info WARNING: *******************************************************************)
543961b263Sstephanendif
553961b263Sstephanendif # 'make clean' check
563961b263Sstephan
5728ef9bddSstephanifeq (,$(wasm-strip))
5828ef9bddSstephan  maybe-wasm-strip = echo "not wasm-stripping"
5928ef9bddSstephanelse
6028ef9bddSstephan  maybe-wasm-strip = $(wasm-strip)
6128ef9bddSstephanendif
6228ef9bddSstephan
634bc2f6b4Sstephandir.top := ../..
6471de8e02Sstephan# Reminder: some Emscripten flags require absolute paths but we want
6571de8e02Sstephan# relative paths for most stuff simply to reduce noise. The
6671de8e02Sstephan# $(abspath...) GNU make function can transform relative paths to
6771de8e02Sstephan# absolute.
6871de8e02Sstephandir.wasm := $(patsubst %/,%,$(dir $(MAKEFILE)))
694bc2f6b4Sstephandir.api := api
704bc2f6b4Sstephandir.jacc := jaccwabyt
714bc2f6b4Sstephandir.common := common
724bc2f6b4Sstephandir.fiddle := fiddle
73b5e2e6fcSstephandir.tool := $(dir.top)/tool
7471de8e02Sstephan########################################################################
75ce2d4ae6Sstephan# dir.dout = output dir for deliverables.
76ce2d4ae6Sstephan#
7771de8e02Sstephan# MAINTENANCE REMINDER: the output .js and .wasm files of emcc must be
7871de8e02Sstephan# in _this_ dir, rather than a subdir, or else parts of the generated
7971de8e02Sstephan# code get confused and cannot load property. Specifically, when X.js
8071de8e02Sstephan# loads X.wasm, whether or not X.js uses the correct path for X.wasm
8171de8e02Sstephan# depends on how it's loaded: an HTML script tag will resolve it
8271de8e02Sstephan# intuitively, whereas a Worker's call to importScripts() will not.
8371de8e02Sstephan# That's a fundamental incompatibility with how URL resolution in
8471de8e02Sstephan# JS happens between those two contexts. See:
8571de8e02Sstephan#
8671de8e02Sstephan# https://zzz.buzz/2017/03/14/relative-uris-in-web-development/
8771de8e02Sstephan#
8871de8e02Sstephan# We unfortunately have no way, from Worker-initiated code, to
8971de8e02Sstephan# automatically resolve the path from X.js to X.wasm.
9071de8e02Sstephan#
91ce2d4ae6Sstephan# We have an "only slightly unsightly" solution for our main builds
92ce2d4ae6Sstephan# but it does not work for the WASMFS builds, so those builds have to
93ce2d4ae6Sstephan# be built to _this_ directory and can only run when the client app is
94ce2d4ae6Sstephan# loaded from the same directory.
95cd0df83cSstephandir.dout := $(dir.wasm)/jswasm
9671de8e02Sstephan# dir.tmp = output dir for intermediary build files, as opposed to
9771de8e02Sstephan# end-user deliverables.
9871de8e02Sstephandir.tmp := $(dir.wasm)/bld
99*7d24ff29SstephanCLEAN_FILES += $(dir.tmp)/* $(dir.dout)/*
10071de8e02Sstephanifeq (,$(wildcard $(dir.dout)))
10171de8e02Sstephan  dir._tmp := $(shell mkdir -p $(dir.dout))
10271de8e02Sstephanendif
10371de8e02Sstephanifeq (,$(wildcard $(dir.tmp)))
10471de8e02Sstephan  dir._tmp := $(shell mkdir -p $(dir.tmp))
10571de8e02Sstephanendif
10671de8e02Sstephan
10771de8e02Sstephancflags.common :=  -I. -I.. -I$(dir.top)
10871de8e02SstephanCLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~
1091fc6ffccSstephanemcc.WASM_BIGINT ?= 1
1104bc2f6b4Sstephansqlite3.c := $(dir.top)/sqlite3.c
11195639269Sstephansqlite3.h := $(dir.top)/sqlite3.h
1124bc2f6b4SstephanSQLITE_OPT = \
1134bc2f6b4Sstephan  -DSQLITE_ENABLE_FTS4 \
1144bc2f6b4Sstephan  -DSQLITE_ENABLE_RTREE \
1154bc2f6b4Sstephan  -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
1164bc2f6b4Sstephan  -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION \
1174bc2f6b4Sstephan  -DSQLITE_ENABLE_STMTVTAB \
1184bc2f6b4Sstephan  -DSQLITE_ENABLE_DBPAGE_VTAB \
1194bc2f6b4Sstephan  -DSQLITE_ENABLE_DBSTAT_VTAB \
1204bc2f6b4Sstephan  -DSQLITE_ENABLE_BYTECODE_VTAB \
1214bc2f6b4Sstephan  -DSQLITE_ENABLE_OFFSET_SQL_FUNC \
1224bc2f6b4Sstephan  -DSQLITE_OMIT_LOAD_EXTENSION \
1234bc2f6b4Sstephan  -DSQLITE_OMIT_DEPRECATED \
1244bc2f6b4Sstephan  -DSQLITE_OMIT_UTF16 \
1254bc2f6b4Sstephan  -DSQLITE_OMIT_SHARED_CACHE \
1264b074692Sstephan  -DSQLITE_OMIT_WAL \
1274bc2f6b4Sstephan  -DSQLITE_THREADSAFE=0 \
1284bc2f6b4Sstephan  -DSQLITE_TEMP_STORE=3 \
1294bc2f6b4Sstephan  -DSQLITE_OS_KV_OPTIONAL=1 \
1306110a5d0Sstephan  '-DSQLITE_DEFAULT_UNIX_VFS="unix-none"' \
131d92c652aSstephan  -DSQLITE_USE_URI=1 \
132d92c652aSstephan  -DSQLITE_WASM_ENABLE_C_TESTS
133d92c652aSstephan# ^^^ most flags are set in sqlite3-wasm.c but we need them
134d92c652aSstephan# made explicit here for building speedtest1.c.
1354bc2f6b4Sstephan
1364bc2f6b4Sstephanifneq (,$(filter release,$(MAKECMDGOALS)))
137b0ccf50cSstephanemcc_opt ?= -Oz -flto
1384bc2f6b4Sstephanelse
139b0ccf50cSstephanemcc_opt ?= -O0
1404bc2f6b4Sstephan# ^^^^ build times for -O levels higher than 0 are painful at
1414bc2f6b4Sstephan# dev-time.
1424bc2f6b4Sstephanendif
143b0ccf50cSstephan# When passing emcc_opt from the CLI, += and re-assignment have no
144b0ccf50cSstephan# effect, so emcc_opt+=-g3 doesn't work. So...
145b0ccf50cSstephanemcc_opt_full := $(emcc_opt) -g3
146b0ccf50cSstephan# ^^^ ALWAYS use -g3. See below for why.
147b0ccf50cSstephan#
1484bc2f6b4Sstephan# ^^^ -flto improves runtime speed at -O0 considerably but doubles
1494bc2f6b4Sstephan# build time.
1504bc2f6b4Sstephan#
1514bc2f6b4Sstephan# ^^^^ -O3, -Oz, -Os minify symbol names and there appears to be no
1524bc2f6b4Sstephan# way around that except to use -g3, but -g3 causes the binary file
1534bc2f6b4Sstephan# size to absolutely explode (approx. 5x larger). This minification
1544bc2f6b4Sstephan# utterly breaks the resulting module, making it unsable except as
1554bc2f6b4Sstephan# self-contained/self-referential-only code, as ALL of the exported
1564bc2f6b4Sstephan# symbols get minified names.
1574bc2f6b4Sstephan#
1584bc2f6b4Sstephan# However, we have an option for using -Oz or -Os:
1594bc2f6b4Sstephan#
1604bc2f6b4Sstephan# Build with (-Os -g3) or (-Oz -g3) then use wasm-strip, from the wabt
1614bc2f6b4Sstephan# tools package (https://github.com/WebAssembly/wabt), to strip the
1624bc2f6b4Sstephan# debugging symbols. That results in a small build with unmangled
1634bc2f6b4Sstephan# symbol names. -Oz gives ever-so-slightly better compression than
1644bc2f6b4Sstephan# -Os: not quite 1% in some completely unscientific tests. Runtime
1654bc2f6b4Sstephan# speed for the unit tests is all over the place either way so it's
1664bc2f6b4Sstephan# difficult to say whether -Os gives any speed benefit over -Oz.
167b0ccf50cSstephan#
168b0ccf50cSstephan# (Much later: -O2 consistently gives the best speeds.)
1694bc2f6b4Sstephan########################################################################
1704bc2f6b4Sstephan
1714bc2f6b4Sstephan
17295639269Sstephan$(sqlite3.c) $(sqlite3.h):
1734bc2f6b4Sstephan	$(MAKE) -C $(dir.top) sqlite3.c
1744bc2f6b4Sstephan
175b5e2e6fcSstephan.PHONY: clean distclean
1764bc2f6b4Sstephanclean:
1774bc2f6b4Sstephan	-rm -f $(CLEAN_FILES)
178b5e2e6fcSstephandistclean: clean
179b5e2e6fcSstephan	-rm -f $(DISTCLEAN_FILES)
1804bc2f6b4Sstephan
1813961b263Sstephanifeq (release,$(filter release,$(MAKECMDGOALS)))
1823961b263Sstephan  ifeq (,$(wasm-strip))
1833961b263Sstephan    $(error Cannot make release-quality binary because wasm-strip is not available. \
1843961b263Sstephan            See notes in the warning above)
1853961b263Sstephan  endif
1863961b263Sstephanelse
1873961b263Sstephan  $(info Development build. Use '$(MAKE) release' for a smaller release build.)
1883961b263Sstephanendif
1893961b263Sstephan
190419e0d3eSstephanbin.version-info := $(dir.wasm)/version-info
19171de8e02Sstephan# ^^^^ NOT in $(dir.tmp) because we need it to survive the cleanup
19271de8e02Sstephan# process for the dist build to work properly.
1933117dc60Sstephan$(bin.version-info): $(dir.wasm)/version-info.c $(sqlite3.h) $(MAKEFILE)
1941b8c2467Sstephan	$(CC) -O0 -I$(dir.top) -o $@ $<
1953117dc60SstephanDISTCLEAN_FILES += $(bin.version-info)
196b5e2e6fcSstephan
1973117dc60Sstephanbin.stripccomments := $(dir.tool)/stripccomments
1983117dc60Sstephan$(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE)
199b5e2e6fcSstephan	$(CC) -o $@ $<
2003117dc60SstephanDISTCLEAN_FILES += $(bin.stripccomments)
2018ffc9899Sstephan
20271de8e02SstephanEXPORTED_FUNCTIONS.api.in := $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-api)
20371de8e02SstephanEXPORTED_FUNCTIONS.api := $(dir.tmp)/EXPORTED_FUNCTIONS.api
20471de8e02Sstephan$(EXPORTED_FUNCTIONS.api): $(EXPORTED_FUNCTIONS.api.in) $(MAKEFILE)
2053961b263Sstephan	cat $(EXPORTED_FUNCTIONS.api.in) > $@
2063961b263Sstephan
20771de8e02Sstephansqlite3-license-version.js := $(dir.tmp)/sqlite3-license-version.js
20895639269Sstephansqlite3-license-version-header.js := $(dir.api)/sqlite3-license-version-header.js
20971de8e02Sstephansqlite3-api-build-version.js := $(dir.tmp)/sqlite3-api-build-version.js
21071de8e02Sstephan# sqlite3-api.jses = the list of JS files which make up $(sqlite3-api.js), in
21171de8e02Sstephan# the order they need to be assembled.
21295639269Sstephansqlite3-api.jses := $(sqlite3-license-version.js)
21395639269Sstephansqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js
214c5313afeSstephansqlite3-api.jses += $(dir.common)/whwasmutil.js
215c5313afeSstephansqlite3-api.jses += $(dir.jacc)/jaccwabyt.js
216c5313afeSstephansqlite3-api.jses += $(dir.api)/sqlite3-api-glue.js
2178ffc9899Sstephansqlite3-api.jses += $(sqlite3-api-build-version.js)
218c5313afeSstephansqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.js
219c5313afeSstephansqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.js
220c5313afeSstephansqlite3-api.jses += $(dir.api)/sqlite3-api-opfs.js
2219a4c63b0Sstephansqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js
2223961b263Sstephan
223cd0df83cSstephan# "External" API files which are part of our distribution
224cd0df83cSstephan# but not part of the sqlite3-api.js amalgamation.
225cd0df83cSstephanSOAP.js := $(dir.api)/sqlite3-opfs-async-proxy.js
226cd0df83cSstephansqlite3-worker1.js := $(dir.api)/sqlite3-worker1.js
227cd0df83cSstephansqlite3-worker1-promiser.js := $(dir.api)/sqlite3-worker1-promiser.js
228cd0df83cSstephandefine CP_XAPI
229cd0df83cSstephansqlite3-api.ext.jses += $$(dir.dout)/$$(notdir $(1))
230cd0df83cSstephan$$(dir.dout)/$$(notdir $(1)): $(1) $$(MAKEFILE)
231cd0df83cSstephan	cp $$< $$@
232cd0df83cSstephanendef
233cd0df83cSstephan$(foreach X,$(SOAP.js) $(sqlite3-worker1.js) $(sqlite3-worker1-promiser.js),\
234cd0df83cSstephan  $(eval $(call CP_XAPI,$(X))))
235cd0df83cSstephanall: $(sqlite3-api.ext.jses)
236cd0df83cSstephan
23771de8e02Sstephansqlite3-api.js := $(dir.tmp)/sqlite3-api.js
2383961b263Sstephan$(sqlite3-api.js): $(sqlite3-api.jses) $(MAKEFILE)
2393961b263Sstephan	@echo "Making $@..."
2403961b263Sstephan	@for i in $(sqlite3-api.jses); do \
2413961b263Sstephan		echo "/* BEGIN FILE: $$i */"; \
2423961b263Sstephan		cat $$i; \
2433961b263Sstephan		echo "/* END FILE: $$i */"; \
2443961b263Sstephan	done > $@
2453961b263Sstephan
2463117dc60Sstephan$(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE)
2478ffc9899Sstephan	@echo "Making $@..."
2488ffc9899Sstephan	@{ \
2498ffc9899Sstephan  echo 'self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \
2508ffc9899Sstephan	echo -n '  sqlite3.version = '; \
2513117dc60Sstephan  $(bin.version-info) --json; \
2528ffc9899Sstephan  echo ';'; \
2538ffc9899Sstephan	echo '});'; \
2548ffc9899Sstephan  } > $@
2558ffc9899Sstephan
256f71c954cSstephan########################################################################
257f71c954cSstephan# --post-js and --pre-js are emcc flags we use to append/prepend JS to
258f71c954cSstephan# the generated emscripten module file.
259f71c954cSstephanpre-js.js := $(dir.api)/pre-js.js
26071de8e02Sstephanpost-js.js := $(dir.tmp)/post-js.js
2613961b263Sstephanpost-jses := \
2623961b263Sstephan  $(dir.api)/post-js-header.js \
2633961b263Sstephan  $(sqlite3-api.js) \
2643961b263Sstephan  $(dir.api)/post-js-footer.js
2653961b263Sstephan$(post-js.js): $(post-jses) $(MAKEFILE)
2663961b263Sstephan	@echo "Making $@..."
2673961b263Sstephan	@for i in $(post-jses); do \
2683961b263Sstephan		echo "/* BEGIN FILE: $$i */"; \
2693961b263Sstephan		cat $$i; \
2703961b263Sstephan		echo "/* END FILE: $$i */"; \
2713961b263Sstephan	done > $@
272b94a9860Sstephanextern-post-js.js := $(dir.api)/extern-post-js.js
273f71c954cSstephanextern-pre-js.js := $(dir.api)/extern-pre-js.js
274f71c954cSstephanpre-post-common.flags := \
275f71c954cSstephan  --post-js=$(post-js.js) \
276f71c954cSstephan  --extern-post-js=$(extern-post-js.js) \
27771de8e02Sstephan  --extern-pre-js=$(sqlite3-license-version.js)
278f71c954cSstephanpre-post-jses.deps := $(post-js.js) \
27995639269Sstephan  $(extern-post-js.js) $(extern-pre-js.js) $(sqlite3-license-version.js)
28095639269Sstephan$(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js) $(MAKEFILE)
28195639269Sstephan	@echo "Making $@..."; { \
28295639269Sstephan    cat $(sqlite3-license-version-header.js); \
28395639269Sstephan    echo '/*'; \
28495639269Sstephan    echo '** This code was built from sqlite3 version...'; \
28595639269Sstephan    echo "** "; \
28695639269Sstephan    awk -e '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' \
28795639269Sstephan        -e '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \
28895639269Sstephan    echo '*/'; \
28995639269Sstephan   } > $@
29095639269Sstephan
291f71c954cSstephan########################################################################
292f71c954cSstephan# call-make-pre-js creates rules for pre-js-$(1).js. $1 = the base
293f71c954cSstephan# name of the JS file on whose behalf this pre-js is for.
294f71c954cSstephandefine call-make-pre-js
295f71c954cSstephanpre-post-$(1).flags ?=
2968a8244b5Sstephan$$(dir.tmp)/pre-js-$(1).js: $$(pre-js.js) $$(MAKEFILE)
297f71c954cSstephan	cp $$(pre-js.js) $$@
2981fc6ffccSstephan	@if [ sqlite3-wasmfs = $(1) ]; then \
2991fc6ffccSstephan		echo "delete Module[xNameOfInstantiateWasm] /*for WASMFS build*/;"; \
3001fc6ffccSstephan	elif [ sqlite3 != $(1) ]; then \
3011fc6ffccSstephan		echo "Module[xNameOfInstantiateWasm].uri = '$(1).wasm';"; \
3021fc6ffccSstephan	fi >> $$@
3038a8244b5Sstephanpre-post-$(1).deps := $$(pre-post-jses.deps) $$(dir.tmp)/pre-js-$(1).js
3048a8244b5Sstephanpre-post-$(1).flags += --pre-js=$$(dir.tmp)/pre-js-$(1).js
305f71c954cSstephanendef
306f71c954cSstephan#$(error $(call call-make-pre-js,sqlite3-wasmfs))
307f71c954cSstephan# /post-js and pre-js
308f71c954cSstephan########################################################################
3093961b263Sstephan
3103961b263Sstephan########################################################################
311cdefd5d0Sstephan# emcc flags for .c/.o/.wasm/.js.
3128a8244b5Sstephanemcc.flags :=
3133961b263Sstephan#emcc.flags += -v # _very_ loud but also informative about what it's doing
3148a8244b5Sstephan# -g3 is needed to keep -O2 and higher from creating broken JS via
315cdefd5d0Sstephan# minification.
3163961b263Sstephan
3173961b263Sstephan########################################################################
3183961b263Sstephan# emcc flags for .c/.o.
3193961b263Sstephanemcc.cflags :=
3203961b263Sstephanemcc.cflags += -std=c99 -fPIC
3213961b263Sstephan# -------------^^^^^^^^ we currently need c99 for WASM-specific sqlite3 APIs.
3224bc2f6b4Sstephanemcc.cflags += -I. -I$(dir.top)
3233961b263Sstephan
3243961b263Sstephan########################################################################
3253961b263Sstephan# emcc flags specific to building the final .js/.wasm file...
3263961b263Sstephanemcc.jsflags := -fPIC
327b5ae85ecSstephanemcc.jsflags += --minify 0
3283961b263Sstephanemcc.jsflags += --no-entry
3293961b263Sstephanemcc.jsflags += -sMODULARIZE
3303961b263Sstephanemcc.jsflags += -sSTRICT_JS
3313961b263Sstephanemcc.jsflags += -sDYNAMIC_EXECUTION=0
3323961b263Sstephanemcc.jsflags += -sNO_POLYFILL
33371de8e02Sstephanemcc.jsflags += -sEXPORTED_FUNCTIONS=@$(EXPORTED_FUNCTIONS.api)
334b5ae85ecSstephanemcc.exportedRuntimeMethods := \
33571de8e02Sstephan    -sEXPORTED_RUNTIME_METHODS=FS,wasmMemory
336b5ae85ecSstephan    # FS ==> stdio/POSIX I/O proxies
337d1582296Sstephan    # wasmMemory ==> required by our code for use with -sIMPORTED_MEMORY
338b5ae85ecSstephanemcc.jsflags += $(emcc.exportedRuntimeMethods)
3393961b263Sstephanemcc.jsflags += -sUSE_CLOSURE_COMPILER=0
3403961b263Sstephanemcc.jsflags += -sIMPORTED_MEMORY
341f71c954cSstephanemcc.environment := -sENVIRONMENT=web,worker
342af9cee12Sstephan########################################################################
343af9cee12Sstephan# -sINITIAL_MEMORY: How much memory we need to start with is governed
344af9cee12Sstephan# at least in part by whether -sALLOW_MEMORY_GROWTH is enabled. If so,
345af9cee12Sstephan# we can start with less. If not, we need as much as we'll ever
346af9cee12Sstephan# possibly use (which, of course, we can't know for sure).  Note,
347af9cee12Sstephan# however, that speedtest1 shows that performance for even moderate
348af9cee12Sstephan# workloads MAY suffer considerably if we start small and have to grow
349af9cee12Sstephan# at runtime. e.g. OPFS-backed (speedtest1 --size 75) take MAY take X
350af9cee12Sstephan# time with 16mb+ memory and 3X time when starting with 8MB. However,
351af9cee12Sstephan# such test results are inconsistent due to browser internals which
352af9cee12Sstephan# are opaque to us.
35310252272Sstephanemcc.jsflags += -sALLOW_MEMORY_GROWTH
354af9cee12Sstephanemcc.INITIAL_MEMORY.128 := 13107200
355af9cee12Sstephanemcc.INITIAL_MEMORY.96  := 100663296
356af9cee12Sstephanemcc.INITIAL_MEMORY.64  := 64225280
357af9cee12Sstephanemcc.INITIAL_MEMORY.32  := 33554432
358af9cee12Sstephanemcc.INITIAL_MEMORY.16  := 16777216
359af9cee12Sstephanemcc.INITIAL_MEMORY.8   := 8388608
360af9cee12Sstephanemcc.INITIAL_MEMORY ?= 16
361af9cee12Sstephanifeq (,$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY)))
362af9cee12Sstephan$(error emcc.INITIAL_MEMORY must be one of: 8, 16, 32, 64, 96, 128 (megabytes))
363af9cee12Sstephanendif
364af9cee12Sstephanemcc.jsflags += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY))
365af9cee12Sstephan# /INITIAL_MEMORY
366af9cee12Sstephan########################################################################
367af9cee12Sstephan
3689a4c63b0Sstephanemcc.jsflags += $(emcc.environment)
3693961b263Sstephan#emcc.jsflags += -sTOTAL_STACK=4194304
370b94a9860Sstephan
371b94a9860Sstephansqlite3.js.init-func := sqlite3InitModule
37289954fe7Sstephan# ^^^^ $(sqlite3.js.init-func) symbol name is hard-coded in
37389954fe7Sstephan# $(extern-post-js.js) as well as in numerous docs. If changed, it
37489954fe7Sstephan# needs to be globally modified in *.js and all related documentation.
375b94a9860Sstephan
376b94a9860Sstephanemcc.jsflags += -sEXPORT_NAME=$(sqlite3.js.init-func)
3773961b263Sstephanemcc.jsflags += -sGLOBAL_BASE=4096 # HYPOTHETICALLY keep func table indexes from overlapping w/ heap addr.
3783961b263Sstephan#emcc.jsflags += -sSTRICT # fails due to missing __syscall_...()
3793961b263Sstephan#emcc.jsflags += -sALLOW_UNIMPLEMENTED_SYSCALLS
3803961b263Sstephan#emcc.jsflags += -sFILESYSTEM=0 # only for experimentation. sqlite3 needs the FS API
3813961b263Sstephan#emcc.jsflags += -sABORTING_MALLOC
3823961b263Sstephanemcc.jsflags += -sALLOW_TABLE_GROWTH
38389954fe7Sstephan# -sALLOW_TABLE_GROWTH is required for installing new SQL UDFs
3843961b263Sstephanemcc.jsflags += -Wno-limited-postlink-optimizations
3853961b263Sstephan# ^^^^^ it likes to warn when we have "limited optimizations" via the -g3 flag.
3863961b263Sstephan#emcc.jsflags += -sSTANDALONE_WASM # causes OOM errors, not sure why
3873961b263Sstephan# https://lld.llvm.org/WebAssembly.html
3883961b263Sstephanemcc.jsflags += -sERROR_ON_UNDEFINED_SYMBOLS=0
3893961b263Sstephanemcc.jsflags += -sLLD_REPORT_UNDEFINED
3903961b263Sstephan#emcc.jsflags += --allow-undefined
39171de8e02Sstephan#emcc.jsflags += --import-undefined
3923961b263Sstephan#emcc.jsflags += --unresolved-symbols=import-dynamic --experimental-pic
3933961b263Sstephan#emcc.jsflags += --experimental-pic --unresolved-symbols=ingore-all --import-undefined
3943961b263Sstephan#emcc.jsflags += --unresolved-symbols=ignore-all
3951fc6ffccSstephanemcc.jsflags += -sWASM_BIGINT=$(emcc.WASM_BIGINT)
3961fc6ffccSstephan
3971fc6ffccSstephan########################################################################
3981fc6ffccSstephan# -sMEMORY64=1 fails to load, erroring with:
3993961b263Sstephan#  invalid memory limits flags 0x5
4003961b263Sstephan#    (enable via --experimental-wasm-memory64)
4013961b263Sstephan#
4023961b263Sstephan# ^^^^ MEMORY64=2 builds and loads but dies when we do things like:
4033961b263Sstephan#
4041fc6ffccSstephan#  new Uint8Array(wasm.heap8u().buffer, ptr, n)
4053961b263Sstephan#
4063961b263Sstephan# because ptr is now a BigInt, so is invalid for passing to arguments
40710252272Sstephan# which have strict must-be-a-Number requirements.
4083961b263Sstephan########################################################################
4093961b263Sstephan
4103961b263Sstephan
411ab7de450Sstephan########################################################################
4123a59dd12Sstephan# -sSINGLE_FILE:
4133a59dd12Sstephan# https://github.com/emscripten-core/emscripten/blob/main/src/settings.js#L1704
4141fc6ffccSstephan# -sSINGLE_FILE=1 would be really nice but we have to build with -g3
4153a59dd12Sstephan# for -O2 and higher to work (else minification breaks the code) and
4163a59dd12Sstephan# cannot wasm-strip the binary before it gets encoded into the JS
4171fc6ffccSstephan# file. The result is that the generated JS file is, because of the -g3
4183a59dd12Sstephan# debugging info, _huge_.
4193a59dd12Sstephan########################################################################
4203a59dd12Sstephan
421*7d24ff29Sstephan########################################################################
422*7d24ff29Sstephan# AN EXPERIMENT: undocumented Emscripten feature: if the target file
423*7d24ff29Sstephan# extension is "mjs", it defaults to ES6 module builds:
424*7d24ff29Sstephan# https://github.com/emscripten-core/emscripten/issues/14383
425*7d24ff29Sstephanifeq (,$(filter esm,$(MAKECMDGOALS)))
426*7d24ff29Sstephansqlite3.js.ext := js
427*7d24ff29Sstephanelse
428*7d24ff29Sstephanesm.deps := $(filter-out esm,$(MAKECMDGOALS))
429*7d24ff29Sstephanesm: $(if $(esm.deps),$(esm.deps),all)
430*7d24ff29Sstephansqlite3.js.ext := mjs
431*7d24ff29Sstephanendif
432*7d24ff29Sstephan# /esm
433*7d24ff29Sstephan########################################################################
434*7d24ff29Sstephansqlite3.js := $(dir.dout)/sqlite3.$(sqlite3.js.ext)
43571de8e02Sstephansqlite3.wasm := $(dir.dout)/sqlite3.wasm
4361174c23eSstephansqlite3-wasm.c := $(dir.api)/sqlite3-wasm.c
43771de8e02Sstephan# sqlite3-wasm.o vs sqlite3-wasm.c: building against the latter
43871de8e02Sstephan# (predictably) results in a slightly faster binary, but we're close
43971de8e02Sstephan# enough to the target speed requirements that the 500ms makes a
44071de8e02Sstephan# difference. Thus we build all binaries against sqlite3-wasm.c
44171de8e02Sstephan# instead of building a shared copy of sqlite3-wasm.o.
442f71c954cSstephan$(eval $(call call-make-pre-js,sqlite3))
443cd0df83cSstephan$(sqlite3.js):
4443961b263Sstephan$(sqlite3.js): $(MAKEFILE) $(sqlite3.wasm.obj) \
44571de8e02Sstephan    $(EXPORTED_FUNCTIONS.api) \
446f71c954cSstephan    $(pre-post-sqlite3.deps)
4470117693fSstephan	@echo "Building $@ ..."
448f71c954cSstephan	$(emcc.bin) -o $@ $(emcc_opt_full) $(emcc.flags) \
449f71c954cSstephan    $(emcc.jsflags) $(pre-post-common.flags) $(pre-post-sqlite3.flags) \
45071de8e02Sstephan    $(cflags.common) $(SQLITE_OPT) $(sqlite3-wasm.c)
4513961b263Sstephan	chmod -x $(sqlite3.wasm)
45228ef9bddSstephan	$(maybe-wasm-strip) $(sqlite3.wasm)
4533961b263Sstephan	@ls -la $@ $(sqlite3.wasm)
4541b8c2467Sstephan$(sqlite3.wasm): $(sqlite3.js)
4553961b263SstephanCLEAN_FILES += $(sqlite3.js) $(sqlite3.wasm)
4563961b263Sstephanall: $(sqlite3.js)
45753f635dfSstephanwasm: $(sqlite3.js)
4583961b263Sstephan# End main Emscripten-based module build
4593961b263Sstephan########################################################################
4603961b263Sstephan
4612cae138fSstephan########################################################################
4628fc8b5b3Sstephan# batch-runner.js...
463fbf0f488Sstephandir.sql := sql
4642cae138fSstephanspeedtest1 := ../../speedtest1
465100b496dSstephanspeedtest1.c := ../../test/speedtest1.c
466fbf0f488Sstephanspeedtest1.sql := $(dir.sql)/speedtest1.sql
4675ad36319Sstephanspeedtest1.cliflags := --size 25 --big-transactions
4682cae138fSstephan$(speedtest1):
4692cae138fSstephan	$(MAKE) -C ../.. speedtest1
47023d39ce5Sstephan$(speedtest1.sql): $(speedtest1) $(MAKEFILE)
47123d39ce5Sstephan	$(speedtest1) $(speedtest1.cliflags) --script $@
472fbf0f488Sstephanbatch-runner.list: $(MAKEFILE) $(speedtest1.sql) $(dir.sql)/000-mandelbrot.sql
473fbf0f488Sstephan	bash split-speedtest1-script.sh $(dir.sql)/speedtest1.sql
474fbf0f488Sstephan	ls -1 $(dir.sql)/*.sql | grep -v speedtest1.sql | sort > $@
475cdefd5d0Sstephanclean-batch:
476cdefd5d0Sstephan	rm -f batch-runner.list $(dir.sql)/speedtest1*.sql
477cdefd5d0Sstephan# ^^^ we don't do this along with 'clean' because we clean/rebuild on
478cdefd5d0Sstephan# a regular basis with different -Ox flags and rebuilding the batch
479cdefd5d0Sstephan# pieces each time is an unnecessary time sink.
4802cae138fSstephanbatch: batch-runner.list
481fbf0f488Sstephanall: batch
4828fc8b5b3Sstephan# end batch-runner.js
4838fc8b5b3Sstephan########################################################################
4848fc8b5b3Sstephan# speedtest1.js...
48528ef9bddSstephan# speedtest1-common.eflags = emcc flags used by multiple builds of speedtest1
48628ef9bddSstephan# speedtest1.eflags = emcc flags used by main build of speedtest1
487b0ccf50cSstephanspeedtest1-common.eflags := $(emcc_opt_full)
48828ef9bddSstephanspeedtest1.eflags :=
4890144a848Sstephanspeedtest1.eflags += -sENVIRONMENT=web
4901fc6ffccSstephanspeedtest1.eflags += -sALLOW_MEMORY_GROWTH
4911fc6ffccSstephanspeedtest1.eflags += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY))
49228ef9bddSstephanspeedtest1-common.eflags += -sINVOKE_RUN=0
493b5ae85ecSstephanspeedtest1-common.eflags += --no-entry
494b5ae85ecSstephan#speedtest1-common.eflags += -flto
49528ef9bddSstephanspeedtest1-common.eflags += -sABORTING_MALLOC
49628ef9bddSstephanspeedtest1-common.eflags += -sSTRICT_JS
49728ef9bddSstephanspeedtest1-common.eflags += -sMODULARIZE
49828ef9bddSstephanspeedtest1-common.eflags += -Wno-limited-postlink-optimizations
49971de8e02SstephanEXPORTED_FUNCTIONS.speedtest1 := $(abspath $(dir.tmp)/EXPORTED_FUNCTIONS.speedtest1)
50071de8e02Sstephanspeedtest1-common.eflags += -sEXPORTED_FUNCTIONS=@$(EXPORTED_FUNCTIONS.speedtest1)
501b5ae85ecSstephanspeedtest1-common.eflags += $(emcc.exportedRuntimeMethods)
502b5ae85ecSstephanspeedtest1-common.eflags += -sALLOW_TABLE_GROWTH
50328ef9bddSstephanspeedtest1-common.eflags += -sDYNAMIC_EXECUTION=0
50428ef9bddSstephanspeedtest1-common.eflags += --minify 0
505b94a9860Sstephanspeedtest1-common.eflags += -sEXPORT_NAME=$(sqlite3.js.init-func)
5061fc6ffccSstephanspeedtest1-common.eflags += -sWASM_BIGINT=$(emcc.WASM_BIGINT)
507f71c954cSstephanspeedtest1-common.eflags += $(pre-post-common.flags)
5080144a848Sstephanspeedtest1.exit-runtime0 := -sEXIT_RUNTIME=0
5090144a848Sstephanspeedtest1.exit-runtime1 := -sEXIT_RUNTIME=1
5100144a848Sstephan# Re -sEXIT_RUNTIME=1 vs 0: if it's 1 and speedtest1 crashes, we get
5110144a848Sstephan# this error from emscripten:
5120144a848Sstephan#
5130144a848Sstephan# > native function `free` called after runtime exit (use
5140144a848Sstephan# NO_EXIT_RUNTIME to keep it alive after main() exits))
5150144a848Sstephan#
5160144a848Sstephan# If it's 0 and it crashes, we get:
5170144a848Sstephan#
5180144a848Sstephan# > stdio streams had content in them that was not flushed. you should
5190144a848Sstephan# set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline
5200144a848Sstephan# when you printf etc.
5210144a848Sstephan#
5220144a848Sstephan# and pending output is not flushed because it didn't end with a
5230144a848Sstephan# newline (by design). The lesser of the two evils seems to be
5240144a848Sstephan# -sEXIT_RUNTIME=1 but we need EXIT_RUNTIME=0 for the worker-based app
5250144a848Sstephan# which runs speedtest1 multiple times.
5263961b263Sstephan
52771de8e02Sstephan$(EXPORTED_FUNCTIONS.speedtest1): $(EXPORTED_FUNCTIONS.api)
52871de8e02Sstephan	@echo "Making $@ ..."
52971de8e02Sstephan	@{ echo _wasm_main; cat $(EXPORTED_FUNCTIONS.api); } > $@
53071de8e02Sstephanspeedtest1.js := $(dir.dout)/speedtest1.js
5318fc8b5b3Sstephanspeedtest1.wasm := $(subst .js,.wasm,$(speedtest1.js))
53271de8e02Sstephanspeedtest1.cflags := $(cflags.common) -DSQLITE_SPEEDTEST1_WASM
53371de8e02Sstephanspeedtest1.cses := $(speedtest1.c) $(sqlite3-wasm.c)
534f71c954cSstephan$(eval $(call call-make-pre-js,speedtest1))
53571de8e02Sstephan$(speedtest1.js): $(MAKEFILE) $(speedtest1.cses) \
536f71c954cSstephan    $(pre-post-speedtest1.deps) \
53771de8e02Sstephan    $(EXPORTED_FUNCTIONS.speedtest1)
5380117693fSstephan	@echo "Building $@ ..."
5398fc8b5b3Sstephan	$(emcc.bin) \
54028ef9bddSstephan        $(speedtest1.eflags) $(speedtest1-common.eflags) $(speedtest1.cflags) \
541f71c954cSstephan        $(pre-post-speedtest1.flags) \
5420b769f5bSstephan        $(SQLITE_OPT) \
5430144a848Sstephan        $(speedtest1.exit-runtime0) \
54471de8e02Sstephan        -o $@ $(speedtest1.cses) -lm
54528ef9bddSstephan	$(maybe-wasm-strip) $(speedtest1.wasm)
5468fc8b5b3Sstephan	ls -la $@ $(speedtest1.wasm)
547100b496dSstephan
548100b496dSstephanspeedtest1: $(speedtest1.js)
5490b769f5bSstephanall: speedtest1
5508fc8b5b3SstephanCLEAN_FILES += $(speedtest1.js) $(speedtest1.wasm)
5518fc8b5b3Sstephan# end speedtest1.js
5523961b263Sstephan########################################################################
5538c3b7501Sstephan
5548c3b7501Sstephan########################################################################
55528ef9bddSstephan# Convenience rules to rebuild with various -Ox levels. Much
55628ef9bddSstephan# experimentation shows -O2 to be the clear winner in terms of speed.
55728ef9bddSstephan# Note that build times with anything higher than -O0 are somewhat
55828ef9bddSstephan# painful.
5595e8bb0aaSstephan
56028ef9bddSstephan.PHONY: o0 o1 o2 o3 os oz
561b5e2e6fcSstephano-xtra := -flto
562d9801185Sstephan# ^^^^ -flto can have a considerably performance boost at -O0 but
563d9801185Sstephan# doubles the build time and seems to have negligible effect on
564d9801185Sstephan# higher optimization levels.
565f75c0c70Sstephano0: clean
5663117dc60Sstephan	$(MAKE) -e "emcc_opt=-O0"
567f75c0c70Sstephano1: clean
568b0ccf50cSstephan	$(MAKE) -e "emcc_opt=-O1 $(o-xtra)"
569f75c0c70Sstephano2: clean
570b0ccf50cSstephan	$(MAKE) -e "emcc_opt=-O2 $(o-xtra)"
571f75c0c70Sstephano3: clean
572b0ccf50cSstephan	$(MAKE) -e "emcc_opt=-O3 $(o-xtra)"
573f75c0c70Sstephanos: clean
5746559e0abSstephan	@echo "WARNING: -Os can result in a build with mysteriously missing pieces!"
575b0ccf50cSstephan	$(MAKE) -e "emcc_opt=-Os $(o-xtra)"
576f75c0c70Sstephanoz: clean
577b0ccf50cSstephan	$(MAKE) -e "emcc_opt=-Oz $(o-xtra)"
57828ef9bddSstephan
57928ef9bddSstephan########################################################################
58028ef9bddSstephan# Sub-makes...
581ed853339Sstephan
5824bc2f6b4Sstephaninclude fiddle.make
5834bc2f6b4Sstephan
584de6186e0Sstephan# Only add wasmfs if wasmfs.enable=1 or we're running (dist)clean
585de6186e0Sstephanwasmfs.enable ?= $(if $(filter %clean,$(MAKECMDGOALS)),1,0)
586de6186e0Sstephanifeq (1,$(wasmfs.enable))
587de6186e0Sstephan# wasmfs build disabled 2022-10-19 per /chat discussion.
588de6186e0Sstephan# OPFS-over-wasmfs was initially a stopgap measure and a convenient
589de6186e0Sstephan# point of comparison for the OPFS sqlite3_vfs's performance, but it
590de6186e0Sstephan# currently doubles our deliverables and build maintenance burden for
591de6186e0Sstephan# little, if any, benefit.
59271de8e02Sstephan#
593ed853339Sstephan########################################################################
594ed853339Sstephan# Some platforms do not support the WASMFS build. Raspberry Pi OS is one
595ed853339Sstephan# of them. As such platforms are discovered, add their (uname -m) name
596ed853339Sstephan# to PLATFORMS_WITH_NO_WASMFS to exclude the wasmfs build parts.
597ed853339SstephanPLATFORMS_WITH_NO_WASMFS := aarch64 # add any others here
598ed853339SstephanTHIS_ARCH := $(shell /usr/bin/uname -m)
599ed853339Sstephanifneq (,$(filter $(THIS_ARCH),$(PLATFORMS_WITH_NO_WASMFS)))
600ed853339Sstephan$(info This platform does not support the WASMFS build.)
601b5e2e6fcSstephanHAVE_WASMFS := 0
602ed853339Sstephanelse
603b5e2e6fcSstephanHAVE_WASMFS := 1
6040117693fSstephaninclude wasmfs.make
605ed853339Sstephanendif
60671de8e02Sstephanendif
60771de8e02Sstephan# /wasmfs
60871de8e02Sstephan########################################################################
6094bc2f6b4Sstephan
6104bc2f6b4Sstephan########################################################################
61171de8e02Sstephan# Create deliverables:
612e79a0943Sstephanifneq (,$(filter dist,$(MAKECMDGOALS)))
613e79a0943Sstephaninclude dist.make
614e79a0943Sstephanendif
6150467b01aSstephan
6160467b01aSstephan########################################################################
6174bc2f6b4Sstephan# Push files to public wasm-testing.sqlite.org server
618a817b30fSstephanwasm-testing.include = $(dir.dout) *.js *.html \
619a817b30fSstephan    batch-runner.list $(dir.sql) $(dir.common) $(dir.fiddle) $(dir.jacc)
6204bc2f6b4Sstephanwasm-testing.exclude = sql/speedtest1.sql
6214bc2f6b4Sstephanwasm-testing.dir     = /jail/sites/wasm-testing
6224bc2f6b4Sstephanwasm-testing.dest   ?= wasm-testing:$(wasm-testing.dir)
6234bc2f6b4Sstephan# ---------------------^^^^^^^^^^^^ ssh alias
624df52a0bcSstephan.PHONY: push-testing
625df52a0bcSstephanpush-testing:
6264bc2f6b4Sstephan	rsync -z -e ssh --ignore-times --chown=stephan:www-data --group -r \
6274bc2f6b4Sstephan    $(patsubst %,--exclude=%,$(wasm-testing.exclude)) \
6284bc2f6b4Sstephan    $(wasm-testing.include) $(wasm-testing.dest)
629df52a0bcSstephan	@echo "Updating gzipped copies..."; \
6304bc2f6b4Sstephan		ssh wasm-testing 'cd $(wasm-testing.dir) && bash .gzip' || \
6314bc2f6b4Sstephan    echo "SSH failed: it's likely that stale content will be served via old gzip files."
6328948fbeeSstephan
633df52a0bcSstephan########################################################################
634df52a0bcSstephan# If we find a copy of the sqlite.org/wasm docs checked out, copy
635df52a0bcSstephan# certain files over to it, noting that some need automatable edits...
636df52a0bcSstephanWDOCS.home ?= ../../../wdoc
637df52a0bcSstephan.PHONY: update-docs
638df52a0bcSstephanifneq (,$(wildcard $(WDOCS.home)/api-index.md))
639df52a0bcSstephanWDOCS.jswasm := $(WDOCS.home)/jswasm
640df52a0bcSstephanupdate-docs: $(bin.stripccomments) $(sqlite3.js) $(sqlite3.wasm)
641df52a0bcSstephan	@echo "Copying files to the /wasm docs. Be sure to use an -Oz build for this!"
6428948fbeeSstephan	cp $(sqlite3.wasm) $(WDOCS.jswasm)/.
643df52a0bcSstephan	$(bin.stripccomments) -k -k < $(sqlite3.js) \
644df52a0bcSstephan		| sed -e '/^[ \t]*$$/d' > $(WDOCS.jswasm)/sqlite3.js
6458948fbeeSstephan	cp demo-123.js demo-123.html demo-123-worker.html $(WDOCS.home)
6468948fbeeSstephan	sed -n -e '/EXTRACT_BEGIN/,/EXTRACT_END/p' \
6478948fbeeSstephan		module-symbols.html > $(WDOCS.home)/module-symbols.html
6488948fbeeSstephanelse
6498948fbeeSstephanupdate-docs:
650df52a0bcSstephan	@echo "Cannot find wasm docs checkout."; \
651df52a0bcSstephan	echo "Pass WDOCS.home=/path/to/wasm/docs/checkout or edit this makefile to suit."; \
652df52a0bcSstephan	exit 127
6538948fbeeSstephanendif
654df52a0bcSstephan# end /wasm docs
655df52a0bcSstephan########################################################################
656