Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / wrappergen / bin / Cpp_Template__SRC / adm / unix / config_files / ac_pkg_swig.m4
1 dnl  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 dnl
3 dnl  This library is free software; you can redistribute it and/or
4 dnl  modify it under the terms of the GNU Lesser General Public
5 dnl  License as published by the Free Software Foundation; either
6 dnl  version 2.1 of the License.
7 dnl
8 dnl  This library is distributed in the hope that it will be useful,
9 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl  Lesser General Public License for more details.
12 dnl
13 dnl  You should have received a copy of the GNU Lesser General Public
14 dnl  License along with this library; if not, write to the Free Software
15 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19 dnl @synopsis AC_PROG_SWIG([major.minor.micro])
20 dnl This macro searches for a SWIG installation on your system. If found you
21 dnl should) SWIG via $(SWIG).  You can use the optional first argument to check
22 dnl if the version of the available SWIG is greater than or equal to the
23 dnl value of the argument.  It should have the format: N[.N[.N]] (N is a
24 dnl number between 0 and 999.  Only the first N is mandatory.)
25 dnl If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that the
26 dnl swig package is this version number or higher.
27 dnl In configure.in, use as:
28 dnl             AC_PROG_SWIG(1.3.17)
29 dnl             SWIG_ENABLE_CXX
30 dnl             SWIG_MULTI_MODULE_SUPPORT
31 dnl             SWIG_PYTHON
32 dnl @authors Sebastian Huber <address@hidden>, Alan W. Irwin
33 dnl <address@hidden>, Rafael Laboissiere <address@hidden> and
34 dnl Andrew Collier <address@hidden>.
35 dnl
36 AC_DEFUN([AC_PROG_SWIG],[
37         AC_PATH_PROG([SWIG],[swig])
38         if test -z "$SWIG" ; then
39                 AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
40                 SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
41         elif test -n "$1" ; then
42                 AC_MSG_CHECKING([for SWIG version])
43                 [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'`]
44                 AC_MSG_RESULT([$swig_version])
45                 if test -n "$swig_version" ; then
46                         # Calculate the required version number components
47                         [required=$1]
48                         [required_major=`echo $required | sed 's/[^0-9].*//'`]
49                         if test -z "$required_major" ; then
50                                 [required_major=0]
51                         fi
52                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
53                         [required_minor=`echo $required | sed 's/[^0-9].*//'`]
54                         if test -z "$required_minor" ; then
55                                 [required_minor=0]
56                         fi
57                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
58                         [required_patch=`echo $required | sed 's/[^0-9].*//'`]
59                         if test -z "$required_patch" ; then
60                                 [required_patch=0]
61                         fi
62                         # Calculate the available version number components
63                         [available=$swig_version]
64                         [available_major=`echo $available | sed 's/[^0-9].*//'`]
65                         if test -z "$available_major" ; then
66                                 [available_major=0]
67                         fi
68                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
69                         [available_minor=`echo $available | sed 's/[^0-9].*//'`]
70                         if test -z "$available_minor" ; then
71                                 [available_minor=0]
72                         fi
73                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
74                         [available_patch=`echo $available | sed 's/[^0-9].*//'`]
75                         if test -z "$available_patch" ; then
76                                 [available_patch=0]
77                         fi
78                         if test $available_major -ne $required_major \
79                                 -o $available_minor -ne $required_minor \
80                                 -o $available_patch -lt $required_patch ; then
81                                 AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version.  You should look at http://www.swig.org])
82                                 SWIG='echo "Error: SWIG version >= $1 is required.  You have '"$swig_version"'.  You should look at http://www.swig.org" ; false'
83                         else
84                                 AC_MSG_NOTICE([SWIG executable is '$SWIG'])
85                                 SWIG_LIB=`$SWIG -swiglib`
86                                 AC_MSG_NOTICE([SWIG runtime library directory is '$SWIG_LIB'])
87                         fi
88                 else
89                         AC_MSG_WARN([cannot determine SWIG version])
90                         SWIG='echo "Error: Cannot determine SWIG version.  You should look at http://www.swig.org" ; false'
91                 fi
92         fi
93         AC_SUBST([SWIG_LIB])
94 ])
95
96 # SWIG_ENABLE_CXX()
97 #
98 # Enable SWIG C++ support.  This affects all invocations of $(SWIG).
99 AC_DEFUN([SWIG_ENABLE_CXX],[
100         AC_REQUIRE([AC_PROG_SWIG])
101         AC_REQUIRE([AC_PROG_CXX])
102         SWIG="$SWIG -c++"
103 ])
104
105 # SWIG_MULTI_MODULE_SUPPORT()
106 #
107 # Enable support for multiple modules.  This effects all invocations
108 # of $(SWIG).  You have to link all generated modules against the
109 # appropriate SWIG runtime library.  If you want to build Python
110 # modules for example, use the SWIG_PYTHON() macro and link the
111 # modules against $(SWIG_PYTHON_LIBS).
112 AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[
113         AC_REQUIRE([AC_PROG_SWIG])
114         SWIG="$SWIG -c"
115 ])
116
117 # SWIG_PYTHON([use-shadow-classes = {no, yes}])
118 #
119 # Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS),
120 # $(SWIG_PYTHON_LIBS) and $(SWIG_PYTHON_OPT) output variables.
121 # $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate
122 # code for Python.  Shadow classes are enabled unless the value of the
123 # optional first argument is exactly 'no'.  If you need multi module
124 # support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use
125 # $(SWIG_PYTHON_LIBS) to link against the appropriate library.  It
126 # contains the SWIG Python runtime library that is needed by the type
127 # check system for example.
128 AC_DEFUN([SWIG_PYTHON],[
129         AC_REQUIRE([AC_PROG_SWIG])
130         AC_REQUIRE([AC_PYTHON_DEVEL])
131         test "x$1" != "xno" || swig_shadow=" -noproxy"
132         AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow])
133         AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS])
134         AC_SUBST([SWIG_PYTHON_LIBS],["-L$SWIG_LIB -lswigpy"])
135 ])
136
137
138 dnl @synopsis AC_LIB_WAD
139 dnl
140 dnl This macro searches for installed WAD library.
141 dnl
142 AC_DEFUN([AC_LIB_WAD],
143 [
144         AC_REQUIRE([AC_PYTHON_DEVEL])
145         AC_ARG_ENABLE(wad,
146         AC_HELP_STRING([--enable-wad], [enable wad module]),
147         [
148                 case "${enableval}" in
149                         no)     ;;
150                         *)      if test "x${enableval}" = xyes;
151                                 then
152                                         check_wad="yes"
153                                 fi ;;
154                 esac
155         ], [])
156
157         if test -n "$check_wad";
158         then
159                 AC_CHECK_LIB(wadpy, _init, [WADPY=-lwadpy], [], $PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS)
160                 AC_SUBST(WADPY)
161         fi
162 ])