# $Id$

SUBDIRS =								\
	helpers

INCLUDES = 								\
	-I$(top_srcdir)							\
	-DBINDIR=\"$(bindir)\"						\
	-DDATADIR=\"$(datadir)\"					\
	-DG_LOG_DOMAIN=\"exo-helper\"					\
	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"

libexec_PROGRAMS =							\
	exo-helper-0.3

exo_helper_built_sources =						\
	exo-helper-enum-types.c						\
	exo-helper-enum-types.h

exo_helper_headers =							\
	exo-helper.h

exo_helper_0_3_SOURCES =						\
	$(exo_helper_built_sources)					\
	$(exo_helper_headers)						\
	exo-helper-chooser-dialog.c					\
	exo-helper-chooser-dialog.h					\
	exo-helper-chooser.c						\
	exo-helper-chooser.h						\
	exo-helper-launcher-dialog.c					\
	exo-helper-launcher-dialog.h					\
	exo-helper-utils.c						\
	exo-helper-utils.h						\
	exo-helper.c							\
	main.c

exo_helper_0_3_CFLAGS =							\
	$(GTK_CFLAGS)							\
	$(LIBXFCE4UTIL_CFLAGS)

exo_helper_0_3_DEPENDENCIES =						\
	$(top_builddir)/exo-support/libexo-support.la			\
	$(top_builddir)/exo/libexo-$(LIBEXO_VERSION_MAJOR).$(LIBEXO_VERSION_MINOR).la

exo_helper_0_3_LDADD =							\
	$(GTK_LIBS)							\
	$(LIBXFCE4UTIL_LIBS)						\
	$(top_builddir)/exo-support/libexo-support.la			\
	$(top_builddir)/exo/libexo-$(LIBEXO_VERSION_MAJOR).$(LIBEXO_VERSION_MINOR).la

bin_SCRIPTS =								\
	exo-preferred-applications

exo-preferred-applications: Makefile $(srcdir)/exo-preferred-applications.in
	sed								\
		-e 's,@libexecdir\@,$(libexecdir),g' 			\
		-e 's,@LIBEXO_VERSION_MAJOR\@,$(LIBEXO_VERSION_MAJOR),g'\
		-e 's,@LIBEXO_VERSION_MINOR\@,$(LIBEXO_VERSION_MINOR),g'\
		< $(srcdir)/exo-preferred-applications.in		\
		> exo-preferred-applications

desktopdir = $(datadir)/applications
desktop_in_files =							\
	exo-preferred-applications.desktop.in
desktop_DATA =								\
	$(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@

##
## Rules to auto-generate built sources
##
## This is a bit tricky with automake, and non-trivial to implement. The
## rules below seem to work fine and don't seem to break the build, but
## they are only enabled in maintainer mode, so arbitrary users don't get
## trapped in automake's oddities. Therefore we ship the autogenerated
## files as part of the dist tarball.
##
if MAINTAINER_MODE
DISTCLEANFILES =							\
	stamp-exo-helper-enum-types.h					\
	$(exo_helper_built_sources)

BUILT_SOURCES =								\
	$(exo_helper_built_sources)

exo-helper-enum-types.h: stamp-exo-helper-enum-types.h
	@true
stamp-exo-helper-enum-types.h: $(exo_helper_headers) Makefile
	( cd $(srcdir) && glib-mkenums \
		--fhead "#ifndef __EXO_HELPER_ENUM_TYPES_H__\n#define __EXO_HELPER_ENUM_TYPES_H__\n#include <exo/exo.h>\nG_BEGIN_DECLS\n" \
		--fprod "/* enumerations from \"@filename@\" */\n" \
		--vhead "GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define EXO_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
		--ftail "G_END_DECLS\n\n#endif /* !__EXO_HELPER_ENUM_TYPES_H__ */" \
		$(exo_helper_headers) ) >> xgen-eeth \
	&& (cmp -s xgen-eeth exo-helper-enum-types.h || cp xgen-eeth exo-helper-enum-types.h ) \
	&& rm -f xgen-eeth \
	&& echo timestamp > $(@F)

exo-helper-enum-types.c: $(exo_helper_headers) Makefile
	( cd $(srcdir) && glib-mkenums \
		--fhead "#undef GTK_DISABLE_DEPRECATED\n#define GTK_ENABLE_BROKEN\n#include <exo-helper/exo-helper.h>\n#include <exo-helper/exo-helper-enum-types.h>\n\n" \
		--fprod "\n/* enumerations from \"@filename@\" */" \
		--vhead "GType\n@enum_name@_get_type (void)\n{\n\tstatic GType type = 0;\n\tif (type == 0) {\n\tstatic const G@Type@Value values[] = {"\
		--vprod "\t{ @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
		--vtail "\t{ 0, NULL, NULL }\n\t};\n\ttype = g_@type@_register_static (\"@EnumName@\", values);\n  }\n\treturn type;\n}\n" \
		$(exo_helper_headers) ) >> xgen-eetc \
	&& cp xgen-eetc exo-helper-enum-types.c \
	&& rm -f xgen-eetc
endif

CLEANFILES =								\
	$(desktop_DATA)							\
	exo-preferred-applications

EXTRA_DIST =								\
	$(desktop_in_files)						\
	exo-preferred-applications.in

# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
