if USE_ALSA
ALSA_C_FILES=src/lib/ic/aseq-discoverer.c src/lib/ic/aseq-device.c
ALSA_H_FILES=src/lib/ic/aseq-discoverer.h src/lib/ic/aseq-device.h
else
ALSA_C_FILES=
ALSA_H_FILES=
endif

if USE_GUDEV
GUDEV_C_FILES=src/lib/ic/gudev-discoverer.c
GUDEV_H_FILES=src/lib/ic/gudev-discoverer.h
else
GUDEV_C_FILES=
GUDEV_H_FILES=
endif

if USE_LINUX_INPUT
LINUX_INPUT_C_FILES=src/lib/ic/input-device.c
LINUX_INPUT_H_FILES=src/lib/ic/input-device.h
else
LINUX_INPUT_C_FILES=
LINUX_INPUT_H_FILES=
endif

if USE_DLLWRAPPER_DIRECT
DLLWRAPPER_LIB=libloader.la
DLLWRAPPER_SRC=src/lib/bml/bmlw.c
else
DLLWRAPPER_LIB=
DLLWRAPPER_SRC=src/lib/bml/bmlipc.c src/lib/bml/strpool.c
endif

# -- libs ----------------------------------------------------------------------

lib_LTLIBRARIES = libbml.la libbuzztrax-gst.la libbuzztrax-ic.la libbuzztrax-core.la

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
  src/lib/bml/libbml.pc \
  src/lib/core/libbuzztrax-core.pc \
  src/lib/gst/libbuzztrax-gst.pc \
  src/lib/ic/libbuzztrax-ic.pc

if USE_DLLWRAPPER
noinst_LTLIBRARIES += libloader.la
libloader_la_SOURCES = \
  src/lib/dllwrapper/ldt_keeper.c \
  src/lib/dllwrapper/pe_image.c \
  src/lib/dllwrapper/module.c \
  src/lib/dllwrapper/ext.c \
  src/lib/dllwrapper/win32.c \
  src/lib/dllwrapper/driver.c \
  src/lib/dllwrapper/pe_resource.c \
  src/lib/dllwrapper/resource.c \
  src/lib/dllwrapper/registry.c \
  src/lib/dllwrapper/elfdll.c \
  src/lib/dllwrapper/afl.c \
  src/lib/dllwrapper/vfl.c \
  src/lib/dllwrapper/stubs.s \
  src/lib/dllwrapper/wrapper.S

libloader_la_CFLAGS = $(PTHREAD_CFLAGS) $(BML_CFLAGS) $(BMLHOST_CFLAGS) -ffast-math
libloader_la_CCASFLAGS = $(BMLHOST_CCASFLAGS)
libloader_la_CPPFLAGS =  \
  -D__WINE__ \
  -DWIN32_PATH=\"/usr/lib/win32\" \
  -DWIN32_LIB_PATH=\"$(libdir)/win32\"
libloader_la_LIBADD = $(LIBM) $(PTHREAD_LIBS) -ldl

noinst_HEADERS += \
  src/lib/dllwrapper/avifmt.h \
  src/lib/dllwrapper/basetsd.h \
  src/lib/dllwrapper/com.h \
  src/lib/dllwrapper/debugtools.h \
  src/lib/dllwrapper/driver.h \
  src/lib/dllwrapper/elfdll.h \
  src/lib/dllwrapper/ext.h \
  src/lib/dllwrapper/heap.h \
  src/lib/dllwrapper/ldt.h \
  src/lib/dllwrapper/ldt_keeper.h \
  src/lib/dllwrapper/loader.h \
  src/lib/dllwrapper/mmreg.h \
  src/lib/dllwrapper/module.h \
  src/lib/dllwrapper/msacmdrv.h \
  src/lib/dllwrapper/msacm.h \
  src/lib/dllwrapper/ntdef.h \
  src/lib/dllwrapper/pe_image.h \
  src/lib/dllwrapper/poppack.h \
  src/lib/dllwrapper/pshpack1.h \
  src/lib/dllwrapper/pshpack2.h \
  src/lib/dllwrapper/pshpack4.h \
  src/lib/dllwrapper/pshpack8.h \
  src/lib/dllwrapper/registry.h \
  src/lib/dllwrapper/resource.h \
  src/lib/dllwrapper/vfw.h \
  src/lib/dllwrapper/win32.h \
  src/lib/dllwrapper/winbase.h \
  src/lib/dllwrapper/windef.h \
  src/lib/dllwrapper/windows.h \
  src/lib/dllwrapper/wineacm.h \
  src/lib/dllwrapper/winerror.h \
  src/lib/dllwrapper/winestring.h \
  src/lib/dllwrapper/winnt.h \
  src/lib/dllwrapper/winreg.h \
  src/lib/dllwrapper/winuser.h \
  src/lib/dllwrapper/wrapper.h
endif


libbmldir = $(includedir)/libbml
libbml_HEADERS = src/lib/bml/bml.h src/lib/bml/BuzzMachineLoader/BuzzMachineLoader.h
libbml_la_SOURCES = src/lib/bml/bml.c src/lib/bml/bmllog.c $(DLLWRAPPER_SRC)
libbml_la_CFLAGS = \
  -I$(srcdir) -I$(top_srcdir)/src/lib \
  $(PTHREAD_CFLAGS) $(BML_CFLAGS)
