diff --git a/configure.ac b/configure.ac index 80061a7a..4ed50d1d 100644 --- a/configure.ac +++ b/configure.ac @@ -164,7 +164,7 @@ if test "$POLL" = "yes"; then fi AC_CHECK_LIB( gnugetopt, getopt_long,) -AC_CHECK_FUNCS([lstat]) +AC_CHECK_FUNCS([lstat getopt_long]) PKG_PROG_PKG_CONFIG() # ----- Check for dlopen diff --git a/main.cpp b/main.cpp index 7d131a6d..50703a19 100644 --- a/main.cpp +++ b/main.cpp @@ -7,9 +7,28 @@ */ #include "znc.h" -#include #include +#ifdef HAVE_GETOPT_LONG +#include +#else +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option { + const char *a; + int opt; + int *flag; + int val; +}; + +static inline int getopt_long(int argc, char * const argv[], const char *optstring, const struct option *, int *) +{ + return getopt(argc, argv, optstring); +} +#endif + static const struct option g_LongOpts[] = { { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'v' },