#
# Sequoia: Database clustering technology.
# Copyright (C) 2005-2006 Continuent, Inc.
# Contact: sequoia@continuent.org
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
# http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Initial developer(s): Gilles Rayrat
# Contributor(s): Marc Herbert
#

# Makefile for the Carob C++ API and tests
#

# Put an absolute path in here to be able to run from any directory
CAROB_ROOT			= ..

LIB_CAROB			= carob
LIB_CAROB_SO 			= ${CAROB_ROOT}/lib${LIB_CAROB}.so
LIB_CAROB_A 			= ${CAROB_ROOT}/lib${LIB_CAROB}.a

INCDIR				= ${CAROB_ROOT}/include


LIB_CPPUNIT			= cppunit
LIB_CPPUNIT_QTUI	= qttestrunner

# TESTSRCS. Please leave one blank line after include
include testslist


TESTOBJS = ${TESTSRCS:%.cpp=%.o}

# for GCC
CXXFLAGS		= -g3 -Wall -fPIC -I${INCDIR}
LDFLAGS 		= -fPIC -Wl,-rpath,${CAROB_ROOT} -L${CAROB_ROOT} -l${LIB_CAROB} -ldl -l${LIB_CPPUNIT} -rdynamic
# For QT ui, uncomment this
#LDFLAGS			+= -l${LIB_CPPUNIT_QTUI}
EXE				= carobTestLauncher


# Uncomment these 2 lines to use log4cxx instead of internal logger
#CXXFLAGS            += -DCAROB_USE_LOG4CXX
#LDFLAGS				+= -llog4cxx


${EXE}: ${TESTOBJS} CarobTestLauncher.o ${LIB_CAROB_SO}
	${CXX} $^ ${LDFLAGS} -o $@

${LIB_CAROB_FILE}:
	${MAKE} -C ${CAROB_ROOT}

# use this when compiling with mingw
static: ${TESTOBJS} CarobTestLauncher.o ${LIB_CAROB_A}
	${CXX} $^ ${LDFLAGS} -o $@

clean:
	${RM} ${TESTOBJS} CarobTestLauncher.o ${EXE}

testslist:
	{ printf "# To update me, delete me.\nTESTSRCS = \\\\\n" ; for i in \
	*cpp [0-9][0-9]-*/Test*.cpp     ; \
	do printf "$$i \\\\\n"; done ; } > $@

distclean: clean
	${RM} testslist
