Salome HOME
8c3fd600d46fe93f866ec5319e1c2c8edb038182
[modules/yacs.git] / adm / unix / config_files / ac_pkg_swig.m4
1 dnl Copyright (C) 2006-2023  CEA, EDF
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, or (at your option) any later version.
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
20 dnl @synopsis AC_PROG_SWIG([major.minor.micro])
21 dnl This macro searches for a SWIG installation on your system. If found you
22 dnl should) SWIG via $(SWIG).  You can use the optional first argument to check
23 dnl if the version of the available SWIG is greater than or equal to the
24 dnl value of the argument.  It should have the format: N[.N[.N]] (N is a
25 dnl number between 0 and 999.  Only the first N is mandatory.)
26 dnl If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that the
27 dnl swig package is this version number or higher.
28 dnl In configure.in, use as:
29 dnl             AC_PROG_SWIG(1.3.17)
30 dnl             SWIG_ENABLE_CXX
31 dnl             SWIG_MULTI_MODULE_SUPPORT
32 dnl             SWIG_PYTHON
33 dnl @authors Sebastian Huber <address@hidden>, Alan W. Irwin
34 dnl <address@hidden>, Rafael Laboissiere <address@hidden> and
35 dnl Andrew Collier <address@hidden>.
36 dnl
37 AC_DEFUN([AC_PROG_SWIG],[
38   swig_ok=no
39         AC_PATH_PROG([SWIG],[swig])
40         if test -z "$SWIG" ; then
41                 AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
42                 SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
43         elif test -n "$1" ; then
44                 AC_MSG_CHECKING([for SWIG version])
45                 [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'`]
46                 AC_MSG_RESULT([$swig_version])
47                 if test -n "$swig_version" ; then
48                         # Calculate the required version number components
49                         [required=$1]
50                         [required_major=`echo $required | sed 's/[^0-9].*//'`]
51                         if test -z "$required_major" ; then
52                                 [required_major=0]
53                         fi
54                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
55                         [required_minor=`echo $required | sed 's/[^0-9].*//'`]
56                         if test -z "$required_minor" ; then
57                                 [required_minor=0]
58                         fi
59                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
60                         [required_patch=`echo $required | sed 's/[^0-9].*//'`]
61                         if test -z "$required_patch" ; then
62                                 [required_patch=0]
63                         fi
64                         # Calculate the available version number components
65                         [available=$swig_version]
66                         [available_major=`echo $available | sed 's/[^0-9].*//'`]
67                         if test -z "$available_major" ; then
68                                 [available_major=0]
69                         fi
70                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
71                         [available_minor=`echo $available | sed 's/[^0-9].*//'`]
72                         if test -z "$available_minor" ; then
73                                 [available_minor=0]
74                         fi
75                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
76                         [available_patch=`echo $available | sed 's/[^0-9].*//'`]
77                         if test -z "$available_patch" ; then
78                                 [available_patch=0]
79                         fi
80       if test $available_major -lt $required_major ; then
81         AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version (major version too low).  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       elif test $available_major -eq $required_major; then
84         if test $available_minor -lt $required_minor ; then
85           AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version (minor version too low).  You should look at http://www.swig.org])
86           SWIG='echo "Error: SWIG version >= $1 is required.  You have '"$swig_version"'.  You should look at http://www.swig.org" ; false'
87         elif test $available_minor -eq $required_minor ;then
88           if test $available_patch -lt $required_patch; then
89             AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version (maintenance version too low).  You should look at http://www.swig.org])
90             SWIG='echo "Error: SWIG version >= $1 is required.  You have '"$swig_version"'.  You should look at http://www.swig.org" ; false'
91           else
92             AC_MSG_NOTICE([SWIG executable is '$SWIG'])
93             swig_ok=yes
94             SWIG_LIB=`$SWIG -swiglib`
95             AC_MSG_NOTICE([SWIG runtime library directory is '$SWIG_LIB'])
96           fi
97         else
98           AC_MSG_NOTICE([SWIG executable is '$SWIG'])
99           swig_ok=yes
100           SWIG_LIB=`$SWIG -swiglib`
101           AC_MSG_NOTICE([SWIG runtime library directory is '$SWIG_LIB'])
102         fi
103       else
104         AC_MSG_NOTICE([SWIG executable is '$SWIG'])
105         swig_ok=yes
106         SWIG_LIB=`$SWIG -swiglib`
107         AC_MSG_NOTICE([SWIG runtime library directory is '$SWIG_LIB'])
108       fi
109                 else
110                         AC_MSG_WARN([cannot determine SWIG version])
111                         SWIG='echo "Error: Cannot determine SWIG version.  You should look at http://www.swig.org" ; false'
112                 fi
113         fi
114         AC_SUBST([SWIG_LIB])
115 ])
116
117 # SWIG_ENABLE_CXX()
118 #
119 # Enable SWIG C++ support.  This affects all invocations of $(SWIG).
120 AC_DEFUN([SWIG_ENABLE_CXX],[
121         AC_REQUIRE([AC_PROG_SWIG])
122         AC_REQUIRE([AC_PROG_CXX])
123         SWIG="$SWIG -c++"
124 ])
125
126 # SWIG_MULTI_MODULE_SUPPORT()
127 #
128 # Enable support for multiple modules.  This effects all invocations
129 # of $(SWIG).  You have to link all generated modules against the
130 # appropriate SWIG runtime library.  If you want to build Python
131 # modules for example, use the SWIG_PYTHON() macro and link the
132 # modules against $(SWIG_PYTHON_LIBS).
133 AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[
134         AC_REQUIRE([AC_PROG_SWIG])
135         SWIG="$SWIG -c"
136 ])
137
138 # SWIG_PYTHON([use-shadow-classes = {no, yes}])
139 #
140 # Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS),
141 # $(SWIG_PYTHON_LIBS) and $(SWIG_PYTHON_OPT) output variables.
142 # $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate
143 # code for Python.  Shadow classes are enabled unless the value of the
144 # optional first argument is exactly 'no'.  If you need multi module
145 # support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use
146 # $(SWIG_PYTHON_LIBS) to link against the appropriate library.  It
147 # contains the SWIG Python runtime library that is needed by the type
148 # check system for example.
149 AC_DEFUN([SWIG_PYTHON],[
150         AC_REQUIRE([AC_PROG_SWIG])
151         AC_REQUIRE([AC_PYTHON_DEVEL])
152         test "x$1" != "xno" || swig_shadow=" -noproxy"
153         AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow])
154         AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS])
155         AC_SUBST([SWIG_PYTHON_LIBS],["-L$SWIG_LIB -lswigpy"])
156 ])
157
158
159 dnl @synopsis AC_LIB_WAD
160 dnl
161 dnl This macro searches for installed WAD library.
162 dnl
163 AC_DEFUN([AC_LIB_WAD],
164 [
165         AC_REQUIRE([AC_PYTHON_DEVEL])
166         AC_ARG_ENABLE(wad,
167         AC_HELP_STRING([--enable-wad], [enable wad module]),
168         [
169                 case "${enableval}" in
170                         no)     ;;
171                         *)      if test "x${enableval}" = xyes;
172                                 then
173                                         check_wad="yes"
174                                 fi ;;
175                 esac
176         ], [])
177
178         if test -n "$check_wad";
179         then
180                 AC_CHECK_LIB(wadpy, _init, [WADPY=-lwadpy], [], $PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS)
181                 AC_SUBST(WADPY)
182         fi
183 ])