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