ifneq "$(MAKECMDGOALS)" "autoconf"
ifneq "$(MAKECMDGOALS)" "distclean"
include config/Makefile.include
endif
endif

all::
	@cd src ; $(MAKE) all ; cd ..

install:: install-exec install-includes install-docs

install-exec:
	@cd src ; $(MAKE) install ; cd ..
	$(INSTALL_MKDIR) $(bindir)
	$(INSTALL_SCRIPT) $(vigra_builddir)/config/vigra-config $(bindir)

install-includes:
	if test "$(includedir)" != "$(vigra_srcdir)/include" ; then \
          $(INSTALL_MKDIR) $(includedir)/vigra ; \
          $(INSTALL_DATA) $(vigra_srcdir)/include/vigra/*.hxx $(includedir)/vigra ; \
        fi
install-headers: install-includes

install-docs:
	$(INSTALL_MKDIR) $(docdir)
	$(INSTALL_DATA) $(vigra_srcdir)/LICENSE.txt $(docdir)
	if test "$(docdir)" != "$(vigra_srcdir)/doc/vigra" ; then \
          $(INSTALL_DATA) \
            $(vigra_srcdir)/doc/vigra/*.html \
            $(vigra_srcdir)/doc/vigra/classvigra*.png $(vigra_srcdir)/doc/vigra/form*.png \
            $(vigra_srcdir)/doc/vigra/doxygen.png $(vigra_srcdir)/doc/vigra/vigra.css \
            $(docdir) ; \
          $(INSTALL_MKDIR) $(docdir)/documents ; \
          $(INSTALL_DATA) \
            $(vigra_srcdir)/doc/vigra/documents/*.ps \
            $(vigra_srcdir)/doc/vigra/documents/*.gif \
            $(docdir)/documents ; \
        fi

examples::
	@cd src ; $(MAKE) examples ; cd ..

check:: test

test::
	@cd test ; $(MAKE) ; cd ..

doc::
	cd docsrc; $(MAKE) VIGRA_VERSION=$(VIGRA_VERSION)

docclean::
	cd docsrc; $(MAKE) -i clean

clean::
	@cd src ; $(MAKE) clean ; cd ..
	@cd test ; $(MAKE) clean ; cd ..
	rm -f a.exe a.out


distclean: clean
	rm -f config/vigra-config config/Makefile.include
	rm -f config.log config.cache config.status libtool
	cp config/Makefile.include.empty config/Makefile.include

maintainer-clean: distclean docclean
	rm -f config/aclocal.m4 configure

autoconf:
	cd config && \
	aclocal --acdir=. && \
	autoconf && mv configure ..

libtoolize:
	@echo "*** SET $LTPARAMS TO EXTRA PARAMS (LIKE --force) IF YOU WISH ***"
	@libtool --version
	@test -h configure.in || ln -s config/configure.in
	@libtoolize -c $(LTPARAMS)
	@test -h configure.in && rm configure.in

.PHONY: autoconf all clean distclean doc docclean examples install install-docs install-exec install-includes install-headers
