include make/defaults.mk

CONFIG ?= release
TARGET ?= JaySynth.so

APP_VERSION := 1.1.0-pre
APP_VERSION_HEX := 0x010001
LIBSRC_PATH ?= $(realpath ./submodule)
JUCE_PATH :=  $(realpath ./sdk/juce/JUCE-3.1.1)
VST2_SDK_PATH ?= $(realpath ./sdk/vst/vstsdk2.4)
JUCE_LIBCODE_PATH ?= $(realpath ./JuceLibraryCode)
SRC_PATH := $(realpath ./src)

NAME =: JaySynth

DEFINES := -Dradio_float_t=double -Dfir_float_t=double -Dsynth_float_t=double
DEFINES += -DHAVE_LROUND
CFLAGS += -fPIC
CXXFLAGS += -fPIC
CXXFLAGS += -std=c++11

LIBS := -lstdc++ -lm -lGL -lX11 -lXext -lXinerama -lasound -ldl -lfreetype -lpthread -lrt
LDFLAGS += $(TARGET_ARCH) $(LIBDIR) -L/usr/X11R6/lib/ -shared

DEFINES += -D__cdecl=""
DEFINES += -DJUCE_GCC=1 -DLINUX=1 -DJUCE_APP_VERSION=$(APP_VERSION) -DJUCE_APP_VERSION_HEX=$(APP_VERSION_HEX)
DEFINES_debug += -DDEBUG=1 -D_DEBUG=1 -DSYNTH_DEBUG
DEFINES_release += -DNDEBUG

DEFINES += -DJucePlugin_Version=$(APP_VERSION)
DEFINES += -DJucePlugin_VersionCode=$(APP_VERSION_HEX)
DEFINES += -DJucePlugin_VersionString=\"$(APP_VERSION)\"

INCLUDES += -I $(JUCE_PATH) -I $(JUCE_PATH)/modules -I $(VST2_SDK_PATH) -I $(LIBSRC_PATH) -I $(JUCE_LIBCODE_PATH) -I $(SRC_PATH)

PACKAGES := JuceLibraryCode plug synth fir

export 


all: app
app: objects link

.PHONY: ${PACKAGES}

objects: ${PACKAGES}

synth:
	@$(MAKE) -C $(SRC_PATH)/synth

plug:
	@$(MAKE) -C $(SRC_PATH)/plug

JuceLibraryCode:
	@$(MAKE) -C $@

fir:
	@$(MAKE) -C $(LIBSRC_PATH)/fir

bear:
	make distclean
	bear --output compile_commands.json -- $(MAKE)

run: install
	carla ~/jaysynth+tal.carxp

install: app
	cp extras/waves/waves_microwave_v2.0_8bit ~/.vst/jaysynth/waves.bin
	cp build/linux/$(CONFIG)/JaySynth.so ~/.vst/jaysynth/JaySynth.so

include $(MAKE_HOME)/link.mk
