2096: Revive Swilena.

https://svn.lrde.epita.fr/svn/oln/trunk Well, this is just a start. The good news is, it took less than a day to reuse the good recipes learned from Olena 0.11, TC and clspr. Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Revive Swilena. * build-aux/pypath.m4, build-aux/swig.m4: New, imported. * build-aux/with-swilena.m4: New, imported from TC and adjusted. * configure.ac: Add support for Libtool, SWIG and Swilena. * Makefile.am (SUBDIRS): Append swilena. * swilena/: New directory. Makefile.am | 3 build-aux/pypath.m4 | 6 + build-aux/swig.m4 | 149 +++++++++++++++++++++++++++ build-aux/with-swilena.m4 | 107 +++++++++++++++++++ configure.ac | 13 ++ swilena/ChangeLog | 23 ++++ swilena/Makefile.am | 7 + swilena/image2d.i | 248 +++++++++++++++++++++++++++++++++++++++++++++ swilena/python/Makefile.am | 73 +++++++++++++ swilena/python/ltihooks.py | 60 ++++++++++ swilena/python/test.py | 58 ++++++++++ swilena/run.in | 57 ++++++++++ swilena/run.mk | 6 + 13 files changed, 810 insertions(+) Index: swilena/image2d.i --- swilena/image2d.i (revision 0) +++ swilena/image2d.i (revision 0) @@ -0,0 +1,248 @@ +// -*- C++ -*- +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. +// reasons why the executable file might be covered by the GNU General +// Public License. + +/// \file image2d.i +/// \brief A simple wrapping of mln::image2d<int> along with some +/// algorithms. + + +%module image2d + + +/*------. +| int. | +`------*/ + +%include "cpointer.i" +// Wrap a class interface around an "int *" (see +// // http://www.swig.org/Doc1.3/Library.html#Library_nn4). +// %pointer_class(int, intp); +/* Create some functions for working with "int *" */ +%pointer_functions(int, intp); + + +/*---------------. +| mln::point2d. | +`---------------*/ + +%{ +#include "mln/core/point.hh" +#include "mln/core/point2d.hh" +%} + +%include "mln/core/point.hh"; +%include "mln/core/point2d.hh"; +/* FIXME: Ignore `mln::point_<M,C>::origin' to circumvent a swig bug. + Without this ignore clause, the generated code would trigger this + error : + + image2d-wrap.cc:3115:144: error: macro "SWIG_as_voidptr" passed 2 + arguments, but takes just 1 + image2d-wrap.cc: In function 'PyObject* point2d_origin_get()': + image2d-wrap.cc:3115: error: 'SWIG_as_voidptr' was not declared in this + scope + + Check whether this bug has been fixed in a recent release of SWIG + or if it has been reported. */ +%ignore mln::point_<mln::grid::square,int>::origin; +// Ignoring to_h_vec saves us the wrapping of +%ignore mln::point_<mln::grid::square,int>::to_h_vec; +// Swig tries to wrap everything by default; prevent it from wrapping +// invalid methods (1D and 3D ctors for a point2d). +%ignore mln::point_<mln::grid::square,int>::point_(const literal::zero_t&); +%ignore mln::point_<mln::grid::square,int>::point_(const literal::one_t&); +%ignore mln::point_<mln::grid::square,int>::point_(int); +%ignore mln::point_<mln::grid::square,int>::point_(int, int, int); +// point2d. +%template(point2d) mln::point_<mln::grid::square,int>; + +/*--------------------. +| mln::image2d<int>. | +`--------------------*/ + +%{ +#include "mln/core/image2d.hh" +%} + +%include "mln/core/box2d.hh"; +%include "mln/core/dpoint2d.hh"; + +%include "mln/core/concept/image.hh"; + +// FIXME: Wrap mln::image2d by hand, for Milena macros disturb swig. +// Annotate the original source code instead? +namespace mln +{ + template <typename T> + struct image2d + /* FIXME: This is a simple wrapping; ignore the base class (for the + moment). */ + // : public internal::image_primary_< box2d, image2d<T> > + /* FIXME: Cheat, so that generic algorithms can use mln::image2d. */ + : public Image< image2d<T> > + { + // Warning: just to make effective types appear in Doxygen: + typedef box2d pset; + typedef point2d psite; + typedef point2d point; + typedef dpoint2d dpoint; +// FIXME: Those typedefs disturb swig. +// typedef mln_fwd_piter(box2d) fwd_piter; +// typedef mln_bkd_piter(box2d) bkd_piter; + typedef line_piter_<point> line_piter; + // End of warning. + + + /// Value associated type. + typedef T value; + + /// Return type of read-only access. + typedef const T& rvalue; + + /// Return type of read-write access. + typedef T& lvalue; + + + /// Skeleton. + typedef image2d< tag::value_<T> > skeleton; + + + /// Value_Set associated type. + typedef mln::value::set<T> vset; + + + /// Constructor without argument. + image2d(); + + /// Constructor with the numbers of rows and columns and the + /// border thickness. + image2d(int nrows, int ncols, unsigned bdr = border::thickness); + + /// Constructor with a box and the border thickness (default is + /// 3). + image2d(const box2d& b, unsigned bdr = border::thickness); + + + /// Initialize an empty image. + void init_(const box2d& b, unsigned bdr = border::thickness); + + + /// Test if \p p is valid. + bool owns_(const point2d& p) const; + + /// Give the set of values of the image. + const vset& values() const; + + /// Give the definition domain. + const box2d& domain() const; + + /// Give the border thickness. + unsigned border() const; + + /// Give the number of cells (points including border ones). + std::size_t ncells() const; + + /// Read-only access to the image value located at point \p p. + const T& operator()(const point2d& p) const; + + /// Read-write access to the image value located at point \p p. + T& operator()(const point2d& p); + +// FIXME: swig won't wrap this operator. +// /// Read-only access to the image value located at offset \p o. +// const T& operator[](unsigned o) const; + +// FIXME: swig won't wrap this operator. +// /// Read-write access to the image value located at offset \p o. +// T& operator[](unsigned o); + + /// Read-only access to the image value located at (\p row, \p col). + const T& at(int row, int col) const; + + /// Read-write access to the image value located at (\p row, \p col). + T& at(int row, int col); + + + /// Fast Image method + + /// Give the offset corresponding to the delta-point \p dp. + int offset(const dpoint2d& dp) const; + + /// Give the point corresponding to the offset \p o. + point2d point_at_offset(unsigned o) const; + + /// Give a hook to the value buffer. + const T* buffer() const; + + /// Give a hook to the value buffer. + T* buffer(); + + + /// Resize image border with new_border. + void resize_(unsigned new_border); + }; + +} // end of namespace mln + +%template(image2d_int) mln::image2d<int>; + + +/*-------------------. +| mln::level::fill. | +`-------------------*/ + +%{ +#include "mln/level/fill.hh" +%} + +// FIXME: Wrap mln::level::fill by hand, for mln_value(I) disturbs +// swig. Annotate the original source code instead? +namespace mln +{ + namespace level + { + template <typename I> + void fill(mln::Image<I>& ima, const typename I::value& v); + } // end of namespace mln::level + +} // end of namespace mln + +%template(fill_image2d_int) mln::level::fill< mln::image2d<int> >; + + +/*----------------------. +| mln::debug::println. | +`----------------------*/ + +%{ + #include "mln/debug/println.hh" +%} + +%include "mln/debug/println.hh" + +%template(println_image2d_int) mln::debug::println< mln::image2d<int> >; Index: swilena/python/ltihooks.py --- swilena/python/ltihooks.py (revision 0) +++ swilena/python/ltihooks.py (revision 0) @@ -0,0 +1,60 @@ +# -*- Mode: Python; py-indent-offset: 4 -*- +# ltihooks.py: python import hooks that understand libtool libraries. +# Copyright (C) 2000 James Henstridge. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import os, ihooks + +class LibtoolHooks(ihooks.Hooks): + def get_suffixes(self): + """Like normal get_suffixes, but adds .la suffixes to list""" + ret = ihooks.Hooks.get_suffixes(self) + ret.insert(0, ('module.la', 'rb', 3)) + ret.insert(0, ('.la', 'rb', 3)) + return ret + + def load_dynamic(self, name, filename, file=None): + """Like normal load_dynamic, but treat .la files specially""" + if len(filename) > 3 and filename[-3:] == '.la': + fp = open(filename, 'r') + dlname = '' + installed = 1 + line = fp.readline() + while line: + if len(line) > 7 and line[:7] == 'dlname=': + dlname = line[8:-2] + elif len(line) > 10 and line[:10] == 'installed=': + installed = line[10:-1] == 'yes' + line = fp.readline() + fp.close() + if dlname: + if installed: + filename = os.path.join(os.path.dirname(filename), + dlname) + else: + filename = os.path.join(os.path.dirname(filename), + '.libs', dlname) + return ihooks.Hooks.load_dynamic(self, name, filename, file) + +importer = ihooks.ModuleImporter() +importer.set_hooks(LibtoolHooks()) + +def install(): + importer.install() +def uninstall(): + importer.uninstall() + +install() Index: swilena/python/test.py --- swilena/python/test.py (revision 0) +++ swilena/python/test.py (revision 0) @@ -0,0 +1,58 @@ +#! /usr/bin/env python + +# Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +# +# This file is part of the Olena Library. This library is free +# software; you can redistribute it and/or modify it under the terms +# of the GNU General Public License version 2 as published by the +# Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this library; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston, MA 02111-1307, USA. +# +# As a special exception, you may use this file as part of a free +# software library without restriction. Specifically, if other files +# instantiate templates or use macros or inline functions from this +# file, or you compile this file and link it with other files to +# produce an executable, this file does not by itself cause the +# resulting executable to be covered by the GNU General Public +# License. +# reasons why the executable file might be covered by the GNU General +# Public License. + +import ltihooks +import image2d + +ima = image2d.image2d_int(3, 3) +image2d.fill_image2d_int(ima, 42) + +# FIXME: For the moment, we can't write +# +# ima(image2d.point2d(i, j)) +# +# but I don't know why. Anyway, eventually we'd like to be able to +# write this: +# +# for p in ima.domain(): +# print "ima(" + str(i) + ", " + str(j) + ") = " + ima(p) +# +# as it is generic and way closer to what we do in C++. +for i in range(0, 3): + for j in range(0, 3): + p = image2d.point2d(i, j) + # FIXME: Handling POD types (like int) as value types is not + # transparent: ima(p) returns a pointer to int wrapped in a SWIG + # object, and cannot be easily converted to a Python integer + # value. Hence this explicit conversion using `intp_value'. + v = image2d.intp_value(ima(p)) + print "ima(" + str(i) + ", " + str(j) + ") = " + str(v) + +print +image2d.println_image2d_int(ima) Index: swilena/python/Makefile.am --- swilena/python/Makefile.am (revision 0) +++ swilena/python/Makefile.am (revision 0) @@ -0,0 +1,73 @@ +## Process this file through Automake to produce Makefile.in -*- Makefile -*- + +## ------------------ ## +## Generic material. ## +## ------------------ ## + +## FIXME: Factor as much as possible. See how we handled this in TC. + +CLEANFILES = +AM_CPPFLAGS = -I$(PYTHONINC) -I$(top_srcdir)/milena +AM_SWIGFLAGS = -c++ -python -I$(top_srcdir)/milena +## We build modules, not plain libs. +AM_LDFLAGS = -avoid-version -module -shared +#### All the modules depend on libhw. +##AM_LIBADD = $(top_builddir)/libhw.la + +## Run Swig to create the C++ wrapper files, the Python interface +## files, and the dependency Makefile snippets. +%-wrap.cc %.py: $(top_srcdir)/swilena/%.i + if $(SWIG) $(AM_SWIGFLAGS) $(SWIGFLAGS) -MD -MF "$(DEPDIR)/$*-wrap.Tcc" -o $@ $<; then \ + mv -f "$(DEPDIR)/$*-wrap.Tcc" "$(DEPDIR)/$*-wrap.Pcc";\ + else \ + rm -f "$(DEPDIR)/$*-wrap.Tcc"; exit 1;\ + fi + +# ltihooks.py: Python import hooks that understand Libtool libraries. +python_PYTHON = ltihooks.py + + +## ----------------- ## +## Wrapped modules. ## +## ----------------- ## + +## FIXME: All of this should be generated. +## Don't forget to add a `deps-reset' target as in TC. + +## image2d. +pyexec_LTLIBRARIES = _image2d.la +nodist__image2d_la_SOURCES = image2d-wrap.cc +_image2d_la_LIBADD = $(AM_LIBADD) +CLEANFILES += $(nodist__image2d_la_SOURCES) image2d.py image2d.py[co] +## Include the dependency files. Copied from Automake's generated +## case for C++. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_image2d-wrap.Pcc@am__quote@ + +nodist_python_PYTHON = image2d.py + + +## ------- ## +## Tests. ## +## ------- ## + +include $(top_srcdir)/swilena/run.mk + +## FIXME: Do we really need to pass top_srcdir and top_builddir to run? +##TESTS_ENVIRONMENT = \ +## top_srcdir="$(top_srcdir)" top_builddir="$(top_builddir)" $(RUN) +TESTS_ENVIRONMENT = $(RUN) +# Ensure `run' is rebuilt before the tests are run. +$(TESTS): $(srcdir)/run.stamp +# The dependency is on `run.in' and not `run', since `run' is +# regenerated at distribution time, and voids the time stamps (which +# we don't want!). +EXTRA_DIST = $(srcdir)/run.stamp +$(srcdir)/run.stamp: $(RUN_IN) + @rm -f $@ + @rm -f $@.tmp + @touch $@.tmp + $(MAKE) $(AM_MAKEFLAGS) $(RUN) + @mv -f $@.tmp $@ + +TESTS = test.py +EXTRA_DIST += $(TESTS) Index: swilena/ChangeLog --- swilena/ChangeLog (revision 0) +++ swilena/ChangeLog (revision 0) @@ -0,0 +1,23 @@ +2008-07-22 Roland Levillain <roland@lrde.epita.fr> + + Revive Swilena. + + * swilena/image2d.i: New SWIG wrapper. + * swilena/run.in: New helper, imported from TC. + * swilena/Makefile.am: New. + * swilena/run.mk: New, imported from TC and adjusted. + + * swilena/python/: New directory. + * swilena/python/ltihooks.py: New, imported. + * swilena/python/test.py: New test. + * swilena/python/Makefile.am: New. + + +$Rev$ +$Id$ +$Date$ + +Local Variables: +ispell-local-dictionary: "american" +coding: iso-latin-1 +End: Property changes on: swilena/ChangeLog ___________________________________________________________________ Name: svn:keywords + Rev Id Date Index: swilena/Makefile.am --- swilena/Makefile.am (revision 0) +++ swilena/Makefile.am (revision 0) @@ -0,0 +1,7 @@ +## Process this file through Automake to produce Makefile.in -*- Makefile -*- + +SUBDIRS = python + +EXTRA_DIST = image2d.i + +check_SCRIPTS = run Index: swilena/run.in --- swilena/run.in (revision 0) +++ swilena/run.in (revision 0) @@ -0,0 +1,57 @@ +#!/bin/sh +# Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris 6 +# (LIP6), d�partement Syst�mes R�partis Coop�ratifs (SRC), Universit� +# Pierre et Marie Curie. +# +# This file is part of Spot, a model checking library. +# +# Spot is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Spot is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Spot; see the file COPYING. If not, write to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + + +# If we are running from make check (srcdir is set) and VERBOSE is +# unset, be quiet. +test -n "$srcdir" && test -z "$VERBOSE" && exec >/dev/null 2>&1 + +# Darwin needs some help in figuring out where non-installed libtool +# libraries are (on this platform libtool encodes the expected final +# path of dependent libraries in each library). +modpath='.libs:@abs_top_builddir@/src/.libs' + +case $1 in + '' | *.py) + PYTHONPATH='@abs_builddir@/python:@abs_srcdir@/python':"$PYTHONPATH" \ + DYLD_LIBRARY_PATH=$modpath \ + exec @PYTHON@ "$@" + ;; + # What's the point in adding `.libs' to SWILENA_RUBY_PATH? + # + # As some of our SWIG interfaces import other SWIG interfaces + # (with the `%import' keyword), we must add the `.libs' directory + # to SWILENA_RUBY_PATH so that the Ruby interpreter can load the + # corresponding dynamic module(s) (SWIG's `%import' statements + # generate code in dynamic modules that bypass Ruby's + # `Kernel.require' mechanism). + *.rb) + SWILENA_RUBY_PATH='@abs_builddir@/ruby:@abs_srcdir@/ruby:.libs' \ + DYLD_LIBRARY_PATH=$modpath \ + exec @RUBY@ "$@" + ;; + *.test) + exec sh -x "$@";; + *) + echo "Unknown extension" 2>&1 + exit 2;; +esac Property changes on: swilena/run.in ___________________________________________________________________ Name: svn:executable + * Index: swilena/run.mk --- swilena/run.mk (revision 0) +++ swilena/run.mk (revision 0) @@ -0,0 +1,6 @@ +# A test/script wrapper. + +RUN = $(top_builddir)/swilena/run +RUN_IN = $(top_srcdir)/swilena/run.in +$(RUN): $(RUN_IN) + cd $(top_builddir)/swilena && $(MAKE) $(AM_MAKEFLAGS) run Index: configure.ac --- configure.ac (revision 2095) +++ configure.ac (working copy) @@ -98,6 +98,19 @@ AM_CONDITIONAL([CFITSIO], [test x$oln_have_cfitsio = xyes]) +## --------- ## +## Swilena. ## +## --------- ## + +AC_PROG_LIBTOOL + +OLN_WITH_SWILENA([with_swilena=yes], [with_swilena=no]) +AM_CONDITIONAL([ENABLE_SWILENA], [test x$with_swilena = xyes]) + +AC_CONFIG_FILES([swilena/Makefile swilena/python/Makefile]) +AC_CONFIG_FILES([swilena/run], [chmod +x swilena/run]) + + ## --------------- ## ## Configuration. ## ## --------------- ## Index: Makefile.am --- Makefile.am (revision 2095) +++ Makefile.am (working copy) @@ -3,3 +3,6 @@ ACLOCAL_AMFLAGS = -I build-aux SUBDIRS = build-aux external milena + +# FIXME: Make Swilena optional (see TC's equipment). +SUBDIRS += swilena Index: build-aux/pypath.m4 --- build-aux/pypath.m4 (revision 0) +++ build-aux/pypath.m4 (revision 0) @@ -0,0 +1,6 @@ +AC_DEFUN([adl_CHECK_PYTHON], + [AM_PATH_PYTHON([2.0]) + AC_CACHE_CHECK([for $am_display_PYTHON includes directory], + [adl_cv_python_inc], + [adl_cv_python_inc=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()" 2>/dev/null`]) + AC_SUBST([PYTHONINC], [$adl_cv_python_inc])]) Index: build-aux/swig.m4 --- build-aux/swig.m4 (revision 0) +++ build-aux/swig.m4 (revision 0) @@ -0,0 +1,149 @@ +dnl @synopsis AC_PROG_SWIG([major.minor.micro]) +dnl +dnl This macro searches for a SWIG installation on your system. If found you +dnl should call SWIG via $(SWIG). You can use the optional first argument to +dnl check if the version of the available SWIG is greater than or equal to the +dnl value of the argument. It should have the format: N[.N[.N]] (N is a +dnl number between 0 and 999. Only the first N is mandatory.) +dnl +dnl If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that the +dnl swig package is this version number or higher. +dnl +dnl In configure.in, use as: +dnl +dnl AC_PROG_SWIG(1.3.17) +dnl SWIG_ENABLE_CXX +dnl SWIG_MULTI_MODULE_SUPPORT +dnl SWIG_PYTHON +dnl +dnl @author Sebastian Huber <sebastian-huber@web.de>, Alan W. Irwin <irwin@beluga.phys.uvic.ca>, Rafael Laboissiere <rafael@laboissiere.net>, and Andrew Collier <abcollier@yahoo.com>. +dnl @version $Id: ac_pkg_swig.m4,v 1.2 2004/12/24 01:20:01 guidod Exp $ +dnl +AC_DEFUN([AC_PROG_SWIG],[ + AC_PATH_PROG([SWIG],[swig]) + if test -z "$SWIG" ; then + AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false' + elif test -n "$1" ; then + AC_MSG_CHECKING([for SWIG version]) + [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + AC_MSG_RESULT([$swig_version]) + if test -n "$swig_version" ; then + # Calculate the required version number components + [required=$1] + [required_major=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_major" ; then + [required_major=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_minor=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_minor" ; then + [required_minor=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_patch=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_patch" ; then + [required_patch=0] + fi + # Calculate the available version number components + [available=$swig_version] + [available_major=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_major" ; then + [available_major=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_minor=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_minor" ; then + [available_minor=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_patch=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_patch" ; then + [available_patch=0] + fi + if test $available_major -ne $required_major \ + -o $available_minor -ne $required_minor \ + -o $available_patch -lt $required_patch ; then + AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false' + else + AC_MSG_NOTICE([SWIG executable is '$SWIG']) + SWIG_LIB=`$SWIG -swiglib` + AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB']) + fi + else + AC_MSG_WARN([cannot determine SWIG version]) + SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false' + fi + fi + AC_SUBST([SWIG_LIB]) +]) + +# SWIG_ENABLE_CXX() +# +# Enable SWIG C++ support. This affects all invocations of $(SWIG). +AC_DEFUN([SWIG_ENABLE_CXX],[ + AC_REQUIRE([AC_PROG_SWIG]) + AC_REQUIRE([AC_PROG_CXX]) + SWIG="$SWIG -c++" +]) + +# SWIG_MULTI_MODULE_SUPPORT() +# +# Enable support for multiple modules. This effects all invocations +# of $(SWIG). You have to link all generated modules against the +# appropriate SWIG runtime library. If you want to build Python +# modules for example, use the SWIG_PYTHON() macro and link the +# modules against $(SWIG_PYTHON_LIBS). +# +AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[ + AC_REQUIRE([AC_PROG_SWIG]) + SWIG="$SWIG -noruntime" +]) + +# SWIG_PYTHON([use-shadow-classes = {no, yes}]) +# +# Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS), +# and $(SWIG_PYTHON_OPT) output variables. +# +# $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate +# code for Python. Shadow classes are enabled unless the value of the +# optional first argument is exactly 'no'. If you need multi module +# support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use +# $(SWIG_PYTHON_LIBS) to link against the appropriate library. It +# contains the SWIG Python runtime library that is needed by the type +# check system for example. +AC_DEFUN([SWIG_PYTHON],[ + AC_REQUIRE([AC_PROG_SWIG]) + AC_REQUIRE([AC_PYTHON_DEVEL]) + test "x$1" != "xno" || swig_shadow=" -noproxy" + AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow]) + AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS]) +]) + + +dnl @synopsis AC_LIB_WAD +dnl +dnl This macro searches for installed WAD library. +dnl +AC_DEFUN([AC_LIB_WAD], +[ + AC_REQUIRE([AC_PYTHON_DEVEL]) + AC_ARG_ENABLE(wad, + AC_HELP_STRING([--enable-wad], [enable wad module]), + [ + case "${enableval}" in + no) ;; + *) if test "x${enableval}" = xyes; + then + check_wad="yes" + fi ;; + esac + ], []) + + if test -n "$check_wad"; + then + AC_CHECK_LIB(wadpy, _init, [WADPY=-lwadpy], [], $PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS) + AC_SUBST(WADPY) + fi +]) Index: build-aux/with-swilena.m4 --- build-aux/with-swilena.m4 (revision 0) +++ build-aux/with-swilena.m4 (revision 0) @@ -0,0 +1,107 @@ +# -*- Autoconf -*- + +# FIXME: Revamp and make it generic, so that it can shared among +# Olena, TC and clspr. + +# _OLN_WITH_SWIG(HAS-SWIG, HAS-NOT) +# --------------------------------- +# Check whether SWIG is requested, enabled, or disabled. If +# requested, check that Python is present as needed. If enabled, +# actually enable only if the environment is complete. +AC_DEFUN([_OLN_WITH_SWIG], +# FIXME: `with-swig' used to be set to `auto', but `no' is prefered +# now, as +# 1. users don't necessarily want to build Swilena by default; +# 2. the `auto' flag is not honored by the checks for Python and Ruby. +[AC_ARG_WITH([swig], + [AC_HELP_STRING([--with-swig], + [require SWIG modules (defaults to no)])], + [], + [with_swig=no]) + +case $with_swig:$enable_shared in + auto:no) + AC_MSG_NOTICE([SWIG use disabled: dynamic libraries disabled]) + with_swig=no + ;; +esac + +if test x$with_swig != xno; then + oln_has_swig=yes + AM_PATH_PYTHON([2.3]) + adl_CHECK_PYTHON + + # Check for Python and SWIG. + save_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I$PYTHONINC" + AC_CHECK_HEADERS([Python.h], + [python_headers=yes], + [python_headers=no]) + + if test x$python_headers = xno; then + oln_has_swig=no + if test x$with_swig = xyes; then + AC_MSG_ERROR( + [Python.h is required to build SWIG modules. + Add `-I python_include_path' to `CPPFLAGS' + or `--without-swig' to disable SWIG modules.]) + fi + fi + + CPPFLAGS=$save_CPPFLAGS + + # Check for Ruby. + AC_CHECK_PROGS([RUBY], [ruby], [$am_aux_dir/missing ruby]) + if test "x$RUBY" = "x$am_aux_dir/missing ruby"; then + AC_MSG_ERROR([no suitable Ruby interpreter found]) + fi + + AC_ARG_VAR([RUBY_CPPFLAGS], [Path to ruby.h]) + AC_ARG_WITH([ruby-includedir], [Include path for ruby.h], + [RUBY_CPPFLAGS="-I$withval"], + [RUBY_CPPFLAGS="-I`$RUBY -e 'puts $:.join("\n")' | \ + while read line + do + if [[ -f ${line}/ruby.h ]]; then + echo $line + fi + done`"]) + save_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS" + AC_CHECK_HEADERS([ruby.h], [], + [AC_MSG_ERROR( + [You need Ruby development files to compile the Ruby interface.])]) + CPPFLAGS=$save_CPPFLAGS + + AC_PROG_SWIG([1.3.29]) + if (eval "$SWIG -version") >/dev/null 2>&1; then :; else + oln_has_swig=no + fi + + case $with_swig:$oln_has_swig in + yes:no) + AC_MSG_ERROR([SWIG 1.3.29 is required. + Use `--without-swig' to disable SWIG modules.]);; + esac +fi + +case $oln_has_swig in + yes) $1;; + * ) $2;; +esac +]) + +# OLN_WITH_SWILENA(WITH, WITHOUT) +# ------------------------------- +# Should we build Swilena or not. +AC_DEFUN([OLN_WITH_SWILENA], +[AC_CACHE_CHECK([whether building Swilena], + [oln_cv_with_swilena], + [_OLN_WITH_SWIG([oln_cv_with_swilena=yes], + [oln_cv_with_swilena=no])]) +case $oln_cv_with_swilena in + yes) $1;; + no ) $2;; + *) AC_MSG_ERROR([incorrect oln_cv_with_swilena value: $oln_cv_with_swilena]);; +esac +])
participants (1)
-
Roland Levillain