##
##  Makefile -- Build procedure for sample random2 Apache module
##  Autogenerated via ``apxs -n random2 -g''.
##

builddir=$(shell pwd)

#   the used tools
APXS=apxs
APACHECTL=apachectl
CC=`$(APXS) -q CC`
INC=-I`$(APXS) -q INCLUDEDIR` `$(APXS) -q CFLAGS`
LD_SHLIB=`apxs -q LDFLAGS_SHLIB`
VERSION = 2.1
DISTNAME = mod_random
DISTVNAME = $(DISTNAME)-$(VERSION)

SRC = mod_random.c
OBJ = ${SRC:.c=.o}
SOBJ = ${SRC:.c=.lo}

SHELL = /bin/sh
PERL = perl
NOOP = $(SHELL) -c true
RM_RF = rm -rf
SUFFIX = .gz
COMPRESS = gzip --best
TAR  = tar
TARFLAGS = cvf
PREOP = @$(NOOP)
POSTOP = @$(NOOP)
TO_UNIX = @$(NOOP)


#   the default target
all: mod_random.so

mod_random.so: $(SRC)
	$(APXS) -c $(INCLUDES) $(LIBS) $(SRC)

#   install the shared object file into Apache 
install:
	$(APXS) -iac $(INCLUDES) $(LIBS) $(SRC)
	@echo "+--------------------------------------------------------+"; \
	echo "| All done.                                              |"; \
	echo "|                                                        |"; \
	echo "| You will need to add the directive:                    |"; \
	echo "| LoadModule random_module modules/mod_random.so         |"; \
	echo "|                                                        |"; \
	echo "| So that you can begin to use mod_random.               |"; \
	echo "|                                                        |"; \
	echo "| Thanks for installing mod_random.                      |"; \
	echo "+--------------------------------------------------------+"; \

#   cleanup
clean:
	-rm -f mod_random2.o mod_random2.lo mod_random2.slo mod_random2.la 

#   simple test
test: reload
	lynx -mime_header http://localhost/random2

#   install and activate shared object by reloading Apache to
#   force a reload of the shared object file
reload: install restart

#   the general Apache start/restart/stop
#   procedures
start:
	$(APACHECTL) start
restart:
	$(APACHECTL) restart
stop:
	$(APACHECTL) stop

dist: version $(DISTVNAME).tar$(SUFFIX)

version:
	echo $(VERSION) > VERSION
#	echo "#define VERSION \"$(VERSION)\"" > version.h

$(DISTVNAME).tar$(SUFFIX) : distdir
	$(PREOP)
	$(TO_UNIX)
	$(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
	$(RM_RF) $(DISTVNAME)
	$(COMPRESS) $(DISTVNAME).tar
		$(POSTOP)

distdir :
	$(RM_RF) $(DISTVNAME)
	$(PERL) -MExtUtils::Manifest=manicopy,maniread \
		-e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"

