Hi Jeff,

* Jeff Squyres wrote on Sat, Jan 21, 2006 at 12:39:26PM CET:
> On Jan 21, 2006, at 3:19 AM, Ralf Wildenhues wrote:
> 
> > Should be fixed in patch below.  Also, and I forgot to add this in the
> > first version of the patch: for configure, produce some output if the
> > SVN server is contacted.  I kept wondering why the configure script
> > halted for a while there in what was a seemingly trivial local  
> > operation until I discovered what took so long there.
> 
> Just FYI: the SVN server is not contacted.  svnversion is a local  
> operation (although it traverses your entire SVN checkout, which is  
> why it can be slow).

Oh.  OK.  I didn't know that.  It felt so slow I figured it just had to
be nonlocal.

> > +    if test "$gv_want_svn" = 1 && test "$gv_need_svn" = 1; then
> 
> Just curious -- I typically use "-a" for multiple ANDed test  
> conditions, but you used "&&".  Is "-a" less portable?

Yes, some old `test's have weird precedence; quoting autoconf.info:
|
| If you need to make multiple checks using `test', combine them with
| the shell operators `&&' and `||' instead of using the `test'
| operators `-a' and `-o'.  On System V, the precedence of `-a' and
| `-o' is wrong relative to the unary operators; consequently, Posix
| does not specify them, so using them is nonportable.  If you
| combine `&&' and `||' in the same statement, keep in mind that
| they have equal precedence.

Not that I believe anyone would use those systems for parallel
computing..

But while we're at it, usually I also /do/ compare numbers with `-eq'
rather than `='.  I did not change all of those in this case because
I was unsure whether some version components should be allowed to be
non-numbers (or empty).

> > +       m4_ifdef([AC_MSG_CHECKING],
> > +                [AC_MSG_CHECKING([Obtaining SVN version])])
> 
> Totally minor point here, but will this print:
> 
> checking Obtaining SVN version...
> 
> If so, we should probably remove the redundant verb.  :-)

Definitely.  What a hard time I'm having getting this patch right. :-/

Next try below -- thanks for the reviews!
Cheers,
Ralf

Index: config/ompi_get_version.m4
===================================================================
--- config/ompi_get_version.m4  (Revision 8776)
+++ config/ompi_get_version.m4  (Arbeitskopie)
@@ -18,33 +18,33 @@
 dnl

 dnl
-dnl This file is almost identical in functionality to
-dnl ompi_get_version.sh.  It is unfortunate that we have to duplicate code,
-dnl but it is really the only what that I can think to do it.  :-( Hence,
-dnl if you change the logic here for determining version numbers, YOU MUST
-dnl ALSO CHANGE IT IN ompi_get_version.sh!!
-dnl 
+dnl This file is also used as input to ompi_get_version.sh.
+dnl

-AC_DEFUN([OMPI_GET_VERSION],[
+m4_define([OMPI_GET_VERSION],[
 gv_ver_file="$1"
 gv_prefix="$2"
+: ${gv_need_svn=0}
+: ${srcdir=.}

 dnl quote eval to suppress macro expansion with non-GNU m4

-gv_run() {
-    str="${gv_prefix}_${2}=\$gv_${1}"
-   [eval] $str
-}
-
-if test -n "$gv_ver_file" -a -f "$gv_ver_file"; then
-    gv_major_version="`egrep '^major=' $gv_ver_file | cut -d= -f2`"
-    gv_minor_version="`egrep '^minor=' $gv_ver_file | cut -d= -f2`"
-    gv_release_version="`egrep '^release=' $gv_ver_file | cut -d= -f2`"
-    gv_greek_version="`egrep '^greek=' $gv_ver_file | cut -d= -f2`"
-    gv_want_svn="`egrep '^want_svn=' $gv_ver_file | cut -d= -f2`"
-    gv_svn_r="`egrep '^svn_r=' $gv_ver_file | cut -d= -f2`"
-
-    if test -n "$gv_release_version" -a "$gv_release_version" != "0"; then
+if test -n "$gv_ver_file" && test -f "$gv_ver_file"; then
+    [eval] "`sed -n \"\
+       t clear
+       : clear
+       s/^major/gv_&_version/
+       s/^minor/gv_&_version/
+       s/^release/gv_&_version/
+       s/^greek/gv_&_version/
+       s/^want_svn/gv_&/
+       s/^svn_r/gv_&/
+       t print
+       b
+       : print
+       p\" < \"\$gv_ver_file\"`"
+       
+    if test -n "$gv_release_version" && test "$gv_release_version" != 0; then
        
