source: trunk/test/defs.sh.in @ 4326

Last change on this file since 4326 was 4326, checked in by Peter, 7 months ago

We had two macros with very similar behaviour: YAT_AC_APPEND in
'yat_svn_release' and private macro _YAT_AC_APPEND_TO_FILE. Replace
with new macro YAT_AC_APPEND_TO_FILE with tested and documented
behaviour. Similarly a macro YAT_AC_WRITE_TO_FILE.

Introduce a new macro YAT_AM_LOCAL, which is recommended to use when
using any of the macros generating automake input.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.9 KB
Line 
1# @configure_input@
2# $Id: defs.sh.in 4326 2023-03-12 00:37:24Z peter $
3
4# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2019, 2020 Peter Johansson
5#
6# This file is part of the yat library, http://dev.thep.lu.se/yat
7#
8# The yat library is free software; you can redistribute it
9# and/or modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; either version 3 of the
11# License, or (at your option) any later version.
12#
13# The yat library is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16# General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with yat. If not, see <http://www.gnu.org/licenses/>.
20
21
22# bootstrap a test project
23#
24bootstrap ()
25{
26    $RM -rf m4
27    $mkdir_p m4
28    cp $abs_top_srcdir/m4/*.m4 m4/.
29    $RM -f m4/lt*.m4 m4/libtool.m4
30    res=0
31    export AUTOM4TE
32    export AUTOCONF
33    export AUTOHEADER
34    export AUTOMAKE
35    export ACLOCAL
36    export AUTOPOINT
37    export LIBTOOLIZE
38    export M4
39    $AUTORECONF -si $verbose || res=$?
40    case $res in
41        0)
42            :;;
43        63)
44            exit_skip;;
45        *)
46            exit $res;;
47    esac
48}
49
50# Usage: run PROG EXPECTED_EXITCODE [OPTION]...
51run ()
52{
53    test $# -ge 2 || exit_fatal
54    foo_prog=$1
55    shift
56    expected_exitcode=$1
57    shift
58    exitcode=0
59    $foo_prog ${1+"$@"} > stdout 2>stderr || exitcode=$?
60    cat stderr >&2
61    cat stdout
62    test $exitcode = $expected_exitcode || Exit 1
63}
64
65Exit () { set +x; exit $1; }
66warn_ () { echo $@ >&2; }
67exit_fail () { warn_ "$me: failed test: $@"; Exit 1; }
68exit_fatal () { warn_ "$me: hard error: $@"; Exit 99; }
69exit_skip () { warn_ "$me: skipped test: $@"; Exit 77; }
70exit_success () { echo "$me: successsful test: $@"; Exit 0; }
71
72check_requirements ()
73{
74# if required tool is not available, exit_skip
75if test -n "$required"; then
76  for tool in $required; do
77    case $tool in
78      aclocal)
79      echo "$me: running $ACLOCAL --version"
80      ($ACLOCAL --version) || exit_skip;
81      ;;
82      autoconf)
83      echo "$me: running $AUTOCONF --version"
84      ($AUTOCONF --version) || exit_skip;
85      ;;
86      automake)
87      echo "$me: running $AUTOMAKE --version"
88      ($AUTOMAKE --version) || exit_skip;
89      # skip test if automake older than v1.10
90      version_am=`$tool --version | head -n 1 | cut -f 2 -d ')'`
91      ver_major=`echo ${version_am} | cut -f 1 -d '.'`
92      test ${ver_major} -ge 1 || exit_skip
93      ver_minor=`echo ${version_am} | cut -f 2 -d '.'`
94      test ${ver_major} -gt 1 || test ${ver_minor} -ge 10 || exit_skip
95      ;;
96      doxygen)
97      test x"${have_doxygen}" = x"yes" || exit_skip no doxygen
98      ;;
99      htslib)
100      test x"${have_htslib}" = x"yes" || exit_skip no libbam
101      ;;
102      libmy-shared)
103      test -r test/lib/libmy-shared.la || exit_fatal "no 'libmy-shared.la'"
104      test -s test/lib/libmy-shared.la || exit_skip no shared lib
105      ;;
106      libmy-static)
107      test -r test/lib/libmy-static.a || exit_fatal "no 'libmy-static.a'"
108      test -s test/lib/libmy-static.a || exit_skip no static lib
109      ;;
110      libtool)
111      echo "$me: running $LIBTOOLIZE --version"
112      ($LIBTOOLIZE --version) || exit_skip libtool not available;
113      ;;
114      pkg-config)
115          echo hello
116          echo "$me: running $PKG_CONFIG --version"
117      ($PKG_CONFIG --version) || exit_skip pkg-config not available;
118      ;;
119      shared)
120      if (test "x${enable_shared}" = "xno"); then
121        echo shared disabled;
122        exit_skip;
123      fi
124      ;;
125      static)
126      if (test "x${enable_static}" = "xno"); then
127        echo static disabled;
128        exit_skip;
129      fi
130      ;;
131      *)
132      echo "$me: running $tool --version"
133      ($tool --version) || exit_skip
134    esac
135  done
136fi
137}
138
139
140me=$0
141# some defs we need in tests
142test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
143test_dir="test/testSubDir/$test_dir"
144abs_top_builddir=@abs_top_builddir@
145abs_top_srcdir=@abs_top_srcdir@
146enable_static="@enable_static@"
147enable_shared="@enable_shared@"
148lt_cv_objdir=@lt_cv_objdir@
149have_doxygen="@have_doxygen@"
150have_htslib="@have_htslib@"
151mkdir_p="@MKDIR_P@ --verbose"
152verbose="--verbose"
153silent=
154configure_opts=
155test x"$enable_shared" = x"no" && configure_opts="--disable-shared"
156test x"$enable_static" = x"no" \
157&& configure_opts="$onfigure_options --disable-static"
158
159# set autotools variables if not set (se we use same as autoreconf)
160: ${LIBTOOLIZE='libtoolize'}
161: ${AUTOCONF='autoconf'}
162: ${AUTOM4TE='autom4te'}
163: ${AUTOMAKE='automake'}
164: ${AUTOHEADER='autoheader'}
165: ${AUTOPOINT='autopoint'}
166: ${AUTORECONF='autoreconf'}
167: ${ACLOCAL='aclocal'}
168: ${GSL_CONFIG=@GSL_CONFIG@}
169: ${M4=m4}
170: ${MAKE=make}
171: ${PKG_CONFIG='pkg-config'}
172: ${RM=rm}
173YAT_CONFIG=$abs_top_builddir/build_support/yat-config
174YAT_LDFLAGS="@YAT_LDFLAGS@"
175CXX="@CXX@"
176CPPFLAGS="@CPPFLAGS@"
177CXXFLAGS="@CXXFLAGS@"
178LDFLAGS="@LDFLAGS@"
179
180# user is always right
181test -z "$DOXYGEN" && DOXYGEN="@DOXYGEN@"
182VERSION="@VERSION@"
Note: See TracBrowser for help on using the repository browser.