CONFIG ?= release
BUILD_DIR := ./build/${CONFIG}
JUCE_ROOT=./JUCE-3.1.1
SRCS := modules/juce_core/juce_core.cpp
SRCS += modules/juce_data_structures/juce_data_structures.cpp
SRCS += modules/juce_events/juce_events.cpp
SRCS += modules/juce_graphics/juce_graphics.cpp
SRCS += modules/juce_gui_basics/juce_gui_basics.cpp
SRCS += modules/juce_gui_extra/juce_gui_extra.cpp
SRCS += modules/juce_opengl/juce_opengl.cpp
OBJS := $(addprefix ${BUILD_DIR}/, $(subst .cpp,.o,$(SRCS)))
	
all: ${JUCE_ROOT} ${BUILD_DIR}/libjuce.a
prepare: ${JUCE_ROOT}

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

${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-3.1.1.zip

clean:
	rm -rf ${BUILD_DIR}/*

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

