1 | # @configure_input@ |
---|
2 | # $Id: common_defs.sh.in 2244 2010-04-20 20:47:26Z peter $ |
---|
3 | |
---|
4 | # Copyright (C) 2009 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 | # 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. |
---|
28 | is_newest () |
---|
29 | { |
---|
30 | test x`find "$@" -newer "$1"` = x |
---|
31 | } |
---|
32 | |
---|
33 | # |
---|
34 | # |
---|
35 | bootstrap () |
---|
36 | { |
---|
37 | @MKDIR_P@ m4 |
---|
38 | autoreconf -siv && true |
---|
39 | res=$? |
---|
40 | case $res in |
---|
41 | 0) |
---|
42 | :;; |
---|
43 | 63) |
---|
44 | exit 77;; |
---|
45 | *) |
---|
46 | exit $res;; |
---|
47 | esac |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | me=$0 |
---|
52 | |
---|
53 | echo "=== Running $me ===" |
---|
54 | |
---|
55 | # if required tool is not available, exit 77 to skip test |
---|
56 | if test -n "$required"; then |
---|
57 | for tool in $required; do |
---|
58 | case $tool in |
---|
59 | libtool) |
---|
60 | # GNU libtool comes as glibtool on Mac OS |
---|
61 | (echo "$me: running libtool --version" && libtool --version) || \ |
---|
62 | (echo "$me: running glibtool --version" && glibtool --version) || exit 77 |
---|
63 | ;; |
---|
64 | static) |
---|
65 | if (test "x@enable_static@" = "xno"); then |
---|
66 | echo static libyat disabled; |
---|
67 | exit 77; |
---|
68 | fi |
---|
69 | ;; |
---|
70 | *) |
---|
71 | echo "$me: running $tool --version" |
---|
72 | ($tool --version) || exit 77 |
---|
73 | esac |
---|
74 | done |
---|
75 | fi |
---|
76 | |
---|
77 | # some defs we need in tests |
---|
78 | test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'` |
---|
79 | test_dir="testSubDir/$test_dir" |
---|
80 | abs_top_builddir=@abs_top_builddir@ |
---|
81 | abs_top_srcdir=@abs_top_srcdir@ |
---|
82 | move_if_change=@abs_top_srcdir@/build_support/move-if-change |
---|
83 | |
---|
84 | rm -rf $test_dir |
---|
85 | @MKDIR_P@ --verbose $test_dir |
---|
86 | |
---|
87 | cd $test_dir |
---|
88 | |
---|
89 | if (echo "$required" | grep autoconf > /dev/null); then |
---|
90 | echo "creating configure.ac" |
---|
91 | cat > configure.ac <<EOF |
---|
92 | AC_INIT([hello],[1.0]) |
---|
93 | AC_CONFIG_SRCDIR([hello.cc]) |
---|
94 | AM_INIT_AUTOMAKE([foreign]) |
---|
95 | AC_CONFIG_MACRO_DIR([m4]) |
---|
96 | AC_LANG(C++) |
---|
97 | AC_PROG_CXXCPP |
---|
98 | AC_PROG_CXX |
---|
99 | EOF |
---|
100 | if (echo "$required" | grep libtool > /dev/null); then |
---|
101 | echo AC_PROG_LIBTOOL >> configure.ac |
---|
102 | fi |
---|
103 | |
---|
104 | |
---|
105 | echo "creating Makefile.am" |
---|
106 | cat > Makefile.am <<EOF |
---|
107 | ACLOCAL_AMFLAGS = -I m4 -I ${abs_top_srcdir}/m4 --install |
---|
108 | AM_CPPFLAGS = \$(YAT_CPPFLAGS) |
---|
109 | AM_CXXFLAGS = \$(YAT_CXXFLAGS) |
---|
110 | LDADD = \$(YAT_LDADD) |
---|
111 | bin_PROGRAMS = hello |
---|
112 | TESTS = hello |
---|
113 | hello_SOURCES = hello.cc |
---|
114 | EOF |
---|
115 | |
---|
116 | echo "creating hello.cc" |
---|
117 | cat > hello.cc <<EOF |
---|
118 | #include <yat/utility/Vector.h> |
---|
119 | #include <yat/utility/version.h> |
---|
120 | #include <algorithm> |
---|
121 | #include <iostream> |
---|
122 | #include <string> |
---|
123 | int main(void) |
---|
124 | { |
---|
125 | using namespace theplu::yat; |
---|
126 | if (utility::version()!="@VERSION@") { |
---|
127 | std::cerr << "Incorrect version of linked libyat\n"; |
---|
128 | return 1; |
---|
129 | } |
---|
130 | // testing something with gsl |
---|
131 | utility::Vector v(10); |
---|
132 | v.resize(120); |
---|
133 | // testing something with boost |
---|
134 | std::copy(v.begin(), v.begin()+10, v.begin()+10); |
---|
135 | return 0; |
---|
136 | } |
---|
137 | EOF |
---|
138 | fi #end of creation of autotool files |
---|
139 | |
---|
140 | # turn on shell traces when in verbose mode |
---|
141 | set -x |
---|