Commit 68786128 by pdw

Patches from Robert Scheck <robert@fedoraproject.org>

* enable building iftop with more recent versions of autoconf/automake
* patch to remove compile time warnings (mostly already applied).
1 parent 40add956
...@@ -11,13 +11,3 @@ such systems, you may want to use the --with-resolver=ares configure option to ...@@ -11,13 +11,3 @@ such systems, you may want to use the --with-resolver=ares configure option to
build a version of iftop which uses the ARES asynchronous DNS library for name build a version of iftop which uses the ARES asynchronous DNS library for name
resolution. An alternative is to use --with-resolver=netdb_1thread, which will resolution. An alternative is to use --with-resolver=netdb_1thread, which will
make iftop run only one name resolution thread. This is not recommended. make iftop run only one name resolution thread. This is not recommended.
On some systems (notably Red Hat Linux) the libpcap header files are installed
under /usr/include/pcap; on these systems, you should manually specify this
when running configure, like this:
$ CPPFLAGS=-I/usr/include/pcap ./configure
For historical interest, the old iftop makefile is included in Makefile.OLD.
#
# Makefile:
# Makefile for iftop.
#
# $Id$
#
VERSION = 0.11pre1
# C compiler to use.
#CC = gcc
# Give the location of pcap.h here:
CFLAGS += -I/usr/include/pcap -g
# CFLAGS += -I/usr/pkg/include
# CFLAGS += -pg -a
# Give the location of libpcap here if it's not in one of the standard
# directories:
# LDFLAGS += -L/usr/local/lib
# LDFLAGS += -pg -a
# Do you want to use curses or ncurses? Probably ncurses, unless curses
# is ncurses on your machine.
# CURSES = -lncurses
#CURSES = -lcurses
#
# 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.
#
# 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
#
# 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
#
# Uncomment if you are using libresolv.
#
#LDLIBS += -lresolv # or /usr/lib/libresolv.a on Linux?
#
# 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
#
# Solaris needs a library to make sockets go and lacks inet_aton.
#
#LDLIBS += -lsocket -lnsl
CFLAGS += -DFAKE_INET_ATON
# PREFIX specifies the base directory for the installation.
PREFIX = /usr/local
#PREFIX = /software
# BINDIR is where the binary lives relative to PREFIX (no leading /).
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.
CFLAGS += -g -Wall "-DIFTOP_VERSION=\"$(VERSION)\""
LDFLAGS += -g #-pthread
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)
HDRS = addr_hash.h hash.h iftop.h ns_hash.h resolver.h sorted_list.h ui.h options.h sll.h\
serv_hash.h threadprof.h ether.h ip.h tcp.h screenfilter.h token.h llc.h \
extract.h ethertype.h
TXTS = README CHANGES INSTALL TODO iftop.8 COPYING
SPECFILE = iftop.spec iftop.spec.in
IFTOP_OBJS = $(IFTOP_SRCS:.c=.o)
IFTOPDUMP_OBJS = $(IFTOPDUMP_SRCS:.c=.o)
iftop: $(IFTOP_OBJS) Makefile
$(CC) $(LDFLAGS) -o $@ $(IFTOP_OBJS) $(LDLIBS)
iftop-dump: $(IFTOPDUMP_OBJS) Makefile
$(CC) $(LDFLAGS) -o $@ $(IFTOPDUMP_OBJS) $(LDLIBS)
#integers.h: integers
# ./integers
install: iftop
install -D iftop $(PREFIX)/$(BINDIR)/iftop
install -D iftop.8 $(PREFIX)/$(MANDIR)/man8/iftop.8
uninstall:
rm -f $(PREFIX)/$(BINDIR)/iftop $(PREFIX)/$(MANDIR)/man8/iftop.8
%.o: %.c Makefile
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *~ *.o core iftop iftop.spec
tarball: depend $(SRCS) $(HDRS) $(TXTS) $(SPECFILE)
mkdir iftop-$(VERSION)
set -e ; for i in Makefile depend $(SRCS) $(HDRS) $(TXTS) $(SPECFILE) ; do cp $$i iftop-$(VERSION)/$$i ; done
tar cvf - iftop-$(VERSION) | gzip --best > iftop-$(VERSION).tar.gz
rm -rf iftop-$(VERSION)
tags :
etags *.c *.h
depend: $(SRCS)
$(CPP) $(CFLAGS) -MM $(SRCS) > depend
nodepend:
rm -f depend
iftop.spec: iftop.spec.in Makefile
sed 's/__VERSION__/$(VERSION)/' < iftop.spec.in > iftop.spec
include depend
...@@ -41,7 +41,7 @@ iftop.cat: iftop.8 ...@@ -41,7 +41,7 @@ iftop.cat: iftop.8
(echo -e ".pl 1100i" ; cat iftop.8 ; echo ".pl \n(nlu+10") | groff -Tascii -man > iftop.cat (echo -e ".pl 1100i" ; cat iftop.8 ; echo ".pl \n(nlu+10") | groff -Tascii -man > iftop.cat
iftop.spec: iftop.spec.in configure.in iftop.spec: iftop.spec.in configure.in
sed 's/__VERSION__/$(VERSION)/' < iftop.spec.in > iftop.spec sed 's/__VERSION__/$(PACKAGE_VERSION)/' < iftop.spec.in > iftop.spec
## These need to be distributed along with configure: ## These need to be distributed along with configure:
......
dnl dnl
dnl configure.in: dnl configure.ac:
dnl Autoconf input for iftop. dnl Autoconf input for iftop.
dnl dnl
dnl I hate autoconf with a passion. It's an utter pain to write these bloody dnl I hate autoconf with a passion. It's an utter pain to write these bloody
...@@ -17,21 +17,19 @@ dnl autoconf ...@@ -17,21 +17,19 @@ dnl autoconf
dnl Now you should have good sources to make into a tarball and distribute. dnl Now you should have good sources to make into a tarball and distribute.
dnl ./configure (perhaps with some arguments) dnl ./configure (perhaps with some arguments)
dnl make dnl make
dnl Tested with Automake 1.4 and autoconf 2.59. dnl Tested with automake 1.9.6-1.14 and autoconf 2.59-2.69.
dnl dnl
dnl Boilerplate configuration dnl Boilerplate configuration
dnl dnl
AC_INIT(iftop.c) AC_INIT([iftop], [1.0pre2], [pdw@ex-parrot.com], [http://www.ex-parrot.com/pdw/iftop/])
AC_CONFIG_AUX_DIR(config) AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AM_CONFIG_HEADER(config.h) AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(iftop, "1.0pre3") AM_INIT_AUTOMAKE
AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number])
dnl Make sure we have a C compiler.... dnl Make sure we have a C compiler....
AC_PROG_CC AC_PROG_CC
...@@ -107,7 +105,7 @@ dnl ...@@ -107,7 +105,7 @@ dnl
for type in u_int8_t u_int16_t u_int32_t ; do for type in u_int8_t u_int16_t u_int32_t ; do
AC_MSG_CHECKING([size of $type]) AC_MSG_CHECKING([size of $type])
AC_RUN_IFELSE([ AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
int main() { int main() {
...@@ -117,7 +115,7 @@ int main() { ...@@ -117,7 +115,7 @@ int main() {
fprintf(f, "%d\n", sizeof($1)); fprintf(f, "%d\n", sizeof($1));
exit(0); exit(0);
} }
], [ ])], [
x=`cat conftestval` x=`cat conftestval`
eval "size_$type=$x" eval "size_$type=$x"
AC_MSG_RESULT([$x]) AC_MSG_RESULT([$x])
...@@ -206,13 +204,13 @@ dnl whether it works so we can support cross-compilation. ...@@ -206,13 +204,13 @@ dnl whether it works so we can support cross-compilation.
if test x$resolver = xnetdb ; then if test x$resolver = xnetdb ; then
AC_MSG_CHECKING([how to call gethostbyaddr_r]) AC_MSG_CHECKING([how to call gethostbyaddr_r])
dnl Try 7 arguments returning a struct hostent*. dnl Try 7 arguments returning a struct hostent*.
AC_LINK_IFELSE(AC_LANG_SOURCE([`cat config/hostentp_ghba_r.c`]), AC_LINK_IFELSE([AC_LANG_SOURCE([`cat config/hostentp_ghba_r.c`])],
[AC_MSG_RESULT([7 args]) [AC_MSG_RESULT([7 args])
ghba_args=8 ghba_args=8
AC_DEFINE(GETHOSTBYADDR_R_RETURNS_HOSTENT_P, 1, AC_DEFINE(GETHOSTBYADDR_R_RETURNS_HOSTENT_P, 1,
[7-argument gethostbyaddr_r returns struct hostent*])], [ [7-argument gethostbyaddr_r returns struct hostent*])], [
dnl Try 8 arguments returning an int. dnl Try 8 arguments returning an int.
AC_LINK_IFELSE(AC_LANG_SOURCE([`cat config/int_ghba_r.c`]), AC_LINK_IFELSE([AC_LANG_SOURCE([`cat config/int_ghba_r.c`])],
[AC_MSG_RESULT([8 args, int return]) [AC_MSG_RESULT([8 args, int return])
ghba_args=8 ghba_args=8
AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT, 1, AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT, 1,
...@@ -235,7 +233,7 @@ if test x$resolver = xnetdb ; then ...@@ -235,7 +233,7 @@ if test x$resolver = xnetdb ; then
testfile=hostentp_ghba_r testfile=hostentp_ghba_r
fi fi
AC_MSG_CHECKING(gethostbyaddr_r usability) AC_MSG_CHECKING(gethostbyaddr_r usability)
AC_RUN_IFELSE([`cat config/$testfile.c`], AC_RUN_IFELSE([AC_LANG_SOURCE([`cat config/$testfile.c`])],
[AC_MSG_RESULT([yes])], [AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no]) [AC_MSG_RESULT([no])
resolver=guess], resolver=guess],
...@@ -387,7 +385,7 @@ for flag in "" -mt -pthread -thread ; do ...@@ -387,7 +385,7 @@ for flag in "" -mt -pthread -thread ; do
CFLAGS="$oldCFLAGS $flag" CFLAGS="$oldCFLAGS $flag"
for lib in "" -lpthread "-lpthread -lposix4" ; do for lib in "" -lpthread "-lpthread -lposix4" ; do
LIBS="$oldLIBS $lib" LIBS="$oldLIBS $lib"
AC_LINK_IFELSE(AC_LANG_SOURCE([`cat config/pthread.c`]), [ AC_LINK_IFELSE([AC_LANG_SOURCE([`cat config/pthread.c`])], [
foundthrlib=$lib foundthrlib=$lib
foundthrflag=$flag foundthrflag=$flag
thrfail=0 thrfail=0
...@@ -407,7 +405,7 @@ fi ...@@ -407,7 +405,7 @@ fi
AC_MSG_RESULT([CFLAGS=$foundthrflag and LIBS=$foundthrlib]) AC_MSG_RESULT([CFLAGS=$foundthrflag and LIBS=$foundthrlib])
AC_MSG_CHECKING([POSIX threads usability]) AC_MSG_CHECKING([POSIX threads usability])
AC_RUN_IFELSE([`cat config/pthread.c`], AC_RUN_IFELSE([AC_LANG_SOURCE([`cat config/pthread.c`])],
[AC_MSG_RESULT([yes])], [AC_MSG_RESULT([yes])],
[AC_MSG_ERROR( [AC_MSG_ERROR(
[it fails. We probably guessed the wrong CFLAGS.])], [it fails. We probably guessed the wrong CFLAGS.])],
...@@ -444,7 +442,7 @@ AC_SUBST(ac_aux_dir) ...@@ -444,7 +442,7 @@ AC_SUBST(ac_aux_dir)
AC_OUTPUT(Makefile config/Makefile) AC_OUTPUT(Makefile config/Makefile)
if echo $VERSION | grep 'pre' ; then if echo $PACKAGE_VERSION | grep 'pre' > /dev/null ; then
AC_MSG_WARN([ AC_MSG_WARN([
****************************************************************************** ******************************************************************************
......
...@@ -211,10 +211,11 @@ static void usage(FILE *fp) { ...@@ -211,10 +211,11 @@ static void usage(FILE *fp) {
" -s num print one single text output afer num seconds, then quit\n" " -s num print one single text output afer num seconds, then quit\n"
" -L num number of lines to print\n" " -L num number of lines to print\n"
"\n" "\n"
"iftop, version " IFTOP_VERSION "\n" "iftop, version " PACKAGE_VERSION "\n"
"copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors\n" "copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors\n"
); );
} }
#endif /* Obsolete code? */
void options_read_args(int argc, char **argv) { void options_read_args(int argc, char **argv) {
int opt; int opt;
......
...@@ -107,10 +107,10 @@ char *do_resolve(struct addr_storage *addr) { ...@@ -107,10 +107,10 @@ char *do_resolve(struct addr_storage *addr) {
* a non thread-safe wrapper to gethostbyaddr. An interesting choice... * a non thread-safe wrapper to gethostbyaddr. An interesting choice...
*/ */
char* do_resolve(struct addr_storage *addr) { char* do_resolve(struct addr_storage *addr) {
struct hostent hostbuf, *hp; struct hostent hostbuf, *hp = NULL;
size_t hstbuflen = 1024; size_t hstbuflen = 1024;
char *tmphstbuf; char *tmphstbuf;
int res; int res = 0;
int herr; int herr;
char * ret = NULL; char * ret = NULL;
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* *
*/ */
#include "config.h"
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h> #include <ctype.h>
...@@ -49,7 +51,7 @@ ...@@ -49,7 +51,7 @@
" > - sort by dest name\n"\ " > - sort by dest name\n"\
" o - freeze current order\n"\ " o - freeze current order\n"\
"\n"\ "\n"\
"iftop, version " IFTOP_VERSION "iftop, version " PACKAGE_VERSION
extern hash_type* history; extern hash_type* history;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!