diff --git a/configure.ac b/configure.ac index b4dbbcb9e..1e4417a40 100644 --- a/configure.ac +++ b/configure.ac @@ -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 + #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 diff --git a/fishd.c b/fishd.c index 8d4801a4f..dd2b6af6b 100644 --- a/fishd.c +++ b/fishd.c @@ -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[] = { diff --git a/main.c b/main.c index 634d4bff2..bb379c8b8 100644 --- a/main.c +++ b/main.c @@ -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[] = { diff --git a/mimedb.c b/mimedb.c index 1aa4f0152..251ecfc07 100644 --- a/mimedb.c +++ b/mimedb.c @@ -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[] = { diff --git a/set_color.c b/set_color.c index dc9b252f6..f65d27640 100644 --- a/set_color.c +++ b/set_color.c @@ -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[] = {