# for cross compilation with mingw export the path to your cross compiler:
# export CROSS_GPP=/usr/x86_64-pc-linux-gnu/i686-mingw32/gcc-bin/4.3.2/i686-mingw32-g++

#   RTS2 only:
# TelescopeServerRTS2 TelescopeServerRTS2.exe are not included in the all,exe
# targets because they require an external lib.
# You can build them like this:
#make TelescopeServerRTS2
# You will need to provide path for xmlrpc++ library from RTS2 distribution. Please get it with:
# svn co https://rts-2.svn.sourceforge.net/svnroot/rts-2/trunk/rts-2/src/xmlrpc/xmlrpc++
#export XMLRPCPP=/pathtoxmlrpclib++_from_rts2


TelescopeServerBAO_CPP = Connection.cpp Listener.cpp Socket2.cpp Server.cpp  \
  ServerBAO.cpp LogFile.cpp MainBAO.cpp

TelescopeServerBAO_O = $(TelescopeServerBAO_CPP:.cpp=.o)
TelescopeServerBAO_OBJ = $(TelescopeServerBAO_CPP:.cpp=.obj)


CCFLAGS = -O4 -Wall -Wextra -Wno-unused-parameter -Werror -DDEBUG3 -DDEBUG4 -DDEBUG5 -lX11
LDFLAGS = -O4 -s -lX11

ifneq ($(XMLRPCPP),)
  CCFLAGS += -I$(XMLRPCPP) 
endif


.SUFFIXES: .cpp .o .obj

.cpp.o:
	g++ $(CCFLAGS)  $< -c -o $@

.cpp.obj:
	$(CROSS_GPP) $(CCFLAGS) $< -c -o $@

all: TelescopeServerBAO 


install: TelescopeServerBAO 
	install -d ~/.stellarium/servers
	install TelescopeServerBAO ~/.stellarium/servers
	

TelescopeServerBAO: $(TelescopeServerBAO_O)
	g++ $(LDFLAGS) -c -o ../src/astro.o ../../communs/astro.cpp
	g++ $(LDFLAGS) -c -o ../src/exception.o ../../communs/exception.cpp
	g++ $(LDFLAGS) -c -o ../src/filetools.o ../../communs/filetools.cpp
	g++ $(LDFLAGS) -c -o ../src/Socket.o ../../communs/Socket.cpp
	g++ $(LDFLAGS) -c -o ../src/ClientSocket.o ../../communs/ClientSocket.cpp
	g++ $(LDFLAGS) -c -o ../src/logs.o ../../communs/logs.cpp
	g++ $(LDFLAGS) -c -o ../src/alignement.o ../../communs/alignement.cpp
	g++ $(LDFLAGS) $(TelescopeServerBAO_O) astro.o exception.o filetools.o Socket.o ClientSocket.o logs.o alignement.o -o $@



depend:
	makedepend -Y -- $(CCFLAGS) -- -f- >make.dep 2>/dev/null \
	$(TelescopeServerBAO_CPP)  \
	sed -e 's/\.o/\.obj/g' make.dep > make.cross_dep

clean:
	rm *.o TelescopeServerBAO

make.dep:
	touch make.dep

make.cross_dep:
	touch make.cross_dep

include make.dep
include make.cross_dep
