~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to bindings/swig/package/sword.m4

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Glassey
  • Date: 2004-01-15 15:50:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040115155007-n9mz4x0zxrs1isd3
Tags: upstream-1.5.7
ImportĀ upstreamĀ versionĀ 1.5.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##      -*- autoconf -*-
 
2
dnl This file was created by Joachim Ansorg <jansorg@gmx.de>
 
3
dnl It provides macord for the autoconf package to find the Sword library on your system.
 
4
 
 
5
dnl ----------------------------------------------------------------------
 
6
dnl             Check wheter to use static linking
 
7
dnl             first parameter is the required version
 
8
dnl             second is whether to use static sword library
 
9
dnl ----------------------------------------------------------------------
 
10
AC_DEFUN(SW_CHECK_SWORD,
 
11
[
 
12
dnl AC_MSG_CHECKING([for a Sword installation])
 
13
 
 
14
dnl The option for the configure script
 
15
AC_ARG_WITH(sword-dir,
 
16
[  --with-sword-dir=DIR     Patch where Sword is being installed (default=/usr) ],
 
17
[
 
18
  ac_sword_dir=$withval
 
19
],ac_sword_dir=/usr
 
20
)
 
21
 
 
22
AC_ARG_ENABLE(static-sword,
 
23
[  --enable-static-sword    Link to the static Sword library],
 
24
        ac_static_sword="YES",
 
25
        [ ac_static_sword="$2" ]
 
26
)
 
27
 
 
28
dnl try to find Sword library files
 
29
AC_MSG_CHECKING([for Sword library files])
 
30
AC_REQUIRE([AC_FIND_ZLIB])
 
31
ac_sword_library_dirs="$ac_sword_dir/lib /usr/lib /usr/lib/sword /usr/local/lib /usr/local/lib/sword /usr/local/sword/lib"
 
32
 
 
33
if test "$ac_static_sword" = "YES"; then
 
34
        SEARCH_LIBS="libsword.a";
 
35
else
 
36
        SEARCH_LIBS="libsword.a libsword.so";
 
37
fi
 
38
 
 
39
 
 
40
AC_CACHE_VAL(ac_cv_sword_libdir, AC_FIND_FILE($SEARCH_LIBS, $ac_sword_library_dirs, ac_cv_sword_libdir))
 
41
 
 
42
if test "$ac_cv_sword_libdir" = "NO"; then
 
43
  AC_MSG_ERROR(SWORD library not found. Try to use configure with --with-sword-dir=/your/SWORD/path!);
 
44
fi
 
45
 
 
46
if test "$ac_static_sword" = "YES"; then
 
47
        LIB_SWORD="$ac_cv_sword_libdir/libsword.a";
 
48
else
 
49
        LIB_SWORD="-L$ac_cv_sword_libdir -lsword";
 
50
fi
 
51
 
 
52
#AC_SUBST(SWORD_LIBRARY_PATH)
 
53
AC_SUBST(LIB_SWORD)
 
54
all_libraries="$all_libraries -L$ac_cv_sword_libdir"
 
55
 
 
56
if test "$ac_static_sword" = "YES"; then
 
57
        MESSAGE="static library $ac_cv_sword_libdir/libsword.a";
 
58
else
 
59
        MESSAGE="$ac_cv_sword_libdir";
 
60
fi
 
61
AC_MSG_RESULT([$MESSAGE])
 
62
 
 
63
 
 
64
 
 
65
dnl -- try to find Swords include files --
 
66
AC_MSG_CHECKING([for Sword include files])
 
67
ac_sword_include_dirs="$ac_sword_dir/include/sword $ac_sword_dir/include /usr/include/sword /usr/include /usr/local/include/sword /usr/local/include /usr/local/sword/include /usr/local/sword/include/sword"
 
68
 
 
69
AC_CACHE_VAL(ac_cv_sword_incdir, AC_FIND_FILE(swmgr.h, $ac_sword_include_dirs, ac_cv_sword_incdir))
 
70
 
 
71
if test "$ac_cv_sword_incdir" = "NO"; then
 
72
        AC_MSG_ERROR([The Sword include file files were not found.
 
73
Please try to use configure with --with-sword-dir=/your/SWORD/path !
 
74
])
 
75
fi
 
76
 
 
77
SWORD_INCLUDES="-I$ac_cv_sword_incdir"
 
78
AC_SUBST(SWORD_INCLUDES)
 
79
all_includes="$all_includes -I$ac_cv_sword_incdir"
 
80
 
 
81
AC_MSG_RESULT([$ac_cv_sword_incdir])
 
82
 
 
83
 
 
84
 
 
85
dnl -- check if Sword matches the minimum version --
 
86
AC_MSG_CHECKING([if you have Sword $1 or later])
 
87
 
 
88
AC_CACHE_VAL(ac_cv_installed_sword_version,
 
89
[
 
90
AC_LANG_SAVE
 
91
AC_LANG_CPLUSPLUS
 
92
ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
 
93
ac_LIBRARY_PATH="$LIBRARY_PATH"
 
94
ac_cxxflags_safe="$CXXFLAGS"
 
95
ac_ldflags_safe="$LDFLAGS"
 
96
ac_libs_safe="$LIBS"
 
97
 
 
98
CXXFLAGS="$CXXFLAGS -I$"
 
99
LDFLAGS="$LDFLAGS -L$ac_cv_sword_libdir"
 
100
LIBS="$LIB_SWORD -lz"
 
101
LD_LIBRARY_PATH="$ac_cv_sword_libdir"
 
102
export LD_LIBRARY_PATH
 
103
LIBRARY_PATH=
 
104
export LIBRARY_PATH
 
105
 
 
106
cat > conftest.$ac_ext <<EOF
 
107
#include <iostream.h>
 
108
#include <swversion.h>
 
109
using std::cout;
 
110
using std::endl;
 
111
using sword::SWVersion;
 
112
 
 
113
int main(int argc, char* argv[]) {
 
114
        if (argc != 2) {
 
115
                cout << SWVersion::currentVersion << endl;
 
116
        }
 
117
        else if (argc == 2) 
 
118
        {
 
119
                if (SWVersion(&argv[[1]]) < SWVersion::currentVersion || SWVersion(&argv[[1]]) == SWVersion::currentVersion)
 
120
                {
 
121
                        cout << 0 << endl;
 
122
                        return 0;
 
123
                }
 
124
                else    
 
125
                {
 
126
                        cout << 1 << endl;
 
127
                        return 1; //version not recent enough
 
128
                }
 
129
        }
 
130
        return 0;
 
131
}
 
132
EOF
 
133
 
 
134
ac_link='${CXX-g++} -o conftest $CXXFLAGS $all_includes $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 
135
if AC_TRY_EVAL(ac_link) && test -s conftest; then
 
136
        if test -x conftest; then
 
137
                eval ac_cv_installed_sword_version=`./conftest 2>&5`
 
138
                echo "configure: ac_cv_installed_sword_version=$ac_cv_installed_sword_version" >&AC_FD_CC
 
139
                eval sword_test_returncode=`./conftest $1 2>&5`;
 
140
                echo "configure: sword_test_returncode=$sword_test_returncode" >&AC_FD_CC
 
141
        fi
 
142
else
 
143
  echo "configure: failed program was:" >&AC_FD_CC
 
144
  cat conftest.$ac_ext >&AC_FD_CC
 
145
fi
 
146
 
 
147
rm -f conftest*
 
148
CXXFLAGS="$ac_cxxflags_safe"
 
149
LDFLAGS="$ac_ldflags_safe"
 
150
LIBS="$ac_libs_safe"
 
151
 
 
152
LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
 
153
export LD_LIBRARY_PATH
 
154
LIBRARY_PATH="$ac_LIBRARY_PATH"
 
155
export LIBRARY_PATH
 
156
AC_LANG_RESTORE
 
157
])
 
158
 
 
159
right_version="ok";
 
160
if test "x$sword_test_returncode" = "x1"; then
 
161
        echo "configure: changing right_version" >&AC_FD_CC
 
162
        right_version="wrong version";
 
163
fi;
 
164
        
 
165
AC_MSG_RESULT([$ac_cv_installed_sword_version])
 
166
echo "configure: right_version=$right_version" >&AC_FD_CC
 
167
if test "x$right_version" != "xok"; then
 
168
        AC_MSG_ERROR([Your Sword installation is not recent enough! $sword_test_returncode Please
 
169
upgrade to version $1!]);
 
170
fi;
 
171
 
 
172
])