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