#-------------------------------------------------------------------------------
#   Copyright (c) 2004 Media Development Loan Fund
#
#   This file is part of the LiveSupport project.
#   http://livesupport.campware.org/
#   To report bugs, send an e-mail to bugs@campware.org
#
#   LiveSupport 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.
#
#   LiveSupport 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 LiveSupport; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#
#   Author   : $Author: maroy $
#   Version  : $Revision: 1.3 $
#   Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/etc/Makefile.in,v $
#
#   @configure_input@
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#   General command definitions
#-------------------------------------------------------------------------------
MKDIR   = mkdir -p
RM      = rm -f
RMDIR   = rm -rf
DOXYGEN = doxygen


#-------------------------------------------------------------------------------
#   Basic directory and file definitions
#-------------------------------------------------------------------------------
BASE_DIR     = @builddir@
DOC_DIR      = ${BASE_DIR}/doc
DOXYGEN_DIR  = ${DOC_DIR}/doxygen
COVERAGE_DIR = ${DOC_DIR}/coverage
ETC_DIR      = ${BASE_DIR}/etc
INCLUDE_DIR  = ${BASE_DIR}/include
LIB_DIR      = ${BASE_DIR}/lib
SRC_DIR      = ${BASE_DIR}/src
TMP_DIR      = ${BASE_DIR}/tmp

USR_DIR         = ${BASE_DIR}/../../usr
USR_INCLUDE_DIR = ${USR_DIR}/include
USR_LIB_DIR     = ${USR_DIR}/lib
BOOST_INCLUDE_DIR    = ${USR_INCLUDE_DIR}/boost-1_31
LIBXMLPP_INCLUDE_DIR = ${USR_INCLUDE_DIR}/libxml++-1.0

MODULES_DIR     = ${BASE_DIR}/..

CORE_DIR         = ${MODULES_DIR}/core
CORE_INCLUDE_DIR = ${CORE_DIR}/include
CORE_LIB_DIR     = ${CORE_DIR}/lib
CORE_LIB         = livesupport_core
CORE_LIB_FILE    = ${CORE_LIB_DIR}/lib${CORE_LIB}.a

STORAGE_SERVER_DIR    = ${MODULES_DIR}/storageServer

VPATH    = ${SRC_DIR}

TEST_RESULTS = ${DOC_DIR}/testResults.xml
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
TEST_XSLT    = ../etc/testResultToHtml.xsl

AUTHENTICATION_LIB      = livesupport_authentication
AUTHENTICATION_LIB_FILE = ${LIB_DIR}/lib${AUTHENTICATION_LIB}.a
TEST_RUNNER      = ${TMP_DIR}/testRunner

DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config


#-------------------------------------------------------------------------------
#  	Configuration parameters
#-------------------------------------------------------------------------------
CPPFLAGS = @CPPFLAGS@
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
                             -pedantic -Wall -Wno-long-long \
                             -I${USR_INCLUDE_DIR} \
                             -I${BOOST_INCLUDE_DIR} \
                             -I${LIBXMLPP_INCLUDE_DIR} \
                             -I${CORE_INCLUDE_DIR} \
                             -I${INCLUDE_DIR} -I${TMP_DIR}
LDFLAGS  = @LDFLAGS@ -pthread -L${USR_LIB_DIR} -L${CORE_LIB_DIR} -L${LIB_DIR}


#-------------------------------------------------------------------------------
#	Dependencies
#-------------------------------------------------------------------------------
AUTHENTICATION_LIB_OBJS = ${TMP_DIR}/AuthenticationClientFactory.o \
                          ${TMP_DIR}/WebAuthenticationClient.o

TEST_RUNNER_OBJS = ${TMP_DIR}/WebAuthenticationClientTest.o \
                   ${TMP_DIR}/TestRunner.o

TEST_RUNNER_LIBS = -l${AUTHENTICATION_LIB} -l${CORE_LIB} -lxml++-1.0 \
                   -lcppunit -ldl -lxmlrpc++ -lssl


#-------------------------------------------------------------------------------
#   Targets
#-------------------------------------------------------------------------------
.PHONY: all dir_setup doc clean docclean depclean distclean

all: dir_setup ${AUTHENTICATION_LIB_FILE}

dir_setup: ${TMP_DIR} ${DOXYGEN_DIR}

doc:
	${DOXYGEN} ${DOXYGEN_CONFIG}

clean:
	${RM} ${AUTHENTICATION_LIB_OBJS} ${AUTHENTICATION_LIB_FILE}
	${RM} ${TEST_RUNNER_OBJS} ${TEST_RUNNER}
	${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info

docclean:
	${RMDIR} ${DOXYGEN_DIR}/html
	${RMDIR} ${COVERAGE_DIR}/*
	${RM} ${TEST_RESULTS}

depclean: clean

distclean: clean docclean
	${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*

check: all ${TEST_RUNNER}
	${MAKE} -C ${STORAGE_SERVER_DIR}
	LD_LIBRARY_PATH=${USR_LIB_DIR} ${TEST_RUNNER} \
                                   -o ${TEST_RESULTS} -s ${TEST_XSLT}


#-------------------------------------------------------------------------------
#   Specific targets
#-------------------------------------------------------------------------------
${AUTHENTICATION_LIB_FILE}: ${AUTHENTICATION_LIB_OBJS}
	${AR} crus $@ $^

${TMP_DIR}:
	${MKDIR} ${TMP_DIR}

${DOXYGEN_DIR}:
	${MKDIR} ${DOXYGEN_DIR}

${TEST_RUNNER}: ${CORE_LIB_FILE} ${TEST_RUNNER_OBJS} ${AUTHENTICATION_LIB_FILE}
	${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}

${CORE_LIB_FILE}:
	${MAKE} -C ${CORE_DIR}


#-------------------------------------------------------------------------------
#   Pattern rules
#-------------------------------------------------------------------------------
${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<