Completely rework configure.ac
[babeltrace.git] / cli / Makefile.am
index 68cf9508777166509fec10cc424917b314134b20..3cd2a1168bf9c6aa760be97bb5d559672170d71a 100644 (file)
@@ -1,11 +1,20 @@
 PLUGINS_PATH = $(abs_top_builddir)/plugins
-AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include \
-               -DCONFIG_IN_TREE_PLUGIN_PATH=\"$(PLUGINS_PATH)/ctf:$(PLUGINS_PATH)/lttng-utils:$(PLUGINS_PATH)/text:$(PLUGINS_PATH)/writer:$(PLUGINS_PATH)/utils\"
-AM_LDFLAGS = -lpopt
+LTTNG_UTILS_PLUGIN_PATH =
 
-bin_PROGRAMS = babeltrace.bin
-noinst_PROGRAMS = babeltrace
-#check_PROGRAMS = babeltrace
+if ENABLE_DEBUG_INFO
+LTTNG_UTILS_PLUGIN_PATH += :$(PLUGINS_PATH)/lttng-utils
+endif
+
+if BABELTRACE_BUILD_WITH_MINGW
+IN_TREE_PLUGIN_PATH := $(shell cygpath -pm "$(PLUGINS_PATH)/ctf:$(PLUGINS_PATH)/text:$(PLUGINS_PATH)/utils$(LTTNG_UTILS_PLUGIN_PATH)")
+else
+IN_TREE_PLUGIN_PATH = $(PLUGINS_PATH)/ctf:$(PLUGINS_PATH)/text:$(PLUGINS_PATH)/utils$(LTTNG_UTILS_PLUGIN_PATH)
+endif
+
+AM_CPPFLAGS += '-DCONFIG_IN_TREE_PLUGIN_PATH="$(IN_TREE_PLUGIN_PATH)"'
+
+bin_PROGRAMS = babeltrace.bin babeltrace-log.bin
+noinst_PROGRAMS = babeltrace babeltrace-log
 
 babeltrace_bin_SOURCES = \
        babeltrace.c \
@@ -16,23 +25,58 @@ babeltrace_bin_SOURCES = \
        babeltrace-cfg-cli-args-connect.c \
        babeltrace-cfg-cli-args-connect.h \
        babeltrace-cfg-cli-args-default.h \
-       babeltrace-cfg-cli-args-default.c
+       babeltrace-cfg-cli-args-default.c \
+       logging.c logging.h
 
 # -Wl,--no-as-needed is needed for recent gold linker who seems to think
 # it knows better and considers libraries with constructors having
 # side-effects as dead code.
-babeltrace_bin_LDFLAGS = -Wl, $(LD_NO_AS_NEEDED), -export-dynamic
+babeltrace_bin_LDFLAGS = $(LD_NO_AS_NEEDED)
+
+# Add all the convenience libraries used by Babeltrace plugins and the
+# library. They will be used when embedding plugins (--enable-built-in-plugins),
+# otherwise we're looking after multiple definitions of the same symbols if
+# a plugin's archive (.a) includes the convenience library because
+# we're using --whole-archive below (needed to make sure the linker does
+# not discard the plugins since the CLI does not use their symbols
+# directly).
 babeltrace_bin_LDADD = \
        $(top_builddir)/lib/libbabeltrace.la \
        $(top_builddir)/compat/libcompat.la \
-       $(top_builddir)/common/libbabeltrace-common.la
+       $(top_builddir)/common/libbabeltrace-common.la \
+       $(top_builddir)/logging/libbabeltrace-logging.la \
+       $(top_builddir)/plugins/libctfcopytrace/libctfcopytrace.la \
+       $(POPT_LIBS)
 
-if BUILT_IN_PLUGINS
-babeltrace_bin_LDFLAGS += -Wl,--whole-archive,$(top_builddir)/plugins/ctf/.libs/libbabeltrace-plugin-ctf.a,$(top_builddir)/plugins/text/.libs/libbabeltrace-plugin-ctf-text.a,$(top_builddir)/plugins/muxer/.libs/libbabeltrace-plugin-muxer.a,$(top_builddir)/plugins/writer/.libs/libbabeltrace-plugin-ctf-writer.a,--no-whole-archive
+if ENABLE_BUILT_IN_PLUGINS
+# Takes a plugin name and outputs the needed LDFLAGS to embed it.
+#
+# The --whole-archive option is important here. From the GNU linker's
+# documentation:
+#
+#     For each archive mentioned on the command line after the
+#     --whole-archive option, include every object file in the archive in
+#     the link, rather than searching the archive for the required object
+#     files.
+#
+# In our case, we find the plugins thanks to special sections in the
+# binary that are filled by plugin objects. If the linker discards those
+# symbols because the CLI does not use them directly, the CLI reports
+# no plugins found (plugins are effectively not embedded).
+pluginarchive = -Wl,--whole-archive,$(PLUGINS_PATH)/$(1)/.libs/babeltrace-plugin-$(1).a,--no-whole-archive
+
+# Built-in plugins
+babeltrace_bin_LDFLAGS += $(call pluginarchive,ctf)
+babeltrace_bin_LDFLAGS += $(call pluginarchive,text)
+babeltrace_bin_LDFLAGS += $(call pluginarchive,utils)
+
+if ENABLE_DEBUG_INFO
+babeltrace_bin_LDFLAGS += $(call pluginarchive,lttng-utils)
+endif
 endif
 
 if BABELTRACE_BUILD_WITH_MINGW
-babeltrace_bin_LDADD += -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
@@ -40,3 +84,15 @@ babeltrace_SOURCES = $(babeltrace_bin_SOURCES)
 babeltrace_LDFLAGS = $(babeltrace_bin_LDFLAGS)
 babeltrace_LDADD =     $(babeltrace_bin_LDADD)
 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 \
+       $(POPT_LIBS)
+babeltrace_log_bin_CFLAGS = $(AM_CFLAGS) '-DBT_CLI_PATH="$(abs_top_builddir)/cli/babeltrace$(EXEEXT)"'
+
+# 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)"'
This page took 0.024913 seconds and 4 git commands to generate.