Fix: always use git describe --all --long for the git version
[lttng-tools.git] / include / Makefile.am
CommitLineData
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##
6version.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 ... "
aa3acc4e 12 @(version_h_tmpl="$(top_srcdir)/include/version.h.tmpl"; \
88564da0
RB
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)"; \
ed343076 24 if [ "$${git_branch}" == "$${git_describe}" ]; then \
88564da0
RB
25 git_version="$${git_describe}"; \
26 else \
27 git_version="$$(git describe --long --all)"; \
28 fi; \
29 fi; \
30 ##
31 ## If the version.h file doesn't exist or is not up to date,
32 ## We replace it by the version.h.tmpl file
33 ##
34 if [ ! -e "$${version_h}" ] || \
35 [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \
36 cp "$${version_h_tmpl}" "$${version_h}"; \
37 fi; \
38 if [ -n "$${git_version}" ]; then \
39 ##
40 ## We remove the leading "v" for the version number
41 ##
42 git_version="$$(echo "$${git_version}" | sed -r "s/^v([0-9])/\1/")"; \
43 ##
44 ## If we have a git version, we verify that it isn't the same
45 ## as the one currently in the file (if there is one), as we
46 ## don't want to update the file if it is already up to date
47 ##
ceb6ba51
DG
48 if [ $$(grep -cE "^#define GIT_VERSION_SED \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
49 sed -i "s'^#define GIT_VERSION_SED.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
88564da0
RB
50 fi; \
51 fi; \
52 fi)
53 @echo "ok"
54
55##
56## version.h is defined as a .PHONY file even if it's a real file as
57## we want our routine to be runned for each build.
58##
59.PHONY: version.h
60
55d09795 61lttnginclude_HEADERS = \
d74df422 62 lttng/health.h \
55d09795 63 lttng/lttng.h \
1239a312
DG
64 lttng/constant.h \
65 lttng/channel.h \
66 lttng/domain.h \
67 lttng/event.h \
68 lttng/handle.h \
69 lttng/session.h \
55d09795 70 lttng/lttng-error.h \
00c76cea 71 lttng/snapshot.h \
88564da0 72 lttng/save.h \
9245bd0e 73 lttng/load.h \
88564da0 74 version.h
da3c9ec1 75
55d09795
MD
76noinst_HEADERS = \
77 lttng/snapshot-internal.h \
00c76cea 78 lttng/health-internal.h \
9245bd0e
DG
79 lttng/save-internal.h \
80 lttng/load-internal.h
This page took 0.026991 seconds and 4 git commands to generate.