diff options
| author | Jiri Olsa <jolsa@redhat.com> | 2013-12-03 08:09:17 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-04 13:17:16 -0500 |
| commit | e0e96d03f004e8953a731053b61e275f276fff01 (patch) | |
| tree | 8b1d03d684ef8769484ae25725d3dce04adcd049 /tools/lib/traceevent/Makefile | |
| parent | c877bbd8eceb14c5eac6779cc804fa8b34044736 (diff) | |
tools lib traceevent: Add plugin build support
Backporting missing pieces of plugin building infrastructure:
- Adding Makefile 'plugins' target to build all
defined plugins
- Adding Makefile 'install_plugins' target as 'install_lib'
target dependency
- Link plugin objects with shared object building
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
Plugins are by default installed into following locations:
'$(HOME)/.traceevent/plugins'
- If we are installing under $(HOME)
'$(prefix)/lib/traceevent/plugins'
- Otherwise
This path is propagated to the plugin object as a plugins search path.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1386076182-14484-4-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/traceevent/Makefile')
| -rw-r--r-- | tools/lib/traceevent/Makefile | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 2ccb5bc800e8..15267988f6b6 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile | |||
| @@ -43,6 +43,30 @@ man_dir_SQ = '$(subst ','\'',$(man_dir))' | |||
| 43 | export man_dir man_dir_SQ INSTALL | 43 | export man_dir man_dir_SQ INSTALL |
| 44 | export DESTDIR DESTDIR_SQ | 44 | export DESTDIR DESTDIR_SQ |
| 45 | 45 | ||
| 46 | set_plugin_dir := 1 | ||
| 47 | |||
| 48 | # Set plugin_dir to preffered global plugin location | ||
| 49 | # If we install under $HOME directory we go under | ||
| 50 | # $(HOME)/.traceevent/plugins | ||
| 51 | # | ||
| 52 | # We dont set PLUGIN_DIR in case we install under $HOME | ||
| 53 | # directory, because by default the code looks under: | ||
| 54 | # $(HOME)/.traceevent/plugins by default. | ||
| 55 | # | ||
| 56 | ifeq ($(plugin_dir),) | ||
| 57 | ifeq ($(prefix),$(HOME)) | ||
| 58 | override plugin_dir = $(HOME)/.traceevent/plugins | ||
| 59 | set_plugin_dir := 0 | ||
| 60 | else | ||
| 61 | override plugin_dir = $(prefix)/lib/traceevent/plugins | ||
| 62 | endif | ||
| 63 | endif | ||
| 64 | |||
| 65 | ifeq ($(set_plugin_dir),1) | ||
| 66 | PLUGIN_DIR = -DPLUGIN_DIR="$(DESTDIR)/$(plugin_dir)" | ||
| 67 | PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))' | ||
| 68 | endif | ||
| 69 | |||
| 46 | # copy a bit from Linux kbuild | 70 | # copy a bit from Linux kbuild |
| 47 | 71 | ||
| 48 | ifeq ("$(origin V)", "command line") | 72 | ifeq ("$(origin V)", "command line") |
| @@ -96,6 +120,7 @@ export prefix bindir src obj | |||
| 96 | # Shell quotes | 120 | # Shell quotes |
| 97 | bindir_SQ = $(subst ','\'',$(bindir)) | 121 | bindir_SQ = $(subst ','\'',$(bindir)) |
| 98 | bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) | 122 | bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) |
| 123 | plugin_dir_SQ = $(subst ','\'',$(plugin_dir)) | ||
| 99 | 124 | ||
| 100 | LIB_FILE = libtraceevent.a libtraceevent.so | 125 | LIB_FILE = libtraceevent.a libtraceevent.so |
| 101 | 126 | ||
| @@ -138,8 +163,8 @@ else | |||
| 138 | print_app_build = echo ' BUILD '$(OBJ); | 163 | print_app_build = echo ' BUILD '$(OBJ); |
| 139 | print_fpic_compile = echo ' CC FPIC '$(OBJ); | 164 | print_fpic_compile = echo ' CC FPIC '$(OBJ); |
| 140 | print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ); | 165 | print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ); |
| 141 | print_plugin_obj_compile = echo ' BUILD PLUGIN OBJ '$(OBJ); | 166 | print_plugin_obj_compile = echo ' CC FPIC '$(OBJ); |
| 142 | print_plugin_build = echo ' BUILD PLUGIN '$(OBJ); | 167 | print_plugin_build = echo ' BUILD PLUGIN '$(OBJ); |
| 143 | print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ); | 168 | print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ); |
| 144 | print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; | 169 | print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; |
| 145 | endif | 170 | endif |
| @@ -187,9 +212,11 @@ PEVENT_LIB_OBJS += parse-filter.o | |||
| 187 | PEVENT_LIB_OBJS += parse-utils.o | 212 | PEVENT_LIB_OBJS += parse-utils.o |
| 188 | PEVENT_LIB_OBJS += kbuffer-parse.o | 213 | PEVENT_LIB_OBJS += kbuffer-parse.o |
| 189 | 214 | ||
| 190 | ALL_OBJS = $(PEVENT_LIB_OBJS) | 215 | PLUGINS := $(PLUGIN_OBJS:.o=.so) |
| 216 | |||
| 217 | ALL_OBJS = $(PEVENT_LIB_OBJS) $(PLUGIN_OBJS) | ||
| 191 | 218 | ||
| 192 | CMD_TARGETS = $(LIB_FILE) | 219 | CMD_TARGETS = $(LIB_FILE) $(PLUGINS) |
| 193 | 220 | ||
| 194 | TARGETS = $(CMD_TARGETS) | 221 | TARGETS = $(CMD_TARGETS) |
| 195 | 222 | ||
| @@ -204,9 +231,17 @@ libtraceevent.so: $(PEVENT_LIB_OBJS) | |||
| 204 | libtraceevent.a: $(PEVENT_LIB_OBJS) | 231 | libtraceevent.a: $(PEVENT_LIB_OBJS) |
| 205 | $(Q)$(do_build_static_lib) | 232 | $(Q)$(do_build_static_lib) |
| 206 | 233 | ||
| 234 | plugins: $(PLUGINS) | ||
| 235 | |||
| 207 | $(PEVENT_LIB_OBJS): %.o: $(src)/%.c TRACEEVENT-CFLAGS | 236 | $(PEVENT_LIB_OBJS): %.o: $(src)/%.c TRACEEVENT-CFLAGS |
| 208 | $(Q)$(do_fpic_compile) | 237 | $(Q)$(do_fpic_compile) |
| 209 | 238 | ||
| 239 | $(PLUGIN_OBJS): %.o : $(src)/%.c | ||
| 240 | $(Q)$(do_compile_plugin_obj) | ||
| 241 | |||
| 242 | $(PLUGINS): %.so: %.o | ||
| 243 | $(Q)$(do_plugin_build) | ||
| 244 | |||
| 210 | define make_version.h | 245 | define make_version.h |
| 211 | (echo '/* This file is automatically generated. Do not modify. */'; \ | 246 | (echo '/* This file is automatically generated. Do not modify. */'; \ |
| 212 | echo \#define VERSION_CODE $(shell \ | 247 | echo \#define VERSION_CODE $(shell \ |
| @@ -294,9 +329,16 @@ define do_install | |||
| 294 | $(INSTALL) $1 '$(DESTDIR_SQ)$2' | 329 | $(INSTALL) $1 '$(DESTDIR_SQ)$2' |
| 295 | endef | 330 | endef |
| 296 | 331 | ||
| 297 | install_lib: all_cmd | 332 | install_lib: all_cmd install_plugins |
| 298 | $(Q)$(call do_install,$(LIB_FILE),$(bindir_SQ)) | 333 | $(Q)$(call do_install,$(LIB_FILE),$(bindir_SQ)) |
| 299 | 334 | ||
| 335 | PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) | ||
| 336 | |||
| 337 | $(PLUGINS_INSTALL): %.install : %.so force | ||
| 338 | $(Q)$(call do_install,$<,$(plugin_dir_SQ)) | ||
| 339 | |||
| 340 | install_plugins: $(PLUGINS_INSTALL) | ||
| 341 | |||
| 300 | install: install_lib | 342 | install: install_lib |
| 301 | 343 | ||
| 302 | clean: | 344 | clean: |
