| 1 | PLUGINS_PATH = $(abs_top_builddir)/plugins |
| 2 | LTTNG_UTILS_PLUGIN_PATH = |
| 3 | |
| 4 | if ENABLE_DEBUG_INFO |
| 5 | LTTNG_UTILS_PLUGIN_PATH += :$(PLUGINS_PATH)/lttng-utils |
| 6 | endif |
| 7 | |
| 8 | IN_TREE_PLUGIN_PATH = $(PLUGINS_PATH)/ctf:$(PLUGINS_PATH)/text:$(PLUGINS_PATH)/utils$(LTTNG_UTILS_PLUGIN_PATH) |
| 9 | |
| 10 | AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include \ |
| 11 | '-DCONFIG_IN_TREE_PLUGIN_PATH="$(IN_TREE_PLUGIN_PATH)"' |
| 12 | AM_LDFLAGS = -lpopt |
| 13 | |
| 14 | bin_PROGRAMS = babeltrace.bin |
| 15 | noinst_PROGRAMS = babeltrace |
| 16 | #check_PROGRAMS = babeltrace |
| 17 | |
| 18 | babeltrace_bin_SOURCES = \ |
| 19 | babeltrace.c \ |
| 20 | babeltrace-cfg.c \ |
| 21 | babeltrace-cfg.h \ |
| 22 | babeltrace-cfg-cli-args.c \ |
| 23 | babeltrace-cfg-cli-args.h \ |
| 24 | babeltrace-cfg-cli-args-connect.c \ |
| 25 | babeltrace-cfg-cli-args-connect.h \ |
| 26 | babeltrace-cfg-cli-args-default.h \ |
| 27 | babeltrace-cfg-cli-args-default.c \ |
| 28 | logging.h |
| 29 | |
| 30 | # -Wl,--no-as-needed is needed for recent gold linker who seems to think |
| 31 | # it knows better and considers libraries with constructors having |
| 32 | # side-effects as dead code. |
| 33 | babeltrace_bin_LDFLAGS = $(LD_NO_AS_NEEDED) -Wl,-export-dynamic |
| 34 | |
| 35 | # Add all the convenience libraries used by Babeltrace plugins and the |
| 36 | # library. They will be used when embedding plugins (BUILT_IN_PLUGINS), |
| 37 | # otherwise we're looking after multiple definitions of the same symbols if |
| 38 | # a plugin's archive (.a) includes the convenience library because |
| 39 | # we're using --whole-archive below (needed to make sure the linker does |
| 40 | # not discard the plugins since the CLI does not use their symbols |
| 41 | # directly). |
| 42 | babeltrace_bin_LDADD = \ |
| 43 | $(top_builddir)/lib/libbabeltrace.la \ |
| 44 | $(top_builddir)/compat/libcompat.la \ |
| 45 | $(top_builddir)/common/libbabeltrace-common.la \ |
| 46 | $(top_builddir)/logging/libbabeltrace-logging.la \ |
| 47 | $(top_builddir)/plugins/libctfcopytrace/libctfcopytrace.la |
| 48 | |
| 49 | if BUILT_IN_PLUGINS |
| 50 | # Takes a plugin name and outputs the needed LDFLAGS to embed it. |
| 51 | # |
| 52 | # The --whole-archive option is important here. From the GNU linker's |
| 53 | # documentation: |
| 54 | # |
| 55 | # For each archive mentioned on the command line after the |
| 56 | # --whole-archive option, include every object file in the archive in |
| 57 | # the link, rather than searching the archive for the required object |
| 58 | # files. |
| 59 | # |
| 60 | # In our case, we find the plugins thanks to special sections in the |
| 61 | # binary that are filled by plugin objects. If the linker discards those |
| 62 | # symbols because the CLI does not use them directly, the CLI reports |
| 63 | # no plugins found (plugins are effectively not embedded). |
| 64 | pluginarchive = -Wl,--whole-archive,$(PLUGINS_PATH)/$(1)/.libs/libbabeltrace-plugin-$(1).a,--no-whole-archive |
| 65 | |
| 66 | # Built-in plugins |
| 67 | babeltrace_bin_LDFLAGS += $(call pluginarchive,ctf) |
| 68 | babeltrace_bin_LDFLAGS += $(call pluginarchive,text) |
| 69 | babeltrace_bin_LDFLAGS += $(call pluginarchive,utils) |
| 70 | |
| 71 | if ENABLE_DEBUG_INFO |
| 72 | babeltrace_bin_LDFLAGS += $(call pluginarchive,lttng-utils) |
| 73 | endif |
| 74 | endif |
| 75 | |
| 76 | if BABELTRACE_BUILD_WITH_MINGW |
| 77 | babeltrace_bin_LDADD += -lrpcrt4 -lintl -liconv -lole32 -lpopt -lpthread |
| 78 | endif |
| 79 | |
| 80 | # Only used for in-tree execution and tests |
| 81 | babeltrace_SOURCES = $(babeltrace_bin_SOURCES) |
| 82 | babeltrace_LDFLAGS = $(babeltrace_bin_LDFLAGS) |
| 83 | babeltrace_LDADD = $(babeltrace_bin_LDADD) |
| 84 | babeltrace_CFLAGS = $(AM_CFLAGS) -DBT_SET_DEFAULT_IN_TREE_CONFIGURATION |