# Generated automatically from Makefile.in by configure.
#
#  Copyright (C) 1998-99  Luca Deri <deri@unipi.it>
#                      
#		       Centro SERRA, University of Pisa
#		       http://www-serra.unipi.it/
#  					
#
#  Copyright (c) 1994, 1996, 1997
# 	The Regents of the University of California.  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that: (1) source code distributions
#  retain the above copyright notice and this paragraph in its entirety, (2)
#  distributions including binary code include the above copyright notice and
#  this paragraph in its entirety in the documentation or other materials
#  provided with the distribution, and (3) all advertising materials mentioning
#  features or use of this software display the following acknowledgement:
#  ``This product includes software developed by the University of California,
#  Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
#  the University nor the names of its contributors may be used to endorse
#  or promote products derived from this software without specific prior
#  written permission.
#  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#

#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
#

# Top level hierarchy
prefix = /usr/local
exec_prefix = ${prefix}
# Pathname of directory to install the binary
BINDEST = ${exec_prefix}/sbin
# Pathname of directory to install the man page
MANDEST = ${prefix}/man
# Fix courtesy of Igor Schein <igor@txc.com>
SHELL=/bin/sh
VERSION=1.2a7
OSNAME=irix6.2

#
# You shouldn't need to edit anything below here.
#

CC = cc
PROG = ntop
CCOPT = -O -xansi -signed -g3
INCLS = -I. -I../libpcap-0.4a7  -I/usr/local/include 
DEFS =  -DHAVE_FCNTL_H=1 -DHAVE_PCAP_H=1 -DHAVE_MALLOC_H=1 -DHAVE_MEMORY_H=1 -DHAVE_CURSES_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_STDARG_H=1 -DHAVE_SYS_SOCKIO_H=1 -DHAVE_GDBM_H=1 -DHAVE_DIRENT_H=1 -DHAVE_DLFCN_H=1 -DHAVE_NETINET_IF_ETHER_H=1 -DHAVE_NET_IF_ARP_H=1 -DHAVE_SYS_SCHED_H=1 -DHAVE_PTHREAD_H=1 -DHAVE_SEMAPHORE_H=1 -DRETSIGTYPE=void -DRETSIGVAL= -D_BSD_SIGNALS=1 -DHAVE_LIBDL=1 -DHAVE_LIBGDBM=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_LIBCRYPT=1 -DHAVE_LIBCURSES=1 

# Standard CFLAGS
CFLAGS = $(CCOPT) $(DEFS) $(INCLS) -DMULTITHREADED -DASYNC_ADDRESS_RESOLUTION -DHAVE_LSOF=\"/usr/local/bin/lsof\" -DHAVE_QUESO=\"/sbin/queso\"   

# Standard LDFLAGS
LDFLAGS =  -L/usr/local/lib 
LDFLAGSPLUGINS = 

# Standard LIBS
LIBS = -lcurses -lcrypt -lgdbm -ldl ../libpcap-0.4a7/libpcap.a  -lpthread

INSTALL = ./install-sh -c

.SUFFIXES: .c .o .dll

# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
# Also, gcc does not remove the .o before forking 'as', which can be a
# problem if you don't own the file but can write to the directory.
.c.o:
	@rm -f $@
	$(CC) $(CFLAGS) -c $*.c

.o.dll:
	@rm -f $@
	$(CC) -o $@ $(DLL_OPTS) $<

CSRC = ntop.c pbuf.c util.c http.c vendor.c report.c qsort.c sql.c address.c admin.c plugin.c
PLUGINS = arpPlugin.dll nfsPlugin.dll odbcPlugin.dll icmpPlugin.dll
GENSRC = version.c

SRC =	$(CSRC) $(GENSRC)

# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
# hack the extra indirection
OBJ =	$(CSRC:.c=.o) $(GENSRC:.c=.o)
HDR =   interface.h machdep.h

DLL_OPTS = -shared

CLEANFILES = $(PROG) $(OBJ) $(PLUGINS:.dll=.o) $(PLUGINS) $(GENSRC) *.dll  so_locations plugins/*


all: $(PROG) plugins

$(PROG): $(OBJ) ../libpcap-0.4a7/libpcap.a
	@rm -f $@
	$(CC) $(CCOPT) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)

version.o: version.c
version.c: VERSION
	@rm -f $@
	sed -e 's/.*/char version[] = "&";/' VERSION > $@
	sh config.guess > OS.NAME
	sed -e 's/.*/char osName[]  = "&";/' OS.NAME >> $@
	echo "char author[]  = \"Luca Deri <deri@unipi.it>\";" >> $@
	rm -f OS.NAME

