SUBDIRS = parser musicbrainz audio

libexec_PROGRAMS = bmp2-bin
transform = s/bmp2-bin/beep-media-player-2-bin/

bmp2_bin_LDFLAGS = -Wl,--export-dynamic 

bmp2_bin_LDADD =					\
		$(ALSA_LIBS)				\
		$(BOOST_LDFLAGS)			\
		$(CDIO_LIBS)				\
		$(CDPARANOIA_LIBS)			\
		$(DBUS_LIBS)				\
		$(GLIBMM_LIBS)				\
		$(GST_LIBS)					\
		$(NM_LIBS)					\
		$(TAGLIB_LIBS)				\
		$(RSVG_LIBS)				\
		$(SEXYMM_LIBS)				\
		$(SOUP_LIBS)				\
		$(SQLITE_LIBS)				\
		$(XML_LIBS)					

bmp2_bin_LDADD += -lgstinterfaces-0.10 -lgstvideo-0.10

bmp2_bin_LDADD +=                                               \
		$(top_builddir)/mcs/libmconfig.la                       \
		$(top_builddir)/jnetlib/libjnetlib.la					\
		$(top_builddir)/json/libjsoncpp.la                      \
		$(top_builddir)/src/parser/libbmpparser.la				\
		$(top_builddir)/src/musicbrainz/libbmpmusicbrainz.la	\
		$(top_builddir)/src/audio/libbmpaudio.la				\
		$(top_builddir)/widgets/libbmpwidgets.la

if HAVE_HAL
bmp2_bin_LDADD += $(top_builddir)/libhal++/libhalcc.la
endif # HAVE_HAL

bmp2_bin_CFLAGS =			\
    $(GLIB_CFLAGS) $(GST_CFLAGS)

bmp2_bin_CXXFLAGS = 		\
    $(ALSA_CFLAGS)			\
    $(BOOST_CPPFLAGS)		\
    $(CDIO_CFLAGS)			\
    $(CDPARANOIA_INCLUDES) 	\
	$(DBUS_CFLAGS)			\
	$(GLIBMM_CFLAGS)		\
	$(GST_CFLAGS)			\
	$(XPROTO_CFLAGS)		\
	$(NM_CFLAGS)			\
	$(RSVG_CFLAGS)			\
	$(SEXYMM_CFLAGS)		\
	$(SOUP_CFLAGS)			\
	$(SQLITE_CFLAGS)		\
	$(TAGLIB_CFLAGS)		\
	$(XML_CFLAGS)          

bmp2_bin_CXXFLAGS +=		\
  -I$(top_srcdir)			\
  -I$(top_srcdir)/libhal++	\
  -I$(top_srcdir)/include	\
  -I$(top_builddir)/include

bmp2_bin_CXXFLAGS += -D__USE_POSIX199309
bmp2_bin_CFLAGS += -D__USE_POSIX199309

if HAVE_LINUX 
bmp2_bin_CXXFLAGS += -D_XOPEN_SOURCE=600
bmp2_bin_CFLAGS += -D_XOPEN_SOURCE=600
endif
  
bmp2_bin_headers =		\
						\
	x_library.hh		\
	x_vfs.hh			\
	x_mcsbind.hh		\
						\
	main.hh				\
	core.hh				\
	debug.hh			\
	logger.hh			\
	sanity.h			\
	signals.hh			\
	base64.h			\
	md5.h				\
	sha1.h				\
	amazon.hh			\
	database.hh			\
	library.hh			\
	lyrics-v2.hh		\
	minisoup.hh			\
	network.hh			\
	uri.hh				\
	util.hh				\
	util-file.hh		\
	util-string.hh		\
	vfs.hh				\
	xml.hh				\
	ld.hh				\
	linkage.hh			\
	paths.hh			\
	widgetloader.h			\
	xts.hh


bmp2_bin_sources =		\
						\
	main.cc				\
	core.cc				\
	debug.cc			\
	logger.cc			\
	sanity.cc			\
	signals.cc			\
	base64.c			\
	md5.c				\
	sha1.c				\
	amazon.cc			\
	database.cc			\
	library.cc			\
	lyrics-v2.cc		\
	minisoup.cc			\
	network.cc			\
	uri.cc				\
	util.cc				\
	util-file.cc		\
	vfs.cc				\
	xml.cc

bmp2_bin_CXXFLAGS +=            \
	$(X_CFLAGS)					\
	$(STARTUP_NOTIFY_CFLAGS)	\
	$(GTKMM_CFLAGS)				\
	$(GLADEMM_CFLAGS)			\
	$(CAIROMM_CFLAGS)   

bmp2_bin_LDADD +=				\
	$(STARTUP_NOTIFY_LIBS)		\
	$(XLIB_LIBS) $(SM_LIBS)		\
	$(GTKMM_LIBS)				\
	$(GLADEMM_LIBS)				\
	$(CAIROMM_LIBS)				\
	$(BOOST_REGEX_LIB)			\
	$(BOOST_FILESYSTEM_LIB)		\
	$(BOOST_IOSTREAMS_LIB)			

