#
#	Makefile for tproxy.
#
#
# Currently supported OPTIONS flags are:
#	DEBUG			Print some stuff to stdout.
#	DNS_LOOKUPS		Look up the hostnames via DNS to translate
#				the HTTP request.
#	USELESS_DNS_LOOKUPS	Look up the hostnames only needed for the log
#				files. Normally turned off.
#	DEBUG_INPUT_REQUESTS	?
#	DEBUG_OUTPUT_REQUESTS	?
#	IPFILTER		Enable the BSD IP filter code.
#				FreeBSD 3.0, NetBSD 1.3.1 and OpenBSD come
#				with this as standard.
#				See http://coombs.anu.edu.au/~avalon/
#	LOG_TO_SYSLOG		Log all faults and accesses to syslog(3).
#				This can be slow in a busy server.
#	LOG_FAULTS_TO_SYSLOG	Log only faults to syslog(3).
#
# Currently unsupported OPTIONS flags are:
#	LOG_TO_FILE		Log all accesses to a dedicated file instead.
#	PATH_LOG_FILE		When defined opens the specified log file
#				automatically without the -l option.
#

#OPTIONS += -DDEBUG
OPTIONS += -DDNS_LOOKUPS
#OPTIONS += -DUSELESS_DNS_LOOKUPS
#OPTIONS += -DDEBUG_INPUT_REQUESTS
#OPTIONS += -DDEBUG_OUTPUT_REQUESTS
#OPTIONS += -DIPFILTER
#OPTIONS += -DLOG_TO_SYSLOG
OPTIONS += -DLOG_FAULTS_TO_SYSLOG
OPTIONS += -DLOG_TO_FILE
#OPTIONS += -DPATH_LOG_FILE=\"/var/log/tproxy.log\"

PREFIX = /usr/local
INSTALL_PROGRAM = install -c -m 555 -o bin -g bin
INSTALL_MAN = install -c -m 444 -o bin -g bin

RM      = rm -f
CC      = gcc
CFLAGS  = -O2 -m486 -Wall $(OPTIONS)
LDFLAGS = -s
LIBS    = #-lresolv

all:		tproxy

tproxy:		tproxy.o
	$(CC) $(LDFLAGS) tproxy.o -o $@ $(LIBS)

tproxy.o:	tproxy.c Makefile
	$(CC) $(CFLAGS) -c tproxy.c -o $@

clean:
	$(RM) tproxy.o *core *~

clobber dist-clean:	clean
	$(RM) tproxy

install:	tproxy
	${INSTALL_PROGRAM} tproxy ${PREFIX}/sbin
	${INSTALL_MAN} tproxy.8 ${PREFIX}/man/man8
