LISPS :=	$(wildcard *.lsp)
SOURCE :=	extensions.ino
OUTPUT :=	LispLibrary.h
TARGET :=	genlib
PLATFORMS :=	picocalc tdeck teensy
TARGETS_LIB :=	$(addprefix ../,$(addsuffix /$(OUTPUT),$(PLATFORMS)))
TARGETS_EXT :=	$(addprefix ../,$(addsuffix /$(SOURCE),$(PLATFORMS)))

CFLAGS += 	-Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g


.PHONY: all
all: $(TARGET)

.PHONY: all
install: $(TARGETS_LIB) $(TARGETS_EXT)

.PHONY: clean
clean:
	rm $(OUTPUT) $(TARGET)

$(TARGET): $(LISPS) $(SOURCE) $(TARGET).c Makefile
	$(CC) $(CFLAGS) -o $(TARGET) $(TARGET).c

$(OUTPUT): $(TARGET) $(LISPS) $(SOURCE) Makefile

$(TARGETS_LIB): $(OUTPUT)
	cp $(OUTPUT) $@

$(TARGETS_EXT): $(SOURCE)
	cp $(SOURCE) $@

print-%: ; @echo '$(subst ','\'',$*=$($*))'
