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