libbml_la_CPPFLAGS = -DNATIVE_BML_DIR="\"$(pkglibdir)\""
libbml_la_LIBADD = $(LIBM) $(PTHREAD_LIBS) $(BML_LIBS) $(DLLWRAPPER_LIB)
libbml_la_LDFLAGS = \
  -export-symbols-regex ^_?\(bml_\|bmlw_\|bmln_\).* \
  -version-info @BT_VERSION_INFO@

noinst_HEADERS += \
  src/lib/bml/bmlipc.h \
  src/lib/bml/bmllog.h \
  src/lib/bml/bmlw.h \
  src/lib/bml/strpool.h

if USE_DLLWRAPPER_IPC
bin_PROGRAMS = bmlhost

bmlhost_SOURCES = \
  src/lib/bml/bmlhost.c \
  src/lib/bml/bmllog.c \
  src/lib/bml/bmlw.c \
  src/lib/bml/bmlipc.c \
  src/lib/bml/strpool.c
bmlhost_CFLAGS = \
  -I$(srcdir) -I$(top_srcdir)/src/lib \
  -I$(top_srcdir)/src/lib/dllwrapper \
  $(BML_CFLAGS) $(BMLHOST_CFLAGS)
bmlhost_LDADD = $(PTHREAD_LIBS) $(BML_LIBS) libloader.la
else
bin_PROGRAMS =
endif

# buzzmachine loader (native adapter)
pkglib_LTLIBRARIES = libbuzzmachineloader.la
libbuzzmachineloader_la_SOURCES = \
  src/lib/bml/BuzzMachineLoader/BuzzMachineCallbacks.cpp \
  src/lib/bml/BuzzMachineLoader/BuzzMachineCallbacksPre12.cpp \
  src/lib/bml/BuzzMachineLoader/BuzzMachineLoader.cpp \
  src/lib/bml/BuzzMachineLoader/MachineDataImpl.cpp \
  src/lib/bml/BuzzMachineLoader/OscTable.cpp \
  src/lib/bml/BuzzMachineLoader/mdkimp.cpp \
  src/lib/bml/BuzzMachineLoader/debug.cpp

noinst_HEADERS += \
  src/lib/bml/BuzzMachineLoader/BuzzMachineCallbacks.h \
  src/lib/bml/BuzzMachineLoader/BuzzMachineCallbacksPre12.h \
  src/lib/bml/BuzzMachineLoader/BuzzMachineLoader.h \
  src/lib/bml/BuzzMachineLoader/CLibInterface.h \
  src/lib/bml/BuzzMachineLoader/CMachine.h \
  src/lib/bml/BuzzMachineLoader/CMICallbacks.h \
  src/lib/bml/BuzzMachineLoader/MachineDataImpl.h \
  src/lib/bml/BuzzMachineLoader/MachineInterface.h \
  src/lib/bml/BuzzMachineLoader/OscTable.h \
  src/lib/bml/BuzzMachineLoader/mdkimp.h \
  src/lib/bml/BuzzMachineLoader/debug.h

libbuzzmachineloader_la_CXXFLAGS = $(PTHREAD_CFLAGS) $(BML_CXXFLAGS) \
  -I$(top_srcdir)/src/lib/dllwrapper \
  -I$(top_srcdir)/src/lib/bml/BuzzMachineLoader
libbuzzmachineloader_la_LIBADD = $(LIBM) $(PTHREAD_LIBS) $(BML_LIBS) -lstdc++
libbuzzmachineloader_la_LDFLAGS = -module -avoid-version
libbuzzmachineloader_la_LIBTOOLFLAGS = --tag=disable-static

# buzzmachine loader (wrapped adapter)

if USE_DLLWRAPPER
dlldir = $(libdir)/win32
dll_DATA = src/lib/bml/BuzzMachineLoader.dll
endif

if BUILD_GST_CONTROL_BINDING_ABS
GST_COMPAT_C_FILES = src/lib/gst/gstdirectcontrolbinding.c
GST_COMPAT_H_FILES = src/lib/gst/gstdirectcontrolbinding.h
else
GST_COMPAT_C_FILES =
GST_COMPAT_H_FILES =
endif

libbuzztrax_gst_la_LIBADD =  \
  $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBM)
libbuzztrax_gst_la_LDFLAGS = \
  -export-symbols-regex \^[_]*\(gstbt_\|GstBt\|GSTBT_\|gst_\|Gst\|GST_\).* \
  -version-info @BT_VERSION_INFO@
libbuzztrax_gst_la_SOURCES = \
  src/lib/gst/audiosynth.c \
  src/lib/gst/childbin.c \
  src/lib/gst/combine.c \
  src/lib/gst/delay.c \
  src/lib/gst/envelope.c \
  src/lib/gst/envelope-adsr.c \
  src/lib/gst/envelope-ad.c \
  src/lib/gst/envelope-d.c \
  src/lib/gst/filter-svf.c \
  src/lib/gst/musicenums.c \
  src/lib/gst/osc-synth.c \
  src/lib/gst/osc-wave.c \
  src/lib/gst/toneconversion.c \
  src/lib/gst/propertymeta.c \
  src/lib/gst/tempo.c \
  $(GST_COMPAT_C_FILES)

