
CXX		:= @CXX@
CXXFLAGS	:= -DHAVE_LIBSAMPLERATE -DHAVE_FFTW3 -DFFTW_DOUBLE_ONLY -DNO_THREAD_CHECKS -DUSE_PTHREADS -DNO_TIMING -DNDEBUG @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ -Irubberband -I. -Isrc $(OPTFLAGS)
CFLAGS		:= @CFLAGS@ $(OPTFLAGS)
LDFLAGS		:= @LDFLAGS@ -lpthread $(LDFLAGS)

LIBRARY_LIBS		:= @SRC_LIBS@ @FFTW_LIBS@ 
PROGRAM_LIBS		:= @SNDFILE_LIBS@ $(LIBRARY_LIBS)
VAMP_PLUGIN_LIBS	:= @Vamp_LIBS@ $(LIBRARY_LIBS)
LADSPA_PLUGIN_LIBS	:= $(LIBRARY_LIBS)

MKDIR			:= mkdir
AR			:= ar

DYNAMIC_EXTENSION	:= .so
DYNAMIC_FULL_VERSION	:= .2.1.0
DYNAMIC_ABI_VERSION	:= .2
DYNAMIC_LIBNAME		:= librubberband$(DYNAMIC_EXTENSION)
DYNAMIC_LDFLAGS		:= -shared -Wl,-Bsymbolic -Wl,-soname=$(DYNAMIC_LIBNAME)$(DYNAMIC_ABI_VERSION)
VAMP_LDFLAGS		:= -shared -Wl,-Bsymbolic -Wl,--version-script=vamp/vamp-plugin.map
LADSPA_LDFLAGS		:= -shared -Wl,-Bsymbolic -Wl,--version-script=ladspa/ladspa-plugin.map

PROGRAM_TARGET 		:= bin/rubberband
STATIC_TARGET  		:= lib/librubberband.a
DYNAMIC_TARGET 		:= lib/$(DYNAMIC_LIBNAME)
VAMP_TARGET    		:= lib/vamp-rubberband$(DYNAMIC_EXTENSION)
LADSPA_TARGET  		:= lib/ladspa-rubberband$(DYNAMIC_EXTENSION)

INSTALL_BINDIR		:= @prefix@/bin
INSTALL_INCDIR		:= @prefix@/include/rubberband
INSTALL_LIBDIR		:= @prefix@/lib
INSTALL_VAMPDIR		:= @prefix@/lib/vamp
INSTALL_LADSPADIR	:= @prefix@/lib/ladspa
INSTALL_LRDFDIR		:= @prefix@/share/ladspa/rdf
INSTALL_PKGDIR		:= @prefix@/lib/pkgconfig

all:	bin lib $(PROGRAM_TARGET) $(STATIC_TARGET) $(DYNAMIC_TARGET) $(VAMP_TARGET) $(LADSPA_TARGET)

static:		$(STATIC_TARGET)
dynamic:	$(DYNAMIC_TARGET)
library:	$(STATIC_TARGET) $(DYNAMIC_TARGET)
program:	$(PROGRAM_TARGET)
vamp:		$(VAMP_TARGET)
ladspa:		$(LADSPA_TARGET)

PUBLIC_INCLUDES := \
	rubberband/rubberband-c.h \
	rubberband/RubberBandStretcher.h

LIBRARY_INCLUDES := \
	src/StretcherChannelData.h \
	src/float_cast/float_cast.h \
	src/StretcherImpl.h \
	src/StretchCalculator.h \
	src/base/Profiler.h \
	src/base/RingBuffer.h \
	src/base/Scavenger.h \
	src/dsp/AudioCurveCalculator.h \
	src/audiocurves/CompoundAudioCurve.h \
	src/audiocurves/ConstantAudioCurve.h \
	src/audiocurves/HighFrequencyAudioCurve.h \
	src/audiocurves/PercussiveAudioCurve.h \
	src/audiocurves/SilentAudioCurve.h \
	src/audiocurves/SpectralDifferenceAudioCurve.h \
	src/dsp/Resampler.h \
	src/dsp/FFT.h \
	src/dsp/MovingMedian.h \
	src/dsp/SincWindow.h \
	src/dsp/Window.h \
	src/system/Allocators.h \
	src/system/Thread.h \
	src/system/VectorOps.h \
	src/system/sysutils.h

