summaryrefslogtreecommitdiffstats
path: root/kig/configure.in.in
blob: 05d5934df223ffbfc59a3c54e342b218e6f02049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
kig_version=0.10.7

kde_save_LIBS=$LIBS
LIBS="$LIBS -lm"
KDE_CHECK_FUNC_EXT(trunc)
LIBS="$kde_save_LIBS"

KDE_LANG_CPLUSPLUS

# this variable is set to true if we need to warn the user that Python
# scripting support has been disabled due to missing headers or libs
# or whatever..  It's not set if the user explicitly disabled python
# scripting ( "./configure --disable-kig-python-scripting" ).  We
# complain about this at the end of the ./configure script.  Check out
# configure.in.bot for the code..
kig_warn_about_disabling_python="no"

# this var is set to yes if we want to compile python scripting, and to 
# no otherwise
kig_enable_python_scripting="yes"

# this var is set to no if we want to disable support for compressed files
# (for compatibility reasons with kde 3.1)
kig_enable_compressed_files="yes"

AC_DEFUN([KIG_PYTHON_NOT_FOUND], [
  AC_MSG_WARN( 
    [[Kig needs the Python and Boost.Python libraries and their headers \
installed for its Python scripting support.  One of both was not \
found, or the versions were incompatible, and Python scripting will be disabled.]] );
  kig_warn_about_disabling_python="yes"
  kig_enable_python_scripting="no" ] )

AC_ARG_ENABLE( kig-python-scripting, 
  [  --disable-kig-python-scripting	Disable Kig Python Scripting support],
  [  kig_enable_python_scripting=$enableval ],
  [  kig_enable_python_scripting=yes] )

AC_ARG_ENABLE( kig-compressed-files, 
  [  --disable-kig-compressed-files	Disable Kig Compressed Files support],
  [  kig_enable_compressed_files=$enableval ],
  [  kig_enable_compressed_files=yes] )

dnl domi: we use some macro's by Ben Burton from the Regina program,
dnl to check for the availability of a good python+boost.python
dnl combination.  They are included here, the end is marked at the 
dnl bottom.  I have changed it only by removing some macro's, and by 
dnl making the other call KIG_PYTHON_NOT_FOUND instead of 
dnl REGINA_DO_NOT_COMPILE, and REGINA_WARN_*.
dnl
dnl    Regina - A Normal Surface Theory Calculator
dnl    Configure Script Macros
dnl
dnl    Copyright (c) 2002-2003, Ben Burton
dnl    For further details contact Ben Burton ([email protected]).
dnl
dnl    This file is free software; you can redistribute it and/or
dnl    modify it under the terms of the GNU General Public License as
dnl    published by the Free Software Foundation; either version 2 of the
dnl    License, or (at your option) any later version.
dnl
dnl    This file is distributed in the hope that it will be useful, but
dnl    WITHOUT ANY WARRANTY; without even the implied warranty of
dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl    General Public License for more details.
dnl
dnl    You should have received a copy of the GNU General Public
dnl    License along with this program; if not, write to the Free
dnl    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
dnl    MA 02110-1301, USA.
dnl
dnl    Note that this copyright notice applies only to macros beginning
dnl    with REGINA_.  Other macros found in acinclude.m4 have been taken
dnl    from external sources; these macros are stored in separate files
dnl    in the admin/ subdirectory and copyright notices can be found in
dnl    these separate files (and in the comments provided with the macros
dnl    themselves).
dnl

dnl    -----------------------------------------------------------------
dnl
dnl                        Macros written for Regina
dnl
dnl    -----------------------------------------------------------------

