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

V=1.0.4

SUBDIRS= \
    mod_auth_cookie      \
    mod_auth_cookie_file \
    mod_auth_external    \
    mod_auth_system      \
    mod_bandwidth        \
    mod_urlcount         \
    mod_disallow_id      \
    mod_peephole         \
    mod_put              \
    mod_qs2ssi           \
    mod_session          \
    mod_roaming          \
    mod_ip_forwarding    \
    mod_macro

EXTRA_SUBDIRS= \


EXTRA = 0
APXS  = 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: 
	@$(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

dist:
	gtar --no-recursion -cvf - `find * -depth -print | sort` |\
    tardy --user_number=0  --user_name=rse \
          --group_number=0 --group_name=apache \
          --prefix=apache-contrib-$(V) - |\
    gzip --best >/tmp/apache-contrib-$(V).tar.gz && \
	mv /tmp/apache-contrib-$(V).tar.gz ..
	ls -l ../apache-contrib-$(V).tar.gz

release:
	scp README taz.apache.org:/pub/apache/dist/contrib/modules/1.3/apache-contrib.README
	scp ../apache-contrib-$(V).tar.gz taz.apache.org:/pub/apache/dist/contrib/modules/1.3/

view-release:
	cftp ftp://ftp.apache.org/apache/dist/contrib/modules/1.3/