libbuzztrax_gstincludedir = $(includedir)/libbuzztrax-gst
libbuzztrax_gstinclude_HEADERS = \
  src/lib/gst/audiosynth.h \
  src/lib/gst/childbin.h \
  src/lib/gst/combine.h \
  src/lib/gst/delay.h \
  src/lib/gst/envelope.h \
  src/lib/gst/envelope-adsr.h \
  src/lib/gst/envelope-ad.h \
  src/lib/gst/envelope-d.h \
  src/lib/gst/filter-svf.h \
  src/lib/gst/musicenums.h \
  src/lib/gst/osc-synth.h \
  src/lib/gst/osc-wave.h \
  src/lib/gst/toneconversion.h \
  src/lib/gst/propertymeta.h \
  src/lib/gst/tempo.h \
  $(GST_COMPAT_H_FILES)

presetdir = $(datadir)/gstreamer-$(GST_MAJORMINOR)/presets
preset_DATA = src/gst/audio/GstBtEBeats.prs src/gst/audio/GstBtSimSyn.prs

libbuzztrax_ic_la_LIBADD = \
  $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBM)
libbuzztrax_ic_la_LDFLAGS = \
  -export-symbols-regex ^_?\(btic_\|BtIc\|BTIC_\).* \
  -version-info @BT_VERSION_INFO@
libbuzztrax_ic_la_SOURCES = \
  src/lib/ic/ic.c \
  src/lib/ic/registry.c\
  $(ALSA_C_FILES) \
  $(GUDEV_C_FILES) \
  src/lib/ic/device.c \
  src/lib/ic/learn.c \
  $(LINUX_INPUT_C_FILES) \
  src/lib/ic/midi-device.c \
  src/lib/ic/control.c \
  src/lib/ic/abs-range-control.c \
  src/lib/ic/trigger-control.c

libbuzztrax_icdir = $(includedir)/libbuzztrax-ic
libbuzztrax_ic_HEADERS = \
  src/lib/ic/ic.h \
  src/lib/ic/version.h \
  src/lib/ic/registry.h \
  $(ALSA_H_FILES) \
  $(GUDEV_H_FILES) \
  src/lib/ic/device.h \
  src/lib/ic/learn.h \
  $(LINUX_INPUT_H_FILES) \
  src/lib/ic/midi-device.h \
  src/lib/ic/control.h \
  src/lib/ic/abs-range-control.h \
  src/lib/ic/trigger-control.h


src/lib/core/marshal.h: src/lib/core/marshal.list
	$(AM_V_at)$(MKDIR_P) src/lib/core
	$(AM_V_GEN) glib-genmarshal --header --prefix=bt_marshal $< >$@

src/lib/core/marshal.c: src/lib/core/marshal.list
	$(AM_V_at)$(MKDIR_P) src/lib/core
	$(AM_V_GEN) glib-genmarshal --body --prefix=bt_marshal $< >$@

BUILT_SOURCES += src/lib/core/marshal.c src/lib/core/marshal.h
CLEANFILES += src/lib/core/marshal.c src/lib/core/marshal.h

EXTRA_libbuzztrax_core_la_SOURCES = src/lib/core/marshal.list
nodist_libbuzztrax_core_la_SOURCES = src/lib/core/marshal.c src/lib/core/marshal.h
libbuzztrax_core_la_LIBADD = \
  libbuzztrax-ic.la \
  libbuzztrax-gst.la \
  $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBM) \
  -lgstaudio-@GST_MAJORMINOR@ -lgstpbutils-@GST_MAJORMINOR@
libbuzztrax_core_la_CFLAGS = -I$(top_builddir)/src/lib/core
libbuzztrax_core_la_LDFLAGS = \
  -export-symbols-regex ^_?\(bt_\|Bt\|BT_\).* \
  -version-info @BT_VERSION_INFO@
libbuzztrax_core_la_SOURCES = \
  src/lib/core/core.c \
  src/lib/core/tools.c \
  src/lib/core/buzzcallbacks.c \
  src/lib/core/application.c \
  src/lib/core/audio-session.c \
  src/lib/core/childproxy.c \
  src/lib/core/cmd-pattern.c \
  src/lib/core/machine.c \
  src/lib/core/parameter-group.c \
  src/lib/core/pattern.c \
  src/lib/core/pattern-control-source.c \
  src/lib/core/persistence.c \
  src/lib/core/processor-machine.c \
  src/lib/core/sequence.c \
  src/lib/core/settings.c \
  src/lib/core/setup.c \
  src/lib/core/sink-bin.c \
  src/lib/core/sink-machine.c \
  src/lib/core/song.c \
  src/lib/core/song-info.c \
  src/lib/core/song-io.c \
  src/lib/core/song-io-native.c \
  src/lib/core/song-io-native-bzt.c \
  src/lib/core/song-io-native-xml.c \
  src/lib/core/source-machine.c \
  src/lib/core/value-group.c \
  src/lib/core/wavetable.c \
  src/lib/core/wave.c \
  src/lib/core/wavelevel.c \
  src/lib/core/wire.c

