diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-01-08 16:19:28 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-01-08 16:30:06 -0500 |
commit | 07570886eda25c6d30fa55d03e71e8e6e29ad082 (patch) | |
tree | 4079c463c47365b4c6cf429299bd64b1cc8938a5 | |
parent | 6b73f870603f04381542adfc3e90f64831299a0d (diff) |
trace-cmd/kernelshark: Implement versioning of the tools
Have the versions of the tools in the Makefile and automate the updating
of them when the numbers in the Makefile change.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 62 | ||||
-rw-r--r-- | kernel-shark.c | 11 | ||||
-rw-r--r-- | trace-cmd.c | 3 | ||||
-rw-r--r-- | trace-cmd.h | 2 | ||||
-rw-r--r-- | trace-output.c | 3 | ||||
-rw-r--r-- | version.h | 17 |
7 files changed, 88 insertions, 13 deletions
@@ -10,6 +10,7 @@ trace-graph | |||
10 | trace-view | 10 | trace-view |
11 | *.pyc | 11 | *.pyc |
12 | *.swp | 12 | *.swp |
13 | tc_version.h | ||
14 | ks_version.h | ||
13 | ctracecmd_wrap.c | 15 | ctracecmd_wrap.c |
14 | |||
15 | ctracecmdgui_wrap.c | 16 | ctracecmdgui_wrap.c |
@@ -1,3 +1,16 @@ | |||
1 | # trace-cmd version | ||
2 | TC_VERSION = 0 | ||
3 | TC_PATCHLEVEL = 6 | ||
4 | TC_EXTRAVERSION = | ||
5 | |||
6 | # Kernel Shark version | ||
7 | KS_VERSION = 0 | ||
8 | KS_PATCHLEVEL = 1 | ||
9 | KS_EXTRAVERSION = | ||
10 | |||
11 | # file format version | ||
12 | FILE_VERSION = 0 | ||
13 | |||
1 | CC = gcc | 14 | CC = gcc |
2 | AR = ar | 15 | AR = ar |
3 | EXT = -std=gnu99 | 16 | EXT = -std=gnu99 |
@@ -8,13 +21,27 @@ LIBS = -L. -ltracecmd -ldl | |||
8 | PACKAGES= gtk+-2.0 | 21 | PACKAGES= gtk+-2.0 |
9 | 22 | ||
10 | ifeq ($(BUILDGUI), 1) | 23 | ifeq ($(BUILDGUI), 1) |
11 | CONFIG_FLAGS = $(shell pkg-config --cflags $(PACKAGES)) \ | 24 | CONFIG_FLAGS = $(shell pkg-config --cflags $(PACKAGES)) -DBUILDGUI \ |
12 | -DGTK_VERSION=$(shell pkg-config --modversion gtk+-2.0 | \ | 25 | -DGTK_VERSION=$(shell pkg-config --modversion gtk+-2.0 | \ |
13 | awk 'BEGIN{FS="."}{ a = ($$1 * (2^16)) + $$2 * (2^8) + $$3; printf ("%d", a);}') | 26 | awk 'BEGIN{FS="."}{ a = ($$1 * (2^16)) + $$2 * (2^8) + $$3; printf ("%d", a);}') |
14 | 27 | ||
15 | CONFIG_LIBS = $(shell pkg-config --libs $(PACKAGES)) | 28 | CONFIG_LIBS = $(shell pkg-config --libs $(PACKAGES)) |
29 | |||
30 | VERSION = $(KS_VERSION) | ||
31 | PATCHLEVEL = $(KS_PATCHLEVEL) | ||
32 | EXTRAVERSION = $(KS_EXTRAVERSION) | ||
33 | |||
34 | else | ||
35 | |||
36 | VERSION = $(TC_VERSION) | ||
37 | PATCHLEVEL = $(TC_PATCHLEVEL) | ||
38 | EXTRAVERSION = $(TC_EXTRAVERSION) | ||
39 | |||
16 | endif | 40 | endif |
17 | 41 | ||
42 | TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION) | ||
43 | KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION) | ||
44 | |||
18 | CFLAGS = -g -Wall $(CONFIG_FLAGS) | 45 | CFLAGS = -g -Wall $(CONFIG_FLAGS) |
19 | 46 | ||
20 | %.o: %.c | 47 | %.o: %.c |
@@ -23,9 +50,9 @@ CFLAGS = -g -Wall $(CONFIG_FLAGS) | |||
23 | PLUGINS = plugin_hrtimer.so plugin_mac80211.so plugin_sched_switch.so \ | 50 | PLUGINS = plugin_hrtimer.so plugin_mac80211.so plugin_sched_switch.so \ |
24 | plugin_kmem.so | 51 | plugin_kmem.so |
25 | 52 | ||
26 | CMD_TARGETS = libparsevent.a libtracecmd.a trace-cmd $(PLUGINS) | 53 | CMD_TARGETS = libparsevent.a libtracecmd.a trace-cmd $(PLUGINS) tc_version.h |
27 | 54 | ||
28 | GUI_TARGETS = trace-graph trace-view kernelshark | 55 | GUI_TARGETS = trace-graph trace-view kernelshark ks_version.h |
29 | 56 | ||
30 | ### | 57 | ### |
31 | # Default we just build trace-cmd | 58 | # Default we just build trace-cmd |
@@ -45,7 +72,7 @@ LIB_FILE = libtracecmd.a | |||
45 | HEADERS = parse-events.h trace-cmd.h trace-local.h trace-hash.h | 72 | HEADERS = parse-events.h trace-cmd.h trace-local.h trace-hash.h |
46 | 73 | ||
47 | trace-read.o:: $(HEADERS) | 74 | trace-read.o:: $(HEADERS) |
48 | trace-cmd.o:: $(HEADERS) $(LIB_FILE) | 75 | trace-cmd.o:: $(HEADERS) $(LIB_FILE) tc_version.h |
49 | trace-util.o:: $(HEADERS) | 76 | trace-util.o:: $(HEADERS) |
50 | trace-ftrace.o:: $(HEADERS) | 77 | trace-ftrace.o:: $(HEADERS) |
51 | trace-input.o:: $(HEADERS) | 78 | trace-input.o:: $(HEADERS) |
@@ -55,7 +82,7 @@ trace-view-main.o:: $(HEADERS) trace-view-store.h trace-view.h libtracecmd.a | |||
55 | trace-filter.o:: $(HEADERS) | 82 | trace-filter.o:: $(HEADERS) |
56 | trace-graph.o:: $(HEADERS) trace-graph.h | 83 | trace-graph.o:: $(HEADERS) trace-graph.h |
57 | trace-graph-main.o:: $(HEADERS) trace-graph.h libtracecmd.a | 84 | trace-graph-main.o:: $(HEADERS) trace-graph.h libtracecmd.a |
58 | kernel-shark.o:: $(HEADERS) kernel-shark.h libtracecmd.a | 85 | kernel-shark.o:: $(HEADERS) kernel-shark.h libtracecmd.a ks_version.h |
59 | 86 | ||
60 | TRACE_VIEW_OBJS = trace-view.o trace-view-store.o trace-filter.o trace-compat.o \ | 87 | TRACE_VIEW_OBJS = trace-view.o trace-view-store.o trace-filter.o trace-compat.o \ |
61 | trace-hash.o | 88 | trace-hash.o |
@@ -150,6 +177,31 @@ plugin_mac80211.so: plugin_mac80211.o | |||
150 | $(CC) -shared -nostartfiles -o $@ $< | 177 | $(CC) -shared -nostartfiles -o $@ $< |
151 | 178 | ||
152 | 179 | ||
180 | define make_version.h | ||
181 | @(echo \#define VERSION_CODE $(shell \ | ||
182 | expr $(VERSION) \* 256 + $(PATCHLEVEL)); \ | ||
183 | echo '#define EXTRAVERSION ' $(EXTRAVERSION); \ | ||
184 | echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)'"'; \ | ||
185 | echo '#define FILE_VERSION '$(FILE_VERSION); \ | ||
186 | ) > $1 | ||
187 | endef | ||
188 | |||
189 | define update_version.h | ||
190 | $(call make_version.h, $@.tmp); \ | ||
191 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | ||
192 | rm -f $@.tmp; \ | ||
193 | else \ | ||
194 | echo ' UPD $@'; \ | ||
195 | mv -f $@.tmp $@; \ | ||
196 | fi; | ||
197 | endef | ||
198 | |||
199 | ks_version.h: force | ||
200 | $(call update_version.h) | ||
201 | |||
202 | tc_version.h: force | ||
203 | $(call update_version.h) | ||
204 | |||
153 | PYTHON_INCLUDES = `python-config --includes` | 205 | PYTHON_INCLUDES = `python-config --includes` |
154 | PYGTK_CFLAGS = `pkg-config --cflags pygtk-2.0` | 206 | PYGTK_CFLAGS = `pkg-config --cflags pygtk-2.0` |
155 | 207 | ||
diff --git a/kernel-shark.c b/kernel-shark.c index 533a8af..8820109 100644 --- a/kernel-shark.c +++ b/kernel-shark.c | |||
@@ -31,8 +31,7 @@ | |||
31 | #include "trace-compat.h" | 31 | #include "trace-compat.h" |
32 | #include "trace-cmd.h" | 32 | #include "trace-cmd.h" |
33 | #include "kernel-shark.h" | 33 | #include "kernel-shark.h" |
34 | 34 | #include "version.h" | |
35 | #define version "0.1.1" | ||
36 | 35 | ||
37 | #define DEBUG_LEVEL 0 | 36 | #define DEBUG_LEVEL 0 |
38 | #if DEBUG_LEVEL > 0 | 37 | #if DEBUG_LEVEL > 0 |
@@ -55,6 +54,7 @@ void usage(char *prog) | |||
55 | { | 54 | { |
56 | printf("Usage: %s\n", prog); | 55 | printf("Usage: %s\n", prog); |
57 | printf(" -h Display this help message\n"); | 56 | printf(" -h Display this help message\n"); |
57 | printf(" -v Display version and exit\n"); | ||
58 | printf(" -i input_file, default is %s\n", default_input_file); | 58 | printf(" -i input_file, default is %s\n", default_input_file); |
59 | } | 59 | } |
60 | 60 | ||
@@ -520,11 +520,16 @@ void kernel_shark(int argc, char **argv) | |||
520 | GtkWidget *spin; | 520 | GtkWidget *spin; |
521 | int c; | 521 | int c; |
522 | 522 | ||
523 | while ((c = getopt(argc, argv, "hi:")) != -1) { | 523 | while ((c = getopt(argc, argv, "hvi:")) != -1) { |
524 | switch(c) { | 524 | switch(c) { |
525 | case 'h': | 525 | case 'h': |
526 | usage(basename(argv[0])); | 526 | usage(basename(argv[0])); |
527 | return; | 527 | return; |
528 | case 'v': | ||
529 | printf("%s - %s\n", | ||
530 | basename(argv[0]), | ||
531 | VERSION_STRING); | ||
532 | return; | ||
528 | case 'i': | 533 | case 'i': |
529 | input_file = optarg; | 534 | input_file = optarg; |
530 | break; | 535 | break; |
diff --git a/trace-cmd.c b/trace-cmd.c index b755ebe..45d8568 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <errno.h> | 34 | #include <errno.h> |
35 | 35 | ||
36 | #include "trace-local.h" | 36 | #include "trace-local.h" |
37 | #include "version.h" | ||
37 | 38 | ||
38 | #define _STR(x) #x | 39 | #define _STR(x) #x |
39 | #define STR(x) _STR(x) | 40 | #define STR(x) _STR(x) |
@@ -753,7 +754,7 @@ void usage(char **argv) | |||
753 | " -e list available events\n" | 754 | " -e list available events\n" |
754 | " -p list available plugins\n" | 755 | " -p list available plugins\n" |
755 | " -o list available options\n" | 756 | " -o list available options\n" |
756 | "\n", p, TRACECMD_VERSION, p, p, p, p, p, p, p); | 757 | "\n", p, VERSION_STRING, p, p, p, p, p, p, p); |
757 | exit(-1); | 758 | exit(-1); |
758 | } | 759 | } |
759 | 760 | ||
diff --git a/trace-cmd.h b/trace-cmd.h index d0b5c92..2c46ac8 100644 --- a/trace-cmd.h +++ b/trace-cmd.h | |||
@@ -4,8 +4,6 @@ | |||
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include "parse-events.h" | 5 | #include "parse-events.h" |
6 | 6 | ||
7 | #define TRACECMD_VERSION "0.5" | ||
8 | |||
9 | void parse_cmdlines(struct pevent *pevent, char *file, int size); | 7 | void parse_cmdlines(struct pevent *pevent, char *file, int size); |
10 | void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size); | 8 | void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size); |
11 | void parse_ftrace_printk(char *file, unsigned int size); | 9 | void parse_ftrace_printk(char *file, unsigned int size); |
diff --git a/trace-output.c b/trace-output.c index 8f21fe4..66f95fb 100644 --- a/trace-output.c +++ b/trace-output.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <errno.h> | 17 | #include <errno.h> |
18 | 18 | ||
19 | #include "trace-cmd.h" | 19 | #include "trace-cmd.h" |
20 | #include "version.h" | ||
20 | 21 | ||
21 | struct tracecmd_output { | 22 | struct tracecmd_output { |
22 | int fd; | 23 | int fd; |
@@ -520,7 +521,7 @@ static struct tracecmd_output *create_file(const char *output_file, int cpus) | |||
520 | if (do_write_check(handle, buf, 10)) | 521 | if (do_write_check(handle, buf, 10)) |
521 | goto out_free; | 522 | goto out_free; |
522 | 523 | ||
523 | if (do_write_check(handle, TRACECMD_VERSION, strlen(TRACECMD_VERSION) + 1)) | 524 | if (do_write_check(handle, FILE_VERSION_STRING, strlen(FILE_VERSION_STRING) + 1)) |
524 | goto out_free; | 525 | goto out_free; |
525 | 526 | ||
526 | /* save endian */ | 527 | /* save endian */ |
diff --git a/version.h b/version.h new file mode 100644 index 0000000..68ce79e --- /dev/null +++ b/version.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _VERSION_H | ||
2 | #define _VERSION_H | ||
3 | |||
4 | #define VERSION(a, b) (((a) << 8) + (b)) | ||
5 | |||
6 | #ifdef BUILDGUI | ||
7 | #include "ks_version.h" | ||
8 | #else | ||
9 | #include "tc_version.h" | ||
10 | #endif | ||
11 | |||
12 | #define _STR(x) #x | ||
13 | #define STR(x) _STR(x) | ||
14 | |||
15 | #define FILE_VERSION_STRING STR(FILE_VERSION) | ||
16 | |||
17 | #endif /* _VERSION_H */ | ||