swissChili | 729acd5 | 2024-03-05 11:52:45 -0500 | [diff] [blame] | 1 | CFLAGS = -Os -DSUPPORT_UTF8 -sASYNCIFY -sEXPORTED_RUNTIME_METHODS=ccall,cwrap,stringToNewUTF8 \ |
| 2 | -sEXPORTED_FUNCTIONS=_test_int,_do_a_conversion -sMODULARIZE -s 'EXPORT_NAME="createMyModule"' \ |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 3 | --no-entry -flto -sASSERTIONS |
swissChili | 729acd5 | 2024-03-05 11:52:45 -0500 | [diff] [blame] | 4 | |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 5 | ESFLAGS = --bundle --minify --loader:.js=jsx --platform=node |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 6 | |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 7 | WEBCFLAGS = -Os -framework WebKit -framework Cocoa -std=c++11 -flto |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 8 | |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 9 | CC=clang |
| 10 | MC=clang |
| 11 | CXX=clang++ |
| 12 | |
| 13 | webview-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 |
swissChili | 4f0a0a8 | 2024-03-08 18:58:38 -0500 | [diff] [blame] | 15 | strip $@ |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 16 | |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 17 | app-bundle: webview-frontend |
| 18 | cp webview-frontend Units.app/Contents/MacOS/ |
| 19 | rm -rf /Applications/Units.app |
| 20 | cp -r Units.app /Applications |
| 21 | |
| 22 | menu.o: webview/menu.m |
| 23 | $(MC) $^ -c -o $@ -flto -Os |
| 24 | |
swissChili | 0512b1c | 2024-12-26 19:13:51 -0800 | [diff] [blame^] | 25 | www: units.lib.wasm |
| 26 | mkdir -p www |
| 27 | cp index.html bundle.js units.lib.* www |
| 28 | |
| 29 | units.lib.wasm: units.c |
swissChili | 729acd5 | 2024-03-05 11:52:45 -0500 | [diff] [blame] | 30 | emcc -o units.lib.js *.c $(CFLAGS) --preload-file definitions.units --preload-file elements.units --preload-file currency.units --preload-file cpi.units |
| 31 | |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 32 | units-host: units.c |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 33 | $(CC) *.c -o units-host -g |
swissChili | 729acd5 | 2024-03-05 11:52:45 -0500 | [diff] [blame] | 34 | |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 35 | %.o: %.c |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 36 | $(CC) -c $^ -Os -o $@ -Os |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 37 | |
swissChili | 0512b1c | 2024-12-26 19:13:51 -0800 | [diff] [blame^] | 38 | bundle.js: frontend.js units.lib.wasm |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 39 | yarn esbuild frontend.js $(ESFLAGS) --outfile=bundle.js |
| 40 | |
| 41 | bundle-webview-js.h: bundle-webview.js |
| 42 | xxd -i $^ > $@ |
| 43 | |
swissChili | 16de322 | 2024-03-08 17:55:11 -0500 | [diff] [blame] | 44 | bundle-webview.js: webview-frontend.js frontend-impl.js styles.css |
swissChili | 4f0a0a8 | 2024-03-08 18:58:38 -0500 | [diff] [blame] | 45 | yarn esbuild styles.css --outfile=styles.css.txt --minify |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 46 | yarn esbuild webview-frontend.js $(ESFLAGS) --outfile=bundle-webview.js |
| 47 | |
swissChili | 0512b1c | 2024-12-26 19:13:51 -0800 | [diff] [blame^] | 48 | watch: units.lib.wasm |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame] | 49 | yarn esbuild frontend.js $(ESFLAGS) --watch --outfile=bundle.js |
| 50 | |
swissChili | 281af44 | 2024-11-14 23:30:29 -0500 | [diff] [blame] | 51 | clean: |
| 52 | rm -f *.o webview-frontend *.wasm |
| 53 | |
swissChili | 0512b1c | 2024-12-26 19:13:51 -0800 | [diff] [blame^] | 54 | .PHONY: watch webview-frontend www |