libbuzztrax_coredir = $(includedir)/libbuzztrax-core
libbuzztrax_core_HEADERS = \
  src/lib/core/core.h \
  src/lib/core/tools.h \
  src/lib/core/version.h \
  src/lib/core/application.h \
  src/lib/core/audio-session.h \
  src/lib/core/childproxy.h \
  src/lib/core/cmd-pattern.h \
  src/lib/core/machine.h \
  src/lib/core/parameter-group.h \
  src/lib/core/pattern.h \
  src/lib/core/pattern-control-source.h \
  src/lib/core/persistence.h \
  src/lib/core/processor-machine.h \
  src/lib/core/sequence.h \
  src/lib/core/settings.h \
  src/lib/core/setup.h \
  src/lib/core/sink-bin.h \
  src/lib/core/sink-machine.h \
  src/lib/core/song.h \
  src/lib/core/song-info.h \
  src/lib/core/song-io.h \
  src/lib/core/song-io-native.h \
  src/lib/core/song-io-native-bzt.h \
  src/lib/core/song-io-native-xml.h \
  src/lib/core/source-machine.h \
  src/lib/core/value-group.h \
  src/lib/core/wavetable.h \
  src/lib/core/wave.h \
  src/lib/core/wavelevel.h \
  src/lib/core/wire.h

# -- songio plugins
songiodir = ${exec_prefix}/lib/buzztrax-songio
songio_LTLIBRARIES = libbtbsl.la
libbtbsl_la_LIBADD = \
  libbuzztrax-core.la \
  $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBINTL)
libbtbsl_la_LDFLAGS = \
  $(BT_LDFLAGS) \
  -export-symbols-regex ^_?\(bt_\|Bt\|BT_\).* \
  -module -avoid-version
libbtbsl_la_LIBTOOLFLAGS = --tag=disable-static
libbtbsl_la_SOURCES = \
  src/lib/core/songio/bsl/bsl.c \
  src/lib/core/songio/bsl/song-io-buzz.c \
  src/lib/core/songio/bsl/bsl.h \
  src/lib/core/songio/bsl/song-io-buzz.h \
  src/lib/core/songio/bsl/song-io-buzz-private.h

noinst_HEADERS += \
  src/lib/core/core_private.h \
  src/lib/ic/ic_private.h

# -- apps ----------------------------------------------------------------------

bin_PROGRAMS += buzztrax-cmd buzztrax-edit
noinst_LTLIBRARIES += libbtcmd.la libbtedit.la
plugin_LTLIBRARIES = \
  libbuzztraxaudio.la \
  libbuzztraxdec.la \
  libgstsidsyn.la

buzztrax_cmd_LDADD = \
  libbuzztrax-core.la \
  libbuzztrax-ic.la \
  libbtcmd.la \
  $(BASE_DEPS_LIBS) $(BT_LIBS)
buzztrax_cmd_SOURCES= \
  src/ui/cmd/bt-cmd.c src/ui/cmd/bt-cmd.h

libbtcmd_la_LIBDADD = \
  libbuzztrax-core.la \
  libbuzztrax-ic.la \
  $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBM)
libbtcmd_la_SOURCES =  \
  src/ui/cmd/cmd-application.c src/ui/cmd/cmd-application.h

buzztrax_edit_LDADD = \
  libbuzztrax-core.la \
  libbuzztrax-ic.la \
  libbtedit.la \
  $(BASE_DEPS_LIBS) $(GUI_DEPS_LIBS) $(BT_LIBS)
buzztrax_edit_CFLAGS = -I$(top_builddir)/src/ui/edit $(GUI_DEPS_CFLAGS)
buzztrax_edit_SOURCES= \
  src/ui/edit/bt-edit.c src/ui/edit/bt-edit.h

EXTRA_libbtedit_la_SOURCES = src/ui/edit/marshal.list
nodist_libbtedit_la_SOURCES = src/ui/edit/marshal.c src/ui/edit/marshal.h \
  src/ui/edit/authors.h
libbtedit_la_LIBADD = \
  libbuzztrax-core.la \
  libbuzztrax-ic.la \
  $(BASE_DEPS_LIBS) $(GUI_DEPS_LIBS) $(BT_LIBS) $(LIBM)