LIBRARY_SOURCES := \
	src/rubberband-c.cpp \
	src/RubberBandStretcher.cpp \
	src/StretcherProcess.cpp \
	src/StretchCalculator.cpp \
	src/base/Profiler.cpp \
	src/dsp/AudioCurveCalculator.cpp \
	src/audiocurves/CompoundAudioCurve.cpp \
	src/audiocurves/SpectralDifferenceAudioCurve.cpp \
	src/audiocurves/HighFrequencyAudioCurve.cpp \
	src/audiocurves/SilentAudioCurve.cpp \
	src/audiocurves/ConstantAudioCurve.cpp \
	src/audiocurves/PercussiveAudioCurve.cpp \
	src/dsp/Resampler.cpp \
	src/dsp/FFT.cpp \
	src/system/Allocators.cpp \
	src/system/sysutils.cpp \
	src/system/Thread.cpp \
	src/StretcherChannelData.cpp \
	src/StretcherImpl.cpp

PROGRAM_SOURCES := \
	main/main.cpp

VAMP_HEADERS := \
	vamp/RubberBandVampPlugin.h

VAMP_SOURCES := \
	vamp/RubberBandVampPlugin.cpp \
	vamp/libmain.cpp

LADSPA_HEADERS := \
	ladspa/RubberBandPitchShifter.h

LADSPA_SOURCES := \
	ladspa/RubberBandPitchShifter.cpp \
	ladspa/libmain.cpp

LIBRARY_OBJECTS := $(LIBRARY_SOURCES:.cpp=.o)
LIBRARY_OBJECTS := $(LIBRARY_OBJECTS:.c=.o)

PROGRAM_OBJECTS := $(PROGRAM_SOURCES:.cpp=.o)
VAMP_OBJECTS    := $(VAMP_SOURCES:.cpp=.o)
LADSPA_OBJECTS  := $(LADSPA_SOURCES:.cpp=.o)

$(PROGRAM_TARGET):	$(LIBRARY_OBJECTS) $(PROGRAM_OBJECTS)
	$(CXX) -o $@ $^ $(PROGRAM_LIBS) $(LDFLAGS)

$(STATIC_TARGET):	$(LIBRARY_OBJECTS)
	$(AR) rsc $@ $^

$(DYNAMIC_TARGET):	$(LIBRARY_OBJECTS)
	$(CXX) $(DYNAMIC_LDFLAGS) $^ -o $@ $(LIBRARY_LIBS) $(LDFLAGS)

$(VAMP_TARGET):		$(LIBRARY_OBJECTS) $(VAMP_OBJECTS)
	$(CXX) $(VAMP_LDFLAGS) -o $@ $^ $(VAMP_PLUGIN_LIBS) $(LDFLAGS)

$(LADSPA_TARGET):	$(LIBRARY_OBJECTS) $(LADSPA_OBJECTS)
	$(CXX) $(LADSPA_LDFLAGS) -o $@ $^ $(LADSPA_PLUGIN_LIBS) $(LDFLAGS)

bin:
	$(MKDIR) $@
lib:
	$(MKDIR) $@

install:	all
	$(MKDIR) -p $(DESTDIR)$(INSTALL_BINDIR)
	$(MKDIR) -p $(DESTDIR)$(INSTALL_INCDIR)
	$(MKDIR) -p $(DESTDIR)$(INSTALL_LIBDIR)
	$(MKDIR) -p $(DESTDIR)$(INSTALL_VAMPDIR)
	$(MKDIR) -p $(DESTDIR)$(INSTALL_LADSPADIR)
	$(MKDIR) -p $(DESTDIR)$(INSTALL_LRDFDIR)
	$(MKDIR) -p $(DESTDIR)$(INSTALL_PKGDIR)
	cp $(PROGRAM_TARGET) $(DESTDIR)$(INSTALL_BINDIR)
	cp $(PUBLIC_INCLUDES) $(DESTDIR)$(INSTALL_INCDIR)
	cp $(STATIC_TARGET) $(DESTDIR)$(INSTALL_LIBDIR)
	rm -f $(DESTDIR)$(INSTALL_LIBDIR)/$(DYNAMIC_LIBNAME)$(DYNAMIC_ABI_VERSION)
	rm -f $(DESTDIR)$(INSTALL_LIBDIR)/$(DYNAMIC_LIBNAME)
	cp $(DYNAMIC_TARGET) $(DESTDIR)$(INSTALL_LIBDIR)/$(DYNAMIC_LIBNAME)$(DYNAMIC_FULL_VERSION)
	test -n "$(DYNAMIC_FULL_VERSION)" && ln -s $(DYNAMIC_LIBNAME)$(DYNAMIC_FULL_VERSION) $(DESTDIR)$(INSTALL_LIBDIR)/$(DYNAMIC_LIBNAME)$(DYNAMIC_ABI_VERSION)
	test -n "$(DYNAMIC_FULL_VERSION)" && ln -s $(DYNAMIC_LIBNAME)$(DYNAMIC_FULL_VERSION) $(DESTDIR)$(INSTALL_LIBDIR)/$(DYNAMIC_LIBNAME)
	cp $(VAMP_TARGET) $(DESTDIR)$(INSTALL_VAMPDIR)
	cp vamp/vamp-rubberband.cat $(DESTDIR)$(INSTALL_VAMPDIR)
	cp $(LADSPA_TARGET) $(DESTDIR)$(INSTALL_LADSPADIR)
	cp ladspa/ladspa-rubberband.cat $(DESTDIR)$(INSTALL_LADSPADIR)
	cp ladspa/ladspa-rubberband.rdf $(DESTDIR)$(INSTALL_LRDFDIR)
	sed "s,%PREFIX%,@prefix@," rubberband.pc.in \
	  > $(DESTDIR)$(INSTALL_PKGDIR)/rubberband.pc

