blob: a4f0efebd36efdaf5aa6310eccbc5ba3425575ce [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
swissChili0512b1c2024-12-26 19:13:51 -080025www: units.lib.wasm
26 mkdir -p www
27 cp index.html bundle.js units.lib.* www
28
29units.lib.wasm: units.c
swissChili729acd52024-03-05 11:52:45 -050030 emcc -o units.lib.js *.c $(CFLAGS) --preload-file definitions.units --preload-file elements.units --preload-file currency.units --preload-file cpi.units
31
swissChiliab615d82024-03-08 17:15:13 -050032units-host: units.c
swissChili281af442024-11-14 23:30:29 -050033 $(CC) *.c -o units-host -g
swissChili729acd52024-03-05 11:52:45 -050034
swissChiliab615d82024-03-08 17:15:13 -050035%.o: %.c
swissChili281af442024-11-14 23:30:29 -050036 $(CC) -c $^ -Os -o $@ -Os
swissChiliab615d82024-03-08 17:15:13 -050037
swissChili0512b1c2024-12-26 19:13:51 -080038bundle.js: frontend.js units.lib.wasm
swissChiliab615d82024-03-08 17:15:13 -050039 yarn esbuild frontend.js $(ESFLAGS) --outfile=bundle.js
40
41bundle-webview-js.h: bundle-webview.js
42 xxd -i $^ > $@
43
swissChili16de3222024-03-08 17:55:11 -050044bundle-webview.js: webview-frontend.js frontend-impl.js styles.css
swissChili4f0a0a82024-03-08 18:58:38 -050045 yarn esbuild styles.css --outfile=styles.css.txt --minify
swissChiliab615d82024-03-08 17:15:13 -050046 yarn esbuild webview-frontend.js $(ESFLAGS) --outfile=bundle-webview.js
47
swissChili0512b1c2024-12-26 19:13:51 -080048watch: units.lib.wasm
swissChiliab615d82024-03-08 17:15:13 -050049 yarn esbuild frontend.js $(ESFLAGS) --watch --outfile=bundle.js
50
swissChili281af442024-11-14 23:30:29 -050051clean:
52 rm -f *.o webview-frontend *.wasm
53
swissChili0512b1c2024-12-26 19:13:51 -080054.PHONY: watch webview-frontend www