configure.ac 9 KB
Newer Older
Johan Dahlin's avatar
Johan Dahlin committed
1
-*- mode: m4 -*-
2
AC_PREREQ([2.68])
Johan Dahlin's avatar
Johan Dahlin committed
3

4 5 6 7 8 9 10 11 12 13 14
# The version of python used is determined by the executable pointed to by the
# --with-python switch, or if that's not set, by the PYTHON environment
# variable.  For instance if your system installs Python 3 as python3 to
# configure to compile pygobject under Python 3 you would do this:
#   $ ./configure --with-python=python3
# or
#   $ PYTHON=python3 ./configure
#
# You can also build against a full interpreter path, such as
#   $ ./configure --with-python=~/my-patched-python/python

Martin Pitt's avatar
Martin Pitt committed
15
m4_define(python_min_ver, 2.7)
16 17
m4_define(python3_min_ver, 3.1)

Johan Dahlin's avatar
Johan Dahlin committed
18
dnl the pygobject version number
John (J5) Palmieri's avatar
John (J5) Palmieri committed
19
m4_define(pygobject_major_version, 3)
20
m4_define(pygobject_minor_version, 11)
21
m4_define(pygobject_micro_version, 91)
Johan Dahlin's avatar
Johan Dahlin committed
22 23 24
m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)

dnl versions of packages we require ...
25
m4_define(introspection_required_version, 1.38.0)
26 27
m4_define(py2cairo_required_version, 1.2.0)
m4_define(py3cairo_required_version, 1.10.0)
28 29
m4_define(glib_required_version, 2.38.0)
m4_define(gio_required_version, 2.38.0)
Johan Dahlin's avatar
Johan Dahlin committed
30

31 32 33
AC_INIT([pygobject],[pygobject_version],
	[http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject],
	[pygobject],[https://live.gnome.org/PyGObject/])
Johan Dahlin's avatar
Johan Dahlin committed
34
AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I .")
35
AC_CONFIG_MACRO_DIR([m4])
36
AC_CONFIG_SRCDIR([gi/gimodule.c])
Johan Dahlin's avatar
Johan Dahlin committed
37 38 39 40 41 42 43 44

AC_DEFINE(PYGOBJECT_MAJOR_VERSION, pygobject_major_version, [pygobject major version])
AC_SUBST(PYGOBJECT_MAJOR_VERSION, pygobject_major_version)
AC_DEFINE(PYGOBJECT_MINOR_VERSION, pygobject_minor_version, [pygobject minor version])
AC_SUBST(PYGOBJECT_MINOR_VERSION, pygobject_minor_version)
AC_DEFINE(PYGOBJECT_MICRO_VERSION, pygobject_micro_version, [pygobject micro version])
AC_SUBST(PYGOBJECT_MICRO_VERSION, pygobject_micro_version)

Marko Lindqvist's avatar
Marko Lindqvist committed
45
AC_CONFIG_HEADERS(config.h)
Johan Dahlin's avatar
Johan Dahlin committed
46
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
47
AM_INIT_AUTOMAKE([1.11.1 foreign no-dist-gzip dist-xz])
Johan Dahlin's avatar
Johan Dahlin committed
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

dnl put the ACLOCAL flags in the makefile
ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"

AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_MSG_CHECKING([for some Win32 platform])
case "$host" in
  *-*-mingw*|*-*-cygwin*)
    platform_win32=yes
    ;;
  *)
    platform_win32=no
    ;;
esac
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")

AC_MSG_CHECKING([for native Win32])
case "$host" in
  *-*-mingw*)
    os_win32=yes
    ;;
  *)
    os_win32=no
    ;;
esac
AC_MSG_RESULT([$os_win32])
AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")

78 79
LT_PREREQ([2.2.6])
LT_INIT([dlopen win32-dll disable-static])
80

Martin Pitt's avatar
Martin Pitt committed
81
AC_SEARCH_LIBS([strerror],[cposix])
Johan Dahlin's avatar
Johan Dahlin committed
82
AC_PROG_CC
83
AM_PROG_CC_C_O
Johan Dahlin's avatar
Johan Dahlin committed
84

85 86 87 88
# option to specify python interpreter to use; this just sets $PYTHON, so that
# we will fallback to reading $PYTHON if --with-python is not given, and
# python.m4 will get the expected input
AC_ARG_WITH(python,
Martin Pitt's avatar
Martin Pitt committed
89
  AS_HELP_STRING([--with-python=PATH],[Path to Python interpreter; searches $PATH if only a program name is given; if not given, searches for a few standard names such as "python3" or "python2"]),
90 91 92 93 94 95 96 97
  [PYTHON="$withval"], [])
if test x"$PYTHON" = xyes; then
	AC_MSG_ERROR([--with-python option requires a path or program argument])
