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