[Iftop-users] Portability to GNU/kFreeBSD

Mats Erik Andersson debian at gisladisker.se
Tue, 25 Oct 2011 21:01:03 +0200


måndag den 24 oktober 2011 klockan 00:11 skrev Mats Erik Andersson detta:
> 
> First off, renew the four files
> 
>      {,config/}config.{guess,sub}
> 
> The present versions are six years old. They are incapable
> of working with GNU/kFreeBSD.
> 
> These are necessary changes (variations present also in [1]):
> 
>   * The correct conditionals in "addrs_ioctl.c" is
> 
>        defined __GLIBC__ & ! defined __linux__
> 
>     in order to catch GNU/kFreeBSD and to avoid NexentaCore.
>     This MUST be changed, whether or not you decide to ignore
>     OpenSolaris.

I feel compelled to clarify the changes needed to get a valid
and buildable support for GNU/kFreeBSD:

    * config.guess, config.sub, config/config.guess, config/config.sub
      are outdated and must be renewed.

    * The patch below must be used to insert correct conditionals.
      The originals are misconceived. (I am myself to blame for that,
      but they were sufficient for the Debian package improvements,
      my original target!) One could argue that

          defined __GLIBC__ && defined __FreeBSD_kernel__

      is even more precise, as it avoids capturing GNU/Hurd,
      but the check on __GLIBC__ alone is preferred for user land,
      so __FreeBSD_kernel__ is best avoided.


Make an informed choice from this additional points,

  Mats Erik Andersson, Debian Maintainer (but not for this software)



diff -Naur iftop-1.0pre2.orig/addrs_ioctl.c iftop-1.0pre2/addrs_ioctl.c
--- iftop-1.0pre2.orig/addrs_ioctl.c	2011-10-02 23:11:30.000000000 +0200
+++ iftop-1.0pre2/addrs_ioctl.c	2011-10-25 11:59:52.000000000 +0200
@@ -19,7 +19,7 @@
 #include <netinet/in.h>
 
 #if defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ \
-      || ( defined __GNUC__ && ! defined __linux__ )
+      || ( defined __GLIBC__ && ! defined __linux__ )
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <net/if_dl.h>
@@ -81,7 +81,7 @@
   }
 #else
 #if defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ \
-      || ( defined __GNUC__ && ! defined __linux__ )
+      || ( defined __GLIBC__ && ! defined __linux__ )
   {
     int sysctlparam[6] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0};
     size_t needed = 0;