aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-01-08 16:19:28 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-01-08 16:30:06 -0500
commit07570886eda25c6d30fa55d03e71e8e6e29ad082 (patch)
tree4079c463c47365b4c6cf429299bd64b1cc8938a5
parent6b73f870603f04381542adfc3e90f64831299a0d (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--.gitignore3
-rw-r--r--Makefile62
-rw-r--r--kernel-shark.c11
-rw-r--r--trace-cmd.c3
-rw-r--r--trace-cmd.h2
-rw-r--r--trace-output.c3
-rw-r--r--version.h17
7 files changed, 88 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 2f8bf85..8e8f5a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ trace-graph
10trace-view 10trace-view
11*.pyc 11*.pyc
12*.swp 12*.swp
13tc_version.h
14ks_version.h
13ctracecmd_wrap.c 15ctracecmd_wrap.c
14
15ctracecmdgui_wrap.c 16ctracecmdgui_wrap.c
diff --git a/Makefile b/Makefile
index 125cb8b..28a7270 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,16 @@
1# trace-cmd version
2TC_VERSION = 0
3TC_PATCHLEVEL = 6
4TC_EXTRAVERSION =
5
6# Kernel Shark version
7KS_VERSION = 0
8KS_PATCHLEVEL = 1
9KS_EXTRAVERSION =
10
11# file format version
12FILE_VERSION = 0
13
1CC = gcc 14CC = gcc
2AR = ar 15AR = ar
3EXT = -std=gnu99 16EXT = -std=gnu99
@@ -8,13 +21,27 @@ LIBS = -L. -ltracecmd -ldl
8PACKAGES= gtk+-2.0 21PACKAGES= gtk+-2.0
9 22
10ifeq ($(BUILDGUI), 1) 23ifeq ($(BUILDGUI), 1)
11CONFIG_FLAGS = $(shell pkg-config --cflags $(PACKAGES)) \ 24CONFIG_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
15CONFIG_LIBS = $(shell pkg-config --libs $(PACKAGES)) 28CONFIG_LIBS = $(shell pkg-config --libs $(PACKAGES))
29
30VERSION = $(KS_VERSION)
31PATCHLEVEL = $(KS_PATCHLEVEL)
32EXTRAVERSION = $(KS_EXTRAVERSION)
33
34else
35
36VERSION = $(TC_VERSION)
37PATCHLEVEL = $(TC_PATCHLEVEL)
38EXTRAVERSION = $(TC_EXTRAVERSION)
39
16endif 40endif
17 41
42TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
43KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION)
44
18CFLAGS = -g -Wall $(CONFIG_FLAGS) 45CFLAGS = -g -Wall $(CONFIG_FLAGS)
19 46
20%.o: %.c 47%.o: %.c
@@ -23,9 +50,9 @@ CFLAGS = -g -Wall $(CONFIG_FLAGS)
23PLUGINS = plugin_hrtimer.so plugin_mac80211.so plugin_sched_switch.so \ 50PLUGINS = plugin_hrtimer.so plugin_mac80211.so plugin_sched_switch.so \
24 plugin_kmem.so 51 plugin_kmem.so
25 52
26CMD_TARGETS = libparsevent.a libtracecmd.a trace-cmd $(PLUGINS) 53CMD_TARGETS = libparsevent.a libtracecmd.a trace-cmd $(PLUGINS) tc_version.h
27 54
28GUI_TARGETS = trace-graph trace-view kernelshark 55GUI_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
45HEADERS = parse-events.h trace-cmd.h trace-local.h trace-hash.h 72HEADERS = parse-events.h trace-cmd.h trace-local.h trace-hash.h
46 73
47trace-read.o:: $(HEADERS) 74trace-read.o:: $(HEADERS)
48trace-cmd.o:: $(HEADERS) $(LIB_FILE) 75trace-cmd.o:: $(HEADERS) $(LIB_FILE) tc_version.h
49trace-util.o:: $(HEADERS) 76trace-util.o:: $(HEADERS)
50trace-ftrace.o:: $(HEADERS) 77trace-ftrace.o:: $(HEADERS)
51trace-input.o:: $(HEADERS) 78trace-input.o:: $(HEADERS)
@@ -55,7 +82,7 @@ trace-view-main.o:: $(HEADERS) trace-view-store.h trace-view.h libtracecmd.a
55trace-filter.o:: $(HEADERS) 82trace-filter.o:: $(HEADERS)
56trace-graph.o:: $(HEADERS) trace-graph.h 83trace-graph.o:: $(HEADERS) trace-graph.h
57trace-graph-main.o:: $(HEADERS) trace-graph.h libtracecmd.a 84trace-graph-main.o:: $(HEADERS) trace-graph.h libtracecmd.a
58kernel-shark.o:: $(HEADERS) kernel-shark.h libtracecmd.a 85kernel-shark.o:: $(HEADERS) kernel-shark.h libtracecmd.a ks_version.h
59 86
60TRACE_VIEW_OBJS = trace-view.o trace-view-store.o trace-filter.o trace-compat.o \ 87TRACE_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
180define 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
187endef
188
189define 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;
197endef
198
199ks_version.h: force
200 $(call update_version.h)
201
202tc_version.h: force
203 $(call update_version.h)
204
153PYTHON_INCLUDES = `python-config --includes` 205PYTHON_INCLUDES = `python-config --includes`
154PYGTK_CFLAGS = `pkg-config --cflags pygtk-2.0` 206PYGTK_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
9void parse_cmdlines(struct pevent *pevent, char *file, int size); 7void parse_cmdlines(struct pevent *pevent, char *file, int size);
10void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size); 8void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size);
11void parse_ftrace_printk(char *file, unsigned int size); 9void 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
21struct tracecmd_output { 22struct 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 */