dnl
dnl    REGINA_LIB_BOOST_PYTHON(TARGET-LIST, REQUIRED-BY)
dnl
dnl    Checks for a usable boost.python installation.
dnl    Issues a warning and adds <TARGET-LIST> (which may consist of
dnl    several targets) to $DO_NOT_COMPILE if boost.python is missing.
dnl
dnl    AC_SUBST()s the following variables:
dnl
dnl        BOOST_PYTHON_INCLUDES: The compiler flags required for
dnl                               building against boost.python,
dnl                               including flags for building against
dnl                               python itself.
dnl        BOOST_PYTHON_LIBS: The linker flags required for building
dnl                           against boost.python.
dnl        PYTHON_LIBS: The linker flags required for building against
dnl                     python itself.
dnl
dnl    AC_DEFINE()s the following variables:
dnl
dnl        HAVE_BOOST_PYTHON: Defined as 1 if we have a usable boost.python
dnl                           installation, or remains undefined otherwise.
dnl
dnl    Example: REGINA_LIB_BOOST_PYTHON(PYTHON, [the Python interface])
dnl
AC_DEFUN([REGINA_LIB_BOOST_PYTHON], [
  AC_LANG_PUSH(C++)
  KDE_CHECK_HEADERS([boost/shared_ptr.hpp], [
    __regina_py_save_cxxflags="$CXXFLAGS"
    __regina_py_save_ldflags="$LDFLAGS"
    __regina_py_save_libs="$LIBS"
    __regina_py_ok=0
    for pyver in python python2.7 python2.6 python2.5 python2.4 python2.3 python2.2; do
      for incdir in "/usr/include/$pyver" "/usr/local/include/$pyver" \
          "/usr/$pyver/include" "/usr/local/$pyver/include" \
          "$prefix/include/$pyver" "$prefix/$pyver/include"; do
        CXXFLAGS="$__regina_py_save_cxxflags -I$incdir"
        LDFLAGS="$__regina_py_save_ldflags -shared"
        if test -z "$qt_libraries"; then
          LDFLAGS="$LDFLAGS"
        else
          LDFLAGS="$LDFLAGS -L$qt_libraries"
        fi
        LDFLAGS="$LDFLAGS -ltqt"

        # Check for python includes.
        AC_TRY_COMPILE([
          #include <Python.h>
        ], [
          PyObject obj;
        ], [
          # Check for compatibility with boost.python.
          AC_MSG_CHECKING([for boost.python with $incdir/Python.h])
          AC_TRY_COMPILE([
            #include <boost/python.hpp>
            const char* greet() { return "Hello world!"; }
            BOOST_PYTHON_MODULE(hello) { boost::python::def("greet", greet); }
          ], [
            /* No main body. */
          ], [
            AC_MSG_RESULT([yes])
	
            # Check for -lpython.
            for pylib in "$pyver" python python2.7 python2.6 python2.3 python2.2; do
              for pylibdir in "/usr/lib" "/usr/local/lib" "/usr/lib/$pyver/config" \
		"/usr/local/lib/$pyver/config"; do
		for extralibs in "" "-lpthread -lm -lutil -ldl"; do
                  AC_MSG_CHECKING([for $pylibdir/lib$pylib and $extralibs with $incdir/Python.h])
		  LDFLAGS="$__regina_py_save_ldflags -L$pylibdir"
		  if test -z "$qt_libraries"; then
			LDFLAGS="$LDFLAGS"
		  else
			LDFLAGS="$LDFLAGS -L$qt_libraries"
		  fi
		  LDFLAGS="$LDFLAGS -ltqt"
		  LIBS="-l$pylib $extralibs"
		  PYVERSHORT=${pyver#python}
		  PYVERSUFFIX=py${PYVERSHORT%.*}${PYVERSHORT#*.}
		  PYVERMAJOR=${PYVERSHORT%.*}
		  if test $PYVERMAJOR -lt 3; then
			KIG_Python_init=initkig
		  else
			KIG_Python_init=PyInit_kig
		  fi
		  AC_TRY_LINK([
		    #include <Python.h>
		  ], [
		    Py_Initialize(); Py_Finalize();
		  ], [
		    AC_MSG_RESULT([yes])
		    for bplib in "-lboost_python-mt-$PYVERSUFFIX" "-lboost_python-mt" "-lboost_python-gcc-mt-1_32" "-lboost_python-gcc-mt-1_31" "-lboost_python-gcc-mt" "-lboost_python-$PYVERSUFFIX" "-lboost_python"; do
		      AC_MSG_CHECKING([compilation of a boost.python program with $bplib])
		      LDFLAGS="$__regina_py_save_ldflags -L$pylibdir"
		      if test -z "$qt_libraries"; then
			LDFLAGS="$LDFLAGS"
		      else
			LDFLAGS="$LDFLAGS -L$qt_libraries"
		      fi
		      LDFLAGS="$LDFLAGS -ltqt"
		      LIBS="-l$pylib $bplib $extralibs"
		      AC_TRY_LINK([
			#include <boost/python.hpp>
			const char* greet() { return "Hello world!"; }
			BOOST_PYTHON_MODULE(hello) { boost::python::def("greet", greet); }
		      ], [
		        /* No main body. */
		      ], [
			AC_MSG_RESULT([yes])
			# And we're done!
			BOOST_PYTHON_INCLUDES="-I$incdir"
			BOOST_PYTHON_LIBS="$bplib"
			PYTHON_LIBS="-l$pylib $extralibs"
			PYTHON_LDFLAGS="-L$pylibdir"
			__regina_py_ok=1
		      ], [
			AC_MSG_RESULT([no])
		      ])
		      if test "$__regina_py_ok" = "1"; then break; fi
		    done
		  ], [
		    AC_MSG_RESULT([no])
		  ])
		  if test "$__regina_py_ok" = "1"; then break; fi
		done
	        if test "$__regina_py_ok" = "1"; then break; fi
              done
              if test "$__regina_py_ok" = "1"; then break; fi
            done
          ], [
            AC_MSG_RESULT([no])
          ])
        ])
        if test "$__regina_py_ok" = "1"; then break; fi
      done
      if test "$__regina_py_ok" = "1"; then break; fi
    done

    CXXFLAGS="$__regina_py_save_cxxflags"
    LDFLAGS="$__regina_py_save_ldflags"
    LIBS="$__regina_py_save_libs"

    if test "$__regina_py_ok" = "1"; then
      AC_DEFINE(HAVE_BOOST_PYTHON, 1,
        [Define to 1 if you have a usable boost.python installation.])
      AC_DEFINE_UNQUOTED(KIG_Python_init, $KIG_Python_init,
        [KIG: Init function for python-boost])
    else
      BOOST_PYTHON_INCLUDES=
      BOOST_PYTHON_LIBS=
      KIG_PYTHON_NOT_FOUND
    fi
  ], [
    KIG_PYTHON_NOT_FOUND
  ])
  AC_LANG_POP(C++)
  AC_SUBST(BOOST_PYTHON_INCLUDES)
  AC_SUBST(BOOST_PYTHON_LIBS)
  AC_SUBST(PYTHON_LDFLAGS)
  AC_SUBST(PYTHON_LIBS)
])

dnl This is the end of the macro's copied from Ben Burton's Regina
dnl program.

if test "x$kig_enable_python_scripting" != xno; then
  kig_enable_python_scripting="yes" # either yes or no..

  kig_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-fno-exceptions//g'`
  REGINA_LIB_BOOST_PYTHON( PYTHON, Kig Python Scripting )
  CXXFLAGS="$kig_save_CXXFLAGS"
fi

if test "x$kig_enable_python_scripting" != xno; then
  AC_DEFINE( KIG_ENABLE_PYTHON_SCRIPTING, 1, [Defined if Kig Python scripting is enabled] )
fi

AM_CONDITIONAL(KIG_COMPILE_PYTHON_SCRIPTING, test x$kig_enable_python_scripting != xno)

if test "x$kig_enable_compressed_files" = xno; then
  CXXFLAGS="$CXXFLAGS -DKIG_NO_COMPRESSED_FILES"
fi

AC_SUBST( KIGVERSION, $kig_version )
AC_DEFINE_UNQUOTED( KIGVERSION, "$kig_version", [The current Kig version as a string] )

KDE_CHECK_HEADERS([ieeefp.h])

# apparently the KDE build system wants to see "dnl AC_OUTPUT( ... )",
# not a normal AC_OUTPUT
dnl AC_OUTPUT( kig/kig.lsm )
dnl AC_OUTPUT( kig/README )
dnl AC_OUTPUT( kig/package-kig.sh )
dnl AC_OUTPUT( kig/VERSION )