Ethereal-dev: Re: [Ethereal-dev] check for NEED_GETOPT_H missing from configure.in?

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Tim Potter <tpot@xxxxxxxxx>
Date: Thu, 24 Oct 2002 17:11:05 +1000
On Tue, Oct 15, 2002 at 03:43:16PM +1000, Tim Potter wrote:

> OK silly question time: I'm having trouble building ethereal:
> 
> gcc -DHAVE_CONFIG_H -I. -I. -I..   -I.. -I../wiretap
> -I/usr/local/include  -DINET6 -D_U_="__attribute__((unused))" -Wall -W
> -g -O2 -I.. -I../wiretap -I/usr/local/include -I/usr/include/gtk-1.2
> -I/usr/include/glib-1.2 -I/usr/lib/glib/include -I/usr/X11R6/include -c
> main.c
> main.c: In function `main':
> main.c:1450: warning: implicit declaration of function `getopt'
> main.c:1696: `optind' undeclared (first use in this function)
> main.c:1696: (Each undeclared identifier is reported only once
> main.c:1696: for each function it appears in.)
> make[2]: *** [main.o] Error 1
> 
> I've tracked it down to the fact that the NEED_CONFIG_H define is not
> being written to config.h.in by autoheader.  Now I think this is because
> there is no check and corresponding AC_DEFINE for it in configure.in.
> 
> Has anyone else been seeing this recently or is my flu medication
> affecting my brain somehow?

So no one else is seeing this problem?  I'm seeing it on Debian unstable
and Redhat 7.3.

Here's my patch anyway.


Tim.

Index: acconfig.h
===================================================================
RCS file: /cvsroot/ethereal/acconfig.h,v
retrieving revision 1.27
diff -u -r1.27 acconfig.h
--- acconfig.h	23 Oct 2002 18:24:04 -0000	1.27
+++ acconfig.h	24 Oct 2002 07:02:30 -0000
@@ -50,6 +50,8 @@
 
 #undef PLUGIN_DIR
 
+#undef NEED_GETOPT_H
+
 @BOTTOM@
 #if defined(HAVE_NET_SNMP) || defined(HAVE_UCD_SNMP)
 #define HAVE_SOME_SNMP
Index: configure.in
===================================================================
RCS file: /cvsroot/ethereal/configure.in,v
retrieving revision 1.185
diff -u -r1.185 configure.in
--- configure.in	23 Oct 2002 18:24:04 -0000	1.185
+++ configure.in	24 Oct 2002 07:02:30 -0000
@@ -525,6 +525,24 @@
 AC_CHECK_HEADERS(arpa/inet.h)
 AC_CHECK_HEADERS(iconv.h)
 
+dnl Is getopt.h required?
+AC_MSG_CHECKING(whether getopt.h is required)
+AC_TRY_COMPILE([
+], [
+	int i = optind;
+], ac_cv_without_getopt_h=yes, ac_cv_without_getopt_h=no)
+AC_TRY_COMPILE([
+#include <getopt.h>
+], [
+int i = optind;
+], ac_cv_with_getopt_h=yes, ac_cv_with_getopt_h=no)
+if test "$ac_cv_with_getopt_h" = yes -a "$ac_cv_without_getopt_h" = no; then
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(NEED_GETOPT_H)
+else
+  AC_MSG_RESULT(no)
+fi
+
 dnl SSL Check
 SSL_LIBS=''
 AC_MSG_CHECKING(whether to use SSL library if available)