fi
if test -n "$PYTHON" && ! which "$PYTHON"; then
	AC_MSG_ERROR([Python interpreter $PYTHON does not exist])
fi

98
# check that we have the minimum version of python necessary to build
99 100 101
JD_PATH_PYTHON(python_min_ver)

# check if we are building for python 3
102
AM_PYTHON_CHECK_VERSION([$PYTHON], [3.0],
103 104 105 106 107 108
			 build_py3k=true,
			 build_py3k=false)

# if building for python 3 make sure we have the minimum version supported
if test $build_py3k = true ; then
  AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver)
109
  AM_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver,
110 111 112
			  [AC_MSG_RESULT(yes)],
			  [AC_MSG_ERROR(too old)])
fi
Johan Dahlin's avatar
Johan Dahlin committed
113

114 115 116 117
# - 'SO' for PyPy, CPython 2.7-3.2
# - 'EXT_SUFFIX' for CPython3.3+ (http://bugs.python.org/issue16754)
# - fallback to '.so'
PYTHON_SO=`$PYTHON -c "import distutils.sysconfig, sys; get = distutils.sysconfig.get_config_var; sys.stdout.write(get('EXT_SUFFIX') or get('SO') or '.so');"`
118 119
AC_SUBST(PYTHON_SO)

120
AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
121 122 123
if test "x$os_win32" = "xyes"; then
  AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.]))
fi
Johan Dahlin's avatar
Johan Dahlin committed
124

Johan Dahlin's avatar
Johan Dahlin committed
125 126
AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h])
old_CPPFLAGS=$CPPFLAGS
127
CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES"
Martin Pitt's avatar
Martin Pitt committed
128 129
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[PySignal_SetWakeupFd(0);]])],
                  [setwakeupfd_ok=yes],[setwakeupfd_ok=no])
Johan Dahlin's avatar
Johan Dahlin committed
130 131 132 133 134 135 136
AC_MSG_RESULT($setwakeupfd_ok)
if test "x$setwakeupfd_ok" != xno; then
  AC_DEFINE(HAVE_PYSIGNAL_SETWAKEUPFD, 1,
                [Define to 1 if PySignal_SetWakeupFd is available])
fi
CPPFLAGS=$old_CPPFLAGS

137
PLATFORM=`$PYTHON -c "import sys; from distutils import util; sys.stdout.write(util.get_platform())"`
Johan Dahlin's avatar
Johan Dahlin committed
138 139
AC_SUBST(PLATFORM)

Johan Dahlin's avatar
Johan Dahlin committed
140
AC_ARG_ENABLE(thread,
Martin Pitt's avatar
Martin Pitt committed
141
  AS_HELP_STRING([--disable-thread],[Disable pygobject threading support]),,
Johan Dahlin's avatar
Johan Dahlin committed
142 143
  enable_thread=yes)

144 145 146
AM_CHECK_PYMOD(thread,,,enable_thread=check_for_py3_module)
if test "x$enable_thread" = xcheck_for_py3_module; then
  dnl Python 3 uses the _thread module so check for that
147
  AM_CHECK_PYMOD(_thread,,enable_thread=yes,enable_thread=no)
148
fi
Johan Dahlin's avatar
Johan Dahlin committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170

AC_MSG_CHECKING(whether to enable threading in pygobject)
if test "x$enable_thread" != xno; then
  extra_mods=gthread
  THREADING_CFLAGS=
  AC_MSG_RESULT(yes)
else
  extra_mods=
  THREADING_CFLAGS="-DDISABLE_THREADING"
  AC_MSG_RESULT(no)
fi
AC_SUBST(THREADING_CFLAGS)
CPPFLAGS="${CPPFLAGS} $THREADING_CFLAGS"