ntop.c: ntop.h
pbuf.c: ntop.h
util.c: ntop.h
http.c: ntop.h
report.c: ntop.h

install:
	$(INSTALL) -m 6550 $(PROG) $(DESTDIR)$(BINDEST)/$(PROG)

install-man:
	$(INSTALL) -m 444 $(PROG).8 $(DESTDIR)$(MANDEST)/man8/$(PROG).8

clean:
	rm -f $(CLEANFILES) *~ #* ntop.html *.db core

distclean:
	rm -f $(CLEANFILES) *~ #* ntop.html *.db core Makefile config.cache config.log config.status

depend:	$(GENSRC)
	./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)

plugins: arpPlugin.dll nfsPlugin.dll odbcPlugin.dll icmpPlugin.dll

arpPlugin.o: arpPlugin.c
	$(CC) -c $(LDFLAGSPLUGINS) $(CFLAGS) $<

nfsPlugin.o: nfsPlugin.c
	$(CC) -c $(LDFLAGSPLUGINS) $(CFLAGS) $<

odbcPlugin.o: odbcPlugin.c
	$(CC) -c $(LDFLAGSPLUGINS) $(CFLAGS) $<

icmpPlugin.o: icmpPlugin.c
	$(CC) -c $(LDFLAGSPLUGINS) $(CFLAGS) $<

arpPlugin.dll: arpPlugin.o
	$(CC) -o $@ $(DLL_OPTS) $<
	ln -fs ../$@ plugins/$@

icmpPlugin.dll: icmpPlugin.o
	$(CC) -o $@ $(DLL_OPTS) $<
	ln -fs ../$@ plugins/$@

nfsPlugin.dll: nfsPlugin.o
	$(CC) -o $@ $(DLL_OPTS) $<
	ln -fs ../$@ plugins/$@

odbcPlugin.dll: odbcPlugin.o
	$(CC) -o $@ $(DLL_OPTS) $<
	ln -fs ../$@ plugins/$@

ntop.html: ntop.8
	@echo " " > ntop.tmp
	@groff -mandoc -Tascii ntop.8 >> ntop.tmp
	@cat ntop.tmp | man2html > ntop.html
	@rm -f ntop.tmp