gv_full_version="$gv_major_version.$gv_minor_version.$gv_release_version"
     else
        gv_full_version="$gv_major_version.$gv_minor_version"
@@ -52,31 +52,37 @@

     gv_full_version="${gv_full_version}${gv_greek_version}"

-    if test "$gv_want_svn" = "1"; then
-        if test "$gv_svn_r" = "-1"; then
+    gv_base_version=$gv_full_version
+
+    if test "$gv_want_svn" = 1 && test "$gv_need_svn" = 1; then
+        if test "$gv_svn_r" = -1; then
+           m4_ifdef([AC_MSG_CHECKING],
+                    [AC_MSG_CHECKING([SVN version])])
             if test -d "$srcdir/.svn"; then
                 ver=r`svnversion "$srcdir"`
                 # make sure svnversion worked
-                if test "$?" != "0" ; then
+                if test "$?" -ne 0 ; then
                     ver=svn`date '+%m%d%Y'` 
                 fi
             else
                 ver=svn`date '+%m%d%Y'`
             fi
             gv_svn_r="$ver"
+           m4_ifdef([AC_MSG_RESULT],
+                    [AC_MSG_RESULT([done])])
         fi
        gv_full_version="${gv_full_version}$gv_svn_r"
     fi

     # Set the values
-
-    gv_run full_version    VERSION
-    gv_run major_version   MAJOR_VERSION
-    gv_run minor_version   MINOR_VERSION
-    gv_run release_version RELEASE_VERSION
-    gv_run greek_version   GREEK_VERSION
-    gv_run want_svn        WANT_SVN
-    gv_run svn_r           SVN_R
+    [eval] "${gv_prefix}_VERSION=\$gv_full_version
+           ${gv_prefix}_BASE_VERSION=\$gv_base_version
+            ${gv_prefix}_MAJOR_VERSION=\$gv_major_version
+            ${gv_prefix}_MINOR_VERSION=\$gv_minor_version
+            ${gv_prefix}_RELEASE_VERSION=\$gv_release_version
+            ${gv_prefix}_GREEK_VERSION=\$gv_greek_version
+            ${gv_prefix}_WANT_SVN=\$gv_want_svn
+            ${gv_prefix}_SVN_R=\$gv_svn_r"
 fi

 # Clean up
Index: config/Makefile.am
===================================================================
--- config/Makefile.am  (Revision 8776)
+++ config/Makefile.am  (Arbeitskopie)
@@ -49,6 +49,7 @@
         ompi_configure_options.m4 \
         ompi_functions.m4 \
         ompi_get_version.m4 \
+        ompi_get_version.m4sh \
         ompi_get_version.sh \
         ompi_make_stripped_flags.m4 \
         ompi_mca.m4 \
Index: autogen.sh
===================================================================
--- autogen.sh  (Revision 8776)
+++ autogen.sh  (Arbeitskopie)
@@ -40,6 +40,10 @@
 if test ! -z "$AUTOCONF"; then
     ompi_autoconf_search="$AUTOCONF"
 fi
+ompi_autom4te_search="autom4te"
+if test ! -z "$AUTOM4TE"; then
+    ompi_autom4te_search="$AUTOM4TE"
+fi
 ompi_libtoolize_search="libtoolize;glibtoolize"
 if test ! -z "$LIBTOOLIZE"; then
     ompi_libtoolize_search="$LIBTOOLIZE"
