# Calf DSP library - example modules

INCLUDES = -I$(top_srcdir) -I$(srcdir)

SUBDIRS = calf

ladspadir = $(with_ladspa_dir)
lv2dir = $(with_lv2_dir)/calf.lv2

bin_PROGRAMS = 
noinst_LTLIBRARIES =

noinst_PROGRAMS = calfbenchmark
pkglib_LTLIBRARIES = calf.la
if USE_DSSI_GUI
bin_PROGRAMS += calf_gtk
endif
if USE_LV2_GUI
noinst_LTLIBRARIES += calflv2gui.la
bin_PROGRAMS += calf_gtk
endif

AM_CXXFLAGS = -ffast-math -finline-limit=80 $(FLUIDSYNTH_DEPS_CFLAGS)

if USE_GUI
AM_CXXFLAGS += $(GUI_DEPS_CFLAGS)
endif
if USE_JACK
AM_CXXFLAGS += $(JACK_DEPS_CFLAGS)
noinst_LTLIBRARIES += libcalfgui.la
bin_PROGRAMS += calfjackhost 
calfjackhost_SOURCES = gtk_session_env.cpp host_session.cpp jack_client.cpp jackhost.cpp gtk_main_win.cpp session_mgr.cpp
calfjackhost_LDADD = libcalfgui.la calf.la $(JACK_DEPS_LIBS) $(GUI_DEPS_LIBS) $(GLIB_DEPS_LIBS) $(FLUIDSYNTH_DEPS_LIBS) -lfftw3f
if USE_LASH
AM_CXXFLAGS += $(LASH_DEPS_CFLAGS)
calfjackhost_LDADD += $(LASH_DEPS_LIBS)
endif
endif

AM_CXXFLAGS += $(GLIB_DEPS_CFLAGS)
noinst_PROGRAMS += calfmakerdf
calfmakerdf_SOURCES = makerdf.cpp 
calfmakerdf_LDADD = calf.la 

calfbenchmark_SOURCES = benchmark.cpp
calfbenchmark_LDADD = calf.la $(GLIB_DEPS_LIBS)

if USE_EXEC_GUI
calf_gtk_SOURCES = dssigui.cpp
calf_gtk_LDADD = calf.la libcalfgui.la $(GLIB_DEPS_LIBS) $(GUI_DEPS_LIBS)
calfbenchmark_CXXFLAGS = $(AM_CXXFLAGS) -DTEST_OSC
calfbenchmark_LDADD += libcalfgui.la
endif

calf_la_SOURCES = audio_fx.cpp metadata.cpp modules.cpp modules_comp.cpp modules_limit.cpp modules_dist.cpp modules_eq.cpp modules_mod.cpp fluidsynth.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp osctlnet.cpp plugin.cpp preset.cpp synth.cpp utils.cpp wavetable.cpp modmatrix.cpp 
calf_la_LIBADD = $(FLUIDSYNTH_DEPS_LIBS) -lfftw3f
if USE_DEBUG
calf_la_LDFLAGS = -rpath $(pkglibdir) -avoid-version -module -lexpat -disable-static 
else
calf_la_LDFLAGS = -rpath $(pkglibdir) -avoid-version -module -lexpat -disable-static -export-symbols-regex "(ladspa_|lv2_|dssi_)descriptor"
endif

if USE_LV2_GTK_GUI

# Version WITH out-of-process GUI - links GTK+, UI controls etc.

noinst_LTLIBRARIES += calflv2gui.la

calflv2gui_la_SOURCES = gui.cpp gui_config.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_knob.cpp ctl_led.cpp ctl_tube.cpp ctl_vumeter.cpp custom_ctl.cpp metadata.cpp giface.cpp plugin_gui_window.cpp preset.cpp preset_gui.cpp lv2gui.cpp osctl.cpp osctlnet.cpp utils.cpp

if USE_DEBUG
calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat $(GUI_DEPS_LIBS) -disable-static
else
calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat -export-symbols-regex "lv2ui_descriptor" $(GUI_DEPS_LIBS) -disable-static
endif

else

# Version WITHOUT out-of-process GUI - links GLib only

if USE_LV2_GUI
calflv2gui_la_SOURCES = metadata.cpp giface.cpp preset.cpp lv2gui.cpp osctl.cpp osctlnet.cpp utils.cpp

