#***************************************************************************
#*   Copyright (C) 2006 by Dave Parker                                     *
#*   drparker@freenet.co.uk                                                *
#*                                                                         *
#*   This program 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 2 of the License, or     *
#*   (at your option) any later version.                                   *
#*                                                                         *
#*   This program 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 this program; if not, write to the                         *
#*   Free Software Foundation, Inc.,                                       *
#*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
#***************************************************************************/

ifdef gp2x
CC=gp2x-g++
LD=$(CC) -static
else
CC=g++ -g
LD=$(CC)
endif

OBJS=main.o chess2x.o piece.o board.o chessconfig.o history.o

all: ../chess2xdata/chess2x 

../chess2xdata/chess2x: $(OBJS) ../libsrc/libgp2xsdl.a
	$(LD) -o ../chess2xdata/chess2x $(OBJS) -L../libsrc -lgp2xsdl `sdl-config --libs` -lSDL_ttf -lfreetype -lSDL_mixer -lsmpeg -lSDL -lmikmod -lvorbisfile -lvorbisenc -lvorbis -logg -lm -lpthread -lstdc++ -lz

main.o: main.cpp chess2x.h
	$(CC) -c `sdl-config --cflags` -I../libsrc main.cpp

chess2x.o: chess2x.cpp chess2x.h piece.h chesscommon.h board.h chessconfig.h history.h
	$(CC) -c `sdl-config --cflags` -I../libsrc chess2x.cpp

piece.o: piece.cpp piece.h chesscommon.h
	$(CC) -c `sdl-config --cflags` -I../libsrc piece.cpp

board.o: board.cpp board.h piece.h
	$(CC) -c `sdl-config --cflags` -I../libsrc board.cpp

chessconfig.o: chessconfig.cpp chessconfig.h
	$(CC) -c `sdl-config --cflags` -I../libsrc chessconfig.cpp

history.o: history.cpp history.h board.h
	$(CC) -c `sdl-config --cflags` -I../libsrc history.cpp

clean:
	rm -f ../chess2xdata/chess2x
	rm -f *.o