@@ -375,6 +379,12 @@

     echo "*** Running GNU tools"

+    if test -f include/mpi.h.in; then
+       cd config
+       run_and_check $ompi_autom4te --language=m4sh ompi_get_version.m4sh -o 
ompi_get_version.sh
+       cd ..
+    fi
+
     run_and_check $ompi_aclocal
     if test "`grep AC_CONFIG_HEADER $file`" != "" -o \
        "`grep AM_CONFIG_HEADER $file`" != ""; then
@@ -1088,6 +1098,7 @@
 fi

 # find all the apps we are going to run
+find_app "autom4te"
 find_app "aclocal"
 find_app "autoheader"
 find_app "autoconf"
--- /dev/null   2005-03-20 10:56:34.000000000 +0100
+++ config/ompi_get_version.m4sh        2006-01-21 08:57:03.000000000 +0100
@@ -0,0 +1,98 @@
+m4_define([_m4_divert(SCRIPT)], 100)
+m4_divert_push([SCRIPT])dnl
+#!/bin/sh
+#
+# ompi_get_version is created from ompi_get_version.m4 and 
ompi_get_version.m4sh.
+#
+# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
+#                         University Research and Technology
+#                         Corporation.  All rights reserved.
+# Copyright (c) 2004-2005 The University of Tennessee and The University
+#                         of Tennessee Research Foundation.  All rights
+#                         reserved.
+# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
+#                         University of Stuttgart.  All rights reserved.
+# Copyright (c) 2004-2005 The Regents of the University of California.
+#                         All rights reserved.
+# $COPYRIGHT$
+# 
+# Additional copyrights may follow
+# 
+# $HEADER$
+#
+
+m4_include([ompi_get_version.m4])
+
+srcfile="$1"
+option="$2"
+
+case "$option" in
+    # svnversion can take a while to run.  If we don't need it, don't run it.
+    --major|--minor|--release|--greek|--base|--help)
+        gv_need_svn=0
+        ;;
+    *)
+        gv_need_svn=1
+esac
+
+
+if test -z "$srcfile"; then
+    option="--help"
+else
+    OMPI_GET_VERSION([$srcfile],[OMPI])
+
+    if test "$option" = ""; then
+       option="--full"
+    fi
+fi
+
+case "$option" in
+    --full|-v|--version)
+       echo $OMPI_VERSION
+       ;;
+    --major)
+       echo $OMPI_MAJOR_VERSION
+       ;;
+    --minor)
+       echo $OMPI_MINOR_VERSION
+       ;;
+    --release)
+       echo $OMPI_RELEASE_VERSION
+       ;;
+    --greek)
+       echo $OMPI_GREEK_VERSION
+       ;;
+    --svn)
+       echo $OMPI_SVN_R
+       ;;
+    --base)
+        echo $OMPI_BASE_VERSION
+        ;;
+    --all)
+        echo ${OMPI_VERSION} ${OMPI_MAJOR_VERSION} ${OMPI_MINOR_VERSION} 
${OMPI_RELEASE_VERSION} ${OMPI_GREEK_VERSION} ${OMPI_SVN_R}
+        ;;
+    -h|--help)
+       cat <<EOF
+$0 <srcfile> [<option>]
+
+<srcfile> - Text version file
+<option>  - One of:
+    --full    - Full version number
+    --major   - Major version number
+    --minor   - Minor version number
+    --release - Release version number
+    --greek   - Greek (alpha, beta, etc) version number
+    --svn     - Subversion repository number
+    --all     - Show all version numbers, separated by :
+    --base    - Show base version number (no svn number)
+    --help    - This message
+EOF
+        ;;
+    *)
+        echo "Unrecognized option $option.  Run $0 --help for options"
+        ;;
+esac
+
+# All done
+
+exit 0

Reply via email to