#
# Makefile for document access counter.
#
# In case standard have advanced and I didn't follow, add -Dname to CFLAGS in
# order to specify the environment vatiable name for the refering document. As 
# for now it stands HTTP_REFERER when you use netscape, Mosaic doesn't support 
# this yet.
#

CC=g++
EXEC_G=/usr/local/etc/httpd/cgi-bin/counter_g
EXEC_A=/usr/local/etc/httpd/cgi-bin/counter_a

#
# CFLAGS may contain:
#    -DLOGFILE=pathname to indicate a diffrent logfile then the default 
#    -DLOCKFILE=pathname to indicate a diffrent lockfile then the default
#    -DTMPFILE=pathname to indicate ...
#    -DENV_REFERER_NAME=env_name environment variable that specifies the name
#                       of the document which called the program
#    -DMAXCOUNT=count, The number of times it will retry to lock access before
#               failing
#    -DDELAY=delay, the delay in seconds between attempts
#    -DLOCAL_ONLY will remove the heading of the url in the logfile
#    -DIGNOREHOST=hostlist, list of hosts to ignore when counting
#
HTTPDIR=/usr/local/etc/httpd
REF=-DENV_REFERER_NAME=HTTP_REFERER
DFILE=-DLOGFILE=\"${HTTPDIR}/htdocs/counts.txt\"
LFILE=-DLOCKFILE=\"${HTTPDIR}/htdocs/counts.lck\"
TFILE=-DTMPFILE=\"${HTTPDIR}/htdocs/tmp.cnt\"
FILES=${DFILE} ${LFILE} ${TFILE}
MAXCOUNT=-DMAXCOUNT=5
DELAY=-DDELAY=1
# MISC=-DLOCAL_ONLY
# ING=IGNOREHOST=\"host_a\",\"host_b"
MISC=
CFLAGS=-g ${REF} ${FILES} ${MAXCOUNT} ${DELAY} ${MISC} ${ING}

counter: counter.cc Makefile
	/bin/rm -f ${EXEC_G} ${EXEC_A}
	${CC} ${CFLAGS} -o counter counter.cc
	cp counter ${EXEC_G}
	ln -s ${EXEC_G} ${EXEC_A}
	chmod 755 ${EXEC_G}

