PLATFORM = LINUX
#PLATFORM = SOLARIS
#PLATFORM = FreeBSD
CC = gcc
#DEBUG = yes
#CFLAGS = -g
#CFLAGS = -O6
STRIP = strip
#STRIP = gstrip
LIBS = -lm
CFLAGS = -I/usr/lib/glib/include

ifeq ($(PLATFORM),SOLARIS)
	LIBS += -lsocket -lnsl -lresolv
endif

ifeq ($(DEBUG),yes)
	CFLAGS += -g
endif


all: ehntserv ehnt asnc.txt
	@echo
	@echo Build complete.  Be sure to read README and INSTALL.

ehnt_client.o : ehnt_client.c ehnt.h netflowv5.h config.h
	$(CC) -c ehnt_client.c -D$(PLATFORM) $(CFLAGS)

ehnt_lookup.o : ehnt_lookup.c ehnt.h netflowv5.h config.h
	$(CC) -c ehnt_lookup.c -D$(PLATFORM) $(CFLAGS)

ehnt_display.o : ehnt_display.c ehnt.h netflowv5.h config.h
	$(CC) -c ehnt_display.c -D$(PLATFORM) $(CFLAGS)

ehnt_processflow.o : ehnt_processflow.c ehnt.h netflowv5.h config.h
	$(CC) -c ehnt_processflow.c -D$(PLATFORM) $(CFLAGS)

ehnt_main.o : ehnt_main.c ehnt.h netflowv5.h config.h
	$(CC) -c ehnt_main.c -D$(PLATFORM) $(CFLAGS)

ehnt : ehnt_client.o ehnt_lookup.o ehnt_display.o ehnt_processflow.o ehnt_main.o
	$(CC) -o ehnt ehnt_client.o ehnt_lookup.o ehnt_display.o ehnt_processflow.o ehnt_main.o $(LIBS) $(CFLAGS)
ifeq ($(DEBUG),yes)
	@echo Debug mode - ehnt not stripped
else
	$(STRIP) ehnt
endif


ehntserv.o : ehntserv.c ehnt.h netflowv5.h config.h
	$(CC) -c ehntserv.c -D$(PLATFORM) $(CFLAGS)

ehntserv : ehntserv.o
	$(CC) $(CFLAGS) -o ehntserv ehntserv.o  $(LIBS) $(CFLAGS)
ifeq ($(DEBUG),yes)
	@echo Debug mode - ehnt not stripped
else
	$(STRIP) ehntserv
endif

asnc.txt :
	perl ./ProcessASN.pl

asn-refresh :
	rm -f asn.txt apnic.an apnic.an.gz ripe.db.an ripe.db.an.gz
	perl ./ProcessASN.pl

clean : 
	rm -f ehntserv.o ehnt_client.o ehnt.o ehnt_display.o ehnt_processflow.o ehnt_lookup.o ehnt_main.o ehntserv ehnt asnc.txt core
