#   the used tools
APXS=/usr/sbin/apxs2
APACHECTL=apachectl

INCLUDES = opccommands.h opcdefines.h

LIB=-L../libopc -L../libds -lds
INC=-I../includes/libopc -I../includes/libds -I../includes/

vpath %.h ../includes ../includes/libds ../includes/libopc
vpath %.headers ../libopc ../libds

all: .checkheaders mod_opc.so

.checkheaders: .libds.headers
	make clean; \
	touch .checkheaders


mod_opc.so: mod_opc.c $(INCLUDES)
	$(APXS) -c $(DEF) $(INC) $(LIB) mod_opc.c

#   install the DSO file into the Apache installation
#   and activate it in the Apache configuration
install: all
	$(APXS) -n mod_opc -i -S LIBEXECDIR=/usr/lib/apache2/modules -S PREFIX=/usr/lib/apache2 -a .libs/mod_opc.so
#	$(APXS) -i -S LIBEXECDIR=/etc/httpd/modules -S PREFIX=/etc/httpd -a mod_opc.so

#   cleanup
clean:
	-rm -f mod_opc.o mod_opc.so mod_opc.obj mod_opc_win.* *.la *.lo *.slo

#   simple test
test: reload
	lynx -mime_header http://localhost/opc/hell.opc

#   reload the module by installing and restarting Apache
reload: install restart

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

