blob: 4f918efe9150a5be29654cb1adb31ddf6910374b [file] [log] [blame]
swissChili729acd52024-03-05 11:52:45 -05001CFLAGS = -Os -DSUPPORT_UTF8 -sASYNCIFY -sEXPORTED_RUNTIME_METHODS=ccall,cwrap,stringToNewUTF8 \
2 -sEXPORTED_FUNCTIONS=_test_int,_do_a_conversion -sMODULARIZE -s 'EXPORT_NAME="createMyModule"' \
swissChili281af442024-11-14 23:30:29 -05003 --no-entry -flto -sASSERTIONS
swissChili729acd52024-03-05 11:52:45 -05004
swissChili281af442024-11-14 23:30:29 -05005ESFLAGS = --bundle --minify --loader:.js=jsx --platform=node
swissChiliab615d82024-03-08 17:15:13 -05006
swissChili281af442024-11-14 23:30:29 -05007WEBCFLAGS = -Os -framework WebKit -framework Cocoa -std=c++11 -flto
swissChiliab615d82024-03-08 17:15:13 -05008
swissChili281af442024-11-14 23:30:29 -05009CC=clang
10MC=clang
11CXX=clang++
12
13webview-frontend: webview-frontend.cpp units.o getopt.o getopt1.o parse.tab.o strfunc.o menu.o | bundle-webview-js.h
14 $(CXX) $^ -o webview-frontend $(WEBCFLAGS) -I json/include
swissChili4f0a0a82024-03-08 18:58:38 -050015 strip $@
swissChiliab615d82024-03-08 17:15:13 -050016
swissChili281af442024-11-14 23:30:29 -050017app-bundle: webview-frontend
18 cp webview-frontend Units.app/Contents/MacOS/
19 rm -rf /Applications/Units.app
20 cp -r Units.app /Applications
21
22menu.o: webview/menu.m
23 $(MC) $^ -c -o $@ -flto -Os
24
swissChiliab615d82024-03-08 17:15:13 -050025units.wasm: units.c
swissChili729acd52024-03-05 11:52:45 -050026 emcc -o units.lib.js *.c $(CFLAGS) --preload-file definitions.units --preload-file elements.units --preload-file currency.units --preload-file cpi.units
27
swissChiliab615d82024-03-08 17:15:13 -050028units-host: units.c
swissChili281af442024-11-14 23:30:29 -050029 $(CC) *.c -o units-host -g
swissChili729acd52024-03-05 11:52:45 -050030
swissChiliab615d82024-03-08 17:15:13 -050031%.o: %.c
swissChili281af442024-11-14 23:30:29 -050032 $(CC) -c $^ -Os -o $@ -Os
swissChiliab615d82024-03-08 17:15:13 -050033
34bundle.js: frontend.js units.wasm
35 yarn esbuild frontend.js $(ESFLAGS) --outfile=bundle.js
36
37bundle-webview-js.h: bundle-webview.js
38 xxd -i $^ > $@
39
swissChili16de3222024-03-08 17:55:11 -050040bundle-webview.js: webview-frontend.js frontend-impl.js styles.css
swissChili4f0a0a82024-03-08 18:58:38 -050041 yarn esbuild styles.css --outfile=styles.css.txt --minify
swissChiliab615d82024-03-08 17:15:13 -050042 yarn esbuild webview-frontend.js $(ESFLAGS) --outfile=bundle-webview.js
43
swissChili4f0a0a82024-03-08 18:58:38 -050044watch: units.wasm
swissChiliab615d82024-03-08 17:15:13 -050045 yarn esbuild frontend.js $(ESFLAGS) --watch --outfile=bundle.js
46
swissChili281af442024-11-14 23:30:29 -050047clean:
48 rm -f *.o webview-frontend *.wasm
49
swissChili16de3222024-03-08 17:55:11 -050050.PHONY: watch webview-frontend