1 # SPDX-FileCopyrightText: 2019-2023 EfficiOS, Inc.
2 # SPDX-License-Identifier: MIT
4 PLUGINS_PATH = $(abs_top_builddir)/src/plugins
5 LTTNG_UTILS_PLUGIN_PATH =
8 LTTNG_UTILS_PLUGIN_PATH += :$(PLUGINS_PATH)/lttng-utils
11 if BABELTRACE_BUILD_WITH_MINGW
12 IN_TREE_PLUGIN_PATH := $(shell cygpath -pm "$(PLUGINS_PATH)/ctf:$(PLUGINS_PATH)/text:$(PLUGINS_PATH)/utils$(LTTNG_UTILS_PLUGIN_PATH)")
14 IN_TREE_PLUGIN_PATH = $(PLUGINS_PATH)/ctf:$(PLUGINS_PATH)/text:$(PLUGINS_PATH)/utils$(LTTNG_UTILS_PLUGIN_PATH)
17 AM_CPPFLAGS += '-DCONFIG_IN_TREE_PLUGIN_PATH="$(IN_TREE_PLUGIN_PATH)"'
19 if ENABLE_PYTHON_PLUGINS
20 AM_CPPFLAGS += '-DCONFIG_IN_TREE_PROVIDER_DIR="$(abs_top_builddir)/src/python-plugin-provider/.libs"'
23 bin_PROGRAMS = babeltrace2.bin
24 noinst_PROGRAMS = babeltrace2
26 babeltrace2_bin_SOURCES = \
30 babeltrace2-cfg-cli-args.c \
31 babeltrace2-cfg-cli-args.h \
32 babeltrace2-cfg-cli-args-connect.c \
33 babeltrace2-cfg-cli-args-connect.h \
34 babeltrace2-cfg-cli-args-default.h \
35 babeltrace2-cfg-cli-args-default.c \
36 babeltrace2-log-level.c \
37 babeltrace2-log-level.h \
38 babeltrace2-plugins.c \
39 babeltrace2-plugins.h \
45 # -Wl,--no-as-needed is needed for recent gold linker who seems to think
46 # it knows better and considers libraries with constructors having
47 # side-effects as dead code.
48 babeltrace2_bin_LDFLAGS = $(AM_LDFLAGS) $(LD_NO_AS_NEEDED)
50 EXTRA_babeltrace2_bin_DEPENDENCIES =
52 # Add all the convenience libraries used by Babeltrace plugins and the
53 # library. They will be used when embedding plugins (--enable-built-in-plugins),
54 # otherwise we're looking after multiple definitions of the same symbols if
55 # a plugin's archive (.a) includes the convenience library because
56 # we're using --whole-archive below (needed to make sure the linker does
57 # not discard the plugins since the CLI does not use their symbols
59 babeltrace2_bin_LDADD = \
60 $(top_builddir)/src/argpar/libargpar.la \
61 $(top_builddir)/src/autodisc/libautodisc.la \
62 $(top_builddir)/src/param-parse/libparam-parse.la \
63 $(top_builddir)/src/string-format/libstring-format.la \
64 $(top_builddir)/src/lib/libbabeltrace2.la \
65 $(top_builddir)/src/compat/libcompat.la \
66 $(top_builddir)/src/common/libcommon.la \
67 $(top_builddir)/src/cpp-common/vendor/fmt/libfmt.la \
68 $(top_builddir)/src/logging/liblogging.la \
69 $(top_builddir)/src/ctfser/libctfser.la
71 if ENABLE_BUILT_IN_PLUGINS
72 # Takes a plugin name and outputs the needed LDFLAGS to embed it.
74 # The --whole-archive option is important here. From the GNU linker's
77 # For each archive mentioned on the command line after the
78 # --whole-archive option, include every object file in the archive in
79 # the link, rather than searching the archive for the required object
82 # In our case, we find the plugins thanks to special sections in the
83 # binary that are filled by plugin objects. If the linker discards those
84 # symbols because the CLI does not use them directly, the CLI reports
85 # no plugins found (plugins are effectively not embedded).
86 pluginarchive = $(LD_WHOLE_ARCHIVE)$(PLUGINS_PATH)/$(1)/.libs/babeltrace-plugin-$(1).a$(LD_NO_WHOLE_ARCHIVE)
89 babeltrace2_bin_LDFLAGS += $(call pluginarchive,ctf)
90 babeltrace2_bin_LDFLAGS += $(call pluginarchive,text)
91 babeltrace2_bin_LDFLAGS += $(call pluginarchive,utils)
93 EXTRA_babeltrace2_bin_DEPENDENCIES += \
94 $(PLUGINS_PATH)/ctf/babeltrace-plugin-ctf.la \
95 $(PLUGINS_PATH)/text/babeltrace-plugin-text.la \
96 $(PLUGINS_PATH)/utils/babeltrace-plugin-utils.la
99 babeltrace2_bin_LDFLAGS += $(call pluginarchive,lttng-utils)
100 babeltrace2_bin_LDADD += $(ELFUTILS_LIBS)
102 EXTRA_babeltrace2_bin_DEPENDENCIES += \
103 $(PLUGINS_PATH)/lttng-utils/babeltrace-plugin-lttng-utils.la
107 if BABELTRACE_BUILD_WITH_MINGW
108 babeltrace2_bin_LDADD += -lws2_32 -lrpcrt4 -lintl -liconv -lole32 -lpthread
111 # Only used for in-tree execution and tests
112 babeltrace2_SOURCES = $(babeltrace2_bin_SOURCES)
113 babeltrace2_LDFLAGS = $(babeltrace2_bin_LDFLAGS)
114 babeltrace2_LDADD = $(babeltrace2_bin_LDADD)
115 babeltrace2_CFLAGS = $(AM_CFLAGS) -DBT_SET_DEFAULT_IN_TREE_CONFIGURATION
116 EXTRA_babeltrace2_DEPENDENCIES = $(EXTRA_babeltrace2_bin_DEPENDENCIES)