#   the used tools
APXS=/usr/local/apache/bin/apxs
APACHECTL=/usr/local/apache/bin/apachectl

#   additional defines, includes and libraries
INC=-I/usr/include/postgresql
LIB=-lpq -L/usr/lib

#   the default target
all: mod_auth_pg.so

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

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

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

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

#   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

