Much more reliable getopt_long test. Idea from Netocrat.

darcs-hash:20060828102949-ac50b-bb55face2f3127018b6c79a72ee71e38f075232a.gz
This commit is contained in:
axel 2006-08-28 20:29:49 +10:00
parent 4afe49d7c6
commit 7310596dab
5 changed files with 41 additions and 5 deletions

View file

@ -454,7 +454,7 @@ fi
# Check for presense of various functions
AC_CHECK_FUNCS( gettext wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
AC_CHECK_FUNCS( futimes wcwidth wcswidth getopt_long wcstok fputwc fgetwc )
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r killpg)
# The Makefile also needs to know if we have gettext, so it knows if the translations should be installed.
@ -586,6 +586,42 @@ else
AC_MSG_RESULT(no)
fi
# Check if getopt_long actually works
AC_MSG_CHECKING([if getopt_long works])
AC_TRY_LINK(
[
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
],
[
static struct option
long_options[] =
{
0, 0, 0, 0
}
;
int opt = getopt_long( 0,
0,
0,
long_options,
0 );
],
have_working_getopt_long=yes,
have_working_getopt_long=no
)
if test "$have_working_getopt_long" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(
[HAVE_WORKING_GETOPT_LONG],
[1],
[Define to 1 if getopt_long actually works.]
)
else
AC_MSG_RESULT(no)
fi
# Check if del_curterm is broken - in that case we redefine
# del_curterm as a no-op, to avoid a double-free

View file

@ -494,7 +494,7 @@ int main( int argc, char ** argv )
*/
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_WORKING_GETOPT_LONG
static struct option
long_options[] =
{

2
main.c
View file

@ -123,7 +123,7 @@ int main( int argc, char **argv )
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_WORKING_GETOPT_LONG
static struct option
long_options[] =
{

View file

@ -1174,7 +1174,7 @@ int main (int argc, char *argv[])
*/
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_WORKING_GETOPT_LONG
static struct option
long_options[] =
{

View file

@ -159,7 +159,7 @@ int main( int argc, char **argv )
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_WORKING_GETOPT_LONG
static struct option
long_options[] =
{