1dnl
2dnl Autoconf macros for configuring the Serveez package.
3dnl
4dnl AC_SERVEEZ([USEFLAG]) -- Locate the Serveez core library.
5dnl When USEFLAG is given (optional argument) the variables SERVEEZ_CFLAGS
6dnl and SERVEEZ_LDFLAGS are set. Otherwise the macro adds these flags to
7dnl the overall linker and compiler flags produced by the ./configure script.
8dnl
9
10AC_DEFUN([AC_SERVEEZ], [
11  AC_ARG_WITH([serveez],
12    [  --with-serveez=DIR      serveez installation in DIR @<:@/usr/local@:>@],
13    [case "$withval" in
14     no)  SVZDIR="no" ;;
15     yes) SVZDIR="/usr/local" ;;
16     *)   SVZDIR="$withval" ;;
17    esac],
18    SVZDIR="/usr/local")
19
20  AC_MSG_CHECKING([for serveez installation])
21  if test "x$SVZDIR" != "xno" ; then
22    SVZDIR="`eval cd "$SVZDIR" 2>/dev/null && pwd`"
23    case $build_os in
24    mingw*)
25	SVZDIR="`eval cygpath -w -i "$SVZDIR"`"
26	SVZDIR="`echo "$SVZDIR" | sed -e 's%\\\\%/%g'`"
27	;;
28    esac
29    if test -f "$SVZDIR/lib/libserveez.so" -o \
30	    -f "$SVZDIR/lib/libserveez.dylib" -o \
31	    -f "$SVZDIR/bin/libserveez.dll" -o \
32	    -f "$SVZDIR/bin/cygserveez.dll" \
33	    ; then
34      if test "x$1" = "x" ; then
35        CFLAGS="$CFLAGS -I$SVZDIR/include"
36        LDFLAGS="$LDFLAGS -L$SVZDIR/lib"
37        LIBS="$LIBS -lserveez"
38        if test "x$CYGWIN" = "xyes" -o "x$MINGW32" = "xyes" ; then
39          if test "x$enable_shared" = "xyes" ; then
40	    CFLAGS="$CFLAGS -D__SERVEEZ_IMPORT__"
41    	  fi
42	fi
43      else
44        SERVEEZ_CFLAGS="-I$SVZDIR/include"
45        SERVEEZ_LDFLAGS="-L$SVZDIR/lib -lserveez"
46        if test "x$CYGWIN" = "xyes" -o "x$MINGW32" = "xyes" ; then
47          if test "x$enable_shared" = "xyes" ; then
48	    SERVEEZ_CFLAGS="$SERVEEZ_CFLAGS -D__SERVEEZ_IMPORT__"
49    	  fi
50	fi
51        AC_SUBST(SERVEEZ_CFLAGS)
52        AC_SUBST(SERVEEZ_LDFLAGS)
53      fi
54      AC_MSG_RESULT([yes])
55    else
56      AC_MSG_RESULT([missing])
57    fi
58  else
59    AC_MSG_RESULT([disabled])
60  fi
61  unset SVZDIR
62])
63