
SUBDIRS = src

expat_peerdir=$(top_builddir)/../expat
wv_peerdir=$(top_builddir)/../wv
libiconv_peerdir=$(top_builddir)/../libiconv
libpng_peerdir=@LIBPNG_PEERDIR@
libpopt_peerdir=$(top_builddir)/../popt

desktop_DATA = abiword.desktop
desktopdir = $(datadir)/applications

icon_DATA = abiword_48.png
icondir= $(datadir)/icons

# Hack: make sure that the PEERS stuff is build first
# We can not use the all target, because on parallel builds there is no
# guarantee that the peerdirs will be built before the main tree.
all-recursive: @PEERS@

expat:
	$(MAKE) -C $(expat_peerdir)
wv:
	$(MAKE) -C $(wv_peerdir) BUILD_FOR_ABIWORD=1 @EPATH_WV_BUILD_FLAGS@
libiconv:
	$(MAKE) -C $(libiconv_peerdir)
popt:
	$(MAKE) -C $(libpopt_peerdir)
libpng:
	$(MAKE) -C $(libpng_peerdir)

test: check

# Hack: don't allow distclean; it will delete Makefile, which is not what
# we want at all.
# We need to hook up to distclean-generic in this way to be in time to
# stop the process.
# late, especially in parallel builds
distclean-generic: distclean-stop
distclean-stop:
	@echo "Please use \`make realclean' or \`make realrealclean' instead"
	@exit 1

clean-local:
	for i in . $(expat_peerdir)  $(wv_peerdir) \
                 $(libpng_peerdir) $(libpopt_peerdir); do \
	  if test $$i != . && test -d $$i ; then \
	    $(MAKE) -C $$i clean || true; \
	  fi; \
	done

realclean: clean
	for i in . $(expat_peerdir)  $(wv_peerdir) \
                 $(libpng_peerdir) $(libpopt_peerdir); do \
	  if test $$i != . && test -d $$i ; then \
	    $(MAKE) -C $$i distclean || true; \
	  fi; \
	done
	@rm -f config.* stamp-h stamp-h[0-9]*
	@find ./ -name .deps | xargs rm -rf
	@find ./ -name GNUmakefile | xargs rm -f

realrealclean: realclean
	@find $(top_srcdir) -name GNUmakefile.in | xargs rm -f
	@rm -f $(top_srcdir)/aclocal.m4 $(top_srcdir)/configure \
               $(top_srcdir)/install-sh $(top_srcdir)/missing \
               $(top_srcdir)/mkinstalldirs $(top_srcdir)/INSTALL

if BIGENDIAN
dictionary = $(top_srcdir)/../abidistfiles/dictionary/BigEndian32.american.hash
else
dictionary = $(top_srcdir)/../abidistfiles/dictionary/LittleEndian32.american.hash
endif

if WITH_ISPELL
INSTALLDICTIONARY = yes
else
INSTALLDICTIONARY = no
endif

dictionary_list=$(top_srcdir)/../abidistfiles/dictionary/ispell_dictionary_list.xml

bonobodir = $(libdir)/bonobo/servers

# Install the datafiles. This is quick-and-dirty.
install-data-local:
	@$(mkinstalldirs) $(DESTDIR)$(bonobodir)
	if test -d $(top_srcdir)/../abidistfiles ; then \
	  for dir in `cd $(top_srcdir)/../abidistfiles; find . -type d ! -name CVS` ; do \
	    $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$$dir ;\
	    if test "$$dir" = "./dictionary"; then \
	      if test "$(INSTALLDICTIONARY)" != "no" ; then \
	        $(INSTALL_DATA) $(dictionary) $(DESTDIR)$(pkgdatadir)/$$dir/american.hash; \
	        $(INSTALL_DATA) $(dictionary_list) $(DESTDIR)$(pkgdatadir)/$$dir/ispell_dictionary_list.xml; \
	      fi; \
	    else \
	      for file in `echo $(top_srcdir)/../abidistfiles/$$dir/* | grep -v MANIFEST`; do \
	        if test -f $$file ; then \
		  sfile=`echo "$$file" | sed 's/\.[^.]*$$//'`; \
		  if test "$$sfile.server" = $$file; then \
		    $(INSTALL_DATA) $$file $(DESTDIR)$(bonobodir); \
		  else \
		    $(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/$$dir; \
		  fi; \
	        fi; \
	      done; \
	    fi; \
	  done; \
	else \
	  echo "Warning: abidistfiles package not found." ;\
	fi
if WITH_GNOME
else
	rm -f $(DESTDIR)$(pkgdatadir)/icons/abiword_logo.xpm #XXX this is very dirty
endif
	@$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/AbiWord
	@for dir in `cd $(top_srcdir)/user/wp; find . -type d ! -name CVS` ; do \
	  $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/AbiWord/$$dir ;\
	  for file in $(top_srcdir)/user/wp/$$dir/* ; do \
	    if test -f $$file ; then \
	      $(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/AbiWord/$$dir; \
	    fi ; \
	  done; \
	done
