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

# iutest root directory
IUTEST_DIR = ..

# Flags passed to the preprocessor.
CPPFLAGS += -I$(IUTEST_DIR)/include

#
# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra

ifeq ($(CXX),clang++)

#
# clang version
#
#

#CXXFLAGS += -std=c++0x

else

#
# GCC version
#
#
GCCVERSION:=$(shell $(CXX) -dumpversion)

dot:=.
empty:=
space:=$(empty) $(empty)
GCCVERSION:=$(subst $(dot),$(space), $(GCCVERSION))
GCCMAJOR:=$(word 1, $(GCCVERSION))
GCCMINOR:=$(word 2, $(GCCVERSION))

ifeq (1,$(shell expr \( $(GCCMAJOR) \> 4 \) \| \( $(GCCMAJOR) \>= 4 \& $(GCCMINOR) \>= 7 \)))
# 4.7 later
CXXFLAGS += -std=c++11
else
#ifeq (1,$(shell expr \( $(GCCMAJOR) \> 4 \) \| \( $(GCCMAJOR) \>= 4 \& $(GCCMINOR) \>= 4 \)))
# 4.4 later
#CXXFLAGS += -std=c++0x
#endif
endif

endif

CXXFLAGS += $(DEFS)


TARGETS = iutest_all_tests \
          iutest_assertion_only_tests \
          iutest_catch_exceptions_tests \
          iutest_disabled_tests \
          iutest_env_var_tests \
          iutest_environment_tests \
          iutest_filter_tests \
          iutest_help_tests \
          iutest_listener_tests \
          iutest_minimum_tests \
          iutest_namespace_tests \
          iutest_no_test_tests \
          iutest_repeat_tests \
          iutest_skip_tests \
          iutest_throw_on_assert_failure_tests \
          iutest_throw_on_failure_tests \
          iutest_uninitialize_tests
          
SRCS   = $(TARGET:%=%.cpp)


# All iutest headers.  Usually you shouldn't change this
# definition.
IUTEST_HEADERS = $(IUTEST_DIR)/include/*.hpp \
                 $(IUTEST_DIR)/include/internal/*.hpp \
                 $(IUTEST_DIR)/include/listener/*.hpp \
                 $(IUTEST_DIR)/include/util/*.hpp \
                 $(IUTEST_DIR)/include/gtest/*.hpp

# House-keeping build targets.

default: $(TARGETS)

all : default test

test :
	@for i in $(TARGETS); do \
		./$$i.exe; \
	done
clean :
	rm -f $(TARGETS) *.o

# Builds a sample test.  

$(TARGETS) : $(SRCS) $(IUTEST_HEADERS) Makefile
	@for i in $(TARGETS); do \
		$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $$i $$i.cpp; \
	done
