Changeset 1854


Ignore:
Timestamp:
Mar 7, 2009, 2:38:22 AM (13 years ago)
Author:
Peter
Message:

fixes #491 and added some laziness to macro tests

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/m4/yat.m4

    r1797 r1854  
    5151#     $yat_config. $yat_config is required for the other macros and
    5252#     therefore if YAT_FIND_YAT has not been called, they will call
    53 #     YAT_FIND_YAT.
     53#     YAT_FIND_YAT. If --without-yat (or equivalently --with-yat=no)
     54#     is given, all tests and actions are turned off.
    5455#
    5556#
     
    103104
    104105#
    105 # serial 1  # version number of yat.m4
     106# serial 2  # version number of yat.m4
    106107#
    107108# see http://www.gnu.org/software/automake/manual/automake.html#Serials
     
    114115YAT_CHECK_HEADER(,[ac_yat_check_yat_res="no"])
    115116YAT_CHECK_LIB(,[ac_yat_check_yat_res="no"])
    116 # ACTION
    117 if test "$ac_yat_check_yat_res" != "no" ; then
    118   m4_default([$2], [:])
    119 else
    120   m4_default([$3], [:])
    121 fi 
     117
     118_YAT_ACTION([test "$ac_yat_check_yat_res" != "no"],[$2],[$3])
    122119
    123120]) # YAT_CHECK_YAT
     
    126123AC_DEFUN([YAT_FIND_YAT],
    127124[
    128   AC_ARG_WITH(yat,
    129               AC_HELP_STRING([--with-yat=DIR],
    130                 [prefix for installed yat library or full path to yat-config]),
    131     [ yat_config=no;
    132       AC_MSG_NOTICE([looking for yat-config])
    133       for p in $withval $withval/yat-config $withval/bin/yat-config ; do 
    134         if test "$yat_config" = "no" ; then
    135           AC_MSG_CHECKING([$p]);
    136           if test -f "$p" && $p --help > /dev/null 2>&1 ; then
    137             yat_config=$p;
    138             AC_MSG_RESULT([yes]);
    139           else
    140             AC_MSG_RESULT([no]);
    141           fi
    142         fi
    143       done     
    144       if test "$yat_config" = "no" ; then
    145         AC_MSG_WARN([
     125  AC_ARG_WITH([yat],
     126     [AC_HELP_STRING([--with-yat=DIR],
     127                [prefix for installed yat library or full path to yat-config])],
     128     [],
     129     [with_yat=yes])
     130
     131  yat_config=no;
     132  yat_ac_want_yat=yes;
     133  AS_IF([test "x$with_yat" = "xno"],
     134    [yat_ac_want_yat=no],
     135    [test "x$with_yat" = "xyes"],       
     136    [AC_PATH_PROG([yat_config], [yat-config], [no])
     137     AS_IF([test "$yat_config" = "no"],
     138       [AC_MSG_WARN([
     139           the yat-config script installed by yat could not be found. If yat was
     140           installed in PREFIX, make sure PREFIX/bin is in your path, or supply
     141           the appropriate --with-yat option])
     142       ])
     143    ],
     144    [AC_MSG_NOTICE([looking for yat-config])
     145     for p in $with_yat $with_yat/yat-config $with_yat/bin/yat-config ; do 
     146       AS_IF([test "x$yat_config" = "xno"],
     147             [AC_MSG_CHECKING([$p]);
     148              AS_IF([test -f "$p" && $p --help > /dev/null 2>&1],
     149                    [yat_config=$p;
     150                     AC_MSG_RESULT([yes]);],
     151                    [AC_MSG_RESULT([no]);])
     152             ])
     153     done     
     154     AS_IF([test "$yat_config" = "no"],
     155        [AC_MSG_WARN([
    146156           the --with-yat parameter is incorrect. It must
    147157           specify an install prefix, or a yat-config file.])
    148       fi
    149     ],
    150     [ AC_PATH_PROG([yat_config], [yat-config], [no])
    151       if test "$yat_config" = "no" ; then
    152         AC_MSG_WARN([
    153           the yat-config script installed by yat could not be found. If yat was
    154           installed in PREFIX, make sure PREFIX/bin is in your path, or supply
    155           the appropriate --with-yat option])
    156       fi
     158        ])
    157159    ])
    158160
    159   # ACTION
    160   if test "$yat_config" != "no" ; then
    161     m4_default([$2], [:])
    162   else
    163     m4_default([$3], [:])
    164   fi 
     161  _YAT_ACTION([test "$yat_config" != "no"],[$1],[$2])
     162
    165163
    166164]) # YAT_FIND_YAT
     
    187185  fi
    188186
    189   # ACTION
    190   if test "$ac_yat_version_ok" = "yes" ; then
    191     m4_default([$2], [:])
    192   else
    193     m4_default([$3], [:])
    194   fi 
     187  _YAT_ACTION([test "$ac_yat_version_ok" = "yes"],[$2],[$3])
    195188
    196189]) # YAT_CHECK_VERSION
     
    248241  fi
    249242
    250   # ACTION
    251   if test "$ac_yat_ok" = "yes" ; then
    252     m4_default([$1], [:])
    253   else
    254     m4_default([$2], [:])
    255   fi 
     243  _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2])
    256244
    257245]) # YAT_CHECK_HEADER
     
    298286  fi
    299287
    300   # ACTION
    301   if test "$ac_yat_ok" = "yes" ; then
    302     m4_default([$1], [:])
    303   else
    304     m4_default([$2], [:])
    305   fi 
     288  _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2])
     289
    306290]) # YAT_CHECK_LIB
    307291
     292# Private macro
     293#
     294# if yat_ac_want_yat = no do nothing
     295# if $1 do $2 else do $3
     296#
     297AC_DEFUN([_YAT_ACTION],
     298[
     299  AS_IF([test "x$yat_ac_want_yat" = "xno"],[],
     300        [$1],[m4_default([$2], [:])],
     301        [m4_default([$2], [:])])
     302])
  • trunk/test/Makefile.am

    r1851 r1854  
    6767
    6868# tests not passing through yet
    69 XFAIL_TESTS = yat_m4_test2.sh
     69XFAIL_TESTS =
    7070
    7171TESTS += documentation_test.sh
  • trunk/test/common_defs.sh.in

    r1851 r1854  
    1919# along with yat. If not, see <http://www.gnu.org/licenses/>.
    2020
     21
     22# function copied from GNU Automake 1.10.2
     23#
     24# is_newest FILE FILES
     25# --------------------
     26# Return false if any file in FILES is newer than FILE.
     27# Resolve ties in favor of FILE.
     28is_newest ()
     29{
     30  test x`find "$@" -newer "$1"` = x
     31}
     32
     33
    2134me=$0
    2235
     
    3649echo "=== Running $me ==="
    3750
    38 # autotools are required, if not found exit 77 to skipt test
    39 
    40 echo "running autoconf --version"
    41 autoconf --version || exit 77
    42 echo "running automake --version"
    43 automake --version || exit 77
    44 
    45 # GNU libtool comes as glibtool on Mac OS
    46 (echo "running libtool --version" && libtool --version) || \
    47 (echo "running glibtool --version" && glibtool --version) || exit 77
    48 
    49 
     51ac_prog_libtool=
     52# if required tool is not available, exit 77 to skip test
     53if test -n "$required"; then
     54  for tool in $required; do
     55    case $tool in
     56      libtool)
     57      # GNU libtool comes as glibtool on Mac OS
     58      (echo "$me: running libtool --version" && libtool --version) || \
     59      (echo "$me: running glibtool --version" && glibtool --version) || exit 77
     60      ac_prog_libtool="AC_PROG_LIBTOOL"
     61      ;;
     62      *)
     63      echo "$me: running $tool --version"
     64      ($tool --version) || exit 77
     65    esac
     66  done
     67fi
     68 
    5069# some defs we need in tests
    5170test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
    5271abs_top_builddir=@abs_top_builddir@
     72abs_top_srcdir=@abs_top_srcdir@
    5373move_if_change=@abs_top_srcdir@/build_support/move-if-change
    5474
    55 cd @abs_builddir@
    56 @MKDIR_P@ --verbose $test_dir && cd $test_dir
     75@MKDIR_P@ --verbose $test_dir
    5776
    58 echo "Create configure.ac"
     77# if not a new acinclude.m4 exists, create a dummy one
     78if (test -f $test_dir/acinclude.m4 && \
     79    is_newest $test_dir/acinclude.m4 common_defs.sh $me); then
     80  :
     81else
     82  echo "creating a dummy acinclude.m4"
     83  echo "dnl a dummy include" > $test_dir/acinclude.m4 
     84fi
     85
     86
     87cd $test_dir
     88echo "creating configure.ac"
    5989cat > configure.ac.tmp <<EOF
    6090AC_INIT([hello],[1.0])
     
    6595AC_PROG_CXXCPP
    6696AC_PROG_CXX
    67 AC_PROG_LIBTOOL
     97$ac_prog_libtool
    6898m4_include(acinclude.m4)
    6999AC_CONFIG_FILES([Makefile])
    70100AC_OUTPUT
    71101EOF
    72 $move_if_change configure.ac.tmp configure.ac
     102$move_if_change -v configure.ac.tmp configure.ac
    73103
    74 echo "Create Makefile.am"
     104echo "creating Makefile.am"
    75105cat > Makefile.am.tmp <<EOF
    76106ACLOCAL_AMFLAGS = -I m4
     
    82112hello_SOURCES = hello.cc
    83113EOF
    84 $move_if_change Makefile.am.tmp Makefile.am
     114$move_if_change -v Makefile.am.tmp Makefile.am
    85115
    86 echo "dnl a dummy include" > acinclude.m4
    87 
    88 echo "Create hello.cc"
     116echo "creating hello.cc"
    89117cat > hello.cc.tmp <<EOF
    90118#include <yat/utility/Vector.h>
     
    108136}
    109137EOF
    110 $move_if_change hello.cc.tmp hello.cc
     138$move_if_change -v hello.cc.tmp hello.cc
    111139
    112140@MKDIR_P@ --verbose m4
    113 cp -v @abs_top_srcdir@/m4/yat.m4 m4/yat.m4.tmp
    114 $move_if_change m4/yat.m4.tmp m4/yat.m4
     141echo "copying yat.m4"
     142cp @abs_top_srcdir@/m4/yat.m4 m4/yat.m4.tmp
     143$move_if_change -v m4/yat.m4.tmp m4/yat.m4
     144
     145
  • trunk/test/yat_m4_test.sh

    r1851 r1854  
    2323# configure.ac. Test if the macro works against an uninstalled yat.
    2424
     25required="autoconf automake libtool"
     26
    2527set -e
    2628
    2729. ./common_defs.sh || exit 1
    2830
    29 echo "Create acinclude.m4.tmp"
     31echo "Creating acinclude.m4"
    3032cat > acinclude.m4.tmp <<EOF
    3133YAT_CHECK_VERSION([0.5.99],,
     
    3537AC_SUBST(YAT_LA_FILE)
    3638EOF
    37 $move_if_change acinclude.m4.tmp acinclude.m4
     39$move_if_change -v acinclude.m4.tmp acinclude.m4
    3840
    3941# bootstrapping
    40 if test -f Makefile; then : else
     42if test -f Makefile; then
     43  :
     44else
    4145  autoreconf -siv
    4246  ./configure --with-yat=$abs_top_builddir/build_support/yat-config
     
    4549# we always wanna relink
    4650rm -f hello
     51echo "running make"
    4752make
    4853echo "running ./hello"
  • trunk/test/yat_m4_test2.sh

    r1851 r1854  
    2222# test that option --with-yat=no works as expected.
    2323
     24required="autoconf automake"
     25
    2426set -e
    2527
    2628. ./common_defs.sh || exit 1
    2729
    28 cat > acinclude.m4 <<EOF
    29 YAT_CHECK_YAT([2.7.8],,AC_MSG_ERROR([test failed - see warning above]))
    30 YAT_FIND_YAT(,[AC_MSG_ERROR([test failed - see warning above])])
    31 YAT_CHECK_VERSION([1.60.2],,[AC_MSG_ERROR([test failed - see warning above])])
    32 YAT_CHECK_HEADER(,[AC_MSG_ERROR([test failed - see warning above])])
    33 YAT_CHECK_LIB(,[AC_MSG_ERROR([test failed - see warning above])])
     30echo "creating acinclude.m4"
     31cat > acinclude.m4.tmp <<EOF
     32YAT_FIND_YAT(,[AC_MSG_ERROR([yat_find_yat failed - see warning above])])
     33YAT_CHECK_VERSION([1.60.2],
     34                  [AC_MSG_ERROR([yat_check_version failed - see warning above])])
     35YAT_CHECK_HEADER(,[AC_MSG_ERROR([yat_check_header failed - see warning above])])
     36YAT_CHECK_LIB(,[AC_MSG_ERROR([yat_check_lib failed - see warning above])])
     37YAT_CHECK_YAT([2.7.8],,AC_MSG_ERROR([yat_check_yat failed - see warning above]))
    3438EOF
     39$move_if_change -v acinclude.m4.tmp acinclude.m4
    3540
    3641# bootstrapping
    37 autoreconf -siv && ./configure --with-yat=no
     42if test -f Makefile; then
     43  :
     44else
     45  autoreconf -fsiv
     46  ./configure --without-yat
     47fi
     48echo "$me: running make Makefile"
     49make Makefile
    3850
    3951echo "Test is OK"
Note: See TracChangeset for help on using the changeset viewer.