#
#  xut - button football (soccer) game
#  Copyright (C) 2008 farrer <farrer@dnteam.org> and gushm <gushm@dnteam.org>
#
#  This file is part of xut.
#
#  xut is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  xut is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with xut.  If not, see <http://www.gnu.org/licenses/>.
#
#

prefix = /usr/local
datadir = ${prefix}/share
localedir = $(datadir)/locale
DEFS = -DLOCALEDIR=\"$(localedir)\"

CFLAGS =  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT $(DEFS) -g -c -Wall -O2
CC = g++
EFLAGS =  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
LDFLAGS = 
LIBS = -lvorbisfile -lvorbis -lopenal -logg -lcal3d -lm -lSDL_ttf -lSDL_image -lSDL -lGLU -lGL  -lSDL -lpthread -L$(prefix)/lib/ 

BIN = ../../bin/

ENDETC = ../etc/
ENDPHYSICS = ../physics/
ENDGUI = ../gui/
ENDLANG = ../lang/
ENDSOUND = ../sound/

ENGINEOBJS= ball.o camera.o field.o fieldpub.o goal.o rules.o team.o teamplayer.o replay.o xut.o
ETCOBJS = $(ENDETC)animodel.o $(ENDETC)overlaps.o $(ENDETC)util.o \
          $(ENDETC)defparser.o $(ENDETC)draw.o $(ENDETC)cursor.o \
			 $(ENDETC)dirs.o $(ENDETC)userinfo.o $(ENDETC)options.o
PHYSICSOBJS = $(ENDPHYSICS)collision.o $(ENDPHYSICS)forceio.o $(ENDPHYSICS)physic.o
GUIOBJS = $(ENDGUI)dntfont.o $(ENDGUI)guimessage.o $(ENDGUI)guiscore.o \
          $(ENDGUI)guistatus.o $(ENDGUI)initial.o $(ENDGUI)selector.o \
			 $(ENDGUI)videocontroller.o $(ENDGUI)maingui.o $(ENDGUI)optscreen.o
LANGOBJS = $(ENDLANG)translate.o
SOUNDOBJS = $(ENDSOUND)ogg_stream.o $(ENDSOUND)sndfx.o $(ENDSOUND)sound.o


all: xut 

ALONEOBJS = main.o $(LANGOBJS) $(ENGINEOBJS) $(ETCOBJS) $(GUIOBJS) $(PHYSICSOBJS) $(SOUNDOBJS)

ball.o: ball.cpp ball.h field.h $(ENDETC)animodel.h
	@printf "Making ball.o... "
	@$(CC) $(CFLAGS) ball.cpp -o ball.o
	@printf "\e[0;32mDone.\e[0;0m\n"

camera.o: camera.cpp camera.h
	@printf "Making camera.o... "
	@$(CC) $(CFLAGS) camera.cpp -o camera.o
	@printf "\e[0;32mDone.\e[0;0m\n"

field.o: field.cpp field.h 
	@printf "Making field.o... "
	@$(CC) $(CFLAGS) field.cpp -o field.o
	@printf "\e[0;32mDone.\e[0;0m\n"

fieldpub.o: fieldpub.cpp fieldpub.h 
	@printf "Making fieldpub.o... "
	@$(CC) $(CFLAGS) fieldpub.cpp -o fieldpub.o
	@printf "\e[0;32mDone.\e[0;0m\n"

goal.o: goal.cpp goal.h field.h $(ENDETC)animodel.h
	@printf "Making goal.o... "
	@$(CC) $(CFLAGS) goal.cpp -o goal.o
	@printf "\e[0;32mDone.\e[0;0m\n"

rules.o: rules.cpp rules.h teamplayer.h field.h team.h ball.h
	@printf "Making rules.o... "
	@$(CC) $(CFLAGS) rules.cpp -o rules.o
	@printf "\e[0;32mDone.\e[0;0m\n"

team.o: team.cpp team.h teamplayer.h $(ENDETC)animodel.h field.h
	@printf "Making team.o... "
	@$(CC) $(CFLAGS) team.cpp -o team.o
	@printf "\e[0;32mDone.\e[0;0m\n"

teamplayer.o: teamplayer.cpp teamplayer.h
	@printf "Making teamplayer.o... "
	@$(CC) $(CFLAGS) teamplayer.cpp -o teamplayer.o
	@printf "\e[0;32mDone.\e[0;0m\n"

replay.o: replay.cpp replay.h
	@printf "Making replay.o... "
	@$(CC) $(CFLAGS) replay.cpp -o replay.o
	@printf "\e[0;32mDone.\e[0;0m\n"

xut.o: xut.cpp xut.h teamplayer.h team.h goal.h field.h replay.h $(ENDETC)options.h $(ENDGUI)selector.h $(ENDGUI)initial.h
	@printf "Making xut.o... "
	@$(CC) $(CFLAGS) xut.cpp -o xut.o
	@printf "\e[0;32mDone.\e[0;0m\n"

#standalone things

main.o: main.cpp main.h xut.h teamplayer.h team.h $(ENDETC)options.h
	@printf "Making main.o... "
	@$(CC) $(CFLAGS) main.cpp -o main.o
	@printf "\e[0;32mDone.\e[0;0m\n"

xut: $(ALONEOBJS)
	@printf "Linking xut... "
	@$(CC) $(LDFLAGS) $(LIBS) $(EFLAGS) $(ALONEOBJS) -o $(BIN)xut
	@printf "\e[0;32mDone.\e[0;0m\n"

#end stand alone things

clean:
	@printf "Cleaning XUT engine Files..."	
	@\rm -f *.o *.e
	@\rm -f $(BIN)xut
	@printf "\e[0;32mDone.\e[0;0m\n"

