From 6e84dbce05959e854d886772841a5d6d0690eb65 Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Sat, 23 Jan 2016 16:44:48 -0800 Subject: [PATCH] LU-7699 build: Convert lustre_ver.h.in into a static .h file The AC_LUSTRE_{MAJOR,MINOR,PATCH,FIX} autoconf output values are no longer necessary. We can instead use AC_DEFINE to set the LUSTRE_{MAJOR,MINOR,PATCH,FIX} CPP macros directly. As a result, the lustre_ver.h file no longer needs to be generated by autoconf and it can be made into a static file. At the same time we set LUSTRE_VERSION_STRING, even though it is not strictly needed, to avoid additional divergence from the client code in the upstream Linux kernel staging area. Change-Id: I6b0364a7af1869beb6acedc63c034565af00ef06 Signed-off-by: Christopher J. Morrone Reviewed-on: http://review.whamcloud.com/18111 Reviewed-by: Dmitry Eremin Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- config/lustre-version.m4 | 23 ++++++++++------------- configure.ac | 2 +- contrib/lbuild/lbuild | 2 +- lustre/autoconf/lustre-core.m4 | 1 - lustre/include/.gitignore | 1 - lustre/include/{lustre_ver.h.in => lustre_ver.h} | 18 ++++++++++-------- 6 files changed, 22 insertions(+), 25 deletions(-) rename lustre/include/{lustre_ver.h.in => lustre_ver.h} (70%) diff --git a/config/lustre-version.m4 b/config/lustre-version.m4 index 9507a50..d5485af 100644 --- a/config/lustre-version.m4 +++ b/config/lustre-version.m4 @@ -1,23 +1,20 @@ # -# LUSTRE_VERSION_VARIABLES +# LUSTRE_VERSION_CPP_MACROS # -AC_DEFUN([LUSTRE_VERSION_VARIABLES], [ - +AC_DEFUN([LUSTRE_VERSION_CPP_MACROS], [ LUSTRE_MAJOR=`echo AC_PACKAGE_VERSION | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\1/']` LUSTRE_MINOR=`echo AC_PACKAGE_VERSION | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\2/']` LUSTRE_PATCH=`echo AC_PACKAGE_VERSION | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\3/']` LUSTRE_FIX=`echo AC_PACKAGE_VERSION | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\5/']` AS_IF([test -z "$LUSTRE_FIX"], [LUSTRE_FIX="0"]) -m4_pattern_allow(AC_LUSTRE) -[AC_LUSTRE_MAJOR]=$LUSTRE_MAJOR -[AC_LUSTRE_MINOR]=$LUSTRE_MINOR -[AC_LUSTRE_PATCH]=$LUSTRE_PATCH -[AC_LUSTRE_FIX]=$LUSTRE_FIX - -AC_SUBST([AC_LUSTRE_MAJOR]) -AC_SUBST([AC_LUSTRE_MINOR]) -AC_SUBST([AC_LUSTRE_PATCH]) -AC_SUBST([AC_LUSTRE_FIX]) +AC_DEFINE_UNQUOTED([LUSTRE_MAJOR], [$LUSTRE_MAJOR], [First number in the Lustre version]) +AC_DEFINE_UNQUOTED([LUSTRE_MINOR], [$LUSTRE_MINOR], [Second number in the Lustre version]) +AC_DEFINE_UNQUOTED([LUSTRE_PATCH], [$LUSTRE_PATCH], [Third number in the Lustre version]) +AC_DEFINE_UNQUOTED([LUSTRE_FIX], [$LUSTRE_FIX], [Fourth number in the Lustre version]) +# Even though the code could just use VERSION or PACKAGE_VERSION directly, +# we use this copy named LUSTRE_VERSION_STRING instead to maintain less +# divergence from the Lustre client code in the upstream Linux kernel code. +AC_DEFINE_UNQUOTED([LUSTRE_VERSION_STRING], ["$PACKAGE_VERSION"], [A copy of PACKAGE_VERSION]) ]) diff --git a/configure.ac b/configure.ac index 0295c7c..2e8b837 100644 --- a/configure.ac +++ b/configure.ac @@ -20,5 +20,5 @@ AM_PROG_AS AC_PATH_PROG(RPMBUILD, rpmbuild) AC_CHECK_TOOLS(AR, ar) -LUSTRE_VERSION_VARIABLES +LUSTRE_VERSION_CPP_MACROS LB_CONFIGURE diff --git a/contrib/lbuild/lbuild b/contrib/lbuild/lbuild index 85d3878..9d6a600 100755 --- a/contrib/lbuild/lbuild +++ b/contrib/lbuild/lbuild @@ -836,7 +836,7 @@ build_lustre() { # Only zfs Lustre DKMS Server is supported build_lustre_dkms() { - local ver=$(eval echo $(awk '/LUSTRE_VERSION_STRING/ {print $3}' lustre/include/lustre_ver.h)) + local ver=$(sed -n -e 's/^LUSTRE_VERSION = //p' LUSTRE-VERSION-FILE) echo "Building Lustre DKMS RPMs for: $BUILD_ARCHS..." ./configure --enable-dist || return 255 diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index d9294bf..9f59979 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2506,7 +2506,6 @@ lustre/conf/Makefile lustre/contrib/Makefile lustre/doc/Makefile lustre/include/Makefile -lustre/include/lustre_ver.h lustre/include/lustre/Makefile lustre/kernel_patches/targets/3.10-rhel7.target lustre/kernel_patches/targets/2.6-rhel6.7.target diff --git a/lustre/include/.gitignore b/lustre/include/.gitignore index d106e44..6466325 100644 --- a/lustre/include/.gitignore +++ b/lustre/include/.gitignore @@ -4,4 +4,3 @@ /stamp-h1 /stamp-h.in /Makefile.in -/lustre_ver.h diff --git a/lustre/include/lustre_ver.h.in b/lustre/include/lustre_ver.h similarity index 70% rename from lustre/include/lustre_ver.h.in rename to lustre/include/lustre_ver.h index 15f3327..0557c2d 100644 --- a/lustre/include/lustre_ver.h.in +++ b/lustre/include/lustre_ver.h @@ -1,14 +1,16 @@ #ifndef _LUSTRE_VER_H_ #define _LUSTRE_VER_H_ -/* This file automatically generated from lustre/include/lustre_ver.h.in, - * based on parameters in lustre/autoconf/lustre-version.ac. - * Changes made directly to this file will be lost. */ -#define LUSTRE_MAJOR @AC_LUSTRE_MAJOR@ -#define LUSTRE_MINOR @AC_LUSTRE_MINOR@ -#define LUSTRE_PATCH @AC_LUSTRE_PATCH@ -#define LUSTRE_FIX @AC_LUSTRE_FIX@ -#define LUSTRE_VERSION_STRING "@PACKAGE_VERSION@" +/* + * LUSTRE_VERSION_STRING + * + * Note that some files may seem to include this header unnecessarily. + * If the file uses LUSTRE_VERSION_STRING, it is likely doing the include + * for compatibility with the Lustre code in the Linux kernel. + * In the Linux kernel, they are likely hard coding LUSTRE_VERSION_STRING + * right here in this file. The out-of-kernel Lustre code generates + * LUSTRE_VERSION_STRING in autoconf with AC_DEFINE. + */ #define OBD_OCD_VERSION(major, minor, patch, fix) \ (((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix)) -- 1.8.3.1