clean:
	rm -f $(LIBRARY_OBJECTS) $(PROGRAM_OBJECTS) $(LADSPA_OBJECTS) $(VAMP_OBJECTS)

distclean:	clean
	rm -f $(PROGRAM_TARGET) $(STATIC_TARGET) $(DYNAMIC_TARGET) $(VAMP_TARGET) $(LADSPA_TARGET)

depend:
	makedepend -Y $(LIBRARY_SOURCES) $(PROGRAM_SOURCES)


# DO NOT DELETE

src/rubberband-c.o: rubberband/rubberband-c.h
src/rubberband-c.o: rubberband/RubberBandStretcher.h
src/RubberBandStretcher.o: src/StretcherImpl.h
src/RubberBandStretcher.o: rubberband/RubberBandStretcher.h src/dsp/Window.h
src/RubberBandStretcher.o: src/dsp/SincWindow.h src/dsp/FFT.h
src/RubberBandStretcher.o: src/audiocurves/CompoundAudioCurve.h
src/RubberBandStretcher.o: src/dsp/AudioCurveCalculator.h
src/RubberBandStretcher.o: src/audiocurves/PercussiveAudioCurve.h
src/RubberBandStretcher.o: src/audiocurves/HighFrequencyAudioCurve.h
src/RubberBandStretcher.o: src/dsp/SampleFilter.h src/base/RingBuffer.h
src/RubberBandStretcher.o: src/base/Scavenger.h src/system/Thread.h
src/RubberBandStretcher.o: src/system/sysutils.h
src/StretcherProcess.o: src/StretcherImpl.h rubberband/RubberBandStretcher.h
src/StretcherProcess.o: src/dsp/Window.h src/dsp/SincWindow.h src/dsp/FFT.h
src/StretcherProcess.o: src/audiocurves/CompoundAudioCurve.h
src/StretcherProcess.o: src/dsp/AudioCurveCalculator.h
src/StretcherProcess.o: src/audiocurves/PercussiveAudioCurve.h
src/StretcherProcess.o: src/audiocurves/HighFrequencyAudioCurve.h
src/StretcherProcess.o: src/dsp/SampleFilter.h src/base/RingBuffer.h
src/StretcherProcess.o: src/base/Scavenger.h src/system/Thread.h
src/StretcherProcess.o: src/system/sysutils.h src/audiocurves/PercussiveAudioCurve.h
src/StretcherProcess.o: src/audiocurves/HighFrequencyAudioCurve.h
src/StretcherProcess.o: src/audiocurves/ConstantAudioCurve.h src/StretchCalculator.h
src/StretcherProcess.o: src/StretcherChannelData.h src/dsp/Resampler.h
src/StretcherProcess.o: src/base/Profiler.h src/system/VectorOps.h
src/StretcherProcess.o: src/system/sysutils.h
src/StretchCalculator.o: src/StretchCalculator.h src/system/sysutils.h
src/base/Profiler.o: src/base/Profiler.h src/system/sysutils.h
src/dsp/AudioCurveCalculator.o: src/dsp/AudioCurveCalculator.h
src/audiocurves/CompoundAudioCurve.o: src/audiocurves/CompoundAudioCurve.h
src/audiocurves/CompoundAudioCurve.o: src/dsp/AudioCurveCalculator.h
src/audiocurves/CompoundAudioCurve.o: src/audiocurves/PercussiveAudioCurve.h
src/audiocurves/CompoundAudioCurve.o: src/audiocurves/HighFrequencyAudioCurve.h
src/audiocurves/CompoundAudioCurve.o: src/dsp/SampleFilter.h src/dsp/MovingMedian.h
src/audiocurves/SpectralDifferenceAudioCurve.o: src/audiocurves/SpectralDifferenceAudioCurve.h
src/audiocurves/SpectralDifferenceAudioCurve.o: src/dsp/AudioCurveCalculator.h
src/audiocurves/SpectralDifferenceAudioCurve.o: src/dsp/Window.h
src/audiocurves/SpectralDifferenceAudioCurve.o: src/system/sysutils.h
src/audiocurves/SpectralDifferenceAudioCurve.o: src/system/VectorOps.h
src/audiocurves/SpectralDifferenceAudioCurve.o: src/system/sysutils.h
src/audiocurves/HighFrequencyAudioCurve.o: src/audiocurves/HighFrequencyAudioCurve.h
src/audiocurves/HighFrequencyAudioCurve.o: src/dsp/AudioCurveCalculator.h
src/audiocurves/SilentAudioCurve.o: src/audiocurves/SilentAudioCurve.h
src/audiocurves/SilentAudioCurve.o: src/dsp/AudioCurveCalculator.h
src/audiocurves/ConstantAudioCurve.o: src/audiocurves/ConstantAudioCurve.h
src/audiocurves/ConstantAudioCurve.o: src/dsp/AudioCurveCalculator.h
src/audiocurves/PercussiveAudioCurve.o: src/audiocurves/PercussiveAudioCurve.h
src/audiocurves/PercussiveAudioCurve.o: src/dsp/AudioCurveCalculator.h
src/audiocurves/PercussiveAudioCurve.o: src/system/VectorOps.h src/system/sysutils.h
src/dsp/Resampler.o: src/dsp/Resampler.h src/system/sysutils.h
src/dsp/Resampler.o: src/base/Profiler.h
src/dsp/FFT.o: src/dsp/FFT.h src/system/sysutils.h src/system/Thread.h
src/dsp/FFT.o: src/base/Profiler.h src/system/VectorOps.h
src/dsp/FFT.o: src/system/sysutils.h
src/system/Allocators.o: src/system/Allocators.h src/system/VectorOps.h
src/system/Allocators.o: src/system/sysutils.h
src/system/sysutils.o: src/system/sysutils.h
src/system/Thread.o: src/system/Thread.h
src/StretcherChannelData.o: src/StretcherChannelData.h src/StretcherImpl.h
src/StretcherChannelData.o: rubberband/RubberBandStretcher.h src/dsp/Window.h
src/StretcherChannelData.o: src/dsp/SincWindow.h src/dsp/FFT.h
src/StretcherChannelData.o: src/audiocurves/CompoundAudioCurve.h
src/StretcherChannelData.o: src/dsp/AudioCurveCalculator.h
src/StretcherChannelData.o: src/audiocurves/PercussiveAudioCurve.h
src/StretcherChannelData.o: src/audiocurves/HighFrequencyAudioCurve.h
src/StretcherChannelData.o: src/dsp/SampleFilter.h src/base/RingBuffer.h
src/StretcherChannelData.o: src/base/Scavenger.h src/system/Thread.h
src/StretcherChannelData.o: src/system/sysutils.h src/dsp/Resampler.h
src/StretcherChannelData.o: src/system/Allocators.h src/system/VectorOps.h
src/StretcherChannelData.o: src/system/sysutils.h
src/StretcherImpl.o: src/StretcherImpl.h rubberband/RubberBandStretcher.h
src/StretcherImpl.o: src/dsp/Window.h src/dsp/SincWindow.h src/dsp/FFT.h
src/StretcherImpl.o: src/audiocurves/CompoundAudioCurve.h
src/StretcherImpl.o: src/dsp/AudioCurveCalculator.h
src/StretcherImpl.o: src/audiocurves/PercussiveAudioCurve.h
src/StretcherImpl.o: src/audiocurves/HighFrequencyAudioCurve.h src/dsp/SampleFilter.h
src/StretcherImpl.o: src/base/RingBuffer.h src/base/Scavenger.h
src/StretcherImpl.o: src/system/Thread.h src/system/sysutils.h
src/StretcherImpl.o: src/audiocurves/PercussiveAudioCurve.h
src/StretcherImpl.o: src/audiocurves/HighFrequencyAudioCurve.h
src/StretcherImpl.o: src/audiocurves/SpectralDifferenceAudioCurve.h src/dsp/Window.h
src/StretcherImpl.o: src/system/VectorOps.h src/system/sysutils.h
src/StretcherImpl.o: src/audiocurves/SilentAudioCurve.h src/audiocurves/ConstantAudioCurve.h
src/StretcherImpl.o: src/dsp/Resampler.h src/StretchCalculator.h
src/StretcherImpl.o: src/StretcherChannelData.h src/base/Profiler.h
main/main.o: rubberband/RubberBandStretcher.h src/system/sysutils.h
main/main.o: src/base/Profiler.h
