#
# src/Makefile.am for qalculate
#

AM_CPPFLAGS = \
	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
	-DPACKAGE_DOC_DIR=\""$(docdir)"\" \
	@GTK_CFLAGS@ \
	@GLIB_CFLAGS@ \
	@WEBKITGTK_CFLAGS@ \
	@GIOUNIX_CFLAGS@ \
	@QALCULATE_CFLAGS@

if PLATFORM_MACOS
AM_CPPFLAGS += $(GTK_MAC_CFLAGS)
endif

if ENABLE_SEARCH_PROVIDER
searchproviderdir=@libexecdir@
searchprovider_PROGRAMS = qalculate-search-provider
endif
bin_PROGRAMS = @QALCULATE_GTK@
EXTRA_PROGRAMS = qalculate-gtk

if PLATFORM_WIN32
qalculate_gtk_LDFLAGS = -mwindows
endif

ui.c : $(top_srcdir)/data/ui.gresource.xml $(top_srcdir)/data/*.ui
	glib-compile-resources --generate-source --target=$@ --sourcedir=$(top_srcdir)/data $(top_srcdir)/data/ui.gresource.xml
	
flags.c : $(top_srcdir)/data/flags.gresource.xml $(top_srcdir)/data/flags/*.png
	glib-compile-resources --generate-source --target=$@ --sourcedir=$(top_srcdir)/data/flags $(top_srcdir)/data/flags.gresource.xml

qalculate_gtk_SOURCES = \
	exchangerates.cc exchangerates.h \
	matrixdialog.cc matrixdialog.h \
	nameseditdialog.cc nameseditdialog.h \
	dataseteditdialog.cc dataseteditdialog.h \
	functioneditdialog.cc functioneditdialog.h \
	uniteditdialog.cc uniteditdialog.h \
	matrixeditdialog.cc matrixeditdialog.h \
	unknowneditdialog.cc unknowneditdialog.h \
	variableeditdialog.cc variableeditdialog.h \
	exportcsvdialog.cc exportcsvdialog.h \
	importcsvdialog.cc importcsvdialog.h \
	setbasedialog.cc setbasedialog.h \
	buttonseditdialog.cc buttonseditdialog.h \
	shortcutsdialog.cc shortcutsdialog.h \
	decimalsdialog.cc decimalsdialog.h \
	precisiondialog.cc precisiondialog.h \
	datasetsdialog.cc datasetsdialog.h \
	functionsdialog.cc functionsdialog.h \
	unitsdialog.cc unitsdialog.h \
	variablesdialog.cc variablesdialog.h \
	plotdialog.cc plotdialog.h \
	periodictabledialog.cc periodictabledialog.h \
	numberbasesdialog.cc numberbasesdialog.h \
	percentagecalculationdialog.cc percentagecalculationdialog.h \
	calendarconversiondialog.cc calendarconversiondialog.h \
	floatingpointdialog.cc floatingpointdialog.h \
	insertfunctiondialog.cc insertfunctiondialog.h \
	preferencesdialog.cc preferencesdialog.h \
	conversionview.cc conversionview.h \
	historyview.cc historyview.h \
	stackview.cc stackview.h \
	keypad.cc keypad.h \
	expressionedit.cc expressionedit.h \
	expressionstatus.cc expressionstatus.h \
	expressioncompletion.cc expressioncompletion.h \
	drawstructure.cc drawstructure.h \
	resultview.cc resultview.h \
	openhelp.cc openhelp.h \
	menubar.cc menubar.h \
	main.cc \
	mainwindow.cc mainwindow.h \
	modes.cc modes.h \
	util.cc util.h \
	unordered_map_define.h support.h settings.h

nodist_qalculate_gtk_SOURCES = ui.c flags.c

qalculate_gtk_LDADD = \
	@GLIB_LIBS@ \
	@GTK_LIBS@ \
	@WEBKITGTK_LIBS@ \
	@QALCULATE_LIBS@

if PLATFORM_MACOS
qalculate_gtk_LDADD += $(GTK_MAC_LIBS)
endif

if ENABLE_SEARCH_PROVIDER
gnome-search-provider2.c: $(top_srcdir)/data/org.gnome.ShellSearchProvider2.xml
	$(AM_V_GEN)gdbus-codegen \
		--c-namespace Shell \
		--generate-c-code gnome-search-provider2 \
		--interface-prefix org.gnome.Shell. \
		$<

qalculate_search_provider_SOURCES = \
	searchprovider.cc \
	support.h

nodist_qalculate_search_provider_SOURCES = gnome-search-provider2.h gnome-search-provider2.c

qalculate_search_provider_LDADD = \
	@GLIB_LIBS@ \
	@GTK_LIBS@ \
	@GIOUNIX_LIBS@ \
	@QALCULATE_LIBS@

searchprovider.o: gnome-search-provider2.c

dbusservicedir = $(datadir)/dbus-1/services
dbusservice_DATA = io.github.Qalculate.SearchProvider.service

io.github.Qalculate.SearchProvider.service: Makefile
	$(AM_V_GEN) (echo '[D-BUS Service]'; \
		echo 'Name=io.github.Qalculate.SearchProvider'; \
		echo 'Exec=@libexecdir@/qalculate-search-provider') > $@.tmp && \
		mv $@.tmp $@

endif


DISTCLEANFILES = $(nodist_qalculate_gtk_SOURCES) $(nodist_qalculate_search_provider_SOURCES) $(dbusservice_DATA)
