# Put all dirs except perl here.
SUBDIRS=$(shell find . -maxdepth 1 -mindepth 1 -type d ! -path ./CVS ! -path ./.svn ! -path ./perl)

build: $(SUBDIRS)

# Make sure that perl's Makefile is built before using it.
perl/Makefile:
	cd perl && perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS)

%: perl/Makefile
# Ugly hack because perl and autoconf have varying ideas of what
# needs to be in PREFIX.
	set -e ; $(foreach DIR,$(SUBDIRS),$(MAKE) -C $(DIR) $@;)
	$(MAKE) -C perl $@ PREFIX=$(PREFIX)/usr

$(SUBDIRS):
	$(MAKE) -C $@ $(ACTION)

.PHONY: $(SUBDIRS) build