bmp2_bin_headers +=            		\
									\
	preferences.hh					\
	shell.hh						\
	splash-screen.hh				\
									\
	exception.hh					\
	database-exception.hh			\
	sm.hh							\
	stock.hh						\
	ui-tools.hh						\
	xds.hh							\
									\
	jamendo-types.hh				\
	podcast-v2-types.hh				\
	radio-directory-types.hh		\
									\
	dialog-about.hh					\
	dialog-add-podcast.hh			\
	dialog-equalizer.hh				\
	dialog-export.hh				\
	dialog-filebrowser.hh			\
	dialog-gsterror.hh				\
	dialog-play-uri.hh				\
	dialog-progress.hh				\
	dialog-remove-update-podcast.hh	\
	dialog-simple-progress.hh		\
	dialog-simple-entry.hh			\
	dialog-track-details.hh			\
									\
	bookmarks-libxml2-sax.hh		\
	jamendodata-libxml2-sax.hh		\
	lastfm-tags-libxml2-sax.hh		\
	podcast-libxml2-sax.hh			\
	podcast-cache-libxml2-sax.hh	\
	xspf-libxml2-sax.hh				\
	lastfm-parsers.hh				\
									\
	bookmarkhandler.hh				\
	urihandler.hh					\
	playbacksource.hh				\
	ui-part-base.hh					\
									\
	jamendo.hh						\
	lastfm.hh						\
	podcast.hh						\
	bookmark-manager.hh				\
	podcast-utils.hh				\
									\
	ui-part-cdda.hh					\
	ui-part-jamendo.hh				\
	ui-part-lastfm.hh				\
	ui-part-library.hh				\
	ui-part-playlist.hh				\
	ui-part-podcasts.hh				\
	ui-part-radio.hh				\
									\
	lastfm-recommend-dialog.hh		\
	lastfm-tag-dialog.hh			\
									\
	lastfm-extra-widgets.hh			\
	radio-directory-view-base.hh	\
									\
	streams-shoutcast.hh			\
	streams-icecast.hh				\
									\
	mb-tagger.hh					\
	video-widget.hh

bmp2_bin_sources +=					\
                                    \
	preferences.cc					\
	shell.cc						\
	splash-screen.cc				\
									\
	sm.cc							\
	stock.cc						\
	ui-tools.cc						\
	xds.cc							\
                                    \
	podcast-v2-types.cc				\
                                    \
    dialog-about.cc					\
	dialog-add-podcast.cc			\
	dialog-equalizer.cc				\
	dialog-export.cc				\
	dialog-filebrowser.cc			\
	dialog-gsterror.cc				\
	dialog-play-uri.cc				\
	dialog-progress.cc				\
	dialog-remove-update-podcast.cc	\
	dialog-simple-progress.cc		\
	dialog-simple-entry.cc			\
	dialog-track-details.cc			\
                                    \
    bookmarks-libxml2-sax.cc        \
	jamendodata-libxml2-sax.cc		\
	lastfm-tags-libxml2-sax.cc		\
	podcast-libxml2-sax.cc			\
	podcast-cache-libxml2-sax.cc	\
	xspf-libxml2-sax.cc				\
									\
	playbacksource.cc				\
									\
	jamendo.cc						\
	lastfm.cc						\
	podcast.cc						\
	bookmark-manager.cc				\
	podcast-utils.cc				\
									\
	ui-part-cdda.cc					\
	ui-part-jamendo.cc				\
	ui-part-lastfm.cc				\
	ui-part-library.cc				\
	ui-part-playlist.cc				\
	ui-part-podcasts.cc				\
	ui-part-radio.cc				\
									\
	lastfm-recommend-dialog.cc		\
	lastfm-tag-dialog.cc			\
	lastfm-parsers.cc               \
	radio-directory-view-base.cc	\
									\
	streams-shoutcast.cc			\
	streams-icecast.cc				\
									\
	mb-tagger.cc					\
	video-widget.cc

if HAVE_LINUX
bmp2_bin_headers += glib-inotify.hh
bmp2_bin_sources += glib-inotify.cc 
endif

#
# GST Elements
#

bmp2_bin_headers += bmpjnethttpsrc.h 
bmp2_bin_sources += bmpjnethttpsrc.cc 
bmp2_bin_headers += gstspectrum.h 
bmp2_bin_sources += gstspectrum.cc fix_fft.cc

bmp2_bin_LDADD += $(LIBOFA_LIBS)
bmp2_bin_CXXFLAGS += $(LIBOFA_CFLAGS)
bmp2_bin_CFLAGS += $(LIBOFA_CFLAGS)
bmp2_bin_sources += gstpuid.h gstpuid.cc 

if HAVE_HAL
bmp2_bin_CXXFLAGS += $(HAL_CFLAGS)
bmp2_bin_LDADD += $(HAL_LIBS)
bmp2_bin_headers += x_hal.hh hal.hh dialog-manage-volume.hh 
bmp2_bin_sources += hal.cc dialog-manage-volume.cc
endif

built_header_make =				\
	dbus-obj-BMP-glue.h			\
	dbus-obj-player-glue.h		\
	dbus-obj-root-glue.h			
#	dbus-obj-tracklist-glue.h	


