CC     ?= cc
CFLAGS ?= -Wall -Wextra -Werror -pipe -Wno-unused-parameter
SRCS   ?= main.c location.c misc.c object.c inventory.c toggle.c execute.c
OBJS   ?= $(addprefix obj/, $(subst .c,.o,$(SRCS)))

all: game tags map.png

game: .depend $(OBJS)
	$(CC) $(OBJS) -o game

object.h: object.txt scripts/object.awk
	awk -v pass=h  -f scripts/object.awk object.txt >  $@

object.c: object.txt scripts/object.awk object.h
	awk -v pass=c1 -f scripts/object.awk object.txt >  $@
	awk -v pass=c2 -f scripts/object.awk object.txt >> $@

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

.depend: $(SRCS)
	$(CC) -MM $^ > .depend

clean:
	@rm -f game map.png obj/* .depend tags object.c object.h
	@echo done

tags: $(OBJS)
	ctags -R

include .depend
include map.makefile
