
SRCDIR:= img
DSTDIR:= build
SOURCES := $(shell find ${SRCDIR} -type f -print)
FILES := $(patsubst $(SRCDIR)/%,$(DSTDIR)/%,$(SOURCES))

all: $(FILES)

palette.out: palette.in
	node palette-gen.js

builddir:
	@mkdir -p build
	@mkdir -p build/gif

build/%: img/% builddir palette.out 
	repalette $< $@ -p $$(cat palette.out) --dither $(DITHER)

build/%.gif: img/%.gif builddir palette.out
	gifsicle --use-colormap gifpalette.out < $< > $@

clean:
	@rm -rf palette.in palette.out build