#    Mohawk Software Framework by Mohawk Software
#    Copyright (C) 1998-2002 Mark L. Woodward
# 
#    This library 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 library 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 library; if not, write to the Free
#    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
#    MA 02111-1307, USA
# 
#    If you want support or to professionally license this library, the author
#    can be reached at info@mohawksoft.com

MOHAWK_HOME=..
include $(MOHAWK_HOME)/src/config.mak

ifdef POSTGRES
PGPLUG=1
endif


ifdef DEBUG
CARGS+=-DTRACE_DEBUG
endif

APILIB=msessionapi

ALL=msessiond$(EXE) plugin.$(DLL_EXT) fnplug.$(DLL_EXT) flexplug.$(DLL_EXT)\
	fileplug.$(DLL_EXT) protplug.$(DLL_EXT) execplug.$(DLL_EXT) $(APILIB).$(LIB_EXT)

ifdef PGPLUG
ALL+=sqlplug.$(DLL_EXT) sqlcache.$(DLL_EXT)
endif

all : $(ALL)

MOBJS=msessiond.$(OBJ_EXT) plugapi.$(OBJ_EXT) svrmgr.$(OBJ_EXT) svrthd.$(OBJ_EXT) mreq.$(OBJ_EXT)

#
# Main msesson daemon program
#
msessiond$(EXE) : $(MOBJS)
	$(GCC) $(CARGS) -o $@ $(MOBJS) $(CEND) $(CENDLIB) 
	
#
# Shared library version.
#
$(APILIB).$(DLL_EXT) : msessionapi.$(OBJ_EXT)

msessiond.$(OBJ_EXT) : msessiond.cpp msessiond.h

svrmgr.$(OBJ_EXT) : svrmgr.cpp msessiond.h

svrthd.$(OBJ_EXT) : svrthd.cpp msessiond.h

plugapi.$(DLL_EXT) : plugapi.cpp msessiond.h plugapi.h

#
#
# Plugins
#
#
# Example plugin
#
plugin.$(DLL_EXT) : plugin.cpp msessiond.h plugapi.h

funct.$(DLL_EXT) : funct.cpp msessiond.h plugapi.h

execplug.$(DLL_EXT) : execplug.cpp msessiond.h plugapi.h

pgplug.$(OBJ_EXT) : pgplug.cpp pgplug.h


#
# These need the ODBC/Database libraries which are optional
#
sqlplug.$(OBJ_EXT) : sqlplug.cpp msessiond.h plugapi.h

sqlplug.$(DLL_EXT) :  sqlplug.$(OBJ_EXT)
	$(LINK_DLL) $(LINK_OUT)$@ $< $(LIBODBC) $(ENDLIBDLL)

sqlcache.$(OBJ_EXT) : sqlcache.cpp msessiond.h plugapi.h

sqlcache.$(DLL_EXT) : sqlcache.$(OBJ_EXT) msessiond.h plugapi.h 
	$(LINK_DLL) $(LINK_OUT)$@ $< $(LIBODBC) $(ENDLIBDLL)


clean :
	rm -f *.$(OBJ_EXT)
	rm -f $(ALL)
	rm -f core*
	rm -f test.blk
	rm -f *.$(DLL_EXT)
	rm -f $(APILIB).$(LIB_EXT)
ifdef WIN32
	rm -f *.ilk
	rm -f *.pdb
	rm -f *.exp
endif

fresh : clean $(ALL)

ifndef BINDIR
BINDIR=../bin
endif

install: $(ALL) 
	cp $(ALL) $(BINDIR)
	cp $(APILIB).$(LIB_EXT) $(LIBDIR)

strip: $(ALL)
	strip $(ALL)