dnl get rid of the -export-dynamic stuff from the configure flags ...
export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`

dnl glib
AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(maybe you want the pygobject-2-4 branch?)],gobject $extra_mods)
if test -n "$export_dynamic"; then
  GLIB_LIBS=`echo $GLIB_LIBS | sed -e "s/$export_dynamic//"`
fi
171 172
PYTHON_BASENAME=`basename $PYTHON`
AC_SUBST([PYTHON_BASENAME])
Johan Dahlin's avatar
Johan Dahlin committed
173

174 175
AS_AC_EXPAND(DATADIR, $datadir)

176
dnl libffi
177 178
AC_MSG_CHECKING(for ffi)
AC_ARG_WITH(ffi,
Martin Pitt's avatar
Martin Pitt committed
179
  AS_HELP_STRING([--without-ffi],[Disable libffi support]),
180 181 182 183
  with_libffi=$withval,
  with_libffi=auto)
if test x"$with_libffi" = xno ; then
  have_libffi=false
184
else
185
  PKG_CHECK_MODULES(FFI, libffi >= 3.0, have_libffi=yes, have_libffi=no)
186
fi
187
if test x"$with_libffi" = xyes && test x"$have_libffi" = xno ; then
188
  AC_MSG_ERROR([ffi requested, but not found])
Paul Pogonyshev's avatar
Paul Pogonyshev committed
189
fi
190
if test x"$have_libffi" = xyes; then
191
  LIBFFI_PC=libffi
192
fi
193
AM_CONDITIONAL(HAVE_LIBFFI, test "$have_libffi" = "yes")
194
AC_SUBST(FFI_CFLAGS)
195
AC_SUBST(FFI_LIBS)
196
AC_SUBST(LIBFFI_PC)
197

198 199 200
dnl gio
PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version)

201
AC_ARG_ENABLE(cairo,
Martin Pitt's avatar
Martin Pitt committed
202
    AS_HELP_STRING([--enable-cairo],[Enable Cairo bindings using introspection information]),
203 204 205
    enable_cairo=$enableval,
    enable_cairo=yes)

206 207 208 209 210 211 212 213 214
PKG_CHECK_MODULES(GI,
    glib-2.0 >= glib_required_version
    gobject-introspection-1.0 >= introspection_required_version
)

GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
AC_SUBST(GI_DATADIR)

if test "$enable_cairo" != no; then
215 216
    PKG_CHECK_MODULES(CAIRO, cairo cairo-gobject)

217
    if test $build_py3k = true; then
218 219 220 221 222 223 224
        PKG_CHECK_MODULES(PYCAIRO,
            py3cairo >= py3cairo_required_version
        )
    else
        PKG_CHECK_MODULES(PYCAIRO,
            pycairo >= py2cairo_required_version
        )
225
    fi
226
fi
227
AM_CONDITIONAL(ENABLE_CAIRO, test "$enable_cairo" = "yes")
228

229 230 231 232 233 234 235
AC_ARG_WITH(common,
    AS_HELP_STRING([--without-common],
        [For package maintainers: do not install Python version independent files]),
    with_common=$enableval,
    with_common=yes)
AM_CONDITIONAL(WITH_COMMON, test "$with_common" = "yes")

Johan Dahlin's avatar
Johan Dahlin committed
236 237 238 239 240 241
INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`

AC_SUBST(INTROSPECTION_SCANNER)
AC_SUBST(INTROSPECTION_COMPILER)

242 243
# compiler warnings, errors, required cflags, and code coverage support
GNOME_COMPILE_WARNINGS([maximum])
244 245 246 247 248 249 250 251 252
AC_MSG_CHECKING(for Gnome code coverage support)
m4_ifdef([GNOME_CODE_COVERAGE],
         [AC_MSG_RESULT(yes)
          GNOME_CODE_COVERAGE],
         [AC_MSG_RESULT(no)
          GNOME_CODE_COVERAGE_RULES=''
          AC_SUBST([GNOME_CODE_COVERAGE_RULES])
          enable_code_coverage="no"])

253 254
if test "x$GCC" = "xyes"; then
  JH_ADD_CFLAG([-Wall])
255
  JH_ADD_CFLAG([-Werror=unused-variable])
256
  JH_ADD_CFLAG([-fno-strict-aliasing])
257 258 259 260 261 262 263 264 265

  case $host_os in
  solaris*)
    ;;
  *)
    JH_ADD_CFLAG([-std=c9x])
    ;;
  esac

266
fi
Johan Dahlin's avatar
Johan Dahlin committed
267

268
CFLAGS="$CFLAGS $WARN_CFLAGS $CODE_COVERAGE_CFLAGS"
269 270
LDFLAGS="$LDFLAGS $CODE_COVERAGE_CFLAGS"

Johan Dahlin's avatar
Johan Dahlin committed
271 272
AC_CONFIG_FILES(
  Makefile
273 274
  pygobject-3.0.pc
  pygobject-3.0-uninstalled.pc
Johan Dahlin's avatar
Johan Dahlin committed
275 276 277
  gi/Makefile
  gi/repository/Makefile
  gi/overrides/Makefile
278
  gi/_gobject/Makefile
Johan Dahlin's avatar
Johan Dahlin committed
279 280
  examples/Makefile
  tests/Makefile
281
  pygtkcompat/Makefile
Johan Dahlin's avatar
Johan Dahlin committed
282 283
  PKG-INFO)
AC_OUTPUT
284

285 286 287 288 289 290 291
AC_MSG_RESULT([
	pygobject $VERSION

	Using python interpreter:	$PYTHON
	libffi support:			$have_libffi
	cairo support:			$enable_cairo
	thread support:			$enable_thread
292
	code coverage support:          $enable_code_coverage
293 294
])