CC = clang
# todo: Only link to libm on debug.
CFLAGS = -Wall -std=c99 -g3 -O3 -flto=full
DEPS = ../Common/lzw.h ../Common/mat.h ../Common/vec.h ../Common/fix.h ../Common/def.h ../Common/bits.h \
	   ../Common/gem.h \
	   ../Common/Timer/time.h \
	    ./Display/display.h \
	    ./draw.h
SRC = ../Common/lzw.c ../Common/fix.c ../Common/mat.c ./draw.c
LINUX = ./amalgam.c
WASM = ./amalgam.c
DOS = maindos.c Display/dos.c

%.o: %.c $(DEPS)
	$(CC) -c -o $@ $< $(CFLAGS)

# TODO: Make it work with no stdlib.
linux: CFLAGS += -msse2 -mbmi2 -nostdlib
linux: $(LINUX) | $(SRC)
	$(CC) -o player $^ $(CFLAGS)

# Note: lld package might need to be downloaded.
wasm: CFLAGS += --target=wasm32 -nostdlib -Wl,--no-entry -msimd128
wasm:
	$(CC) -o player.wasm $(WASM) $(CFLAGS)

dos: $(DOS) $(DEPS)
	wcl386 -bt=dos4g -ox -l=dos4g $(DOS)

clean:
	rm -r *.o ../*.o
