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 | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame^] | 3 | --no-entry |
swissChili | 729acd5 | 2024-03-05 11:52:45 -0500 | [diff] [blame] | 4 | |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame^] | 5 | ESFLAGS = --bundle --minify --loader:.js=jsx |
| 6 | |
| 7 | WEBCFLAGS = -Os -framework WebKit -std=c++11 |
| 8 | |
| 9 | webview-frontend: webview-frontend.cpp units.o getopt.o getopt1.o parse.tab.o strfunc.o |
| 10 | g++ $^ -o webview-frontend $(WEBCFLAGS) -I json/include |
| 11 | |
| 12 | webview-frontend.cpp: bundle-webview-js.h |
| 13 | |
| 14 | units.wasm: units.c |
swissChili | 729acd5 | 2024-03-05 11:52:45 -0500 | [diff] [blame] | 15 | emcc -o units.lib.js *.c $(CFLAGS) --preload-file definitions.units --preload-file elements.units --preload-file currency.units --preload-file cpi.units |
| 16 | |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame^] | 17 | units-host: units.c |
swissChili | 729acd5 | 2024-03-05 11:52:45 -0500 | [diff] [blame] | 18 | gcc *.c -o units-host -g |
| 19 | |
swissChili | ab615d8 | 2024-03-08 17:15:13 -0500 | [diff] [blame^] | 20 | %.o: %.c |
| 21 | gcc -c $^ -Os -o $@ |
| 22 | |
| 23 | bundle.js: frontend.js units.wasm |
| 24 | yarn esbuild frontend.js $(ESFLAGS) --outfile=bundle.js |
| 25 | |
| 26 | bundle-webview-js.h: bundle-webview.js |
| 27 | xxd -i $^ > $@ |
| 28 | |
| 29 | bundle-webview.js: webview-frontend.js frontend-impl.js |
| 30 | yarn esbuild webview-frontend.js $(ESFLAGS) --outfile=bundle-webview.js |
| 31 | |
| 32 | watch: |
| 33 | yarn esbuild frontend.js $(ESFLAGS) --watch --outfile=bundle.js |
| 34 | |
| 35 | .PHONY: watch |