#Change these to install somewhere else
# System wide:
#PACKAGE_DATA_DIR=/usr/local/share/$(TARGET)/
#BINDIR=/usr/local/bin/
#DOCDIR=/usr/local/share/doc/$(TARGET)/
# Local:
#PACKAGE_DATA_DIR=$(HOME)/Games/$(TARGET)/
#BINDIR=$(HOME)/Games/$(TARGET)/
#DOCDIR=$(HOME)/Games/$(TARGET)/
# The current folder:
PACKAGE_DATA_DIR=./data/
BINDIR=./
DOCDIR=./

#You won't need to alter these
TARGET=gnurobbo
SOURCES=$(wildcard *.c)
OBJECTS=$(patsubst %.c, %.o, $(SOURCES))
VERSION=`cat VERSION`

#These should be ok for most
CC=gcc
CFLAGS=-O3 -pipe -Wall -fomit-frame-pointer -I/usr/include `sdl-config --cflags` -DPLATFORM_PC -DVERSION=\"$(VERSION)\" -DPACKAGE_DATA_DIR=\"$(PACKAGE_DATA_DIR)/\" 
LINK=gcc
LDFLAGS=-L/usr/lib
LIBS=`sdl-config --libs` -lSDL_ttf

#You won't need to alter anything below
all: $(SOURCES) $(TARGET)

$(TARGET): $(OBJECTS)
	$(LINK) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@

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

.PHONY: all clean install

clean:
	rm $(OBJECTS)

install:
	mkdir -p $(PACKAGE_DATA_DIR)/levels
	mkdir -p $(PACKAGE_DATA_DIR)/skins/original $(PACKAGE_DATA_DIR)/skins/tronic
	mkdir -p $(PACKAGE_DATA_DIR)/locales/en_GB $(PACKAGE_DATA_DIR)/locales/pl_PL
	mkdir -p $(BINDIR)
	mkdir -p $(DOCDIR)
	cp data/levels/* $(PACKAGE_DATA_DIR)/levels/
	cp data/skins/original/* $(PACKAGE_DATA_DIR)/skins/original/
	cp data/skins/tronic/* $(PACKAGE_DATA_DIR)/skins/tronic/
	cp data/locales/en_GB/* $(PACKAGE_DATA_DIR)/locales/en_GB/
	cp data/locales/pl_PL/* $(PACKAGE_DATA_DIR)/locales/pl_PL/
	cp $(TARGET) $(BINDIR)/
	cp ChangeLog COPYING README $(DOCDIR)/



