#SYNOPSIS:
#
##   make [all]  - makes everything.
#   make TARGET - makes the given target.
#   #   make clean  - removes all files generated by make.

include ${TRICK_HOME}/share/trick/makefiles/Makefile.common

# Flags passed to the preprocessor.
TRICK_CPPFLAGS += -I${GTEST_HOME}/include -I$(TRICK_HOME)/include -g -Wall -Wextra -DGTEST_HAS_TR1_TUPLE=0

TRICK_LIBS = ${TRICK_LIB_DIR}/libtrick_units.a
TRICK_EXEC_LINK_LIBS += ${GTEST_HOME}/lib/libgtest.a ${GTEST_HOME}/lib/libgtest_main.a

#Added pthreads for Ubuntu
TRICK_EXEC_LINK_LIBS += -lpthread

TESTS = UnitConvTestSuite \
				UnitTestSuite

GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
                $(GTEST_DIR)/include/gtest/internal/*.h

all : $(TESTS)

test: $(TESTS)
	./UnitConvTestSuite --gtest_output=xml:${TRICK_HOME}/trick_test/UnitConvTestSuite.xml
	./UnitTestSuite --gtest_output=xml:${TRICK_HOME}/trick_test/UnitTestSuite.xml

clean :
	rm -f $(TESTS)
	rm -f *.o
	rm -rf XMLtestReports

UnitTestSuite.o : UnitTestSuite.cpp
	$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c $<

UnitTestSuite : UnitTestSuite.o
	@echo 'Building UnitTestSuite'
	$(TRICK_LD) $(TRICK_LDFLAGS) -o $@ $^ $(OTHER_OBJECTS) -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)

UnitConvTestSuite.o : UnitConvTestSuite.cpp
	$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c $<

UnitConvTestSuite : UnitConvTestSuite.o
	@echo 'Building UnitConvTestSuite'
	$(TRICK_LD) $(TRICK_LDFLAGS) -o $@ $^ $(OTHER_OBJECTS) -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)

#TestSuite3.o : UnitTestSuite3.cpp
#	$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c $<

#UnitTestSuite3 : UnitTestSuite3.o
#	echo "GTEST_HOME  = " ${GTEST_HOME}
#	$(TRICK_LD) $(TRICK_LDFLAGS) -o $@ $^ $(OTHER_OBJECTS) -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)