nodist_bmp2_bin_SOURCES = $(built_header_make) $(built_source_make) 

bmp2_bin_SOURCES = $(bmp2_bin_headers) $(bmp2_bin_sources)

EXTRA_DIST =					\
	dbus-obj-BMP.xml.in			\
	dbus-obj-player.xml.in		\
	dbus-obj-root.xml.in		\
	dbus-obj-tracklist.xml.in

BUILT_SOURCES = $(built_header_make) $(built_source_make)

dbus-obj-root-glue.h: dbus-obj-root.xml
	@echo "* Generating '/' DBus glue"
	@dbus-binding-tool --mode=glib-server --prefix=Core::MprisRoot::mpris_root \
	$(abs_top_builddir)/src/dbus-obj-root.xml > \
	dbus-obj-root-glue.h.temp
	@cat dbus-obj-root-glue.h.temp   | sed s:G_BEGIN_DECLS:: | sed s:G_END_DECLS:: > \
	dbus-obj-root-glue.h.temp.1
	@cat dbus-obj-root-glue.h.temp.1 | sed s/dbus_glib_Core\:\:MprisRoot\:\:mpris_root/dbus_glib_mpris_root/g > \
	dbus-obj-root-glue.h.temp.2
	@cat dbus-obj-root-glue.h.temp.2 | sed s/dbus_glib_marshal_Core\:\:MprisRoot\:\:mpris_root/dbus_glib_marshal_mpris_root/g > \
	dbus-obj-root-glue.h
	@rm -f dbus-obj-root-glue.h.temp
	@rm -f dbus-obj-root-glue.h.temp.1
	@rm -f dbus-obj-root-glue.h.temp.2

dbus-obj-BMP-glue.h: dbus-obj-BMP.xml
	@echo "* Generating '/BMP' DBus glue"
	@dbus-binding-tool --mode=glib-server --prefix=Core::BMP::bmp \
	$(abs_top_builddir)/src/dbus-obj-BMP.xml > \
	dbus-obj-BMP-glue.h.temp
	@cat dbus-obj-BMP-glue.h.temp   | sed s:G_BEGIN_DECLS:: | sed s:G_END_DECLS:: > \
	dbus-obj-BMP-glue.h.temp.1
	@cat dbus-obj-BMP-glue.h.temp.1 | sed s/dbus_glib_Core\:\:BMP\:\:bmp/dbus_glib_bmp/g > \
	dbus-obj-BMP-glue.h.temp.2
	@cat dbus-obj-BMP-glue.h.temp.2 | sed s/dbus_glib_marshal_Core\:\:BMP\:\:bmp/dbus_glib_marshal_bmp/g > \
	dbus-obj-BMP-glue.h
	@rm -f dbus-obj-BMP-glue.h.temp
	@rm -f dbus-obj-BMP-glue.h.temp.1
	@rm -f dbus-obj-BMP-glue.h.temp.2

dbus-obj-player-glue.h: dbus-obj-player.xml
	@echo "* Generating '/Player' DBus glue"
	@dbus-binding-tool --mode=glib-server --prefix=PlayerShell::Player::player \
	$(abs_top_builddir)/src/dbus-obj-player.xml > \
	dbus-obj-player-glue.h.temp
	@cat dbus-obj-player-glue.h.temp   | sed s:G_BEGIN_DECLS:: | sed s:G_END_DECLS:: > \
	dbus-obj-player-glue.h.temp.1
	@cat dbus-obj-player-glue.h.temp.1 | sed s/dbus_glib_PlayerShell\:\:Player\:\:player/dbus_glib_player/g > \
	dbus-obj-player-glue.h.temp.2
	@cat dbus-obj-player-glue.h.temp.2 | sed s/dbus_glib_marshal_PlayerShell\:\:Player\:\:player/dbus_glib_marshal_player/g > \
	dbus-obj-player-glue.h
	@rm -f dbus-obj-player-glue.h.temp
	@rm -f dbus-obj-player-glue.h.temp.1
	@rm -f dbus-obj-player-glue.h.temp.2

CLEANFILES = $(built_header_make) $(built_source_make) 

dbus-marshalers.c: dbus-marshalers.list 
	@echo "* Generating dbus-marshalers.c"
	@glib-genmarshal --prefix=bmp_dbus_marshal --body   $(srcdir)/dbus-marshalers.list > dbus-marshalers.c

dbus-marshalers.h: dbus-marshalers.list
	@echo "* Generating dbus-marshalers.h"
	@glib-genmarshal --prefix=bmp_dbus_marshal --header $(srcdir)/dbus-marshalers.list > dbus-marshalers.h


EXTRA_DIST += dbus-marshalers.list

BUILT_SOURCES += dbus-marshalers.c dbus-marshalers.h

bmp2_bin_sources += dbus-marshalers.c

CLEANFILES += $(BUILT_SOURCES)
DISTCLEANFILES = $(CLEANFILES)

install-exec-hook:
	(cd $(DESTDIR)$(bindir) && \
	rm -f bmp2$(EXEEXT); \
       $(LN_S) beep-media-player-2$(EXEEXT) bmp2$(EXEEXT); \
    )

