+Real implementation of 'captive-cmdline' client
authorshort <>
Sat, 22 Mar 2003 19:53:24 +0000 (19:53 +0000)
committershort <>
Sat, 22 Mar 2003 19:53:24 +0000 (19:53 +0000)
Separated for on-demand use: POPT_LIBS,GNOME_VFS_MODULE_*

configure.in

index f89188d..5be6841 100644 (file)
@@ -74,7 +74,7 @@ AH_VERBATIM([ENABLE_NLS_HOOK],[
 #      define _(String) dgettext (PACKAGE,String)
 #else
 #      define _(String) gettext (String)
-#endif /* LIBSURPRISE */
+#endif /* LIBCAPTIVE */
 #      ifdef gettext_noop
 #              define N_(String) gettext_noop (String)
 #      else
@@ -98,11 +98,69 @@ CFLAGS="$CFLAGS $GLIB_CFLAGS"
 LIBS="$LIBS $GLIB_LIBS"
 
 dnl popt
-AC_CHECK_LIB(popt,poptParseArgvString,,[AC_MSG_ERROR([Captive requires popt library.])])
+AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([Captive requires popt library.])])
+AC_SUBST(POPT_LIBS)
+
+AC_ARG_WITH(readline,  [  --with-readline=[no/yes/auto]        cmdline client w/line editing [default=auto]],,with_readline=auto)
+AC_CHECK_HEADERS(readline/history.h)
+dnl Check for libraries, if needed by configuration options.
+if test "$with_readline" != "no"
+then
+       if test -d "/usr/lib/termcap"
+       then
+               READLINE_LDFLAGS="$READLINE_LDFLAGS -L/usr/lib/termcap"
+       fi
+       have_libreadline=false
+       need_failed=""
+       for need in "" termcap ncurses; do
+               if test "x$need" != "x"
+               then
+                       AC_CHECK_LIB($need, main,,
+                               [ need_failed="$need_failed $need"
+                               continue ]
+                               )
+                       lneed=-l$need
+               else
+                       lneed=""
+               fi
+               dnl Prevent AC_CHECK_LIB() here as it would _cache_ the value ignoring
+               dnl our ever-changing "additiona libraries" parameter
+               captive_save_LIBS="$LIBS"
+               LIBS="-lreadline $lneed $READLINE_LIBS"
+               AC_TRY_LINK(,[ main() ],
+                       [ have_libreadline=true
+                       READLINE_LIBS="$LIBS" ])
+               LIBS="$captive_save_LIBS"
+               if $have_libreadline
+               then
+                       break
+               fi
+       done
+       if $have_libreadline
+       then
+               AC_DEFINE(HAVE_LIBREADLINE,,[Use functions from libreadline?])
+               AC_CHECK_LIB(readline, add_history,
+                       AC_DEFINE(HAVE_ADD_HISTORY,,[Use 'history' extension of libreadline?]),,
+                       $READLINE_LIBS)
+       else
+               for need in $need_failed; do
+                       AC_MSG_WARN(captive recommends $need library as your readline library
+                       probably needs it.)
+               done
+               if test "$with_readline" = "yes"
+               then
+                       AC_MSG_ERROR([captive did not find the requested readline library for its cmdline client line editing capability.])
+               else
+                       AC_MSG_WARN([captive recommends readline library for its cmdline client line editing capability.])
+               fi
+       fi
+fi
+AC_SUBST(READLINE_LIBS)
+AC_SUBST(READLINE_LDFLAGS)
 
 PKG_CHECK_MODULES(GNOME_VFS_MODULE,gnome-vfs-module-2.0)
-CFLAGS="$CFLAGS $GNOME_VFS_MODULE_CFLAGS"
-LIBS="$LIBS $GNOME_VFS_MODULE_LIBS"
+AC_SUBST(GNOME_VFS_MODULE_CFLAGS)
+AC_SUBST(GNOME_VFS_MODULE_LIBS)
 
 dnl for $(top_srcdir)/src/libcaptive/sandbox/split-sandbox.c
 AM_PATH_LINC(,,[AC_MSG_ERROR([Captive requires linc library used by ORBit.])])