From f5d109c8ad56a2e59d0e81caf49eea19a9a897d5 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 19 Jun 2010 15:53:34 +0200 Subject: [PATCH] add isl_version --- Makefile.am | 6 ++++++ configure.ac | 3 +++ doc/Makefile.am | 4 +++- doc/manual.tex | 3 ++- include/isl_version.h | 14 ++++++++++++++ isl_options.c | 7 +++++++ isl_version.c | 6 ++++++ m4/ax_detect_git_head.m4 | 27 +++++++++++++++++++++++++++ 8 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 include/isl_version.h create mode 100644 isl_version.c create mode 100644 m4/ax_detect_git_head.m4 diff --git a/Makefile.am b/Makefile.am index 05887b13..e0e0534e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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@'"' > $@ diff --git a/configure.ac b/configure.ac index 31cd7cf4..d3cc5866 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/doc/Makefile.am b/doc/Makefile.am index e0924be1..aa79a6c9 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -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 diff --git a/doc/manual.tex b/doc/manual.tex index 3e7ce961..191f4d19 100644 --- a/doc/manual.tex +++ b/doc/manual.tex @@ -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 index 00000000..7f8f23d6 --- /dev/null +++ b/include/isl_version.h @@ -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 diff --git a/isl_options.c b/isl_options.c index 92890d8a..558373f5 100644 --- a/isl_options.c +++ b/isl_options.c @@ -13,6 +13,7 @@ #include "isl_ctx.h" #include "isl_options.h" +#include 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 index 00000000..1a59f55c --- /dev/null +++ b/isl_version.c @@ -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 index 00000000..d5859835 --- /dev/null +++ b/m4/ax_detect_git_head.m4 @@ -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 +]) -- 2.11.4.GIT