libbtedit_la_CFLAGS = -I$(top_builddir)/src/ui/edit $(GUI_DEPS_CFLAGS)
libbtedit_la_SOURCES = \
  src/ui/edit/about-dialog.c src/ui/edit/about-dialog.h \
  src/ui/edit/change-log.c src/ui/edit/change-log.h \
  src/ui/edit/change-logger.c src/ui/edit/change-logger.h \
  src/ui/edit/crash-recover-dialog.c src/ui/edit/crash-recover-dialog.h \
  src/ui/edit/edit-application.c src/ui/edit/edit-application.h \
  src/ui/edit/interaction-controller-menu.c src/ui/edit/interaction-controller-menu.h \
  src/ui/edit/machine-canvas-item.c src/ui/edit/machine-canvas-item.h \
  src/ui/edit/machine-menu.c src/ui/edit/machine-menu.h \
  src/ui/edit/machine-actions.c src/ui/edit/machine-actions.h \
  src/ui/edit/machine-list-model.c src/ui/edit/machine-list-model.h \
  src/ui/edit/machine-preset-properties-dialog.c src/ui/edit/machine-preset-properties-dialog.h \
  src/ui/edit/machine-properties-dialog.c src/ui/edit/machine-properties-dialog.h \
  src/ui/edit/machine-preferences-dialog.c src/ui/edit/machine-preferences-dialog.h \
  src/ui/edit/machine-rename-dialog.c src/ui/edit/machine-rename-dialog.h \
  src/ui/edit/main-window.c src/ui/edit/main-window.h \
  src/ui/edit/main-menu.c src/ui/edit/main-menu.h \
  src/ui/edit/main-toolbar.c src/ui/edit/main-toolbar.h \
  src/ui/edit/main-pages.c src/ui/edit/main-pages.h \
  src/ui/edit/main-page-machines.c src/ui/edit/main-page-machines.h \
  src/ui/edit/main-page-patterns.c src/ui/edit/main-page-patterns.h \
  src/ui/edit/main-page-sequence.c src/ui/edit/main-page-sequence.h \
  src/ui/edit/main-page-waves.c src/ui/edit/main-page-waves.h \
  src/ui/edit/main-page-info.c src/ui/edit/main-page-info.h \
  src/ui/edit/main-statusbar.c src/ui/edit/main-statusbar.h \
  src/ui/edit/missing-framework-elements-dialog.c src/ui/edit/missing-framework-elements-dialog.h \
  src/ui/edit/missing-song-elements-dialog.c src/ui/edit/missing-song-elements-dialog.h \
  src/ui/edit/object-list-model.c src/ui/edit/object-list-model.h \
  src/ui/edit/panorama-popup.c src/ui/edit/panorama-popup.h \
  src/ui/edit/pattern-list-model.c src/ui/edit/pattern-list-model.h \
  src/ui/edit/pattern-properties-dialog.c src/ui/edit/pattern-properties-dialog.h \
  src/ui/edit/playback-controller-ic.c src/ui/edit/playback-controller-ic.h \
  src/ui/edit/playback-controller-socket.c src/ui/edit/playback-controller-socket.h \
  src/ui/edit/preset-list-model.c src/ui/edit/preset-list-model.h \
  src/ui/edit/render-dialog.c src/ui/edit/render-dialog.h \
  src/ui/edit/sequence-grid-model.c src/ui/edit/sequence-grid-model.h \
  src/ui/edit/sequence-view.c src/ui/edit/sequence-view.h \
  src/ui/edit/settings-dialog.c src/ui/edit/settings-dialog.h \
  src/ui/edit/settings-page-audiodevices.c src/ui/edit/settings-page-audiodevices.h \
  src/ui/edit/settings-page-directories.c src/ui/edit/settings-page-directories.h \
  src/ui/edit/settings-page-interaction-controller.c src/ui/edit/settings-page-interaction-controller.h \
  src/ui/edit/settings-page-playback-controller.c src/ui/edit/settings-page-playback-controller.h \
  src/ui/edit/settings-page-shortcuts.c src/ui/edit/settings-page-shortcuts.h \
  src/ui/edit/settings-page-ui.c src/ui/edit/settings-page-ui.h \
  src/ui/edit/signal-analysis-dialog.c src/ui/edit/signal-analysis-dialog.h \
  src/ui/edit/tip-dialog.c src/ui/edit/tip-dialog.h \
  src/ui/edit/tools.c src/ui/edit/tools.h \
  src/ui/edit/ui-resources.c src/ui/edit/ui-resources.h \
  src/ui/edit/volume-popup.c src/ui/edit/volume-popup.h \
  src/ui/edit/wave-list-model.c src/ui/edit/wave-list-model.h \
  src/ui/edit/waveform-viewer.c src/ui/edit/waveform-viewer.h \
  src/ui/edit/wavelevel-list-model.c src/ui/edit/wavelevel-list-model.h \
  src/ui/edit/wire-canvas-item.c src/ui/edit/wire-canvas-item.h \
  \
  src/ui/edit/pattern-editor.c src/ui/edit/pattern-editor.h \
  src/ui/edit/gtkscrolledsyncwindow.c src/ui/edit/gtkscrolledsyncwindow.h \
  src/ui/edit/gtkvumeter.c src/ui/edit/gtkvumeter.h \
  \
  src/ui/edit/btmemoryaudiosrc.c src/ui/edit/btmemoryaudiosrc.h

src/ui/edit/marshal.h: src/ui/edit/marshal.list
	$(AM_V_at)$(MKDIR_P) src/ui/edit
	$(AM_V_GEN) glib-genmarshal --header --prefix=bt_marshal $< >$@

src/ui/edit/marshal.c: src/ui/edit/marshal.list
	$(AM_V_at)$(MKDIR_P) src/ui/edit
	$(AM_V_GEN) glib-genmarshal --body --prefix=bt_marshal $< >$@

