##
##  Makefile -- Apache Extension Modules top-level Makefile
##  Written by Ralf S. Engelschall <rse@apache.org>
##

SUBDIRS= \
    mod_throttle \
    mod_auth_mysql \
    mod_auth_sys

EXTRA_SUBDIRS=

EXTRA = 0
APXS  = $$(pwd)/../debian/local-apxs

SUBDIRFLAGS = APXS=$(APXS) EXTRA=$(EXTRA)

all:
	@if [ ".$(APXS)" = .apxs -a ".`which apxs`" = . ]; then \
		echo ""; \
		echo "** ERROR: APXS tool not found."; \
		echo "** ERROR: You need Apache 1.3's APXS in your PATH"; \
		echo "** ERROR: Alternatively use 'make APXS=/path/to/bin/apxs'"; \
		echo ""; \
		exit 1; \
	fi
	@$(MAKE) $(MFLAGS) $(SUBDIRFLAGS) TARGET=all subdirmove

install: 
	@$(MAKE) $(MFLAGS) $(SUBDIRFLAGS) TARGET=install subdirmove

clean: 
	rm -f $$(find . -name "*~")
	@$(MAKE) $(MFLAGS) $(SUBDIRFLAGS) TARGET=clean EXTRA=1 subdirmove

distclean: clean

subdirmove:
	@if [ ".`$(MAKE) -v dummy 2>/dev/null | grep 'GNU Make'`" != . ]; then \
		flag="--no-print-directory"; \
	else \
		flag=""; \
	fi; \
	if [ ".$(EXTRA)" = .0 ]; then \
	    subdirs="$(SUBDIRS)"; \
	else \
	    subdirs="$(SUBDIRS) $(EXTRA_SUBDIRS)"; \
	fi; \
	for dir in $$subdirs; do \
	    echo "===> $$dir ($(TARGET))"; \
		(cd $$dir; $(MAKE) $(MFLAGS) $$flag APXS="$(APXS)" $(TARGET)) || exit 1; \
	    echo "<=== $$dir"; \
	done
