
SUBDIRS = src

expat_peerdir=@EXPAT_PEERDIR@
wv_peerdir=@WV_PEERDIR@
psiconv_peerdir=@PSICONV_PEERDIR@
libiconv_peerdir=@LIBICONV_PEERDIR@
libpng_peerdir=@LIBPNG_PEERDIR@

# 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
psiconv:
	$(MAKE) -C $(psiconv_peerdir)
libiconv:
	$(MAKE) -C $(libiconv_peerdir)
# libpng:
# 	$(MAKE) -C $(libpng_peerdir)

# 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) $(psiconv_peerdir) \
                 $(libpng_peerdir); do \
	  if test $$i != . ; then \
	    $(MAKE) -C $$i clean || true; \
	  fi; \
	done

realclean: clean
	for i in . $(expat_peerdir)  $(wv_peerdir) $(psiconv_peerdir) \
                 $(libpng_peerdir); do \
	  if test $$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

# Install the datafiles. This is quick-and-dirty.
install-data-local:
	@if test -d $(top_srcdir)/../unixfonts/fonts ; then \
	  $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/fonts ;\
	  for file in $(top_srcdir)/../unixfonts/fonts/* ; do \
	    if test -f $$file ; then \
	      $(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/fonts; \
	    fi ;\
	  done; \
	else \
	  echo "Warning: unixfonts package not found." ;\
	fi
	@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 \
              $(INSTALL_DATA) $(dictionary) $(DESTDIR)$(pkgdatadir)/$$dir/american.hash; \
            else \
              for file in $(top_srcdir)/../abidistfiles/$$dir/* ; do \
                if test -f $$file ; then \
                  $(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/$$dir; \
                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
	@$(INSTALL_DATA) $(top_srcdir)/CREDITS.TXT $(DESTDIR)$(pkgdatadir)/AbiWord/help/en-US/credits.txt
