# Test App - Util/Makefile
# Makefile for Util, requires GNU "make"
.PHONY: release debug

#Required libraries
REQ_LIBS := libZUtil.a libsst-concurrency.a libsst-os.a libsst-atomic.a libsst-crypto.a libsst-random.a  libsst-math.a

#Name of binary
BINNAME := ZTestSuite.bin

#In debug mode, use debug versions of libraries
ifeq ($(TARGET),debug)
	REQ_LIBS := $(foreach lib,$(REQ_LIBS), $(subst .a,_d.a, $(lib)))
	BINNAME := $(subst .bin,_d.bin, $(BINNAME))	
endif

# Generate the lib names with the full dist name.
# This is only used for dependency checking
REQ_LIBS_DIST := $(foreach lib,$(REQ_LIBS), $(DIST)/$(lib)) 

#Generate LDFLAGS for $REQ_LIBS: "libfoo.a" becomes "-lfoo"
REQ_LIBS_LDFLAGS := $(foreach lib,$(REQ_LIBS), $(subst lib,-l,$(lib)))
REQ_LIBS_LDFLAGS := -L$(DIST) $(foreach lib,$(REQ_LIBS_LDFLAGS), $(subst .a,,$(lib)))

override LDFLAGS := $(subst noop,noop, -L.. $(REQ_LIBS_LDFLAGS) $(LDFLAGS)) $(ZENGINE_BASE_LIBS)

SRC = \
	Test-SST_Atomic.cpp \
	Test-SST_Endian.cpp \
	Test-SST_SafeArithmetic.cpp \
	Test-SST_FileSys.cpp \
	Test-ZAlloc.cpp \
	Test-ZAllocWindow.cpp \
	Test-ZArrayAlgo.cpp \
	Test-ZArray.cpp \
	Test-ZAssert.cpp \
	Test-ZBasicStringAlgo.cpp \
	Test-ZBasicString.cpp \
	Test-ZConcurrency.cpp \
	Test-ZHashMap.cpp \
	Test-ZIniReader.cpp \
	Test-ZIniWriter.cpp \
	Test-ZJSONReader.cpp \
	Test-ZJSONWriter.cpp \
	Test-ZKVTree.cpp \
	Test-ZListAlgo.cpp \
	Test-ZList.cpp \
	Test-ZName.cpp \
	Test-ZRandomGenerator.cpp \
	Test-ZReferenceCounter.cpp \
	Test-ZRegistry.cpp \
	Test-ZRingBuffer.cpp \
	Test-ZSimplexNoise.cpp \
	Test-ZSlabAllocator.cpp \
	Test-ZSmartPointer.cpp \
	Test-ZTaskStream.cpp \
	Test-ZWeakPointer.cpp \
	Test-ZXMLReader.cpp \
	Test-ZXMLWriter.cpp \
	ZTestSuiteMain.cpp \
	ZUnitTest.cpp 

	
SRC+= \
	Test-SST_Mat22d.cpp \
	Test-SST_Mat22f.cpp \
	Test-SST_Mat22i.cpp \
	Test-SST_Mat22u.cpp \
	Test-SST_Mat33d.cpp \
	Test-SST_Mat33f.cpp \
	Test-SST_Mat33i.cpp \
	Test-SST_Mat33u.cpp \
	Test-SST_Mat44d.cpp \
	Test-SST_Mat44f.cpp \
	Test-SST_Mat44i.cpp \
	Test-SST_Mat44u.cpp \
	Test-SST_Vec2d.cpp \
	Test-SST_Vec2f.cpp \
	Test-SST_Vec2i.cpp \
	Test-SST_Vec2u.cpp \
	Test-SST_Vec3d.cpp \
	Test-SST_Vec3f.cpp \
	Test-SST_Vec3i.cpp \
	Test-SST_Vec3u.cpp \
	Test-SST_Vec4d.cpp \
	Test-SST_Vec4f.cpp \
	Test-SST_Vec4i.cpp \
	Test-SST_Vec4u.cpp \
    Test-SST_Transform.cpp \
	Test-SST_Geo.cpp 
#   Test-SST_Net.cpp 



OBJ := $(addprefix obj/$(ARCH)/$(TARGET)/,$(subst .cpp,.o,$(SRC)) )
$(shell mkdir -p obj/$(ARCH)/$(TARGET))

all: $(BINNAME)

# CLEAN
clean:
	@-rm -r -f obj ZTestSuite*.bin 

$(BINNAME): $(OBJ) $(REQ_LIBS_DIST) 
	@echo LD $@
	$(CXX) $+ $(LDFLAGS) -o $@

# *.cpp files to *.o files
obj/$(ARCH)/$(TARGET)/%.o: %.cpp
	@echo CXX $@
	@$(CXX) $(CXXFLAGS) -I../Include -I../Lib/Include -c $< -o $@

