build: add option --enable-socket-wrapper to build binaries with socket wrapper support
[ctdb.git] / configure.ac
1 AC_PREREQ(2.50)
2 AC_INIT(ctdb, m4_esyscmd([grep 'Version:' ./packaging/RPM/ctdb.spec 2>/dev/null | head -1 | sed -e 's/[ \t]*Version:[ \t]*\([^ \t]*\)[ \t]*.*/\1/' | tr -d '\n']))
3 AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
4 AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
5 AC_DEFUN([SMB_EXT_LIB], [echo -n ""])
6 AC_DEFUN([SMB_ENABLE], [echo -n ""])
7 AC_CONFIG_SRCDIR([server/ctdbd.c])
8
9 if test "${libdir}" = '${exec_prefix}/lib'; then
10   case `uname -m` in
11     x86_64|ppc64|powerpc64)
12       libdir='${exec_prefix}/lib64'
13       ;;
14     *)
15       libdir='${exec_prefix}/lib'
16       ;;
17   esac
18 fi
19
20 case `uname` in
21   Linux*)
22     CTDB_SYSTEM_OBJ=common/system_linux.o
23     CTDB_SCSI_IO=bin/scsi_io
24     CTDB_PCAP_LDFLAGS=
25     ;;
26   AIX*)
27     CTDB_SYSTEM_OBJ=common/system_aix.o
28     CTDB_SCSI_IO=
29     CTDB_PCAP_LDFLAGS=-lpcap
30     ;;
31   *)
32     echo unknown system  cant configure
33     exit
34     ;;
35 esac
36
37 AC_LIBREPLACE_ALL_CHECKS
38 AC_LIBREPLACE_NETWORK_CHECKS
39
40 if test "$ac_cv_prog_gcc" = yes; then
41    CFLAGS="$CFLAGS -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings"
42 fi
43
44 LOGDIR='${localstatedir}/log'
45 AC_ARG_WITH([logdir],
46         [  --with-logdir=DIR       path to log directory [[LOCALSTATEDIR/log]]],
47         LOGDIR=$withval)
48 if test ! -z "$LOGDIR"; then
49   if test "$LOGDIR" = "yes" -o "$LOGDIR" = "no"; then
50     AC_MSG_ERROR([--with-logdir must specify a path])
51   fi
52 fi
53 AC_SUBST(LOGDIR)
54
55 AC_CONFIG_HEADER(config.h)
56
57 EXTRA_OBJ=""
58
59 m4_include(libpopt.m4)
60 m4_include(libtalloc.m4)
61 m4_include(libtdb.m4)
62 m4_include(libtevent.m4)
63 m4_include(ib/config.m4)
64 m4_include(lib/util/signal.m4)
65 m4_include(lib/util/fault.m4)
66 m4_include(lib/socket_wrapper/config.m4)
67
68 AC_CHECK_HEADERS(sched.h)
69 AC_CHECK_HEADERS(pcp/pmapi.h pcp/impl.h pcp/pmda.h, [], [],
70 [[#ifdef HAVE_PCP_PMAPI_H
71 # include <pcp/pmapi.h>
72 #endif
73 #ifdef HAVE_PCP_IMPL_H
74 # include <pcp/impl.h>
75 #endif
76 ]])
77
78 AC_CHECK_FUNCS(sched_setscheduler)
79 AC_CHECK_FUNCS(mlockall)
80
81 AC_CACHE_CHECK([for sin_len in sock],ctdb_cv_HAVE_SOCK_SIN_LEN,[
82 AC_TRY_COMPILE([#include <sys/types.h>
83 #include <sys/socket.h>
84 #include <netinet/in.h>],
85 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
86 ctdb_cv_HAVE_SOCK_SIN_LEN=yes,ctdb_cv_HAVE_SOCK_SIN_LEN=no)])
87 if test x"$ctdb_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
88     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
89 fi
90
91 if test x"$ac_cv_header_pcp_pmda_h" = x"yes"; then
92     CTDB_PMDA=bin/pmdactdb
93     CTDB_PMDA_INSTALL=install_pmda
94 else
95     CTDB_PMDA=
96     CTDB_PMDA_INSTALL=
97 fi
98
99
100 AC_SUBST(EXTRA_OBJ)
101 AC_SUBST(CTDB_SYSTEM_OBJ)
102 AC_SUBST(CTDB_SCSI_IO)
103 AC_SUBST(CTDB_PCAP_LDFLAGS)
104 AC_SUBST(CTDB_PMDA)
105 AC_SUBST(CTDB_PMDA_INSTALL)
106
107 AC_OUTPUT(Makefile ctdb.pc)