Commit | Line | Data |
---|---|---|
88564da0 RB |
1 | ## |
2 | ## The version.h file must be verified and generated or updated if the | |
3 | ## git commit id (called git version here) changed since the last build | |
4 | ## of lttng-tools. | |
5 | ## | |
6 | version.h: | |
7 | ## | |
8 | ## We first create variables for the current git version and | |
9 | ## the locations of the version.h and version.h.tmpl files | |
10 | ## | |
11 | @echo -n "Generating version.h ... " | |
12 | @(version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \ | |
13 | if [ -f "$${version_h_tmpl}" ]; then \ | |
14 | version_h="$(top_builddir)/include/version.h"; \ | |
15 | ## | |
16 | ## We check the git version format we will use depending on | |
17 | ## whether or not we are in the master branch or on a tag | |
18 | ## | |
19 | git_branch="$$(git describe --all 2>/dev/null)"; \ | |
20 | if [ -z "$${git_branch}" ]; then \ | |
21 | git_version=""; \ | |
22 | else \ | |
23 | git_describe="$$(git describe)"; \ | |
24 | if [ "$${git_branch}" == "$${git_describe}" ] || \ | |
25 | [ "$${git_branch}" == "heads/master" ]; then \ | |
26 | git_version="$${git_describe}"; \ | |
27 | else \ | |
28 | git_version="$$(git describe --long --all)"; \ | |
29 | fi; \ | |
30 | fi; \ | |
31 | ## | |
32 | ## If the version.h file doesn't exist or is not up to date, | |
33 | ## We replace it by the version.h.tmpl file | |
34 | ## | |
35 | if [ ! -e "$${version_h}" ] || \ | |
36 | [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \ | |
37 | cp "$${version_h_tmpl}" "$${version_h}"; \ | |
38 | fi; \ | |
39 | if [ -n "$${git_version}" ]; then \ | |
40 | ## | |
41 | ## We remove the leading "v" for the version number | |
42 | ## | |
43 | git_version="$$(echo "$${git_version}" | sed -r "s/^v([0-9])/\1/")"; \ | |
44 | ## | |
45 | ## If we have a git version, we verify that it isn't the same | |
46 | ## as the one currently in the file (if there is one), as we | |
47 | ## don't want to update the file if it is already up to date | |
48 | ## | |
49 | if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ | |
50 | if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ | |
51 | ## | |
52 | ## If there is already a GIT_VERSION defined, | |
53 | ## we just replace it by the new version | |
54 | ## | |
55 | sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ | |
56 | else \ | |
57 | ## | |
58 | ## Else, we add a GIT_VERSION define | |
59 | ## containing our new version. | |
60 | ## | |
61 | sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ | |
62 | fi; \ | |
63 | fi; \ | |
64 | fi; \ | |
65 | fi) | |
66 | @echo "ok" | |
67 | ||
68 | ## | |
69 | ## version.h is defined as a .PHONY file even if it's a real file as | |
70 | ## we want our routine to be runned for each build. | |
71 | ## | |
72 | .PHONY: version.h | |
73 | ||
55d09795 | 74 | lttnginclude_HEADERS = \ |
d74df422 | 75 | lttng/health.h \ |
55d09795 MD |
76 | lttng/lttng.h \ |
77 | lttng/lttng-error.h \ | |
00c76cea | 78 | lttng/snapshot.h \ |
88564da0 RB |
79 | lttng/save.h \ |
80 | version.h | |
da3c9ec1 | 81 | |
55d09795 MD |
82 | noinst_HEADERS = \ |
83 | lttng/snapshot-internal.h \ | |
00c76cea JG |
84 | lttng/health-internal.h \ |
85 | lttng/save-internal.h |