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

V=1.0.8

SUBDIRS= \
    mod_allowdev         \
    mod_auth_cache       \
    mod_auth_cookie      \
    mod_auth_cookie_file \
    mod_auth_external    \
    mod_auth_inst        \
    mod_auth_sys         \
    mod_auth_system      \
    mod_eaccess          \
    mod_bandwidth        \
    mod_cgisock          \
    mod_cache            \
    mod_urlcount         \
    mod_disallow_id      \
    mod_lock             \
    mod_peephole         \
    mod_put              \
    mod_qs2ssi           \
    mod_session          \
    mod_ticket           \
    mod_roaming          \
    mod_ip_forwarding

EXTRA_SUBDIRS= \
    mod_monitor          \
    mod_define          

EXTRA      = 0
APXS       = apxs
APXSFLAGS  =

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)" APXSFLAGS="$(APXSFLAGS)" $(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:/www/apache.org/dist/contrib/modules/1.3/apache-contrib.README
	scp ../apache-contrib-$(V).tar.gz taz.apache.org:/www/apache.org/dist/contrib/modules/1.3/

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

