Snapshot of upstream SQLite 3.40.1
[sqlcipher.git] / ext / wasm / dist.make
blob5aee8af779d2034b2b93b52b4266501208e7e19d
1 #!/do/not/make
2 #^^^ help emacs select edit mode
4 # Intended to include'd by ./GNUmakefile.
6 # 'make dist' rules for creating a distribution archive of the WASM/JS
7 # pieces, noting that we only build a dist of the built files, not the
8 # numerous pieces required to build them.
9 #######################################################################
10 MAKEFILE.dist := $(lastword $(MAKEFILE_LIST))
12 ########################################################################
13 # Chicken/egg situation: we need $(bin.version-info) to get the version
14 # info for the archive name, but that binary may not yet be built, and
15 # won't be built until we expand the dependencies. We have to use a
16 # temporary name for the archive.
17 dist-name = sqlite-wasm-TEMP
18 #ifeq (0,1)
19 # $(info WARNING *******************************************************************)
20 # $(info ** Be sure to create the desired build configuration before creating the)
21 # $(info ** distribution archive. Use one of the following targets to do so:)
22 # $(info **)
23 # $(info ** o2: builds with -O2, resulting in the fastest builds)
24 # $(info ** oz: builds with -Oz, resulting in the smallest builds)
25 # $(info /WARNING *******************************************************************)
26 #endif
28 ########################################################################
29 # dist.build must be the name of a target which triggers the
30 # build of the files to be packed into the dist archive. The
31 # intention is that it be one of (o0, o1, o2, o3, os, oz), each of
32 # which uses like-named -Ox optimization level flags. The o2 target
33 # provides the best overall runtime speeds. The oz target provides
34 # slightly slower speeds (roughly 10%) with significantly smaller WASM
35 # file sizes. Note that -O2 (the o2 target) results in faster binaries
36 # than both -O3 and -Os (the o3 and os targets) in all tests run to
37 # date.
38 dist.build ?= oz
40 dist-dir.top := $(dist-name)
41 dist-dir.jswasm := $(dist-dir.top)/$(notdir $(dir.dout))
42 dist-dir.common := $(dist-dir.top)/common
43 dist.top.extras := \
44 demo-123.html demo-123-worker.html demo-123.js \
45 tester1.html tester1-worker.html tester1.js \
46 demo-jsstorage.html demo-jsstorage.js \
47 demo-worker1.html demo-worker1.js \
48 demo-worker1-promiser.html demo-worker1-promiser.js
49 dist.jswasm.extras := $(sqlite3-api.ext.jses) $(sqlite3.wasm)
50 dist.common.extras := \
51 $(wildcard $(dir.common)/*.css) \
52 $(dir.common)/SqliteTestUtil.js
54 .PHONY: dist
55 ########################################################################
56 # dist: create the end-user deliverable archive.
58 # Maintenance reminder: because dist depends on $(dist.build), and
59 # $(dist.build) will depend on clean, having any deps on
60 # $(dist-archive) which themselves may be cleaned up by the clean
61 # target will lead to grief in parallel builds (-j #). Thus
62 # $(dist-target)'s deps must be trimmed to non-generated files or
63 # files which are _not_ cleaned up by the clean target.
65 # Note that we require $(bin.version-info) in order to figure out the
66 # dist file's name, so cannot (without a recursive make) have the
67 # target name equal to the archive name.
68 dist: \
69 $(bin.stripccomments) $(bin.version-info) \
70 $(dist.build) \
71 $(MAKEFILE) $(MAKEFILE.dist)
72 @echo "Making end-user deliverables..."
73 @rm -fr $(dist-dir.top)
74 @mkdir -p $(dist-dir.jswasm) $(dist-dir.common)
75 @cp -p $(dist.top.extras) $(dist-dir.top)
76 @cp -p README-dist.txt $(dist-dir.top)/README.txt
77 @cp -p index-dist.html $(dist-dir.top)/index.html
78 @cp -p $(dist.jswasm.extras) $(dist-dir.jswasm)
79 @$(bin.stripccomments) -k -k < $(sqlite3.js) \
80 > $(dist-dir.jswasm)/$(notdir $(sqlite3.js))
81 @cp -p $(dist.common.extras) $(dist-dir.common)
82 @set -e; \
83 vnum=$$($(bin.version-info) --download-version); \
84 vdir=sqlite-wasm-$$vnum; \
85 arczip=$$vdir.zip; \
86 echo "Making $$arczip ..."; \
87 rm -fr $$arczip $$vdir; \
88 mv $(dist-dir.top) $$vdir; \
89 zip -qr $$arczip $$vdir; \
90 rm -fr $$vdir; \
91 ls -la $$arczip; \
92 set +e; \
93 unzip -lv $$arczip || echo "Missing unzip app? Not fatal."
95 # We need a separate `clean` rule to account for weirdness in
96 # a sub-make, where we get a copy of the $(dist-name) dir
97 # copied into the new $(dist-name) dir.
98 .PHONY: dist-clean
99 clean: dist-clean
100 dist-clean:
101 rm -fr $(dist-name) $(wildcard sqlite-wasm-*.zip)