src/ui/edit/authors.h: $(top_srcdir)/AUTHORS
	$(AM_V_GEN)sed -e 's/^/"/' -e 's/$$/",/' $(top_srcdir)/AUTHORS >$@

BUILT_SOURCES += $(nodist_libbtedit_la_SOURCES)
CLEANFILES += $(nodist_libbtedit_la_SOURCES)

cssdir = $(datadir)/$(PACKAGE)
css_DATA = src/ui/edit/bt-edit.css \
  src/ui/edit/bt-edit.compact.css \
  src/ui/edit/bt-edit.normal.css \
  src/ui/edit/bt-edit.dark.css \
  src/ui/edit/bt-edit.light.css \
  src/ui/edit/bt-edit.dark.compact.css \
  src/ui/edit/bt-edit.light.compact.css \
  src/ui/edit/bt-edit.dark.normal.css \
  src/ui/edit/bt-edit.light.normal.css

# -- plugins -------------------------------------------------------------------

ORC_SOURCE = src/gst/bml/gstbmlorc
include $(top_srcdir)/orc.mak

noinst_HEADERS += \
  src/gst/audio/plugin.h \
  src/gst/audio/audiodelay.h \
  src/gst/audio/ebeats.h \
  src/gst/audio/simsyn.h \
  src/gst/audio/wavereplay.h \
  src/gst/audio/wavetabsyn.h \
  src/gst/dec/bt-dec.h \
  src/gst/sidsyn/sidsyn.h \
  src/gst/sidsyn/sidsynv.h \
  src/gst/sidsyn/envelope.h \
  src/gst/sidsyn/extfilt.h \
  src/gst/sidsyn/filter.h \
  src/gst/sidsyn/pot.h \
  src/gst/sidsyn/siddefs.h \
  src/gst/sidsyn/sidemu.h \
  src/gst/sidsyn/spline.h \
  src/gst/sidsyn/voice.h \
  src/gst/sidsyn/wave.h

plugin_LTLIBRARIES += libgstbml.la
noinst_HEADERS += \
  src/gst/bml/gstbmlsrc.h src/gst/bml/gstbmltransform.h \
  src/gst/bml/gstbml.h src/gst/bml/gstbmlv.h \
  src/gst/bml/plugin.h src/gst/bml/common.h

# native
libgstbmln_la_SOURCES = \
  src/gst/bml/gstbml.c src/gst/bml/gstbmlsrc.c src/gst/bml/gstbmltransform.c \
  src/gst/bml/gstbmlv.c
libgstbmln_la_CFLAGS = -DBML_NATIVE \
  -I$(srcdir) -I$(builddir) -I$(builddir)/src/gst/bml \
  $(GST_PLUGIN_CFLAGS) \
  $(BASE_DEPS_CFLAGS) \
  $(ORC_CFLAGS)

# wrapped
libgstbmlw_la_SOURCES = \
  src/gst/bml/gstbml.c src/gst/bml/gstbmlsrc.c src/gst/bml/gstbmltransform.c \
  src/gst/bml/gstbmlv.c
libgstbmlw_la_CFLAGS = -DBML_WRAPPED \
  -I$(srcdir) -I$(builddir) \
  -I$(builddir)/src/gst/bml -I$(top_srcdir)/src/lib/dllwrapper \
  $(GST_PLUGIN_CFLAGS) \
  $(BASE_DEPS_CFLAGS) \
  $(ORC_CFLAGS)

if USE_DLLWRAPPER
BMLW_LA = libgstbmlw.la
else
BMLW_LA =
endif

noinst_LTLIBRARIES += libgstbmln.la $(BMLW_LA)

libgstbml_la_SOURCES = src/gst/bml/plugin.c src/gst/bml/common.c
nodist_libgstbml_la_SOURCES = $(ORC_NODIST_SOURCES)
libgstbml_la_CFLAGS = \
  -I$(srcdir) -I$(builddir) -I$(builddir)/src/gst/bml \
  -DLIBDIR=\"\${libdir}\" \
  $(GST_PLUGIN_CFLAGS) \
  $(BASE_DEPS_CFLAGS) \
  $(ORC_CFLAGS)
libgstbml_la_LIBADD = \
  libbuzztrax-gst.la \
  libgstbmln.la $(BMLW_LA) libbml.la \
  $(BASE_DEPS_LIBS) $(ORC_LIBS) $(BML_LIBS) \
  $(GST_PLUGIN_LIBS) -lgstaudio-1.0 $(LIBM)
libgstbml_la_LDFLAGS =  $(GST_PLUGIN_LDFLAGS)
libgstbml_la_LIBTOOLFLAGS = --tag=disable-static


libbuzztraxdec_la_CFLAGS = $(GST_PLUGIN_CFLAGS)
libbuzztraxdec_la_LIBADD = \
  libbuzztrax-core.la \
  libbuzztrax-ic.la \
  $(BASE_DEPS_LIBS) $(LIBM)
libbuzztraxdec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libbuzztraxdec_la_SOURCES = src/gst/dec/bt-dec.c
libbuzztraxdec_la_LIBTOOLFLAGS = --tag=disable-static


if FLUIDSYNTH_SUPPORT
plugin_LTLIBRARIES += libgstfluidsynth.la
noinst_HEADERS += src/gst/fluidsynth/fluidsynth.h

