| 1 | ## SPDX-License-Identifier: GPL-2.0-only |
| 2 | ## |
| 3 | ## This target generates an include file that contains the git version |
| 4 | ## string of the current branch, it must be continuously updated when |
| 5 | ## we build in the git repo and shipped in dist tarballs to reflect the |
| 6 | ## status of the tree when it was generated. If the tree is clean and |
| 7 | ## the current commit is tag a starting with "v", consider this a |
| 8 | ## release version and set an empty git version. |
| 9 | ## |
| 10 | ## Here is what the inline script does: |
| 11 | ## |
| 12 | ## First, delete any stale "version.i.tmp" file. |
| 13 | ## |
| 14 | ## If "bootstrap" and ".git" exists in the top source directory and the git |
| 15 | ## executable is available, get the current git version string in the form: |
| 16 | ## |
| 17 | ## "latest_tag"(-"number_of_commits_on_top")(-g"latest_commit_hash")(-dirty) |
| 18 | ## |
| 19 | ## And store it in "version.i.tmp", if the current commit is tagged, the tag |
| 20 | ## starts with "v" and the tree is clean, consider this a release version and |
| 21 | ## overwrite the git version with an empty string in "version.i.tmp". |
| 22 | ## |
| 23 | ## If we don't have a "version.i.tmp" nor a "version.i", generate an empty |
| 24 | ## string as a failover. If a "version.i" is present, for example when building |
| 25 | ## from a distribution tarball, get the git_version using grep. |
| 26 | ## |
| 27 | ## Fetch the EXTRA_VERSION_NAME define from "version/extra_version_name" and output it |
| 28 | ## to "version.i.tmp". |
| 29 | ## |
| 30 | ## Fetch the EXTRA_VERSION_DESCRIPTION define from "version/extra_version_description", |
| 31 | ## sanitize and format it with a sed script to replace all non-alpha-numeric values |
| 32 | ## with "-" and join all lines by replacing "\n" with litteral string c-style "\n\t" and |
| 33 | ## output it to "version.i.tmp". |
| 34 | ## |
| 35 | ## Repeat the same logic for the "version/extra_patches" directory. |
| 36 | ## Data fetched from "version/extra_patches" must be sanitized and |
| 37 | ## formatted. |
| 38 | ## The data is fetched using "ls" with an ignore pattern for the README file. |
| 39 | ## The sanitize step uses sed with a script to replace all |
| 40 | ## non-alpha-numeric values, except " " (space), to "-". |
| 41 | ## The formatting step uses sed with a script to join all lines |
| 42 | ## by replacing "\n" with litteral string c-style "\n\t". |
| 43 | ## |
| 44 | ## If we don't have a "version.i" or we have both files (version.i, version.i.tmp) |
| 45 | ## and they are different, copy "version.i.tmp" over "version.i". |
| 46 | ## This way the dependent targets are only rebuilt when the git version |
| 47 | ## string or either one of extra version string change. |
| 48 | ## |
| 49 | version_verbose = $(version_verbose_@AM_V@) |
| 50 | version_verbose_ = $(version_verbose_@AM_DEFAULT_V@) |
| 51 | version_verbose_0 = @echo " GEN " $@; |
| 52 | |
| 53 | version.i: |
| 54 | $(version_verbose)rm -f version.i.tmp; \ |
| 55 | if (test ! -f version.i && test -f "$(top_srcdir)/include/version.i"); then \ |
| 56 | cp "$(top_srcdir)/include/version.i" version.i; \ |
| 57 | fi; \ |
| 58 | if (test -r "$(top_srcdir)/bootstrap" && test -r "$(top_srcdir)/.git") && \ |
| 59 | test -x "`which git 2>&1;true`"; then \ |
| 60 | GIT_VERSION_STR="`cd "$(top_srcdir)" && git describe --tags --dirty`"; \ |
| 61 | GIT_CURRENT_TAG="`cd "$(top_srcdir)" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null`"; \ |
| 62 | echo "#define GIT_VERSION \"$$GIT_VERSION_STR\"" > version.i.tmp; \ |
| 63 | if ! $(GREP) -- "-dirty" version.i.tmp > /dev/null && \ |
| 64 | test "x$$GIT_CURRENT_TAG" != "x"; then \ |
| 65 | echo "#define GIT_VERSION \"\"" > version.i.tmp; \ |
| 66 | fi; \ |
| 67 | fi; \ |
| 68 | if test ! -f version.i.tmp; then \ |
| 69 | if test -f version.i; then \ |
| 70 | $(GREP) "^#define \bGIT_VERSION\b.*" version.i > version.i.tmp; \ |
| 71 | else \ |
| 72 | echo '#define GIT_VERSION ""' > version.i.tmp; \ |
| 73 | fi; \ |
| 74 | fi; \ |
| 75 | echo "#define EXTRA_VERSION_NAME \"`$(SED) -n '1p' "$(top_srcdir)/version/extra_version_name" 2> /dev/null`\"" >> version.i.tmp; \ |
| 76 | echo "#define EXTRA_VERSION_DESCRIPTION \"`$(SED) -E ':a ; N ; $$!ba ; s/[^a-zA-Z0-9 \n\t\.,]/-/g ; s/\r{0,1}\n/\\\n\\\t/g' "$(top_srcdir)/version/extra_version_description" 2> /dev/null`\"" >> version.i.tmp; \ |
| 77 | echo "#define EXTRA_VERSION_PATCHES \"`ls --ignore='README' -1 "$(top_srcdir)/version/extra_patches" | $(SED) -E ':a ; N ; $$!ba ; s/[^a-zA-Z0-9 \n\t\.]/-/g ; s/\r{0,1}\n/\\\n\\\t/g' 2> /dev/null`\"" >> version.i.tmp; \ |
| 78 | if test ! -f version.i || \ |
| 79 | test x"`cat version.i.tmp`" != x"`cat version.i`"; then \ |
| 80 | mv version.i.tmp version.i; \ |
| 81 | fi; \ |
| 82 | rm -f version.i.tmp; \ |
| 83 | true |
| 84 | |
| 85 | ## |
| 86 | ## version.i is defined as a .PHONY target even if it's a real file, |
| 87 | ## we want the target to be re-run on every make. |
| 88 | ## |
| 89 | .PHONY: version.i |
| 90 | |
| 91 | CLEANFILES = version.i.tmp |
| 92 | |
| 93 | ## |
| 94 | ## Only clean "version.i" on dist-clean, we need to keep it on regular |
| 95 | ## clean when it's part of a dist tarball. |
| 96 | ## |
| 97 | DISTCLEANFILES = version.i |
| 98 | |
| 99 | lttnginclude_HEADERS = \ |
| 100 | lttng/health.h \ |
| 101 | lttng/lttng.h \ |
| 102 | lttng/constant.h \ |
| 103 | lttng/channel.h \ |
| 104 | lttng/domain.h \ |
| 105 | lttng/event.h \ |
| 106 | lttng/handle.h \ |
| 107 | lttng/session.h \ |
| 108 | lttng/lttng-error.h \ |
| 109 | lttng/snapshot.h \ |
| 110 | lttng/save.h \ |
| 111 | lttng/load.h \ |
| 112 | lttng/endpoint.h \ |
| 113 | lttng/rotation.h \ |
| 114 | lttng/location.h \ |
| 115 | lttng/userspace-probe.h \ |
| 116 | lttng/session-descriptor.h \ |
| 117 | lttng/destruction-handle.h \ |
| 118 | lttng/clear.h \ |
| 119 | lttng/clear-handle.h \ |
| 120 | lttng/tracker.h \ |
| 121 | lttng/kernel-probe.h |
| 122 | |
| 123 | lttngactioninclude_HEADERS= \ |
| 124 | lttng/action/action.h \ |
| 125 | lttng/action/group.h \ |
| 126 | lttng/action/notify.h \ |
| 127 | lttng/action/rotate-session.h \ |
| 128 | lttng/action/snapshot-session.h \ |
| 129 | lttng/action/start-session.h \ |
| 130 | lttng/action/stop-session.h |
| 131 | |
| 132 | lttngconditioninclude_HEADERS= \ |
| 133 | lttng/condition/condition.h \ |
| 134 | lttng/condition/buffer-usage.h \ |
| 135 | lttng/condition/session-consumed-size.h \ |
| 136 | lttng/condition/session-rotation.h \ |
| 137 | lttng/condition/evaluation.h |
| 138 | |
| 139 | lttngnotificationinclude_HEADERS= \ |
| 140 | lttng/notification/channel.h \ |
| 141 | lttng/notification/notification.h |
| 142 | |
| 143 | lttngtriggerinclude_HEADERS= \ |
| 144 | lttng/trigger/trigger.h |
| 145 | |
| 146 | lttngeventruleinclude_HEADERS= \ |
| 147 | lttng/event-rule/event-rule.h \ |
| 148 | lttng/event-rule/kprobe.h \ |
| 149 | lttng/event-rule/syscall.h \ |
| 150 | lttng/event-rule/uprobe.h \ |
| 151 | lttng/event-rule/tracepoint.h |
| 152 | |
| 153 | noinst_HEADERS = \ |
| 154 | lttng/snapshot-internal.h \ |
| 155 | lttng/health-internal.h \ |
| 156 | lttng/save-internal.h \ |
| 157 | lttng/load-internal.h \ |
| 158 | lttng/action/action-internal.h \ |
| 159 | lttng/action/group-internal.h \ |
| 160 | lttng/action/notify-internal.h \ |
| 161 | lttng/action/rotate-session-internal.h \ |
| 162 | lttng/action/snapshot-session-internal.h \ |
| 163 | lttng/action/start-session-internal.h \ |
| 164 | lttng/action/stop-session-internal.h \ |
| 165 | lttng/condition/condition-internal.h \ |
| 166 | lttng/condition/buffer-usage-internal.h \ |
| 167 | lttng/condition/session-consumed-size-internal.h \ |
| 168 | lttng/condition/evaluation-internal.h \ |
| 169 | lttng/condition/session-rotation-internal.h \ |
| 170 | lttng/notification/notification-internal.h \ |
| 171 | lttng/trigger/trigger-internal.h \ |
| 172 | lttng/endpoint-internal.h \ |
| 173 | lttng/notification/channel-internal.h \ |
| 174 | lttng/channel-internal.h \ |
| 175 | lttng/event-internal.h \ |
| 176 | lttng/rotate-internal.h \ |
| 177 | lttng/ref-internal.h \ |
| 178 | lttng/location-internal.h \ |
| 179 | lttng/userspace-probe-internal.h \ |
| 180 | lttng/session-internal.h \ |
| 181 | lttng/session-descriptor-internal.h \ |
| 182 | lttng/kernel-probe-internal.h \ |
| 183 | lttng/event-rule/event-rule-internal.h \ |
| 184 | lttng/event-rule/kprobe-internal.h \ |
| 185 | lttng/event-rule/syscall-internal.h \ |
| 186 | lttng/event-rule/uprobe-internal.h \ |
| 187 | lttng/event-rule/tracepoint-internal.h \ |
| 188 | version.h \ |
| 189 | version.i |