add isl_version
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 19 Jun 2010 13:53:34 +0000 (15:53 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 19 Jun 2010 17:25:23 +0000 (19:25 +0200)
Makefile.am
configure.ac
doc/Makefile.am
doc/manual.tex
include/isl_version.h [new file with mode: 0644]
isl_options.c
isl_version.c [new file with mode: 0644]
m4/ax_detect_git_head.m4 [new file with mode: 0644]

index 05887b1..e0e0534 100644 (file)
@@ -93,6 +93,7 @@ libisl_la_SOURCES = \
        isl_tab_pip.c \
        isl_transitive_closure.c \
        isl_vec.c \
+       isl_version.c \
        isl_vertices_private.h \
        isl_vertices.c
 EXTRA_libisl_la_SOURCES = \
@@ -188,6 +189,7 @@ pkginclude_HEADERS = \
        include/isl_set.h \
        include/isl_stream.h \
        include/isl_vec.h \
+       include/isl_version.h
        include/isl_vertices.h
 
 EXTRA_DIST = \
@@ -205,8 +207,12 @@ EXTRA_DIST = \
        test_inputs
 
 dist-hook:
+       echo @GIT_HEAD_VERSION@ > $(distdir)/GIT_HEAD_ID
        (cd doc; make manual.pdf)
        cp doc/manual.pdf $(distdir)/doc/
 
 pkgconfigdir=$(pkgconfig_libdir)
 pkgconfig_DATA = $(pkgconfig_libfile)
+
+gitversion.h: @GIT_HEAD@
+       echo '#define GIT_HEAD_ID "'@GIT_HEAD_VERSION@'"' > $@
index 31cd7cf..d3cc586 100644 (file)
@@ -84,6 +84,9 @@ AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
 PACKAGE_CFLAGS="-I$prefix/include/isl"
 AX_CREATE_PKGCONFIG_INFO
 
+AX_DETECT_GIT_HEAD
+echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
+
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_HEADERS(include/isl_config.h)
 AC_CONFIG_FILES(Makefile)
index e0924be..aa79a6c 100644 (file)
@@ -6,10 +6,12 @@ export BSTINPUTS := $(srcdir):$(BSTINPUTS)
 user.tex: user.pod
        $(PERL) $(srcdir)/mypod2latex $< $@
 manual.pdf: manual.tex user.tex $(srcdir)/implementation.tex
+       (cd ..; echo "@GIT_HEAD_VERSION@") > version.tex
        $(PDFLATEX) $<
        bibtex manual
        $(PDFLATEX) $<
        $(PDFLATEX) $<
 user.html: user.pod
-       $(POD2HTML) --infile=$< --outfile=$@ --title="Integer Set Library: Manual"
+       (cd ..; echo "@GIT_HEAD_VERSION@") > version
+       $(POD2HTML) --infile=$< --outfile=$@ --title="Integer Set Library: Manual [version `cat version`]"
 endif
index 3e7ce96..191f4d1 100644 (file)
@@ -43,7 +43,8 @@
 
 \begin{document}
 
-\title{Integer Set Library: Manual}
+\title{Integer Set Library: Manual\\
+\small Version: \input{version} }
 \author{Sven Verdoolaege}
 
 \maketitle
diff --git a/include/isl_version.h b/include/isl_version.h
new file mode 100644 (file)
index 0000000..7f8f23d
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef ISL_VERSION_H
+#define ISL_VERSION_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+const char *isl_version(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
index 92890d8..558373f 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "isl_ctx.h"
 #include "isl_options.h"
+#include <isl_version.h>
 
 struct isl_arg_choice isl_lp_solver_choice[] = {
        {"tab",         ISL_LP_TAB},
@@ -74,6 +75,11 @@ static struct isl_arg_flags bernstein_recurse[] = {
        {0}
 };
 
+static void print_version(void)
+{
+       printf("%s", isl_version());
+}
+
 struct isl_arg isl_options_arg[] = {
 ISL_ARG_CHOICE(struct isl_options, lp_solver, 0, "lp-solver", \
        isl_lp_solver_choice,   ISL_LP_TAB, "lp solver to use")
@@ -96,6 +102,7 @@ ISL_ARG_CHOICE(struct isl_options, bound, 0, "bound", bound,
        ISL_BOUND_BERNSTEIN, "algorithm to use for computing bounds")
 ISL_ARG_FLAGS(struct isl_options, bernstein_recurse, 0,
        "bernstein-recurse", bernstein_recurse, ISL_BERNSTEIN_FACTORS, NULL)
+ISL_ARG_VERSION(print_version)
 ISL_ARG_END
 };
 
diff --git a/isl_version.c b/isl_version.c
new file mode 100644 (file)
index 0000000..1a59f55
--- /dev/null
@@ -0,0 +1,6 @@
+#include "gitversion.h"
+
+const char *isl_version(void)
+{
+       return GIT_HEAD_ID"\n";
+}
diff --git a/m4/ax_detect_git_head.m4 b/m4/ax_detect_git_head.m4
new file mode 100644 (file)
index 0000000..d585983
--- /dev/null
@@ -0,0 +1,27 @@
+AC_DEFUN([AX_DETECT_GIT_HEAD], [
+       AC_SUBST(GIT_HEAD_ID)
+       AC_SUBST(GIT_HEAD)
+       AC_SUBST(GIT_HEAD_VERSION)
+       if test -f $srcdir/.git/HEAD; then
+               GIT_HEAD="$srcdir/.git/index"
+               GIT_REPO="$srcdir/.git"
+               GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
+       elif test -f $srcdir/GIT_HEAD_ID; then
+               GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
+       else
+               mysrcdir=`(cd $srcdir; pwd)`
+               head=`basename $mysrcdir | sed -e 's/.*-//'`
+               head2=`echo $head | sed -e 's/[^0-9a-f]//'`
+               head3=`echo $head2 | sed -e 's/........................................//'`
+               if test "x$head3" = "x" -a "x$head" = "x$head2"; then
+                       GIT_HEAD_ID="$head"
+               else
+                       GIT_HEAD_ID="UNKNOWN"
+               fi
+       fi
+       if test -z "$GIT_REPO" ; then
+               GIT_HEAD_VERSION="$GIT_HEAD_ID"
+       else
+           GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
+       fi
+])