d2061f1e05ea75bb7db8fd542dc683d19253bdca
[lttng-tools.git] / include / Makefile.am
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_srcdir)/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_SED \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
50 sed -i "s'^#define GIT_VERSION_SED.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
51 fi; \
52 fi; \
53 fi)
54 @echo "ok"
55
56 ##
57 ## version.h is defined as a .PHONY file even if it's a real file as
58 ## we want our routine to be runned for each build.
59 ##
60 .PHONY: version.h
61
62 lttnginclude_HEADERS = \
63 lttng/health.h \
64 lttng/lttng.h \
65 lttng/constant.h \
66 lttng/channel.h \
67 lttng/domain.h \
68 lttng/event.h \
69 lttng/handle.h \
70 lttng/session.h \
71 lttng/lttng-error.h \
72 lttng/snapshot.h \
73 lttng/save.h \
74 lttng/load.h \
75 version.h
76
77 noinst_HEADERS = \
78 lttng/snapshot-internal.h \
79 lttng/health-internal.h \
80 lttng/save-internal.h \
81 lttng/load-internal.h
This page took 0.033156 seconds and 5 git commands to generate.