make-rpm: ntop ntop.html
	echo "Only root can do this. Wait please...."
	cp ntop packages/rpm/sbin
	cp -r ntop.html html/* packages/rpm/etc/ntop/html
	chown -R root.sys packages/rpm
	cp -pr CHANGES COPYING FAQ FILES INSTALL README TO_DO VERSION ntop.html /usr/src/redhat/BUILD
	chmod gou+x packages/rpm/sbin/ntop
	chmod u+s packages/rpm/sbin/ntop
	cp ntop.8 packages/rpm/usr/man/man8
	rpm -bb packages/rpm/ntop-$(VERSION)-1.spec
	mv /usr/src/redhat/RPMS/$(MACHTYPE)/ntop-$(VERSION)-1.$(MACHTYPE).rpm packages
	rm packages/rpm/sbin/ntop
	rm packages/rpm/usr/man/man8/ntop.8

make-suse: ntop ntop.html
	echo "Only root can do this. Wait please...."
	cp ntop packages/rpm/sbin
	cp -r ntop.html html/* packages/rpm/etc/ntop/html
	chown -R root.sys packages/rpm
	cp -pr CHANGES COPYING FAQ FILES INSTALL README TO_DO VERSION ntop.html /usr/src/packages/BUILD
	chmod gou+x packages/rpm/sbin/ntop
	chmod u+s packages/rpm/sbin/ntop
	cp ntop.8 packages/rpm/usr/man/man8
	rpm -bb packages/rpm/ntop-$(VERSION)-1.spec
	mv /usr/src/packages/RPMS/$(HOSTTYPE)/ntop-$(VERSION)-1.suse-$(HOSTTYPE).rpm packages
	rm packages/rpm/sbin/ntop
	rm packages/rpm/usr/man/man8/ntop.8

make-deb: ntop ntop.html
	echo "Only root can do this. Wait please...."
	cp ntop packages/debian/sbin
	cp -r ntop.html html/* packages/debian/etc/ntop/html
	chown root.sys packages/debian/sbin/ntop
	chmod gou+x packages/debian/sbin/ntop
	chmod u+s packages/debian/sbin/ntop
	cp ntop.8 packages/debian/usr/man/man8
	gzip packages/debian/usr/man/man8/ntop.8
	dpkg-deb -b packages/debian packages/ntop-$(VERSION)-$(OSNAME).deb
	rm packages/debian/sbin/ntop
	rm packages/debian/usr/man/man8/ntop.8.gz

make-generic: ntop ntop.html
	cp ntop packages/generic/sbin
	cp -r ntop.html html/* packages/generic/etc/ntop/html
	chown root.sys packages/generic/sbin/ntop
	chmod gou+x packages/generic/sbin/ntop
	chmod u+s packages/generic/sbin/ntop
	cp ntop.8 packages/generic/usr/man/man8
	gzip packages/generic/usr/man/man8/ntop.8
	cd packages/generic; tar cvf - . > ../ntop-$(VERSION)-$(OSNAME).tar
	compress packages/ntop-$(VERSION)-$(OSNAME).tar
	rm packages/generic/sbin/ntop
	rm packages/generic/usr/man/man8/ntop.8.gz
	rm packages/generic/etc/ntop/html/*

make-slack: ntop ntop.html
	echo "Only root can do this. Wait please...."
	cp ntop packages/slackware/sbin
	cp -r ntop.html html/* packages/slackware/etc/ntop/html
	chown root.sys packages/slackware/sbin/ntop
	chmod gou+x packages/slackware/sbin/ntop
	chmod u+s packages/slackware/sbin/ntop
	cp ntop.8 packages/slackware/usr/man/man8
	gzip packages/slackware/usr/man/man8/ntop.8
	cd packages/slackware; tar cvfz - . > ../ntop-$(VERSION)-slackware.tgz
	mv packages/ntop-$(VERSION)-slackware.tgz packages/slackware
	rm packages/slackware/sbin/ntop
	rm packages/slackware/usr/man/man8/ntop.8.gz
	rm packages/slackware/etc/ntop/html/*
	echo "The package file is under packages/slackware: have fun!"


make-bsd: ntop ntop.html
	echo "Only root can do this. Wait please...."
	cp ntop packages/freebsd/sbin
	cp -r ntop.html html/* packages/freebsd/etc/ntop/html
	chown root.sys packages/freebsd/sbin/ntop
	chmod gou+x packages/freebsd/sbin/ntop
	chmod u+s packages/freebsd/sbin/ntop
	cp ntop.8 packages/freebsd/usr/man/man8
	gzip packages/freebsd/usr/man/man8/ntop.8
	cd packages/freebsd; tar cvfz - . > ../ntop-$(VERSION)-freebsd.tgz
	mv packages/ntop-$(VERSION)-freebsd.tgz packages/freebsd
	rm packages/freebsd/sbin/ntop
	rm packages/freebsd/usr/man/man8/ntop.8.gz
	rm packages/freebsd/etc/ntop/html/*
	echo "The package file is under packages/freebsd: have fun!"


make-solaris: ntop ntop.html
	echo "Only root can do this. Wait please...."
	/bin/rm -rf /opt/ntop
	/bin/rm -rf /var/spool/ntop
	mkdir -p /opt/ntop/bin
	mkdir -p /opt/ntop/man/man8
	mkdir -p /opt/ntop/etc/ntop/html
	cp ntop /opt/ntop/bin
	cp -r ntop.html html/* /opt/ntop/etc/ntop/html
	chown -R bin /opt/ntop
	chgrp -R bin /opt/ntop
	chmod gou+x /opt/ntop/bin/ntop
	chmod u+s /opt/ntop/bin/ntop
	cp ntop.8 /opt/ntop/man/man8
	cd /opt/ntop; find . -print | pkgproto > prototype
	echo "i pkginfo=/opt/ntop/pkginfo" >> prototype
	cat /opt/ntop/prototype >> prototype
	mv prototype /opt/ntop/prototype
	cp packages/solaris/ntop/pkginfo /opt/ntop
	cd /opt/ntop; pkgmk -o -r `pwd`
	cd /var/spool/pkg; pkgtrans -o -s `pwd` /tmp/ntop-$(VERSION)-solaris.$(MACHTYPE)
	cd /tmp; gzip ntop-$(VERSION)-solaris.$(MACHTYPE)
	/bin/rm -rf /opt/ntop
	/bin/rm -rf /var/spool/ntop
	echo "The package file is in /tmp/ntop-$(VERSION)-solaris.$(MACHTYPE).gz: have fun!"
