From 43e607f2bcafd519262cc705d3fa8a3ca1316697 Mon Sep 17 00:00:00 2001 From: Min Si Date: Sun, 11 Nov 2018 10:54:35 -0600 Subject: [PATCH] Set version number in header file. --- configure.ac | 62 ++++++++++++++++++++++++++++++++++++- src/{shmem.h => shmem.h.in} | 28 +++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) rename src/{shmem.h => shmem.h.in} (95%) diff --git a/configure.ac b/configure.ac index 7209222b..d1619150 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,66 @@ AC_INIT([OSHMPI], AC_CONFIG_SRCDIR([src/shmem.c]) +# build info +CONFIGURE_ARGS_CLEAN=`echo $* | tr '"' ' '` +AC_SUBST(CONFIGURE_ARGS_CLEAN) + +# these values come from the m4_include above +OSHMPI_VERSION=OSHMPI_VERSION_m4 +AC_SUBST(OSHMPI_VERSION) +OSHMPI_RELEASE_DATE="OSHMPI_RELEASE_DATE_m4" +AC_SUBST(OSHMPI_RELEASE_DATE) + +if test -z "$OSHMPI_VERSION" ; then + AC_MSG_ERROR([OSHMPI_VERSION is empty, check maint/version.m4 for errors]) +fi + +# Produce a numeric version assuming the following format: +# Version: [MAJ].[MIN].[REV][EXT][EXT_NUMBER] +# Example: 1.0.7rc1 has +# MAJ = 1 +# MIN = 0 +# REV = 7 +# EXT = rc +# EXT_NUMBER = 1 +# +# Converting to numeric version will convert EXT to a format number: +# ALPHA (a) = 0 +# BETA (b) = 1 +# RC (rc) = 2 +# PATCH (p) = 3 +# Regular releases are treated as patch 0 +# +# Numeric version will have 1 digit for MAJ, 2 digits for MIN, +# 2 digits for REV, 1 digit for EXT and 2 digits for EXT_NUMBER. +changequote(<<,>>) +V1=`expr $OSHMPI_VERSION : '\([0-9]*\)\.[0-9]*\.*[0-9]*[a-zA-Z]*[0-9]*'` +V2=`expr $OSHMPI_VERSION : '[0-9]*\.\([0-9]*\)\.*[0-9]*[a-zA-Z]*[0-9]*'` +V3=`expr $OSHMPI_VERSION : '[0-9]*\.[0-9]*\.*\([0-9]*\)[a-zA-Z]*[0-9]*'` +V4=`expr $OSHMPI_VERSION : '[0-9]*\.[0-9]*\.*[0-9]*\([a-zA-Z]*\)[0-9]*'` +V5=`expr $OSHMPI_VERSION : '[0-9]*\.[0-9]*\.*[0-9]*[a-zA-Z]*\([0-9]*\)'` +changequote([,]) + +if test "$V2" -le 9 ; then V2=0$V2 ; fi +if test "$V3" = "" ; then V3=0; fi +if test "$V3" -le 9 ; then V3=0$V3 ; fi +if test "$V4" = "a" ; then + V4=0 +elif test "$V4" = "b" ; then + V4=1 +elif test "$V4" = "rc" ; then + V4=2 +elif test "$V4" = "" ; then + V4=3 + V5=0 +elif test "$V4" = "p" ; then + V4=3 +fi +if test "$V5" -le 9 ; then V5=0$V5 ; fi + +OSHMPI_NUMVERSION=`expr $V1$V2$V3$V4$V5 + 0` +AC_SUBST(OSHMPI_NUMVERSION) + # From ARMCI-MPI AC_CONFIG_AUX_DIR(m4) AC_CONFIG_MACRO_DIR(m4) @@ -250,5 +310,5 @@ fi #if test -n "$enable_extension_" ; then # AC_DEFINE(EXTENSION_,1,[Define to enable ]) #fi - +AC_CONFIG_FILES([src/shmem.h]) AC_OUTPUT(Makefile) diff --git a/src/shmem.h b/src/shmem.h.in similarity index 95% rename from src/shmem.h rename to src/shmem.h.in index ca1815dd..f325137d 100644 --- a/src/shmem.h +++ b/src/shmem.h.in @@ -21,6 +21,34 @@ #include #include +/* OSHMPI_VERSION is the version string. OSHMPI_NUMVERSION is the + * numeric version that can be used in numeric comparisons. + * + * OSHMPI_VERSION uses the following format: + * Version: [MAJ].[MIN].[REV][EXT][EXT_NUMBER] + * Example: 1.0.7rc1 has + * MAJ = 1 + * MIN = 0 + * REV = 7 + * EXT = rc + * EXT_NUMBER = 1 + * + * OSHMPI_NUMVERSION will convert EXT to a format number: + * ALPHA (a) = 0 + * BETA (b) = 1 + * RC (rc) = 2 + * PATCH (p) = 3 + * Regular releases are treated as patch 0 + * + * Numeric version will have 1 digit for MAJ, 2 digits for MIN, 2 + * digits for REV, 1 digit for EXT and 2 digits for EXT_NUMBER. So, + * 1.0.7rc1 will have the numeric version 10007201. + */ +#define OSHMPI_VERSION "@OSHMPI_VERSION@" +#define OSHMPI_NUMVERSION @OSHMPI_NUMVERSION@ +#define OSHMPI_RELEASE_DATE "@OSHMPI_RELEASE_DATE@" +#define OSHMPI_BUILD_INFO "@CONFIGURE_ARGS_CLEAN@" + /* These few lines and the ones they replaced are the only changes to this file. */ /* This header is not needed for the SHMEM public API, but we include it here so * * we can tell the user at compile time if they are using an MPI implementation *