Makefile.OLD 4.07 KB
Newer Older
chris's avatar
chris committed
1
#
pdw's avatar
pdw committed
2
# Makefile:
chris's avatar
chris committed
3 4 5 6
# Makefile for iftop.
#
# $Id$
#
pdw's avatar
pdw committed
7

pdw's avatar
pdw committed
8
VERSION = 0.11pre1
pdw's avatar
pdw committed
9

chris's avatar
chris committed
10
# C compiler to use.
pdw's avatar
pdw committed
11 12
#CC = gcc

chris's avatar
chris committed
13
# Give the location of pcap.h here:
chris's avatar
chris committed
14
CFLAGS += -I/usr/include/pcap -g
15
# CFLAGS += -I/usr/pkg/include
pdw's avatar
pdw committed
16
# CFLAGS += -pg -a
chris's avatar
chris committed
17 18 19

# Give the location of libpcap here if it's not in one of the standard
# directories:
pdw's avatar
pdw committed
20
# LDFLAGS += -L/usr/local/lib
pdw's avatar
pdw committed
21
# LDFLAGS += -pg -a
pdw's avatar
pdw committed
22

chris's avatar
chris committed
23 24
# Do you want to use curses or ncurses? Probably ncurses, unless curses
# is ncurses on your machine.
pdw's avatar
pdw committed
25 26
# CURSES = -lncurses
#CURSES = -lcurses
chris's avatar
chris committed
27

pdw's avatar
pdw committed
28
#
chris's avatar
chris committed
29 30 31 32 33 34 35 36 37
# Name resolution. Sensible systems have gethostbyaddr_r, which is reentrant
# and can be called from several threads of a multithreaded program. Other
# systems don't, or their implementations don't work ([cough] FreeBSD). For
# these you can use gethostbyaddr (not recommended, since then only one thread
# can resolve a name at once), libresolv (not recommended and may not work
# depending on which header files you have), or ares, an asynchronous DNS
# resolution library from
#   ftp://athena-dist.mit.edu/pub/ATHENA/ares/
# For systems without a working gethostbyaddr_r, this is recommended.
pdw's avatar
pdw committed
38
#
chris's avatar
chris committed
39 40 41 42 43 44 45 46
# Leave exactly one of these uncommented, or comment all of them out if you
# don't care about name resolution at all.
#
CFLAGS += -DUSE_GETHOSTBYADDR_R
#CFLAGS += -DUSE_GETHOSTBYADDR
#CFLAGS += -DUSE_LIBRESOLV
#CFLAGS += -DUSE_ARES

chris's avatar
chris committed
47 48 49 50 51 52
#
# On some machines, gethostbyaddr_r returns int; on others, struct hostent*.
# Comment out this line if you are using one of the latter.
#
#CFLAGS += -DGETHOSTBYADD_R_RETURNS_INT

chris's avatar
chris committed
53 54 55 56
#
# Uncomment if you are using libresolv.
#
#LDLIBS += -lresolv # or /usr/lib/libresolv.a on Linux?
chris's avatar
chris committed
57

chris's avatar
chris committed
58 59 60 61 62 63 64
#
# Uncomment if you are using ares.
#
#LDLIBS += -lares 
# ... and uncomment these if your libares is in an unusual place.
#CFLAGS += -I/software/include
#LDFLAGS += -L/software/lib
pdw's avatar
pdw committed
65

chris's avatar
chris committed
66 67 68
#
# Solaris needs a library to make sockets go and lacks inet_aton.
#
pdw's avatar
pdw committed
69
#LDLIBS += -lsocket -lnsl
chris's avatar
chris committed
70
CFLAGS += -DFAKE_INET_ATON
chris's avatar
chris committed
71 72

# PREFIX specifies the base directory for the installation.
pdw's avatar
pdw committed
73 74
PREFIX = /usr/local
#PREFIX = /software
pdw's avatar
pdw committed
75

chris's avatar
chris committed
76
# BINDIR is where the binary lives relative to PREFIX (no leading /).
chris's avatar
chris committed
77 78 79 80 81 82 83
BINDIR = sbin

# MANDIR is where the manual page goes.
MANDIR = man
#MANDIR = share/man     # FHS-ish

# You shouldn't need to change anything below this point.
chris's avatar
chris committed
84
CFLAGS  += -g -Wall "-DIFTOP_VERSION=\"$(VERSION)\""
chris's avatar
chris committed
85
LDFLAGS += -g #-pthread
pdw's avatar
pdw committed
86 87 88 89 90 91 92 93 94
LDLIBS += -lpcap $(CURSES) -lm -lpthread