libgstfluidsynth_la_SOURCES = src/gst/fluidsynth/fluidsynth.c
libgstfluidsynth_la_CFLAGS = \
  -I$(srcdir) -I$(top_srcdir) \
  -DDATADIR=\"$(datadir)\" \
  $(GST_PLUGIN_CFLAGS) \
  $(BASE_DEPS_CFLAGS) \
  $(FLUIDSYNTH_CFLAGS)
libgstfluidsynth_la_LIBADD = \
  libbuzztrax-gst.la  \
  $(BASE_DEPS_LIBS) $(FLUIDSYNTH_LIBS) $(GST_PLUGIN_LIBS)
libgstfluidsynth_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstfluidsynth_la_LIBTOOLFLAGS = --tag=disable-static
endif


libgstsidsyn_la_SOURCES = \
  src/gst/sidsyn/sidsyn.cc \
  src/gst/sidsyn/sidsynv.cc \
  src/gst/sidsyn/envelope.cc \
  src/gst/sidsyn/extfilt.cc \
  src/gst/sidsyn/filter.cc \
  src/gst/sidsyn/pot.cc \
  src/gst/sidsyn/sidemu.cc \
  src/gst/sidsyn/voice.cc \
  src/gst/sidsyn/wave.cc \
  src/gst/sidsyn/wave6581_PST.cc \
  src/gst/sidsyn/wave6581_PS_.cc \
  src/gst/sidsyn/wave6581_P_T.cc \
  src/gst/sidsyn/wave6581__ST.cc \
  src/gst/sidsyn/wave8580_PST.cc \
  src/gst/sidsyn/wave8580_PS_.cc \
  src/gst/sidsyn/wave8580_P_T.cc \
  src/gst/sidsyn/wave8580__ST.cc
libgstsidsyn_la_CXXFLAGS = \
  -I$(srcdir) -I$(top_srcdir) \
  -DDATADIR=\"$(datadir)\" \
  $(GST_PLUGIN_CFLAGS) \
  $(BASE_DEPS_CFLAGS)
libgstsidsyn_la_LIBADD = \
  libbuzztrax-gst.la \
  $(BASE_DEPS_LIBS) $(GST_PLUGIN_LIBS)
libgstsidsyn_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstsidsyn_la_LIBTOOLFLAGS = --tag=disable-static


libbuzztraxaudio_la_SOURCES = \
  src/gst/audio/plugin.c \
  src/gst/audio/audiodelay.c \
  src/gst/audio/ebeats.c \
  src/gst/audio/simsyn.c \
  src/gst/audio/wavereplay.c \
  src/gst/audio/wavetabsyn.c
libbuzztraxaudio_la_CFLAGS = \
  -I$(srcdir) -I$(top_srcdir) \
  -DDATADIR=\"$(datadir)\" \
  $(GST_PLUGIN_CFLAGS) \
  $(BASE_DEPS_CFLAGS)
libbuzztraxaudio_la_LIBADD = \
  libbuzztrax-gst.la \
  $(BASE_DEPS_LIBS) $(GST_PLUGIN_LIBS)
libbuzztraxaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libbuzztraxaudio_la_LIBTOOLFLAGS = --tag=disable-static


# -- common --------------------------------------------------------------------

desktopdir = ${with_desktop_dir}/applications
desktop_in_files = \
  src/lib/core/songio/bsl/buzztrax-songio-buzz.desktop.in \
  src/ui/edit/buzztrax-edit.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@

# install .xml mime info file
sharedmimedir = $(datadir)/mime
sharedmimepackagedir = $(sharedmimedir)/packages
sharedmimepackage_in_files = \
  src/lib/buzztrax.xml.in \
  src/lib/core/songio/bsl/buzztrax-songio-buzz.xml.in
sharedmimepackage_DATA = $(sharedmimepackage_in_files:.xml.in=.xml)
@INTLTOOL_XML_RULE@

# update desktop/mime database
update-desktop-db:
if WITH_UPDATE_DESKTOP
	@-if test -z "$(DESTDIR)"; then \
	  echo "Updating Desktop database."; \
	  test -z "$(UPDATE_DESKTOP_DATABASE)" || $(UPDATE_DESKTOP_DATABASE) "$(DESTDIR)$(desktopdir)"; \
	else \
	  echo "*** Desktop database not updated.  After (un)install, run this:"; \
	  echo "***   $(UPDATE_DESKTOP_DATABASE) "$(DESTDIR)$(desktopdir)";"; \
	fi
endif
update-mime-db:
if WITH_UPDATE_MIME
	@-if test -z "$(DESTDIR)"; then \
	  echo "Updating MIME database."; \
	  test -z "$(UPDATE_MIME_DATABASE)" || $(UPDATE_MIME_DATABASE) "$(DESTDIR)$(sharedmimedir)"; \
	else \
	  echo "*** MIME database not updated.  After (un)install, run this:"; \
	  echo "***   $(UPDATE_MIME_DATABASE) "$(DESTDIR)$(sharedmimedir)";"; \
	fi
endif

