TARGET = dist/eink-x3.chip.wasm
SOURCES = eink-x3.chip.c

.PHONY: all clean test
all: $(TARGET) dist/eink-x3.chip.json

test: dist
	$(CC) -O2 -Wall -o dist/test test/test.c
	./dist/test

dist:
	mkdir -p dist

$(TARGET): dist $(SOURCES) wokwi-api.h
	clang --target=wasm32 -nostdlib -O2 -Wall -Werror -Wno-unused-function \
	  -Wl,--no-entry -Wl,--import-memory -Wl,--export-table -Wl,--export-dynamic \
	  -o $(TARGET) $(SOURCES)

dist/eink-x3.chip.json: dist eink-x3.chip.json
	cp eink-x3.chip.json dist/

clean:
	rm -rf dist