if USE_DEBUG
calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat $(GLIB_DEPS_LIBS) -disable-static
else
calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat -export-symbols-regex "lv2ui_descriptor" $(GLIB_DEPS_LIBS) -disable-static
endif

endif

endif

if USE_GUI
libcalfgui_la_SOURCES = ctl_curve.cpp ctl_keyboard.cpp ctl_knob.cpp ctl_led.cpp ctl_tube.cpp ctl_vumeter.cpp custom_ctl.cpp gui.cpp gui_config.cpp gui_controls.cpp osctl.cpp osctlnet.cpp osctl_glib.cpp plugin_gui_window.cpp preset_gui.cpp utils.cpp
libcalfgui_la_LDFLAGS = -static -disable-shared -lexpat
endif

clean-local:
	$(RM) -f calfjackhost *~

install-data-hook:
	install -d -m 755 $(DESTDIR)$(pkgdatadir) 
	install -c -m 644 $(top_srcdir)/presets.xml $(DESTDIR)$(pkgdatadir)
if USE_GUI
	install -c -m 644 $(top_srcdir)/calf-gui.xml $(DESTDIR)$(pkgdatadir)
endif
if USE_LADSPA
	install -d -m 755 $(DESTDIR)$(with_ladspa_dir)
	install -d -m 755 $(DESTDIR)$(with_ladspa_rdf_dir)
	cp $(CURDIR)/.libs/calf.so $(DESTDIR)$(with_ladspa_dir)/calf.so
	$(top_builddir)/src/calfmakerdf > $(DESTDIR)$(with_ladspa_rdf_dir)/calf.rdf
endif
if USE_DSSI
	install -d -m 755 $(DESTDIR)$(with_dssi_dir)
	install -d -m 755 $(DESTDIR)$(with_dssi_dir)/calf
	cp $(CURDIR)/.libs/calf.so $(DESTDIR)$(with_dssi_dir)/calf.so
	cp $(CURDIR)/.libs/calf_gtk $(DESTDIR)$(with_dssi_dir)/calf/calf_gtk
endif
if USE_LV2
	install -d -m 755 $(DESTDIR)$(lv2dir)
	cp $(CURDIR)/.libs/calf.so $(DESTDIR)$(lv2dir)/calf.so
	cp $(CURDIR)/.libs/calf_gtk $(DESTDIR)$(lv2dir)/calf_gtk
if USE_LV2_GUI
	install -c -m 755 $(top_builddir)/src/.libs/calflv2gui.so $(DESTDIR)$(lv2dir)/calflv2gui.so
endif
	rm -f $(DESTDIR)$(lv2dir)/*.ttl
	$(top_builddir)/src/calfmakerdf -m ttl -p $(DESTDIR)$(lv2dir)/
endif

#remove calf.so, calf.rdf and - if empty - ladspa dir in usr/share
uninstall-hook:
if USE_LV2
if USE_LV2_GUI
	rm -f $(DESTDIR)$(lv2dir)/calflv2gui.so
	rm -f $(DESTDIR)$(lv2dir)/calf_gtk
endif
	rm -f $(DESTDIR)$(lv2dir)/calf.so
	rm -f $(DESTDIR)$(lv2dir)/*.ttl
	rmdir -p $(DESTDIR)$(lv2dir) || true
endif
if USE_GUI
	rm -f $(DESTDIR)$(pkgdatadir)/calf-gui.xml
endif
	rm -f $(DESTDIR)$(pkgdatadir)/presets*.xml
	rmdir $(DESTDIR)$(pkgdatadir) || true
if USE_LADSPA
	$(RM) -f $(DESTDIR)$(with_ladspa_dir)/calf.so
	$(RM) -f $(DESTDIR)$(with_ladspa_rdf_dir)/calf.rdf
	rmdir -p $(DESTDIR)$(with_ladspa_rdf_dir) || true
endif
if USE_DSSI
	$(RM) -f $(DESTDIR)$(with_dssi_dir)/calf.so
if USE_DSSI_GUI
	$(RM) -f $(DESTDIR)$(with_dssi_dir)/calf/calf_gtk
endif
	rmdir -p $(DESTDIR)$(with_dssi_dir)/calf || true
endif