COMMON_SRCS = addr_hash.c hash.c ns_hash.c util.c sorted_list.c\
       options.c serv_hash.c threadprof.c screenfilter.c cfgfile.c stringmap.c addrs_ioctl.c
IFTOP_ONLY_SRCS = iftop.c ui.c stringmap.c
IFTOPDUMP_ONLY_SRCS = iftop-dump.c counter_hash.c
SRCS = $(COMMON_SRCS) $(IFTOPDUMP_ONLY_SRCS) $(IFTOP_ONLY_SRCS)
IFTOP_SRCS = $(IFTOP_ONLY_SRCS)  $(COMMON_SRCS)
IFTOPDUMP_SRCS = $(IFTOPDUMP_ONLY_SRCS) $(COMMON_SRCS)
95
HDRS = addr_hash.h hash.h iftop.h ns_hash.h resolver.h sorted_list.h ui.h options.h sll.h\
pdw's avatar
pdw committed
96 97
       serv_hash.h threadprof.h ether.h ip.h tcp.h screenfilter.h token.h llc.h \
       extract.h ethertype.h
pdw's avatar
.  
pdw committed
98
TXTS = README CHANGES INSTALL TODO iftop.8 COPYING
pdw's avatar
pdw committed
99
SPECFILE = iftop.spec iftop.spec.in
pdw's avatar
pdw committed
100

pdw's avatar
pdw committed
101 102 103 104 105
IFTOP_OBJS = $(IFTOP_SRCS:.c=.o)
IFTOPDUMP_OBJS = $(IFTOPDUMP_SRCS:.c=.o)

iftop: $(IFTOP_OBJS) Makefile
	$(CC) $(LDFLAGS) -o $@ $(IFTOP_OBJS) $(LDLIBS) 
pdw's avatar
pdw committed
106

pdw's avatar
pdw committed
107 108
iftop-dump: $(IFTOPDUMP_OBJS) Makefile
	$(CC) $(LDFLAGS) -o $@ $(IFTOPDUMP_OBJS) $(LDLIBS) 
pdw's avatar
pdw committed
109

pdw's avatar
pdw committed
110 111
#integers.h: integers
#	./integers
chris's avatar
chris committed
112

chris's avatar
chris committed
113
install: iftop
pdw's avatar
pdw committed
114 115
	install -D iftop   $(PREFIX)/$(BINDIR)/iftop
	install -D iftop.8 $(PREFIX)/$(MANDIR)/man8/iftop.8
chris's avatar
chris committed
116 117 118 119

uninstall:
	rm -f $(PREFIX)/$(BINDIR)/iftop $(PREFIX)/$(MANDIR)/man8/iftop.8

pdw's avatar
pdw committed
120 121 122
%.o: %.c Makefile
	$(CC) $(CFLAGS) -c -o $@ $<

pdw's avatar
pdw committed
123
clean:
124
	rm -f *~ *.o core iftop iftop.spec
pdw's avatar
pdw committed
125

pdw's avatar
pdw committed
126
tarball: depend $(SRCS) $(HDRS) $(TXTS) $(SPECFILE)
chris's avatar
chris committed
127
	mkdir iftop-$(VERSION)
pdw's avatar
pdw committed
128
	set -e ; for i in Makefile depend $(SRCS) $(HDRS) $(TXTS) $(SPECFILE) ; do cp $$i iftop-$(VERSION)/$$i ; done
chris's avatar
chris committed
129 130 131
	tar cvf - iftop-$(VERSION) | gzip --best > iftop-$(VERSION).tar.gz
	rm -rf iftop-$(VERSION)

pdw's avatar
pdw committed
132 133 134
tags :
	etags *.c *.h

pdw's avatar
pdw committed
135
depend: $(SRCS)
chris's avatar
chris committed
136
	$(CPP) $(CFLAGS)  -MM $(SRCS) > depend
pdw's avatar
pdw committed
137 138 139

nodepend:
	rm -f depend
140 141 142 143

iftop.spec: iftop.spec.in Makefile
	sed 's/__VERSION__/$(VERSION)/' < iftop.spec.in > iftop.spec
  
chris's avatar
chris committed
144
        
pdw's avatar
pdw committed
145
include depend