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