##
##  Makefile -- Build file  for mod_random Apache module
##

#   the used tools
APXS=apxs
APACHECTL=apachectl
VERSION = 1.4
DISTNAME = mod_random
DISTVNAME = $(DISTNAME)-$(VERSION)

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)


#   additional defines, includes and libraries
#DEF=-Dmy_define=my_value
#INC=-Imy/include/dir
#LIB=-Lmy/lib/dir -lmylib

#   the default target
all: mod_random.so

#   compile the shared object file
mod_random.so: mod_random.c
	$(APXS) -c $(DEF) $(INC) $(LIB) mod_random.c

#   install the shared object file into Apache 
install: all
	$(APXS) -i -a -n 'random' mod_random.so

#   cleanup
clean:
	-rm -f mod_random.o mod_random.so

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

#   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)');"

