#
#	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 (TODO):
#	LOG_TO_FILE		Log all accesses to a dedicated file instead.
#	PATH_LOG_FILE		The access log file path.
#

#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 -DPATH_LOG_FILE=\"/var/log/tproxy.log\"

INSTDIR = /usr/sbin
TARGET  = in.tproxyd

INSTALL = install -c -m555 -o bin -g bin
RM      = rm -f
CC      = gcc
CFLAGS  = -O2 -m486 -Wall $(OPTIONS)
LDFLAGS = -s
LIBS    = #-lresolv

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

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

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

dist-clean:	clean
	$(RM) $(TARGET)

install:	$(TARGET)
	$(INSTALL) $(TARGET) $(INSTDIR)