if USE_GIR
libbtcore_gir_sources=$(patsubst %,$(srcdir)/%, $(libbuzztrax_core_la_SOURCES))
libbtcore_gir_headers=$(patsubst %,$(srcdir)/%, $(libbuzztrax_core_HEADERS))

BuzztraxCore-@BT_MAJORMINOR@.gir: $(G_IR_SCANNER) libbuzztrax-core.la BuzztraxIc-@BT_MAJORMINOR@.gir
	-$(AM_V_GEN)PKG_CONFIG_PATH="$(PKG_CONFIG_PATH):$(top_srcdir)/src/lib/ic/" $(G_IR_SCANNER) -v \
	   --namespace=BuzztraxCore \
	   --nsversion @BT_MAJORMINOR@ \
	   --warn-all \
	   -I$(builddir) \
	   -I$(srcdir) \
	   -I$(top_srcdir)/src/lib/ \
	   --add-include-path=$(top_srcdir)/src/lib/ic/ \
	   --identifier-prefix=Bt \
	   --symbol-prefix=bt \
	   --c-include='src/lib/core/core.h' \
	   --include=GLib-2.0 \
	   --include=GObject-2.0 \
	   --include=Gst-@GST_MAJORMINOR@ \
	   --include=libxml2-2.0 \
	   --include-uninstalled=$(top_builddir)/BuzztraxIc-$(BT_MAJORMINOR).gir \
	   --library=libbuzztrax-core.la \
	   --library=libbuzztrax-gst.la \
	   --libtool="$(top_builddir)/libtool" \
	   --pkg glib-2.0 \
	   --pkg gobject-2.0 \
	   --pkg libxml-2.0 \
	   --pkg gstreamer-@GST_MAJORMINOR@ \
	   --pkg-export libbuzztrax-core \
	   --add-init-section="bt_init(NULL,NULL);" \
	   --output $@ \
	   $(libbtcore_gir_sources) $(libbtcore_gir_headers) || touch $@

libbtic_gir_sources=$(patsubst %,$(srcdir)/%, $(libbuzztrax_ic_la_SOURCES))
libbtic_gir_headers=$(patsubst %,$(srcdir)/%, $(libbuzztrax_ic_HEADERS))

BuzztraxIc-@BT_MAJORMINOR@.gir: $(G_IR_SCANNER) libbuzztrax-ic.la
	-$(AM_V_GEN)$(G_IR_SCANNER) -v \
	   --namespace=BuzztraxIc \
	   --nsversion @BT_MAJORMINOR@ \
	   --warn-all \
	   -I$(builddir) \
	   -I$(srcdir) \
	   -I$(top_srcdir)/src/lib/ \
	   --identifier-prefix=BtIc \
	   --symbol-prefix=btic \
	   --c-include='src/lib/ic/ic.h' \
	   --include=GLib-2.0 \
	   --include=GObject-2.0 \
	   --include=Gst-@GST_MAJORMINOR@ \
	   --library=libbuzztrax-ic.la \
	   --libtool="$(top_builddir)/libtool" \
	   --pkg glib-2.0 \
	   --pkg gobject-2.0 \
	   --pkg gstreamer-@GST_MAJORMINOR@ \
	   --pkg-export libbuzztrax-ic \
	   --add-init-section="btic_init(NULL,NULL);" \
	   --output $@ \
	   $(libbtic_gir_sources) $(libbtic_gir_headers) || touch $@

BUILT_GIRSOURCES = BuzztraxCore-@BT_MAJORMINOR@.gir BuzztraxIc-@BT_MAJORMINOR@.gir

girdir = $(datadir)/gir
gir_DATA = $(BUILT_GIRSOURCES)

typelibsdir = $(libdir)/girepository-1.0
typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)

TXML = $(dist_gir_DATA:.gir=.gir.txml)

.gir.typelib:
	-$(AM_V_GEN)$(G_IR_COMPILER) --includedir=. $(G_IR_COMPILER_OPTS) $< -o $@  || touch $@
else
BUILT_GIRSOURCES=
endif

BUILT_SOURCES += $(BUILT_GIRSOURCES)

EXTRA_DIST += \
  $(desktop_in_files) $(sharedmimepackage_in_files) \
  $(css_DATA) \
  $(preset_DATA) \
  src/lib/bml/libbml.pc.in \
  src/lib/bml/BuzzMachineLoader.dll \
  src/lib/bml/BuzzMachineLoader/README \
  src/lib/core/libbuzztrax-core.pc.in \
  src/lib/core/marshal.list \
  src/lib/core/version.h.in \
  src/lib/dllwrapper/README \
  src/lib/gst/libbuzztrax-gst.pc.in \
  src/lib/ic/libbuzztrax-ic.pc.in \
  src/lib/ic/version.h.in \
  src/ui/edit/marshal.list

# CLEANFILES is for files generated by make
CLEANFILES += \
  $(desktop_DATA) $(sharedmimepackage_DATA) \
  $(typelibs_DATA) $(TXML) \
  $(BUILT_GIRSOURCES)

# DISTCLEANFILES is for files generated by configure
DISTCLEANFILES += \
  $(pkgconfig_DATA) \
  src/lib/core/version.h \
  src/lib/ic/version.h

