#Set this to @ to keep the makefile quiet
SILENCE = 

#---- Outputs ----#
COMPONENT_NAME = vn100_compass

#--- Inputs ----#
PROJECT_HOME_DIR = .
ifeq "$(CPPUTEST_HOME)" ""
    CPPUTEST_HOME = ~/tools/cpputest
endif

# --- SRC_FILES and SRC_DIRS ---
# Production code files are compiled and put into 
# a library to link with the test runner.
#
# Test code of the same name overrides
# production code at link time.
#
# SRC_FILES specifies individual production
# code files.
SRC_FILES  += ../src/VN100.cc \
            ../src/VN100UartSensor.cc \
            ../src/VN100SpiSensor.cc \
            ../src/VN100Sensor.cc \
            ../src/VN100Output.cc \
            ../src/VN100RawMeasOutput.cc \
            ../src/VN100Log.cc \
            ../src/VN100RawMeasLog.cc \
            ../src/VN100IronCalibrationLog.cc \
            ../../utils/Attributes.cc \
            ../../utils/Attribute.cc \
            ../../utils/AttributeParser.cc

# --- TEST_SRC_FILES and TEST_SRC_DIRS ---
# Test files are always included in the build.
# Production code is pulled into the build unless
# it is overriden by code of the same name in the
# test code.
#
# TEST_SRC_FILES specifies individual test files to build.  
# TEST_SRC_DIRS, builds everything in the directory
TEST_SRC_FILES += mocks/termios_Mock.cc
TEST_SRC_FILES += mocks/sys/dev_read_Mock.cc
TEST_SRC_DIRS += .
TEST_SRC_DIRS += mocks

# --- MOCKS_SRC_DIRS ---
# MOCKS_SRC_DIRS specifies a directories where you can put your
# mocks, stubs and fakes.  You can also just put them
# in TEST_SRC_DIRS
MOCKS_SRC_DIRS += mocks
MOCKS_SRC_DIRS += mocks/sys

CPPUTEST_CXXFLAGS += -include mocks/malloc_fix.h
CPPUTEST_CFLAGS += -include mocks/malloc_fix.h
CPPUTEST_CXXFLAGS += -DCPPUTEST_HAVE_STRDUP
CPPUTEST_CFLAGS += -DCPPUTEST_HAVE_STRDUP
CPPUTEST_CFLAGS += -g
CPPUTEST_CXXFLAGS += -g
CPPUTEST_CFLAGS += -O0
CPPUTEST_CXXFLAGS += -O0

CPPUTEST_CXXFLAGS += -D VERSION_BUILD_DATE=\""$(shell date +%Y_%m_%dT%T%Z)"\"
CPPUTEST_CXXFLAGS += -D VERSION_BUILD_TAG=\"$(BUILD_TAG)\"
CPPUTEST_CXXFLAGS += -D VERSION_BUILD_INFO=\"$(BUILD_INFO)\"
CPPUTEST_CXXFLAGS += -D MOCK_IPC=1

# Turn on CppUMock
CPPUTEST_USE_EXTENSIONS = Y

# INCLUDE_DIRS are searched in order after the included file's
# containing directory
INCLUDE_DIRS += $(CPPUTEST_HOME)/include
INCLUDE_DIRS += $(CPPUTEST_HOME)/include/Platforms/Gcc
INCLUDE_DIRS += mocks
INCLUDE_DIRS += /usr/include
INCLUDE_DIRS += ../src
INCLUDE_DIRS += ../vnc_driver/include
INCLUDE_DIRS += ../../utils \
                ../../framework \
                ../../taskIF


# --- CPPUTEST_OBJS_DIR ---
# CPPUTEST_OBJS_DIR lets you control where the
# build artifact (.o and .d) files are stored.
#
# If you have to use "../" to get to your source path
# the makefile will put the .o and .d files in surprising
# places.
#
# To make up for each level of "../"in the source path,
# add place holder subdirectories to CPPUTEST_OBJS_DIR
# each.  
# e.g. if you have "../../src", set to "test-objs/1/2"
#
# This is kind of a kludge, but it causes the
# .o and .d files to be put under objs.
CPPUTEST_OBJS_DIR = test-obj/1/2

CPPUTEST_LIB_DIR = test-lib/1/2

# You may have to tweak these compiler flags
#    CPPUTEST_WARNINGFLAGS - apply to C and C++
#    CPPUTEST_CFLAGS - apply to C files only
#    CPPUTEST_CXXFLAGS - apply to C++ files on;y
#    CPPUTEST_CPPFLAGS - apply to C and C++ Pre-Processor
#
# If you get an error like this
#     TestPlugin.h:93:59: error: 'override' keyword is incompatible
#        with C++98 [-Werror,-Wc++98-compat] ...
# The compiler is basically telling you how to fix the
# build problem.  You would add this flag setting
#     CPPUTEST_CXXFLAGS += -Wno-c++14-compat




# Some flags to quiet clang
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang"), 1)
CPPUTEST_WARNINGFLAGS += -Wno-unknown-warning-option
CPPUTEST_WARNINGFLAGS += -Wno-covered-switch-default
CPPUTEST_WARNINGFLAGS += -Wno-reserved-id-macro
CPPUTEST_WARNINGFLAGS += -Wno-keyword-macro
CPPUTEST_WARNINGFLAGS += -Wno-documentation
CPPUTEST_WARNINGFLAGS += -Wno-missing-noreturn
endif

CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wfatal-errors
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Wno-format-nonliteral
CPPUTEST_WARNINGFLAGS += -Wno-sign-conversion
CPPUTEST_WARNINGFLAGS += -Wno-pedantic
CPPUTEST_WARNINGFLAGS += -Wno-shadow
CPPUTEST_WARNINGFLAGS += -Wno-missing-field-initializers
CPPUTEST_WARNINGFLAGS += -Wno-unused-parameter
# CPPUTEST_WARNINGFLAGS += -Wno-maybe-uninitialized
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wno-missing-prototypes
CPPUTEST_CFLAGS += -Wno-strict-prototypes
CPPUTEST_CXXFLAGS += -Wno-error=write-strings
# CPPUTEST_CXXFLAGS += -Wno-c++14-compat
# CPPUTEST_CXXFLAGS += --std=c++11
CPPUTEST_CXXFLAGS += --std=c++98    #prevent warnings re: depricated use of throw(Exception("error"))
# CPPUTEST_CXXFLAGS += -Wno-c++98-compat-pedantic
# CPPUTEST_CXXFLAGS += -Wno-c++98-compat

# We live with really old C++
CPPUTEST_CXXFLAGS += -Wno-error=deprecated
CPPUTEST_CFLAGS += -Wno-error=deprecated

# Check if libvnc is already built, and if not, build it.
# ifeq (,$(wildcard ../vnc_driver/build/libvnc.a))
# 	LIB_VNC_RESULT:=$(shell bash ../build_vnc_lib.sh)
# endif
# Link againds the libvnc
LD_LIBRARIES += ../vnc_driver/build/libvnc.a

include $(CPPUTEST_HOME)/build/MakefileWorker.mk