Cleanup: popt library detection
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 29 Jun 2017 19:26:12 +0000 (15:26 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 17 Jul 2017 19:35:27 +0000 (15:35 -0400)
Simplify popt detection code and use a variable to store the detected
lib instead of using the global LIBS variable.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
cli/Makefile.am
configure.ac
plugins/ctf/common/metadata/Makefile.am

index 08d7252e434f6bfc28fbee6e30a9e66e3c2cb91c..f2a180d67f8df4c86db40074738a54d75b43fcf8 100644 (file)
@@ -12,7 +12,6 @@ IN_TREE_PLUGIN_PATH = $(PLUGINS_PATH)/ctf:$(PLUGINS_PATH)/text:$(PLUGINS_PATH)/u
 endif
 
 AM_CPPFLAGS += '-DCONFIG_IN_TREE_PLUGIN_PATH="$(IN_TREE_PLUGIN_PATH)"'
-AM_LDFLAGS = -lpopt
 
 bin_PROGRAMS = babeltrace.bin babeltrace-log.bin
 noinst_PROGRAMS = babeltrace babeltrace-log
@@ -46,7 +45,8 @@ babeltrace_bin_LDADD = \
        $(top_builddir)/compat/libcompat.la \
        $(top_builddir)/common/libbabeltrace-common.la \
        $(top_builddir)/logging/libbabeltrace-logging.la \
-       $(top_builddir)/plugins/libctfcopytrace/libctfcopytrace.la
+       $(top_builddir)/plugins/libctfcopytrace/libctfcopytrace.la \
+       $(POPT_LIBS)
 
 if BUILT_IN_PLUGINS
 # Takes a plugin name and outputs the needed LDFLAGS to embed it.
@@ -76,7 +76,7 @@ endif
 endif
 
 if BABELTRACE_BUILD_WITH_MINGW
-babeltrace_bin_LDADD += -lws2_32 -lrpcrt4 -lintl -liconv -lole32 -lpopt -lpthread
+babeltrace_bin_LDADD += -lws2_32 -lrpcrt4 -lintl -liconv -lole32 -lpthread
 endif
 
 # Only used for in-tree execution and tests
@@ -87,13 +87,12 @@ babeltrace_CFLAGS = $(AM_CFLAGS) -DBT_SET_DEFAULT_IN_TREE_CONFIGURATION
 
 # babeltrace-log rules and config below
 babeltrace_log_bin_SOURCES = babeltrace-log.c
-babeltrace_log_bin_LDADD = $(top_builddir)/compat/libcompat.la
+babeltrace_log_bin_LDADD = \
+       $(top_builddir)/compat/libcompat.la \
+       $(POPT_LIBS)
 babeltrace_log_bin_CFLAGS = $(AM_CFLAGS) '-DBT_CLI_PATH="$(abs_top_builddir)/cli/babeltrace$(EXEEXT)"'
 
-if BABELTRACE_BUILD_WITH_MINGW
-babeltrace_log_bin_LDADD += -lpopt
-endif
-
+# Only used for in-tree execution and tests
 babeltrace_log_SOURCES = $(babeltrace_log_bin_SOURCES)
 babeltrace_log_LDADD =         $(babeltrace_log_bin_LDADD)
 babeltrace_log_CFLAGS =        $(AM_CFLAGS) '-DBT_CLI_PATH="$(bindir)/babeltrace$(EXEEXT)"'
index e9958cf2ab3e3a72f828e77314a1e3e13f8b8fc7..fd1ac814c6b601a8cdf9eca3ec7f980e10a22dd1 100644 (file)
@@ -236,9 +236,24 @@ AC_CHECK_LIB([c], [posix_fallocate],
 ]
 )
 
-AC_CHECK_LIB([popt], [poptGetContext], [],
-        [AC_MSG_ERROR([Cannot find popt.])]
+# Check libpopt
+PKG_CHECK_MODULES([POPT], [popt],
+  [
+    dnl PKG_CHECK_MODULES defines POPT_LIBS
+  ],
+  [
+    AC_MSG_WARN([pkg-config was unable to find a valid .pc for libpopt. Set PKG_CONFIG_PATH to specify the pkgconfig configuration file location])
+    AC_MSG_WARN([Finding libpopt without pkg-config.])
+    AC_CHECK_LIB([popt],
+      [poptGetContext],
+      [POPT_LIBS="-lpopt"],
+      [
+        AC_MSG_FAILURE([Cannot find libpopt. Either set PKG_CONFIG_PATH to the configuration file location or use LDFLAGS=-Ldir to specify the library location])
+      ]
+    )
+  ]
 )
+AC_SUBST(POPT_LIBS)
 
 # Plugins
 AC_ARG_VAR([PLUGINSDIR], [built-in plugins install directory [LIBDIR/babeltrace/plugins]])
index fa8b34186f268e921bf7aa826f61679a60fa151a..8c6e877913718b22d0f79a6ecd6d58e071c66a93 100644 (file)
@@ -36,7 +36,7 @@ libctf_ast_la_LIBADD += -lc
 endif
 
 if BABELTRACE_BUILD_WITH_MINGW
-libctf_ast_la_LIBADD += -lrpcrt4 -lintl -liconv -lole32 -lpopt
+libctf_ast_la_LIBADD += -lrpcrt4 -lintl -liconv -lole32 $(POPT_LIBS)
 endif
 
 CLEANFILES = $(BUILT_SOURCES) parser.output
This page took 0.026849 seconds and 4 git commands to generate.