Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Make it build on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dieterv committed Aug 18, 2011
1 parent 782aae1 commit 09b5606
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 20 deletions.
33 changes: 28 additions & 5 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
[AC_REQUIRE([AM_PATH_PYTHON])
AC_MSG_CHECKING(for headers required to compile python extensions)
dnl deduce PYTHON_INCLUDES
if test -x "$PYTHON-config"; then
PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
else
py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
if test "x$PYTHON_INCLUDES" == x; then
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
if test "$py_prefix" != "$py_exec_prefix"; then
PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
Expand All @@ -65,3 +63,28 @@ $2])
CPPFLAGS="$save_CPPFLAGS"
])

dnl a macro to check for ability to embed python
dnl AM_CHECK_PYTHON_LIBS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
dnl function also defines PYTHON_LIBS
AC_DEFUN([AM_CHECK_PYTHON_LIBS],
[AC_REQUIRE([AM_CHECK_PYTHON_HEADERS])
AC_MSG_CHECKING(for libraries required to embed python)
dnl deduce PYTHON_LIBS
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
if test "x$PYTHON_LIBS" == x; then
PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
fi
if test "x$PYTHON_LIB_LOC" == x; then
PYTHON_LIB_LOC="${py_prefix}/lib"
fi
AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_LIB_LOC)
dnl check if the headers exist:
save_LIBS="$LIBS"
LIBS="$LIBS $PYTHON_LIBS"
AC_TRY_LINK_FUNC(Py_Initialize, dnl
[LIBS="$save_LIBS"; AC_MSG_RESULT(yes); $1], dnl
[LIBS="$save_LIBS"; AC_MSG_RESULT(no); $2])
])

15 changes: 14 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ AC_CONFIG_HEADERS(src/config.h)

AM_INIT_AUTOMAKE([1.9.6 -Wall])

# Checks for host ---
AC_CANONICAL_HOST
case "$host" in
*-*-mingw*)
os_win32=yes
;;
*)
os_win32=no
;;
esac
AM_CONDITIONAL(OS_WIN32, [test "x$os_win32" = "xyes"])

# Check for Win32
AC_CANONICAL_HOST
case "$host" in
Expand Down Expand Up @@ -61,7 +73,8 @@ AS_IF([test "x$have_xpyb" = "xyes"],
[AC_DEFINE([HAVE_XPYB], [1], [Define to 1 if xpyb is available])])

# Checks for header files ---
AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found]))

# checks for types and compilers ---
AC_C_CONST
Expand Down
37 changes: 23 additions & 14 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
EXTRA_DIST = \
wscript

pycairoexecdir = $(pyexecdir)/cairo

# Header
pkgincludedir = $(includedir)/pycairo
pkginclude_HEADERS = pycairo.h

# Python module
pycairoexecdir = $(pyexecdir)/cairo
pycairoexec_PYTHON = __init__.py

# Python extension module
pycairoexec_LTLIBRARIES = _cairo.la
_cairo_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_cairo
_cairo_la_LIBADD = $(CAIRO_LIBS)
_cairo_la_CPPFLAGS = $(PYTHON_INCLUDES) $(CAIRO_CFLAGS)
_cairo_la_CFLAGS = $(CAIRO_CFLAGS) $(PYTHON_INCLUDES)
_cairo_la_LIBADD = $(CAIRO_LIBS) $(PYTHON_LIBS)
_cairo_la_LDFLAGS = -module -avoid-version -export-symbols-regex -export-symbols-regex "_cairo|init_cairo"

if OS_WIN32
_cairo_la_LDFLAGS += \
-no-undefined \
-shrext ".pyd"
endif

_cairo_la_SOURCES = \
cairomodule.c \
context.c \
font.c \
path.c \
pattern.c \
matrix.c \
private.h \
pycairo.h \
surface.c
cairomodule.c \
context.c \
font.c \
path.c \
pattern.c \
matrix.c \
private.h \
pycairo.h \
surface.c

0 comments on commit 09b5606

Please sign in to comment.