CC = gcc 
BINDIR= ./bin
DATADIR= ./dat
SOUNDDIR= $(DATADIR)/sounds
SRCPATH= ./src
CONFIGDIR=$(HOME)/.spacezero
RECORDFILE=$(CONFIGDIR)record

#
# The binary executable will be copied in the next directory.
#
INSTALL_DIR=/usr/local/bin

#
# All data files will be copied in the next directory.
# tar.gz 

INSTALL_DATA_DIR=/usr/local/share/spacezero

# DEB pkg 
#INSTALL_DATA_DIR=/usr/share/spacezero




OPENALFLAGS= -lopenal -lalut
#GTKFLAGS=`pkg-config --cflags gtk+-2.0`
GTKFLAGS= -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo
#GTKLIBS=`pkg-config --libs gtk+-2.0`
GTKLIBS=  -lgtk-x11-2.0 -lgdk-x11-2.0  -lglib-2.0
GTKLIBS12=`gtk-config --cflags`

LDFLAGS=  -lm -lpthread $(OPENALFLAGS) $(GTKLIBS)
LDFLAGS12=  -lm -lpthread $(OPENALFLAGS) $(GTKLIBS12)
CFLAGS=  -Wall -O3 -I./include -DDATADIR=\"$(DATADIR)\" -DINSTALL_DATA_DIR=\"$(INSTALL_DATA_DIR)\"
CFLAGS12=  -Wall -O3 -I./include -DGTK12 -DDATADIR=\"$(DATADIR)\" -DINSTALL_DATA_DIR=\"$(INSTALL_DATA_DIR)\"
PROGRAM=$(BINDIR)/spacezero


SOUND_OBJS= $(SRCPATH)/sound.o
SOUND_SRCS= $(SRCPATH)/sound.c


PROGRAM_OBJS=$(SRCPATH)/spacezero.o $(SRCPATH)/objects.o $(SRCPATH)/ai.o $(SRCPATH)/save.o $(SRCPATH)/shell.o $(SRCPATH)/spacecomm.o $(SRCPATH)/help.o $(SRCPATH)/comm.o $(SRCPATH)/graphics.o  $(SRCPATH)/functions.o $(SRCPATH)/data.o $(SOUND_OBJS)
PROGRAM_SRCS=$(SRCPATH)/spacezero.c $(SRCPATH)/objects.c $(SRCPATH)/ai.c $(SRCPATH)/save.c $(SRCPATH)/shell.c $(SRCPATH)/spacecomm.c $(SRCPATH)/help.c $(SRCPATH)/comm.c $(SRCPATH)/graphics.c  $(SRCPATH)/functions.c $(SRCPATH)/data.c $(SOUND_SRCS)



all: dirs spacezero


spacezero: $(PROGRAM_OBJS) 
	$(CC) $(GTKFLAGS) $(PROGRAM_OBJS)  $(LDFLAGS) $(CFLAGS) -g -o $(PROGRAM)

gtk12: $(PROGRAM_SRCS) 
	$(CC) `gtk-config --cflags` $(PROGRAM_SRCS)  $(LDFLAGS12) $(CFLAGS12) -g -o $(PROGRAM) `gtk-config --libs`

install:
	-if [ ! -d $(INSTALL_DIR) ] ; then mkdir -p $(INSTALL_DIR) ; fi
	-if [ ! -d $(INSTALL_DATA_DIR) ] ; then mkdir -p $(INSTALL_DATA_DIR); fi
	-if [ ! -d $(INSTALL_DATA_DIR)/sounds ] ; then mkdir -p $(INSTALL_DATA_DIR)/sounds; fi
	cp $(SOUNDDIR)/* $(INSTALL_DATA_DIR)/sounds
	cp $(PROGRAM) $(INSTALL_DIR)

dirs:
	-if [ ! -d $(BINDIR) ] ; then mkdir $(BINDIR) ; fi
	-if [ ! -d $(CONFIGDIR) ] ; then mkdir $(CONFIGDIR) ; fi

clean: 
	rm -f src/*.o bin/spacezero

mrproper: clean
	rm -f src/*~ include/*~

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