####### tdevelop will overwrite this part!!! (begin)##########

SUBDIRS = src po doc icons xslt

ADMIN_DIST = \
admin/acinclude.m4.in \
admin/am_edit \
admin/am_edit.py \
admin/conf.change.pl \
admin/config.pl \
admin/libtool.m4.in \
admin/Makefile.common

EXTRA_DIST = \
COPYING ChangeLog INSTALL README TODO \
tellico.lsm tellico.dtd x-tellico.desktop \
configure.in.in AUTHORS NEWS tellico.tips \
tellico.desktop tellico.xml $(ADMIN_DIST)

####### tdevelop will overwrite this part!!! (end)############
# not a GNU package. You can remove this line, if 
# have all needed files, that a GNU package needs
AUTOMAKE_OPTIONS = foreign

KDE_OPTIONS = noautodist

#$(top_srcdir)/configure.in: configure.in.in $(top_srcdir)/subdirs
$(top_srcdir)/configure.in: configure.in.in
	cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common subdirs
	cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common configure.in

$(top_srcdir)/subdirs:
	cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common subdirs

$(top_srcdir)/acinclude.m4: $(top_srcdir)/admin/acinclude.m4.in $(top_srcdir)/admin/libtool.m4.in
	@cd $(top_srcdir) && cat admin/acinclude.m4.in admin/libtool.m4.in > acinclude.m4

xdg_apps_DATA = tellico.desktop
xdg_mimedir = $(kde_datadir)/mime/packages
xdg_mime_DATA = tellico.xml

mimedir = $(kde_mimedir)/application
mime_DATA = x-tellico.desktop

localdir = $(kde_datadir)/tellico
local_DATA = tellico.dtd tellico.tips

CLEANFILES = *~ *.loT

DISTCLEANFILES = stamp-h1 stamp-h.in stamp-h2 $(distdir).tar.gz $(CLEANFILES)

MAINTAINERCLEANFILES = \
subdirs configure configure.in \
aclocal.m4 acinclude.m4 configure.files \
Makefile.in $(DISTCLEANFILES)


package-messages:
	$(MAKE) -f admin/Makefile.common package-messages
	$(MAKE) -C po merge

messages:
	@ rm -f tips.cpp xslt.cpp z3950.cpp scripts.cpp
	@ touch $(podir)/tellico.pot;
	./preparetips tellico.tips > tips.cpp; \
	$(XGETTEXT)  --join-existing tips.cpp -o $(podir)/tellico.pot; \
	./prepare_i18n_xslt > xslt.cpp; \
	$(XGETTEXT)  --join-existing xslt.cpp -o $(podir)/tellico.pot; \
	./prepare_desktop src/fetch/z3950-servers.cfg > z3950.cpp; \
	$(XGETTEXT)  --join-existing z3950.cpp -o $(podir)/tellico.pot; \
	./prepare_desktop src/fetch/scripts/*.spec > scripts.cpp; \
	$(XGETTEXT)  --join-existing scripts.cpp -o $(podir)/tellico.pot;
	@ rm -f tips.cpp xslt.cpp z3950.cpp scripts.cpp


dist-hook:
# am_edit needs to modify the Makefile.in files, so they must be writeable
	-find $(distdir) -exec chmod a+w {} \;
	cd $(distdir) && perl admin/am_edit -padmin
	cd $(distdir) && $(MAKE) -f admin/Makefile.common subdirs
# don't include dist file inside the dist file
#	cd $(srcdir) && rm -f $(distdir).tar.gz
# remove any executable
	rm -rf $(distdir)/src/tellico

PUBLIC_ID=-//Robby Stephenson/DTD Tellico V9.0//EN
SYSTEM_ID=http://www.periapsis.org/tellico/dtd/v9/tellico.dtd

install-data-local:
	@if test x"@XML_CATALOG_FILE@" != x; then \
          echo @XMLCATALOG@ --noout --add "delegatePublic" \
               "$(PUBLIC_ID)" \
               "file://$(localdir)/tellico.dtd" "@XML_CATALOG_FILE@" ; \
          @XMLCATALOG@ --noout --add "delegatePublic" \
               "$(PUBLIC_ID)" \
               "file://$(localdir)/tellico.dtd" "@XML_CATALOG_FILE@" ; \
          echo @XMLCATALOG@ --noout --add "delegateSystem" \
               "$(SYSTEM_ID)" \
               "file://$(localdir)/tellico.dtd" "@XML_CATALOG_FILE@" ; \
          @XMLCATALOG@ --noout --add "delegateSystem" \
               "$(SYSTEM_ID)" \
               "file://$(localdir)/tellico.dtd" "@XML_CATALOG_FILE@" ; \
          echo @XMLCATALOG@ --noout --add "delegateURI" \
               "$(SYSTEM_ID)" \
               "file://$(localdir)/tellico.dtd" "@XML_CATALOG_FILE@" ; \
          @XMLCATALOG@ --noout --add "delegateURI" \
               "$(SYSTEM_ID)" \
               "file://$(localdir)/tellico.dtd" "@XML_CATALOG_FILE@" ; \
	fi

uninstall-local:
	@if test x"@XML_CATALOG_FILE@" != x; then \
          echo @XMLCATALOG@ --noout --del \
               "$(PUBLIC_ID)" "@XML_CATALOG_FILE@" ; \
          @XMLCATALOG@ --noout --del \
               "$(PUBLIC_ID)" "@XML_CATALOG_FILE@" ; \
          echo @XMLCATALOG@ --noout --del \
               "$(SYSTEM_ID)" "@XML_CATALOG_FILE@" ; \
          @XMLCATALOG@ --noout --del \
               "$(SYSTEM_ID)" "@XML_CATALOG_FILE@" ; \
          echo @XMLCATALOG@ --noout --del \
               "$(SYSTEM_ID)" "@XML_CATALOG_FILE@" ; \
          @XMLCATALOG@ --noout --del \
               "$(SYSTEM_ID)" "@XML_CATALOG_FILE@" ; \
	fi

# probably a better way to do this
uninstall-hook:
	-if [ -d $(localdir) ]; then rmdir $(localdir); fi
