[PATCH 2/2] Optionally use an external popt library

Dan Nicholson dbn.lists at gmail.com
Wed Mar 31 14:50:48 PDT 2010


The one imported into pkg-config has seen very little maintenance, so
let's give users the option to use the upstream version. The default is
to use the included sources, but it can search for the system library
using --with-installed-popt.
---
 Makefile.am  |    9 ++++++++-
 configure.in |   16 ++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0545eac..27ba09f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,9 +6,16 @@ GLIB_SUBDIR = glib-1.2.10
 included_glib_includes = -I./glib-1.2.10
 pkg_config_LDADD=glib-1.2.10/libglib.la
 endif
+
+if USE_INSTALLED_POPT
+pkg_config_LDADD += $(POPT_LIBS)
+else
 pkg_config_LDADD += popt/libpopt.la
 popt_includes = -I./popt
-SUBDIRS = $(GLIB_SUBDIR) popt check
+POPT_SUBDIR = popt
+endif
+
+SUBDIRS = $(GLIB_SUBDIR) $(POPT_SUBDIR) check
 
 m4dir = $(datadir)/aclocal
 m4_DATA = pkg.m4
diff --git a/configure.in b/configure.in
index 98712f4..91d8e7d 100644
--- a/configure.in
+++ b/configure.in
@@ -135,6 +135,22 @@ else
   AC_CONFIG_SUBDIRS(glib-1.2.10)
 fi # !native_win32
 
+AC_ARG_WITH([installed-popt],
+  [AS_HELP_STRING([--with-installed-popt], [use installed popt library])],
+  [with_installed_popt="$withval"],
+  [with_installed_popt=no])
+if test "x$with_installed_popt" = xyes; then
+  _save_libs="$LIBS"
+  AC_CHECK_LIB([popt], [poptGetContext], [:],
+    [AC_MSG_ERROR([could not link to installed popt library])])
+  LIBS="$_save_libs"
+  POPT_LIBS=-lpopt
+else
+  POPT_LIBS=""
+fi
+AC_SUBST([POPT_LIBS])
+AM_CONDITIONAL([USE_INSTALLED_POPT], [test "x$with_installed_popt" = xyes])
+
 AC_FUNC_ALLOCA
 
 AC_CHECK_FUNCS(setresuid setreuid,break)
-- 
1.6.6.1



More information about the pkg-config mailing list