| 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}" ]; then \ |
| 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 | ## |
| 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}"; \ |
| 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 | |
| 61 | lttnginclude_HEADERS = \ |
| 62 | lttng/health.h \ |
| 63 | lttng/lttng.h \ |
| 64 | lttng/constant.h \ |
| 65 | lttng/channel.h \ |
| 66 | lttng/domain.h \ |
| 67 | lttng/event.h \ |
| 68 | lttng/handle.h \ |
| 69 | lttng/session.h \ |
| 70 | lttng/lttng-error.h \ |
| 71 | lttng/snapshot.h \ |
| 72 | lttng/save.h \ |
| 73 | lttng/load.h \ |
| 74 | version.h |
| 75 | |
| 76 | noinst_HEADERS = \ |
| 77 | lttng/snapshot-internal.h \ |
| 78 | lttng/health-internal.h \ |
| 79 | lttng/save-internal.h \ |
| 80 | lttng/load-internal.h |