-# sometimes getopt_long cannot parse same arguments twice
-# e.g. on certain versions of CygWin32
-AC_CACHE_CHECK([for working getopt_long],rsync_cv_HAVE_GETOPT_LONG,[
-AC_TRY_RUN([#include <getopt.h>
-main() {
- int i, x = 0; char *argv[] = { "x", "--xx" };
- struct option o[] = {{"xx", 0, 0, 1}, {0,0,0,0}};
- getopt_long(2, argv, "x", o, &i) == 1 ? x++ : 0; optind = 0;
- getopt_long(2, argv, "x", o, &i) == 1 ? x++ : 0;
- exit(x == 2 ? 0 : 1);
-}], rsync_cv_HAVE_GETOPT_LONG=yes,rsync_cv_HAVE_GETOPT_LONG=no,
- rsync_cv_HAVE_GETOPT_LONG=cross)])
-if test x"$rsync_cv_HAVE_GETOPT_LONG" = x"yes"; then
- AC_DEFINE(HAVE_GETOPT_LONG)
+AC_CONFIG_SUBDIRS(popt-1.2)
+AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
+
+AC_MSG_CHECKING("whether to use included libpopt...")
+if test x"$with_included_popt" = x"yes"
+then
+ AC_MSG_RESULT("$srcdir/popt-1.2")
+ BUILD_LIBPOPT=popt-1.2/libpopt.a
+ LDFLAGS="$CFLAGS -L popt-1.2"
+ CFLAGS="$CFLAGS -I $srcdir/popt-1.2"
+else
+ AC_MSG_RESULT(no)