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

CROSS       = arm-none-linux-
CXX         = $(CROSS)g++
AR          = $(CROSS)ar

LOCAL_MODULE = apn_test

LOCAL_SRC_FILES = $(wildcard *.cpp) $(wildcard ./inc/*.h)
LOCAL_OBJ_FILES = $(LOCAL_SRC_FILES:.cpp=.o)
LOCAL_STATIC_LIBS = ./libs/libgmock_test.a

CPPFLAGS += -isystem ./include -I../../inc

# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra -pthread
LOCAL_LIBS += -lpthread -lstdc++ -llog -L..  -lapn -lxml2

.PHONY: build clean install

all : $(LOCAL_MODULE)

clean :
	$(warning ########## clean $(LOCAL_MODULE) ##########)
	rm -f $(LOCAL_MODULE) *.o

# Builds test.
%.o: %.cpp
	$(warning ----->build $<)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LOCAL_STATIC_LIBS) -o $@ -c $<

$(LOCAL_MODULE) :$(LOCAL_OBJ_FILES) $(LOCAL_STATIC_LIBS)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LOCAL_LIBS)  $(LOCAL_STATIC_LIBS) $^ -o $@

install:
	$(warning ########## install $(LOCAL_MODULE) ##########)
	mkdir -p $(ROOT)/$(base_bindir)/
	install $(LOCAL_MODULE) $(ROOT)/$(base_bindir)/
