Commit e4a02d44 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Create an include file with more usual defines for the various

versions. Tidy up autoconf to keep simple. Fix dependencies so
that we do not keep rebuilding library and examples.


Former-commit-id: ebff646b432b6982965d059c8e54a24969575fcd
parent 327cfb21
......@@ -11,6 +11,8 @@ config.sub
ltmain.sh
libtool
src/git_revision.h
swift*.tar.gz
doc/doxyfile.stamp
doc/html/
doc/latex/
......
......@@ -238,21 +238,9 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(
[AC_DEFINE(HAVE__RTC,1,[Define if you have the UNICOS _rtc() intrinsic.])],[rtc_ok=no])
AC_MSG_RESULT($rtc_ok)
#Check for git
AC_PATH_PROG(gitrevisioncommand, git)
# If the git command exists and we are in a directory generated by Git
AM_CONDITIONAL(HAVE_GIT_WC, test "X$gitrevisioncommand" != "X" && test `$gitrevisioncommand describe --abbrev=8 --always --tags --dirty 2>&1 | sed -n 1p | cut -f 1 -d " "` != "fatal:")
# Generate the git revision command: either a call to git or a call to print the pre-generated file
if test "X$gitrevisioncommand" = "X" || test `$gitrevisioncommand describe --abbrev=8 --always --tags --dirty 2>&1 | sed -n 1p | cut -f 1 -d " "` = "fatal:"; then
my_git_revision="echo `cat src/git_revision` '\'"
else
my_git_revision="echo `git describe --abbrev=8 --always --tags --dirty` '\'"
fi
AC_SUBST(my_git_revision)
# Check for git, needed for revision stamps.
AC_PATH_PROG([GIT_CMD], [git])
AC_SUBST([GIT_CMD])
# Make the documentation.
DX_INIT_DOXYGEN(libswift,doc/Doxyfile,doc/)
......
......@@ -573,7 +573,7 @@ int main ( int argc , char *argv[] ) {
#endif
/* Greeting message */
message( "This is SWIFT version %s\n", git_revision());
message( "This is %s\n", package_version() );
/* Init the space. */
bzero( &s , sizeof(struct space) );
......
......@@ -22,6 +22,9 @@ AM_CFLAGS = -DTIMER -DCOUNTER -DCPU_TPS=2.30e9
# Assign a "safe" version number
AM_LDFLAGS = $(LAPACK_LIBS) $(BLAS_LIBS) $(HDF5_LDFLAGS) -version-info 0:0:0 # -fsanitize=address
# The git command, if available.
GIT_CMD = @GIT_CMD@
# Build the libswiftsim library
lib_LTLIBRARIES = libswiftsim.la
# Build a MPI-enabled version too?
......@@ -32,7 +35,7 @@ endif
# List required headers
include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
common_io.h multipole.h git_revision.h
common_io.h multipole.h
# Common source files
AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
......@@ -53,20 +56,16 @@ libswiftsim_mpi_la_CFLAGS = $(AM_CFLAGS) -DWITH_MPI
libswiftsim_mpi_la_SHORTNAME = mpi
# Git revision
# Generate a file with the Git revision chain using the pre-defined command
git_revision.c: GIT_REV_CHAIN
echo 'const char* git_revision(void) { const char* Git_Revision = "\' > git_revision.c
@my_git_revision@ >> git_revision.c
echo '"; return Git_Revision; }' >> git_revision.c
# If we are in a git directory save the revision number
if HAVE_GIT_WC
git_revision: GIT_REV_CHAIN
@my_git_revision@ > git_revision
endif
# Git revision, if any sources change then update the git_revision.h file.
git_revision.h: git_revision.h.in $(AM_SOURCES) $(include_HEADERS) $(noinst_HEADERS)
if test "X$(GIT_CMD)" != "X"; then \
GIT_REVISION=`git describe --abbrev=8 --always --tags --dirty`; \
sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \
-e "s,@GIT_REVISION\@,$${GIT_REVISION}," git_revision.h.in > git_revision.h; \
fi
GIT_REV_CHAIN:
# Make sure git_revision is built first.
BUILT_SOURCES = git_revision.h
BUILT_SOURCES=git_revision.c
EXTRA_DIST=git_revision
# And distribute the built file.
EXTRA_DIST = git_revision.h git_revision.h.in
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include <stdio.h>
#include "git_revision.h"
const char* git_revision( void )
{
static const char *revision = GIT_REVISION;
return revision;
}
const char* package_version( void )
{
static char buf[256];
static int initialised = 0;
if ( ! initialised ) {
sprintf( buf, "SWIFT version: %s, at revision: %s",
PACKAGE_VERSION, GIT_REVISION );
initialised = 1;
}
return buf;
}
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
* Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
* Copyright (c) 2015 Peter W. Draper (p.w.draper@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
......@@ -21,13 +22,13 @@
/**
* @file git_revision.h
* @brief Git revision hash key.
* @brief Package version and git revision sha.
*/
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
#define GIT_REVISION "@GIT_REVISION@"
const char* package_version(void);
const char* git_revision(void);
#endif /* GIT_REVISION_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment