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

include $(dir $(lastword $(MAKEFILE_LIST)))../../../../share/trick/makefiles/Makefile.common

COVERAGE_FLAGS += -fprofile-arcs -ftest-coverage -O0

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

TRICK_LIBS = -L ${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick 
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main
TRICK_SYSTEM_LDFLAGS  += ${COVERAGE_FLAGS}

# All tests produced by this Makefile.  Remember to add new tests you
# created to the list.
TESTS = Executive_test

OTHER_OBJECTS = ../../include/object_${TRICK_HOST_CPU}/io_JobData.o \
                ../../include/object_${TRICK_HOST_CPU}/io_SimObject.o

# House-keeping build targets.

all : $(TESTS)

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

code-coverage: test
	# Give rid of any old code-coverage HTML we may have.
	rm -rf lcov_html
	# Gather coverage information about the src code.
	lcov --capture \
	--directory ../object_${TRICK_HOST_CPU} \
	--base-directory ../ \
	--output-file src_coverage.info
	# Filter out information about directories that we don't care about.
	lcov --remove src_coverage.info '/Applications/*' '/usr/include/*' \
	--output-file MemoryManager_code_coverage.info
	# Generate HTML
	genhtml MemoryManager_code_coverage.info \
	--output-directory lcov_html
	# Clean up
	# rm *.info

clean :
	rm -f $(TESTS) *.o *.gcda *.gcno *.info
	rm -rf lcov_html

Executive_test.o : Executive_test.cpp
	$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<

Executive_test : Executive_test.o
	$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ $(OTHER_OBJECTS) $(TRICK_LIBS) $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
