1 | # @configure_input@ |
---|
2 | # $Id: defs.sh.in 3110 2013-11-09 23:42:16Z peter $ |
---|
3 | |
---|
4 | # Copyright (C) 2009, 2010, 2011, 2012, 2013 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 | # |
---|
24 | bootstrap () |
---|
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 | autoreconf -si $verbose || res=$? |
---|
32 | case $res in |
---|
33 | 0) |
---|
34 | :;; |
---|
35 | 63) |
---|
36 | exit_skip;; |
---|
37 | *) |
---|
38 | exit $res;; |
---|
39 | esac |
---|
40 | } |
---|
41 | |
---|
42 | # Usage: run PROG EXPECTED_EXITCODE [OPTION]... |
---|
43 | run () |
---|
44 | { |
---|
45 | test $# -ge 2 || exit_fatal |
---|
46 | foo_prog=$1 |
---|
47 | shift |
---|
48 | expected_exitcode=$1 |
---|
49 | shift |
---|
50 | exitcode=0 |
---|
51 | $foo_prog ${1+"$@"} > stdout 2>stderr || exitcode=$? |
---|
52 | cat stderr >&2 |
---|
53 | cat stdout |
---|
54 | test $exitcode = $expected_exitcode || Exit 1 |
---|
55 | } |
---|
56 | |
---|
57 | Exit () { set +x; exit $1; } |
---|
58 | warn_ () { echo $@ >&2; } |
---|
59 | exit_fail () { warn_ "$me: failed test: $@"; Exit 1; } |
---|
60 | exit_fatal () { warn_ "$me: hard error: $@"; Exit 99; } |
---|
61 | exit_skip () { warn_ "$me: skipped test: $@"; Exit 77; } |
---|
62 | exit_success () { echo "$me: successsful test: $@"; Exit 0; } |
---|
63 | |
---|
64 | check_requirements () |
---|
65 | { |
---|
66 | # if required tool is not available, exit_skip |
---|
67 | if test -n "$required"; then |
---|
68 | for tool in $required; do |
---|
69 | case $tool in |
---|
70 | automake) |
---|
71 | echo "$me: running $tool --version" |
---|
72 | ($tool --version) || exit_skip; |
---|
73 | # skip test if automake older than v1.10 |
---|
74 | version_am=`$tool --version | head -n 1 | cut -f 2 -d ')'` |
---|
75 | ver_major=`echo ${version_am} | cut -f 1 -d '.'` |
---|
76 | test ${ver_major} -ge 1 || exit_skip |
---|
77 | ver_minor=`echo ${version_am} | cut -f 2 -d '.'` |
---|
78 | test ${ver_major} -gt 1 || test ${ver_minor} -ge 10 || exit_skip |
---|
79 | ;; |
---|
80 | doxygen) |
---|
81 | test @have_doxygen@ = "yes" || exit_skip no doxygen |
---|
82 | ;; |
---|
83 | libbam) |
---|
84 | test @have_libbam@ = "yes" || exit_skip no libbam |
---|
85 | ;; |
---|
86 | libmy-shared) |
---|
87 | test -r test/lib/libmy-shared.la || exit_fatal "no 'libmy-shared.la'" |
---|
88 | test -s test/lib/libmy-shared.la || exit_skip no shared lib |
---|
89 | ;; |
---|
90 | libmy-static) |
---|
91 | test -r test/lib/libmy-static.a || exit_fatal "no 'libmy-static.a'" |
---|
92 | test -s test/lib/libmy-static.a || exit_skip no static lib |
---|
93 | ;; |
---|
94 | libtool) |
---|
95 | # GNU libtool comes as glibtool on Mac OS |
---|
96 | (echo "$me: running libtool --version" && libtool --version) || \ |
---|
97 | (echo "$me: running glibtool --version" && glibtool --version) || \ |
---|
98 | exit_skip |
---|
99 | ;; |
---|
100 | shared) |
---|
101 | if (test "x@enable_shared@" = "xno"); then |
---|
102 | echo shared disabled; |
---|
103 | exit_skip; |
---|
104 | fi |
---|
105 | ;; |
---|
106 | static) |
---|
107 | if (test "x@enable_static@" = "xno"); then |
---|
108 | echo static disabled; |
---|
109 | exit_skip; |
---|
110 | fi |
---|
111 | ;; |
---|
112 | *) |
---|
113 | echo "$me: running $tool --version" |
---|
114 | ($tool --version) || exit_skip |
---|
115 | esac |
---|
116 | done |
---|
117 | fi |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | me=$0 |
---|
122 | # some defs we need in tests |
---|
123 | test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'` |
---|
124 | test_dir="test/testSubDir/$test_dir" |
---|
125 | abs_top_builddir=@abs_top_builddir@ |
---|
126 | abs_top_srcdir=@abs_top_srcdir@ |
---|
127 | lt_cv_objdir=@lt_cv_objdir@ |
---|
128 | have_doxygen="@have_doxygen@" |
---|
129 | mkdir_p="@MKDIR_P@ --verbose" |
---|
130 | verbose="--verbose" |
---|
131 | silent= |
---|
132 | |
---|
133 | GSL_CONFIG=@GSL_CONFIG@ |
---|
134 | |
---|
135 | # user is always right |
---|
136 | test -z "$DOXYGEN" && DOXYGEN="@DOXYGEN@" |
---|
137 | VERSION="@VERSION@" |
---|