PDBGEN_BACKUP = 0
PDBGEN_GROUPS =

pdb_sources = \
	pdb/brush.pdb			\
	pdb/brush_select.pdb		\
	pdb/brushes.pdb			\
	pdb/buffer.pdb			\
	pdb/channel.pdb			\
	pdb/color.pdb			\
	pdb/context.pdb			\
	pdb/debug.pdb			\
	pdb/display.pdb			\
	pdb/drawable.pdb		\
	pdb/drawable_color.pdb		\
	pdb/drawable_transform.pdb	\
	pdb/dynamics.pdb		\
	pdb/edit.pdb			\
	pdb/fileops.pdb			\
	pdb/floating_sel.pdb		\
	pdb/font_select.pdb		\
	pdb/fonts.pdb			\
	pdb/gimp.pdb			\
	pdb/gimprc.pdb			\
	pdb/gradient.pdb		\
	pdb/gradient_select.pdb		\
	pdb/gradients.pdb		\
	pdb/help.pdb			\
	pdb/image.pdb			\
	pdb/image_color_profile.pdb	\
	pdb/image_convert.pdb		\
	pdb/image_grid.pdb		\
	pdb/image_guides.pdb		\
	pdb/image_sample_points.pdb	\
	pdb/image_select.pdb		\
	pdb/image_transform.pdb		\
	pdb/image_undo.pdb		\
	pdb/item.pdb			\
	pdb/item_transform.pdb		\
	pdb/layer.pdb			\
	pdb/message.pdb			\
	pdb/paint_tools.pdb		\
	pdb/palette.pdb			\
	pdb/palette_select.pdb		\
	pdb/palettes.pdb		\
	pdb/paths.pdb			\
	pdb/pattern.pdb			\
	pdb/pattern_select.pdb		\
	pdb/patterns.pdb		\
	pdb/plug_in.pdb			\
	pdb/plug_in_compat.pdb		\
	pdb/procedural_db.pdb		\
	pdb/progress.pdb		\
	pdb/selection.pdb		\
	pdb/selection_tools.pdb		\
	pdb/text_layer.pdb		\
	pdb/text_tool.pdb		\
	pdb/transform_tools.pdb		\
	pdb/unit.pdb			\
	pdb/vectors.pdb

EXTRA_DIST = \
	README			\
	README_NEW_PDB_PROC	\
	app.pl			\
	enumcode.pl		\
	enumgen.pl		\
	enums.pl		\
	groups.pl		\
	lib.pl			\
	pdb.pl			\
	pdbgen.pl		\
	stddefs.pdb		\
	util.pl			\
	$(pdb_sources)

enum_headers = \
	../../libgimpbase/gimpbaseenums.h	\
	../../libgimpconfig/gimpconfigenums.h	\
	../../app/operations/operations-enums.h	\
	../../app/core/core-enums.h		\
	../../app/paint/paint-enums.h

pdb_scripts = \
	pdbgen.pl	\
	stddefs.pdb	\
	pdb.pl		\
	util.pl		\
	enums.pl	\
	groups.pl

enum_deps = \
	enums.pl		\
	$(srcdir)/util.pl

pdbgen_deps = \
	$(enum_deps)		\
	$(srcdir)/app.pl	\
	$(srcdir)/lib.pl	\
	$(srcdir)/pdb.pl	\
	$(srcdir)/stddefs.pdb	\
	$(srcdir)/pdbgen.pl

stamp_files = \
	stamp-enums		\
	stamp-groups		\
	stamp-pdbgen		\
	stamp-enum-code		\
	stamp-enum-code-py

DISTCLEANFILES = $(stamp_files)

$(srcdir)/enums.pl: stamp-enums
	@:
stamp-enums: $(srcdir)/enumgen.pl $(enum_headers) Makefile.am
	rootme=`pwd`; \
	destdir=`cd $(top_srcdir) && pwd`; export destdir; \
	builddir=`cd $(top_builddir) && pwd`; export builddir; \
	cd $(srcdir) && $(PERL) enumgen.pl $(enum_headers) \
	&& echo timestamp > $$rootme/stamp-enums

$(srcdir)/groups.pl: stamp-groups
	@:
stamp-groups: Makefile.am
	rootme=`pwd`; cd $(srcdir) \
	&& echo "# This file is autogenerated" > $$rootme/groups.pl.tmp \
	&& echo "@groups = qw(" >> $$rootme/groups.pl.tmp \
	&& (for pdb in $(pdb_sources); do \
	      group=`echo $$pdb | sed -e 's%pdb/\([^.]*\)\..*%\1%'`; \
	      echo "    $$group" >> $$rootme/groups.pl.tmp; \
	    done) \
	&& echo ");" >> $$rootme/groups.pl.tmp \
	&& (cmp -s $$rootme/groups.pl.tmp groups.pl || \
            cp $$rootme/groups.pl.tmp groups.pl) \
	&& rm $$rootme/groups.pl.tmp \
	&& echo timestamp > $$rootme/stamp-groups

stamp-pdbgen: $(pdbgen_deps) $(pdb_scripts) $(pdb_sources) Makefile.am
	rootme=`pwd`; \
	destdir=`cd $(top_srcdir) && pwd`; export destdir; \
	builddir=`cd $(top_builddir) && pwd`; export builddir; \
	cd $(srcdir) && \
	   PDBGEN_BACKUP=$(PDBGEN_BACKUP) PDBGEN_GROUPS=$(PDBGEN_GROUPS) \
	   $(PERL) pdbgen.pl app lib \
	&& echo timestamp > $$rootme/stamp-pdbgen

stamp-enum-code: $(srcdir)/enumcode.pl $(enum_deps)
	rootme=`pwd`; \
	destdir=`cd $(top_srcdir) && pwd`; export destdir; \
	builddir=`cd $(top_builddir) && pwd`; export builddir; \
	cd $(srcdir) && \
	  PDBGEN_BACKUP=$(PDBGEN_BACKUP) \
	  $(PERL) enumcode.pl \
	 && echo timestamp > $$rootme/stamp-enum-code

all-local: stamp-pdbgen stamp-enum-code
