| 1 | AM_CPPFLAGS += -DINSTALL_LIBDIR=\"$(libdir)\" |
| 2 | |
| 3 | noinst_LTLIBRARIES = libbabeltrace2-common.la |
| 4 | |
| 5 | libbabeltrace2_common_la_SOURCES = \ |
| 6 | assert.h \ |
| 7 | assert.c \ |
| 8 | common.c \ |
| 9 | common.h \ |
| 10 | logging.c \ |
| 11 | logging.h |
| 12 | |
| 13 | noinst_HEADERS = \ |
| 14 | align.h \ |
| 15 | babeltrace.h \ |
| 16 | list.h \ |
| 17 | mmap-align.h \ |
| 18 | version.h \ |
| 19 | version.i |
| 20 | |
| 21 | ## |
| 22 | ## This target generates an include file that contains the git version |
| 23 | ## string of the current branch, it must be continuously updated when |
| 24 | ## we build in the git repo and shipped in dist tarballs to reflect the |
| 25 | ## status of the tree when it was generated. If the tree is clean and |
| 26 | ## the current commit is tag a starting with "v", consider this a |
| 27 | ## release version and set an empty git version. |
| 28 | ## |
| 29 | ## Here is what the inline script does: |
| 30 | ## |
| 31 | ## First, delete any stale "version.i.tmp" file. |
| 32 | ## |
| 33 | ## If "bootstrap" and ".git" exists in the top source directory and the git |
| 34 | ## executable is available, get the current git version string in the form: |
| 35 | ## |
| 36 | ## "latest_tag"(-"number_of_commits_on_top")(-g"latest_commit_hash")(-dirty) |
| 37 | ## |
| 38 | ## And store it in "version.i.tmp", if the current commit is tagged, the tag |
| 39 | ## starts with "v" and the tree is clean, consider this a release version and |
| 40 | ## overwrite the git version with an empty string in "version.i.tmp". |
| 41 | ## |
| 42 | ## If we don't have a "version.i.tmp" nor a "version.i", generate an empty |
| 43 | ## string as a failover. |
| 44 | ## |
| 45 | ## If we don't have a "version.i" or we have both files and they are different, |
| 46 | ## copy "version.i.tmp" over "version.i". This way the dependent targets are |
| 47 | ## only rebuilt when the version string changes. |
| 48 | ## |
| 49 | |
| 50 | version_verbose = $(version_verbose_@AM_V@) |
| 51 | version_verbose_ = $(version_verbose_@AM_DEFAULT_V@) |
| 52 | version_verbose_0 = @echo " GEN " $@; |
| 53 | |
| 54 | version.i: |
| 55 | $(version_verbose)rm -f version.i.tmp; \ |
| 56 | if (test -r "$(top_srcdir)/bootstrap" && test -r "$(top_srcdir)/.git") && \ |
| 57 | test -x "`which git 2>&1;true`"; then \ |
| 58 | GIT_VERSION_STR="`cd "$(top_srcdir)" && git describe --tags --dirty`"; \ |
| 59 | GIT_CURRENT_TAG="`cd "$(top_srcdir)" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null`"; \ |
| 60 | echo "#define GIT_VERSION \"$$GIT_VERSION_STR\"" > version.i.tmp; \ |
| 61 | if ! $(GREP) -- "-dirty" version.i.tmp > /dev/null && \ |
| 62 | test "x$$GIT_CURRENT_TAG" != "x"; then \ |
| 63 | echo "#define GIT_VERSION \"\"" > version.i.tmp; \ |
| 64 | fi; \ |
| 65 | fi; \ |
| 66 | if test ! -f version.i.tmp; then \ |
| 67 | if test ! -f version.i; then \ |
| 68 | echo '#define GIT_VERSION ""' > version.i; \ |
| 69 | fi; \ |
| 70 | elif test ! -f version.i || \ |
| 71 | test x"`cat version.i.tmp`" != x"`cat version.i`"; then \ |
| 72 | mv version.i.tmp version.i; \ |
| 73 | fi; \ |
| 74 | rm -f version.i.tmp; \ |
| 75 | true |
| 76 | |
| 77 | ## |
| 78 | ## version.i is defined as a .PHONY target even if it's a real file, |
| 79 | ## we want the target to be re-run on every make. |
| 80 | ## |
| 81 | .PHONY: version.i |
| 82 | |
| 83 | CLEANFILES = version.i.tmp |
| 84 | |
| 85 | ## |
| 86 | ## Only clean "version.i" on dist-clean, we need to keep it on regular |
| 87 | ## clean when it's part of a dist tarball. |
| 88 | ## |
| 89 | DISTCLEANFILES = version.i |