.PHONY: all clean install

# change this to suit your preference
PREFIX = /usr/local

BINDIR = $(PREFIX)/games
DATADIR = $(PREFIX)/share/railblaster

CFLAGS = -W -Wall -Werror -O2 -DSHAREPATH=\"$(DATADIR)/\" \
         `allegro-config --cflags` `pkg-config --cflags libmodplug` -g
LDFLAGS = `allegro-config --libs` `pkg-config --libs libmodplug`
OBJS = game.o draw.o field.o images.o sound.o \
       main.o colors.o xm.o ctimer.o crandom.o font.o

all: railblaster

railblaster: $(OBJS)
	$(CC) -o railblaster $(LDFLAGS) $(OBJS)

game.o: game.c game.h game_int.h field.h colors.h images.h sound.h \
        main.h crandom.h
draw.o: draw.c game.h field.h images.h font.h colors.h game_int.h
colors.o: colors.c colors.h
field.o: field.c field.h main.h config.h crandom.h
images.o: images.h config.h main.h
sound.o: sound.c config.h main.h sound.h
font.o: font.c font.h
main.o: main.c main.h game.h ctimer.h sound.h
ctimer.o: ctimer.c ctimer.h
crandom.o: crandom.c ctimer.h
xm.o: xm.c main.h

clean:
	rm -f *.o railblaster

install: railblaster
	mkdir -p $(DATADIR)
	cp data/* $(DATADIR)
	mkdir -p $(BINDIR)
	cp railblaster $(BINDIR)
