BUILD_DIR := ./build/${CONFIG}
JUCE_ROOT := ./${JUCE_VER}
OBJS := $(addprefix ${BUILD_DIR}/, $(subst .cpp,.o,$(SRCS)))

.PHONY: ${JUCE_VER}.patch	
all: ${JUCE_ROOT} ${BUILD_DIR}/libjuce.a
prepare: ${JUCE_ROOT}
patch: ${JUCE_VER}.patch

${JUCE_VER}.patch:
	@unzip ${JUCE_VER}.zip -d temp >/dev/null
	@diff -r ${JUCE_VER} temp/${JUCE_VER} > ${JUCE_VER}.patch
	@rm -rf temp
	@echo "Created" ${JUCE_VER}.patch

CXXFLAGS += -std=c++11
CXXFLAGS_debug := ${CXXFLAGS} -O0 -g
CXXFLAGS_release := ${CXXFLAGS} -O2
	
INCLUDES += -I./ -I/usr/include/freetype2
DEFINES += -D${TARGET}

${OBJS}: $(BUILD_DIR)/%.o : ${JUCE_ROOT}/%.cpp
	mkdir -p $(dir $@)
	g++ ${CXXFLAGS_${CONFIG}} ${DEFINES} ${INCLUDES} -o $@ -c $<

${BUILD_DIR}/libjuce.a: ${OBJS}
	ar -q $@ ${OBJS}

${JUCE_ROOT}:
	unzip ${JUCE_VER}.zip

clean:
	rm -rf ${BUILD_DIR}/*

distclean:
	rm -rf ${BUILD_DIR}
	rm -rf ${JUCE_ROOT}

