Re: Autoconf and differences between GNU getopt and OpenBSD getopt

Simon Josefsson <[email protected]> Fri, 15 Oct 2004 11:15:30 +0200
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs
Message-ID <[email protected]>
Derek Robert Price <[email protected]> writes:

> Glancing at the latest gl_GETOPT test, it appears to be only using the
> existance of the getopt.h header file to decide whether to use the
> substitute getopt() function or not:
>
> AC_DEFUN([gl_GETOPT],
> [
>   gl_PREREQ_GETOPT
>                                                                             
>  
>
>   GETOPT_H=
>   AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
>   AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
>                                                                             
>  
>
>   if test -n "$GETOPT_H"; then
>      gl_GETOPT_SUBSTITUTE
>   fi
> ])
>
>
> So, it does make sense that, if Alex's version of BSD comes packaged
> with a getopt.h header but an incompatible getopt() function, then the
> latest gl_GETOPT would incorrectly choose to use the system getopt()
> function rather than the GNULIB substitute.

Do BSD really have getopt_long_only?  If so, then the getopt.m4 need
to be improved...

> Something like Alex's test program should probably be added to
> gl_GETOPT, unless someone can suggest a better way to detect or work
> around the problem.

...however, if BSD does not have getopt_long_only, it seems to me that
the above test should work.

Thanks.