features/glupy: Rename Glupy python module to avoid namespace conflict
[obnox/glusterfs.git] / configure.ac
1 dnl  Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com>
2 dnl  This file is part of GlusterFS.
3 dnl
4 dnl  This file is licensed to you under your choice of the GNU Lesser
5 dnl  General Public License, version 3 or any later version (LGPLv3 or
6 dnl  later), or the GNU General Public License, version 2 (GPLv2), in all
7 dnl  cases as published by the Free Software Foundation.
8
9 AC_INIT([glusterfs],[3git],[gluster-users@gluster.org],,[https://github.com/gluster/glusterfs.git])
10
11 AM_INIT_AUTOMAKE
12
13 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
14
15 if make --help 2>&1 | grep -q no-print-directory; then
16    AM_MAKEFLAGS="$AM_MAKEFLAGS --no-print-directory";
17 fi
18
19 if make --help 2>&1 | grep -q quiet; then
20    AM_MAKEFLAGS="$AM_MAKEFLAGS --quiet"
21 fi
22
23 if libtool --help 2>&1 | grep -q quiet; then
24    AM_LIBTOOLFLAGS="--quiet";
25 fi
26
27 AC_CONFIG_HEADERS([config.h])
28
29 AC_CONFIG_FILES([Makefile
30                 libglusterfs/Makefile
31                 libglusterfs/src/Makefile
32                 geo-replication/src/peer_gsec_create
33                 geo-replication/src/peer_add_secret_pub
34                 glusterfsd/Makefile
35                 glusterfsd/src/Makefile
36                 rpc/Makefile
37                 rpc/rpc-lib/Makefile
38                 rpc/rpc-lib/src/Makefile
39                 rpc/rpc-transport/Makefile
40                 rpc/rpc-transport/socket/Makefile
41                 rpc/rpc-transport/socket/src/Makefile
42                 rpc/rpc-transport/rdma/Makefile
43                 rpc/rpc-transport/rdma/src/Makefile
44                 rpc/xdr/Makefile
45                 rpc/xdr/src/Makefile
46                 xlators/Makefile
47                 xlators/mount/Makefile
48                 xlators/mount/fuse/Makefile
49                 xlators/mount/fuse/src/Makefile
50                 xlators/mount/fuse/utils/mount.glusterfs
51                 xlators/mount/fuse/utils/mount_glusterfs
52                 xlators/mount/fuse/utils/Makefile
53                 xlators/storage/Makefile
54                 xlators/storage/posix/Makefile
55                 xlators/storage/posix/src/Makefile
56                 xlators/storage/bd/Makefile
57                 xlators/storage/bd/src/Makefile
58                 xlators/cluster/Makefile
59                 xlators/cluster/afr/Makefile
60                 xlators/cluster/afr/src/Makefile
61                 xlators/cluster/stripe/Makefile
62                 xlators/cluster/stripe/src/Makefile
63                 xlators/cluster/dht/Makefile
64                 xlators/cluster/dht/src/Makefile
65                 xlators/performance/Makefile
66                 xlators/performance/write-behind/Makefile
67                 xlators/performance/write-behind/src/Makefile
68                 xlators/performance/read-ahead/Makefile
69                 xlators/performance/read-ahead/src/Makefile
70                 xlators/performance/readdir-ahead/Makefile
71                 xlators/performance/readdir-ahead/src/Makefile
72                 xlators/performance/io-threads/Makefile
73                 xlators/performance/io-threads/src/Makefile
74                 xlators/performance/io-cache/Makefile
75                 xlators/performance/io-cache/src/Makefile
76                 xlators/performance/symlink-cache/Makefile
77                 xlators/performance/symlink-cache/src/Makefile
78                 xlators/performance/quick-read/Makefile
79                 xlators/performance/quick-read/src/Makefile
80                 xlators/performance/open-behind/Makefile
81                 xlators/performance/open-behind/src/Makefile
82                 xlators/performance/md-cache/Makefile
83                 xlators/performance/md-cache/src/Makefile
84                 xlators/debug/Makefile
85                 xlators/debug/trace/Makefile
86                 xlators/debug/trace/src/Makefile
87                 xlators/debug/error-gen/Makefile
88                 xlators/debug/error-gen/src/Makefile
89                 xlators/debug/io-stats/Makefile
90                 xlators/debug/io-stats/src/Makefile
91                 xlators/protocol/Makefile
92                 xlators/protocol/auth/Makefile
93                 xlators/protocol/auth/addr/Makefile
94                 xlators/protocol/auth/addr/src/Makefile
95                 xlators/protocol/auth/login/Makefile
96                 xlators/protocol/auth/login/src/Makefile
97                 xlators/protocol/client/Makefile
98                 xlators/protocol/client/src/Makefile
99                 xlators/protocol/server/Makefile
100                 xlators/protocol/server/src/Makefile
101                 xlators/features/Makefile
102                 xlators/features/changelog/Makefile
103                 xlators/features/changelog/src/Makefile
104                 xlators/features/changelog/lib/Makefile
105                 xlators/features/changelog/lib/src/Makefile
106                 xlators/features/glupy/Makefile
107                 xlators/features/glupy/examples/Makefile
108                 xlators/features/glupy/src/Makefile
109                 xlators/features/glupy/src/setup.py
110                 xlators/features/locks/Makefile
111                 xlators/features/locks/src/Makefile
112                 xlators/features/quota/Makefile
113                 xlators/features/quota/src/Makefile
114                 xlators/features/marker/Makefile
115                 xlators/features/marker/src/Makefile
116                 xlators/features/read-only/Makefile
117                 xlators/features/read-only/src/Makefile
118                 xlators/features/compress/Makefile
119                 xlators/features/compress/src/Makefile
120                 xlators/features/mac-compat/Makefile
121                 xlators/features/mac-compat/src/Makefile
122                 xlators/features/quiesce/Makefile
123                 xlators/features/quiesce/src/Makefile
124                 xlators/features/index/Makefile
125                 xlators/features/index/src/Makefile
126                 xlators/features/protect/Makefile
127                 xlators/features/protect/src/Makefile
128                 xlators/features/gfid-access/Makefile
129                 xlators/features/gfid-access/src/Makefile
130                 xlators/playground/Makefile
131                 xlators/playground/template/Makefile
132                 xlators/playground/template/src/Makefile
133                 xlators/encryption/Makefile
134                 xlators/encryption/rot-13/Makefile
135                 xlators/encryption/rot-13/src/Makefile
136                 xlators/encryption/crypt/Makefile
137                 xlators/encryption/crypt/src/Makefile
138                 xlators/features/qemu-block/Makefile
139                 xlators/features/qemu-block/src/Makefile
140                 xlators/system/Makefile
141                 xlators/system/posix-acl/Makefile
142                 xlators/system/posix-acl/src/Makefile
143                 xlators/nfs/Makefile
144                 xlators/nfs/server/Makefile
145                 xlators/nfs/server/src/Makefile
146                 xlators/mgmt/Makefile
147                 xlators/mgmt/glusterd/Makefile
148                 xlators/mgmt/glusterd/src/Makefile
149                 cli/Makefile
150                 cli/src/Makefile
151                 doc/Makefile
152                 extras/Makefile
153                 extras/init.d/Makefile
154                 extras/init.d/glusterd.plist
155                 extras/init.d/glusterd-Debian
156                 extras/init.d/glusterd-Redhat
157                 extras/init.d/glusterd-SuSE
158                 extras/systemd/Makefile
159                 extras/systemd/glusterd.service
160                 extras/benchmarking/Makefile
161                 extras/hook-scripts/Makefile
162                 extras/ocf/Makefile
163                 extras/ocf/glusterd
164                 extras/ocf/volume
165                 extras/LinuxRPM/Makefile
166                 extras/geo-rep/Makefile
167                 extras/hook-scripts/add-brick/Makefile
168                 extras/hook-scripts/add-brick/pre/Makefile
169                 extras/hook-scripts/add-brick/post/Makefile
170                 extras/hook-scripts/start/Makefile
171                 extras/hook-scripts/start/post/Makefile
172                 extras/hook-scripts/set/Makefile
173                 extras/hook-scripts/set/post/Makefile
174                 extras/hook-scripts/stop/Makefile
175                 extras/hook-scripts/stop/pre/Makefile
176                 contrib/fuse-util/Makefile
177                 contrib/uuid/uuid_types.h
178                 glusterfs-api.pc
179                 libgfchangelog.pc
180                 api/Makefile
181                 api/src/Makefile
182                 api/examples/Makefile
183                 api/examples/__init__.py
184                 api/examples/setup.py
185                 geo-replication/Makefile
186                 geo-replication/src/Makefile
187                 geo-replication/syncdaemon/Makefile
188                 glusterfs.spec])
189
190 AC_CANONICAL_HOST
191
192 AC_PROG_CC
193 AC_DISABLE_STATIC
194 AC_PROG_LIBTOOL
195
196 # Initialize CFLAGS before usage
197 AC_ARG_ENABLE([debug],
198               AC_HELP_STRING([--enable-debug],
199                              [Enable debug build options.]))
200 if test "x$enable_debug" = "xyes"; then
201         BUILD_DEBUG=yes
202         CFLAGS="${CFLAGS} -g -O0 -DDEBUG"
203 else
204         BUILD_DEBUG=no
205         CFLAGS="${CFLAGS} -g -O2"
206 fi
207
208 AC_ARG_WITH(pkgconfigdir,
209             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
210             [pkgconfigdir=$withval],
211             [pkgconfigdir='${libdir}/pkgconfig'])
212 AC_SUBST(pkgconfigdir)
213
214 AC_ARG_WITH(mountutildir,
215             [  --with-mountutildir=DIR mount helper utility in DIR @<:@/sbin@:>@],
216             [mountutildir=$withval],
217             [mountutildir='/sbin'])
218 AC_SUBST(mountutildir)
219
220 AC_ARG_WITH(systemddir,
221             [  --with-systemddir=DIR systemd service files in DIR @<:@/usr/lib/systemd/system@:>@],
222             [systemddir=$withval],
223             [systemddir='/usr/lib/systemd/system'])
224 AC_SUBST(systemddir)
225
226 AC_ARG_WITH(initdir,
227             [  --with-initdir=DIR init.d scripts in DIR @<:@/etc/init.d@:>@],
228             [initdir=$withval],
229             [initdir='/etc/init.d'])
230 AC_SUBST(initdir)
231
232 AC_ARG_WITH(launchddir,
233             [  --with-launchddir=DIR launchd services in DIR @<:@/Library/LaunchDaemons@:>@],
234             [launchddir=$withval],
235             [launchddir='/Library/LaunchDaemons'])
236 AC_SUBST(launchddir)
237
238 AC_ARG_WITH([ocf],
239             [AS_HELP_STRING([--without-ocf], [build OCF-compliant cluster resource agents])],
240             ,
241             [OCF_SUBDIR='ocf'],
242             )
243 AC_SUBST(OCF_SUBDIR)
244
245 # LEX needs a check
246 AC_PROG_LEX
247 if test  "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then
248    AC_MSG_ERROR([Flex or lex required to build glusterfs.])
249 fi
250
251 dnl
252 dnl Word sizes...
253 dnl
254 AC_CHECK_SIZEOF(short)
255 AC_CHECK_SIZEOF(int)
256 AC_CHECK_SIZEOF(long)
257 AC_CHECK_SIZEOF(long long)
258 SIZEOF_SHORT=$ac_cv_sizeof_short
259 SIZEOF_INT=$ac_cv_sizeof_int
260 SIZEOF_LONG=$ac_cv_sizeof_long
261 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
262 AC_SUBST(SIZEOF_SHORT)
263 AC_SUBST(SIZEOF_INT)
264 AC_SUBST(SIZEOF_LONG)
265 AC_SUBST(SIZEOF_LONG_LONG)
266
267 # YACC needs a check
268 AC_PROG_YACC
269 if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then
270    AC_MSG_ERROR([GNU Bison required to build glusterfs.])
271 fi
272
273 AC_CHECK_TOOL([LD],[ld])
274
275 AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required to build glusterfs]))
276
277 AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs]))
278
279 AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))
280
281 AC_CHECK_FUNC([gettext], [has_gettext=yes], AC_CHECK_LIB([intl], [gettext], , AC_MSG_ERROR([gettext support is required to build glusterfs])))
282
283 AC_CHECK_HEADERS([sys/xattr.h])
284
285 AC_CHECK_HEADERS([sys/extattr.h])
286
287 AC_CHECK_HEADERS([openssl/md5.h])
288
289 AC_CHECK_HEADERS([linux/falloc.h])
290
291 case $host_os in
292   darwin*)
293     if ! test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -ge 5; then
294       AC_MSG_ERROR([You need at least OS X 10.5 (Leopard) to build Glusterfs])
295     fi
296     ;;
297 esac
298
299 dnl Mac OS X does not have spinlocks
300 AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
301 if test "x${have_spinlock}" = "xyes"; then
302    AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
303 fi
304 AC_SUBST(HAVE_SPINLOCK)
305
306 dnl some os may not have GNU defined strnlen function
307 AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
308 if test "x${have_strnlen}" = "xyes"; then
309    AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen])
310 fi
311 AC_SUBST(HAVE_STRNLEN)
312
313
314 AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes])
315 AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes])
316
317 if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then
318   AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid])
319 fi
320
321
322 # FUSE section
323 AC_ARG_ENABLE([fuse-client],
324               AC_HELP_STRING([--disable-fuse-client],
325                              [Do not build the fuse client. NOTE: you cannot mount glusterfs without the client]))
326
327 BUILD_FUSE_CLIENT=no
328 if test "x$enable_fuse_client" != "xno"; then
329    FUSE_CLIENT_SUBDIR=fuse
330    BUILD_FUSE_CLIENT="yes"
331 fi
332
333 AC_ARG_ENABLE([bd-xlator],
334               AC_HELP_STRING([--enable-bd-xlator], [Build BD xlator]))
335
336 if test "x$enable_bd_xlator" != "xno"; then
337   AC_CHECK_LIB([lvm2app],
338                [lvm_init,lvm_lv_from_name],
339                [HAVE_BD_LIB="yes"],
340                [HAVE_BD_LIB="no"])
341
342 if test "x$HAVE_BD_LIB" = "xyes"; then
343     # lvm_lv_from_name() has been made public with lvm2-2.02.79
344     AC_CHECK_DECLS(
345                   [lvm_lv_from_name],
346                   [NEED_LVM_LV_FROM_NAME_DECL="no"],
347                   [NEED_LVM_LV_FROM_NAME_DECL="yes"],
348                   [[#include <lvm2app.h>]])
349   fi
350 fi
351
352 if test "x$enable_bd_xlator" = "xyes" -a "x$HAVE_BD_LIB" = "xno"; then
353    echo "BD xlator requested but required lvm2 development library not found."
354    exit 1
355 fi
356
357 BUILD_BD_XLATOR=no
358 if test "x${enable-bd-xlator}" != "xno" -a "x${HAVE_BD_LIB}" = "xyes"; then
359   BUILD_BD_XLATOR=yes
360   AC_DEFINE(HAVE_BD_XLATOR, 1, [define if lvm2app library found and bd xlator
361                             enabled])
362   if test "x$NEED_LVM_LV_FROM_NAME_DECL" = "xyes"; then
363     AC_DEFINE(NEED_LVM_LV_FROM_NAME_DECL, 1, [defined if lvm_lv_from_name()
364                   was not found in the lvm2app.h header, but can be linked])
365   fi
366 fi
367
368 AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes])
369
370 # start encryption/crypt section
371
372 AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no])
373
374 AC_ARG_ENABLE([crypt-xlator],
375         AC_HELP_STRING([--enable-crypt-xlator], [Build crypt encryption xlator]))
376
377 if test "x$enable_crypt_xlator" = "xyes" -a "x$have_cmac_h" = "xno"; then
378    echo "Encryption xlator requires OpenSSL with cmac.h"
379    exit 1
380 fi
381
382 BUILD_CRYPT_XLATOR=no
383 if test "x$enable_crypt_xlator" != "xno" -a "x$have_cmac_h" = "xyes"; then
384    BUILD_CRYPT_XLATOR=yes
385    AC_DEFINE(HAVE_CRYPT_XLATOR, 1, [enable building crypt encryption xlator])
386 fi
387
388 AM_CONDITIONAL([ENABLE_CRYPT_XLATOR], [test x$BUILD_CRYPT_XLATOR = xyes])
389
390 AC_SUBST(FUSE_CLIENT_SUBDIR)
391 # end FUSE section
392
393
394 # FUSERMOUNT section
395 AC_ARG_ENABLE([fusermount],
396               AC_HELP_STRING([--disable-fusermount],
397                              [Use system's fusermount]))
398
399 BUILD_FUSERMOUNT="yes"
400 if test "x$enable_fusermount" = "xno"; then
401   BUILD_FUSERMOUNT="no"
402 else
403   AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
404   FUSERMOUNT_SUBDIR="contrib/fuse-util"
405 fi
406
407 AC_SUBST(FUSERMOUNT_SUBDIR)
408 #end FUSERMOUNT section
409
410 # QEMU_BLOCK section
411
412 AC_ARG_ENABLE([qemu-block],
413                 AC_HELP_STRING([--enable-qemu-block],
414                         [Build QEMU Block formats translator]))
415
416 if test "x$enable_qemu_block" != "xno"; then
417   PKG_CHECK_MODULES([GLIB], [glib-2.0],
418                     [HAVE_GLIB_2="yes"],
419                     [HAVE_GLIB_2="no"])
420 fi
421
422 if test "x$enable_qemu_block" = "xyes" -a "x$HAVE_GLIB_2" = "xno"; then
423    echo "QEMU Block formats translator requires libglib-2.0, but missing."
424    exit 1
425 fi
426
427 BUILD_QEMU_BLOCK=no
428 if test "x${enable_qemu_block}" != "xno" -a "x${HAVE_GLIB_2}" = "xyes"; then
429   BUILD_QEMU_BLOCK=yes
430   AC_DEFINE(HAVE_QEMU_BLOCK, 1, [define if libglib-2.0 library found and QEMU
431                              Block translator enabled])
432 fi
433
434 AM_CONDITIONAL([ENABLE_QEMU_BLOCK], [test x$BUILD_QEMU_BLOCK = xyes])
435
436 # end QEMU_BLOCK section
437
438 # EPOLL section
439 AC_ARG_ENABLE([epoll],
440               AC_HELP_STRING([--disable-epoll],
441                              [Use poll instead of epoll.]))
442
443 BUILD_EPOLL=no
444 if test "x$enable_epoll" != "xno"; then
445    AC_CHECK_HEADERS([sys/epoll.h],
446                     [BUILD_EPOLL=yes],
447                     [BUILD_EPOLL=no])
448 fi
449 # end EPOLL section
450
451
452 # IBVERBS section
453 AC_ARG_ENABLE([ibverbs],
454               AC_HELP_STRING([--disable-ibverbs],
455                              [Do not build the ibverbs transport]))
456
457 if test "x$enable_ibverbs" != "xno"; then
458   AC_CHECK_LIB([ibverbs],
459                [ibv_get_device_list],
460                [HAVE_LIBIBVERBS="yes"],
461                [HAVE_LIBIBVERBS="no"])
462   AC_CHECK_LIB([rdmacm], [rdma_create_id], [HAVE_RDMACM="yes"], [HAVE_RDMACM="no"])
463 fi
464
465 if test "x$enable_ibverbs" = "xyes"; then
466    if test "x$HAVE_LIBIBVERBS" = "xno"; then
467       echo "ibverbs-transport requested, but libibverbs is not present."
468       exit 1
469    fi
470
471    if test "x$HAVE_RDMACM" = "xno"; then
472       echo "ibverbs-transport requested, but librdmacm is not present."
473       exit 1
474    fi
475 fi
476
477 BUILD_RDMA=no
478 BUILD_IBVERBS=no
479 if test "x$enable_ibverbs" != "xno" -a "x$HAVE_LIBIBVERBS" = "xyes" -a "x$HAVE_RDMACM" = "xyes"; then
480   IBVERBS_SUBDIR=ib-verbs
481   BUILD_IBVERBS=yes
482   RDMA_SUBDIR=rdma
483   BUILD_RDMA=yes
484 fi
485
486 AC_SUBST(IBVERBS_SUBDIR)
487 AC_SUBST(RDMA_SUBDIR)
488 # end IBVERBS section
489
490
491 # SYNCDAEMON section
492 AC_ARG_ENABLE([georeplication],
493               AC_HELP_STRING([--disable-georeplication],
494                              [Do not install georeplication components]))
495
496 BUILD_SYNCDAEMON=no
497 case $host_os in
498      linux*)
499 #do nothing
500        ;;
501      netbsd*)
502 #do nothing
503        ;;
504      *)
505 #disabling geo replication for non-linux platforms
506         enable_georeplication=no
507         ;;
508 esac
509 SYNCDAEMON_COMPILE=0
510 if test "x$enable_georeplication" != "xno"; then
511   SYNCDAEMON_SUBDIR=geo-replication
512   SYNCDAEMON_COMPILE=1
513
514   BUILD_SYNCDAEMON="yes"
515   AM_PATH_PYTHON([2.4])
516   echo -n "checking if python is python 2.x... "
517   if echo $PYTHON_VERSION | grep ^2; then
518     :
519   else
520     echo no
521     AC_MSG_ERROR([only python 2.x is supported])
522   fi
523   echo -n "checking if python has ctypes support... "
524   if "$PYTHON" -c 'import ctypes' 2>/dev/null; then
525     echo yes
526   else
527     echo no
528     AC_MSG_ERROR([python does not have ctypes support])
529   fi
530 fi
531 AC_SUBST(SYNCDAEMON_COMPILE)
532 AC_SUBST(SYNCDAEMON_SUBDIR)
533 # end SYNCDAEMON section
534
535 # CDC xlator - check if libz is present if so enable HAVE_LIB_Z
536 echo -n "checking if libz is present... "
537
538 PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0],
539                   [echo "yes (features requiring zlib enabled)"  AC_DEFINE(HAVE_LIB_Z, 1, [define if zlib is present])],
540                   [echo "no"] )
541
542 AC_SUBST(LIBZ_CFLAGS)
543 AC_SUBST(LIBZ_LIBS)
544 # end CDC xlator secion
545
546 # check for systemtap/dtrace
547 BUILD_SYSTEMTAP=no
548 AC_MSG_CHECKING([whether to include systemtap tracing support])
549 AC_ARG_ENABLE([systemtap],
550               [AS_HELP_STRING([--enable-systemtap],
551               [Enable inclusion of systemtap trace support])],
552               [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP="def"])
553
554 AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test "x${ENABLE_SYSTEMTAP}" = "xyes"])
555 AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
556
557 if test "x${ENABLE_SYSTEMTAP}" != "xno"; then
558     AC_CHECK_PROG(DTRACE, dtrace, "yes", "no")
559     AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND="yes"],
560                     [SDT_H_FOUND="no"])
561 fi
562
563 if test "x${ENABLE_SYSTEMTAP}" = "xyes"; then
564     if test "x${DTRACE}" = "xno"; then
565         AC_MSG_ERROR([dtrace not found])
566     elif test "$x{SDT_H_FOUND}" = "xno"; then
567         AC_MSG_ERROR([systemtap support needs sys/sdt.h header])
568     fi
569 fi
570
571 if test "x${DTRACE}" = "xyes" -a "x${SDT_H_FOUND}" = "xyes"; then
572     AC_MSG_CHECKING([x"${DTRACE}"xy"${SDT_H_FOUND}"y])
573     AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using  probes.])
574     BUILD_SYSTEMTAP=yes
575 fi
576 # end of systemtap/dtrace
577
578 # xml-output
579 AC_ARG_ENABLE([xml-output],
580               AC_HELP_STRING([--disable-xml-output],
581                              [Disable the xml output]))
582 BUILD_XML_OUTPUT="yes"
583 if test "x$enable_xml_output" != "xno"; then
584     #check if libxml is present if so enable HAVE_LIB_XML
585     m4_ifdef([AM_PATH_XML2],[AM_PATH_XML2([2.6.19])], [no_xml=yes])
586     if test "x${no_xml}" = "x"; then
587         AC_DEFINE([HAVE_LIB_XML], [1], [Define to 1 if using libxml2.])
588     else
589         if test "x$enable_georeplication" != "xno"; then
590            AC_MSG_ERROR([libxml2 devel libraries not found])
591         else
592            AC_MSG_WARN([libxml2 devel libraries not found disabling XML support])
593            BUILD_XML_OUTPUT="no"
594         fi
595
596     fi
597 else
598     if test "x$enable_georeplication" != "xno"; then
599        AC_MSG_ERROR([geo-replication requires xml output])
600     fi
601     BUILD_XML_OUTPUT="no"
602 fi
603 # end of xml-output
604
605 dnl FreeBSD > 5 has execinfo as a Ported library for giving a workaround
606 dnl solution to GCC backtrace functionality
607
608 AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes],
609                AC_CHECK_LIB([execinfo], [backtrace], [have_backtrace=yes]))
610 dnl               AC_MSG_ERROR([libexecinfo not found libexecinfo required.])))
611
612 if test "x${have_backtrace}" = "xyes"; then
613    AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
614 fi
615 AC_SUBST(HAVE_BACKTRACE)
616
617 dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
618 AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes])
619 if test "x${have_malloc_stats}" = "xyes"; then
620    AC_DEFINE(HAVE_MALLOC_STATS, 1, [define if found malloc_stats])
621 fi
622 AC_SUBST(HAVE_MALLOC_STATS)
623
624 dnl Linux, Solaris, Cygwin
625 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
626 dnl FreeBSD, NetBSD
627 AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])
628 case $host_os in
629         *netbsd*)
630         CFLAGS="${CFLAGS} -D_INCOMPLETE_XOPEN_C063"
631         ;;
632 esac
633 AC_CHECK_FUNC([linkat], [have_linkat=yes])
634 if test "x${have_linkat}" = "xyes"; then
635    AC_DEFINE(HAVE_LINKAT, 1, [define if found linkat])
636 fi
637 AC_SUBST(HAVE_LINKAT)
638
639 dnl check for Monotonic clock
640 AC_CHECK_FUNC([clock_gettime], [has_monotonic_clock=yes], AC_CHECK_LIB([rt], [clock_gettime], , AC_MSG_WARN([System doesn't have monotonic clock using contrib])))
641
642 dnl Check for argp
643 AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
644 AC_CONFIG_SUBDIRS(argp-standalone)
645
646 BUILD_ARGP_STANDALONE=no
647 if test "x${ac_cv_header_argp_h}" = "xno"; then
648    BUILD_ARGP_STANDALONE=yes
649    ARGP_STANDALONE_CPPFLAGS='-I${top_srcdir}/argp-standalone'
650    ARGP_STANDALONE_LDADD='${top_builddir}/argp-standalone/libargp.a'
651 fi
652
653 AC_SUBST(ARGP_STANDALONE_CPPFLAGS)
654 AC_SUBST(ARGP_STANDALONE_LDADD)
655
656 AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))
657
658 AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes])
659 if test "x${have_llistxattr}" = "xyes"; then
660    AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists])
661 fi
662
663 AC_CHECK_FUNC([fdatasync], [have_fdatasync=yes])
664 if test "x${have_fdatasync}" = "xyes"; then
665    AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists])
666 fi
667
668 AC_CHECK_FUNC([fallocate], [have_fallocate=yes])
669 if test "x${have_fallocate}" = "xyes"; then
670    AC_DEFINE(HAVE_FALLOCATE, 1, [define if fallocate exists])
671 fi
672
673 AC_CHECK_FUNC([posix_fallocate], [have_posix_fallocate=yes])
674 if test "x${have_posix_fallocate}" = "xyes"; then
675    AC_DEFINE(HAVE_POSIX_FALLOCATE, 1, [define if posix_fallocate exists])
676 fi
677
678
679 # Check the distribution where you are compiling glusterfs on
680
681 GF_DISTRIBUTION=
682 AC_CHECK_FILE([/etc/debian_version])
683 AC_CHECK_FILE([/etc/SuSE-release])
684 AC_CHECK_FILE([/etc/redhat-release])
685
686 if test "x$ac_cv_file__etc_debian_version" = "xyes"; then
687    GF_DISTRIBUTION=Debian
688 fi
689 if test "x$ac_cv_file__etc_SuSE_release" = "xyes"; then
690    GF_DISTRIBUTION=SuSE
691 fi
692 if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then
693    GF_DISTRIBUTION=Redhat
694 fi
695
696 AC_SUBST(GF_DISTRIBUTION)
697
698 GF_HOST_OS=""
699 GF_LDFLAGS="-rdynamic"
700
701 # check for gcc -Werror=format-security
702 saved_CFLAGS=$CFLAGS
703 CFLAGS="-Wformat -Werror=format-security"
704 AC_MSG_CHECKING([whether $CC accepts -Werror=format-security])
705 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no])
706 echo $cc_werror_format_security
707 if test "x$cc_werror_format_security" = "xno"; then
708     CFLAGS="$saved_CFLAGS"
709 else
710     CFLAGS="$saved_CFLAGS $CFLAGS"
711 fi
712
713 # check for gcc -Werror=implicit-function-declaration
714 saved_CFLAGS=$CFLAGS
715 CFLAGS="-Werror=implicit-function-declaration"
716 AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration])
717 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no])
718 echo $cc_werror_implicit
719 if test "x$cc_werror_implicit" = "xno"; then
720     CFLAGS="$saved_CFLAGS"
721 else
722     CFLAGS="$saved_CFLAGS $CFLAGS"
723 fi
724
725 case $host_os in
726      linux*)
727         GF_HOST_OS="GF_LINUX_HOST_OS"
728         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS}"
729         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
730         GF_LDADD="${ARGP_STANDALONE_LDADD}"
731         GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\""
732         ;;
733      solaris*)
734         GF_HOST_OS="GF_SOLARIS_HOST_OS"
735         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -m64"
736         GF_LDFLAGS=""
737         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
738         GF_LDADD="${ARGP_STANDALONE_LDADD}"
739         GF_GLUSTERFS_LIBS="-lnsl -lresolv -lsocket"
740         BUILD_FUSE_CLIENT=no
741         FUSE_CLIENT_SUBDIR=""
742         ;;
743      *netbsd*)
744         GF_HOST_OS="GF_BSD_HOST_OS"
745         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_INCOMPLETE_XOPEN_C063"
746         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
747         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
748         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
749         GF_LDADD="${ARGP_STANDALONE_LDADD}"
750         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
751            GF_GLUSTERFS_LIBS="-lexecinfo"
752         fi
753         GF_FUSE_LDADD="-lperfuse"
754         BUILD_FUSE_CLIENT=yes
755         LEXLIB=""
756         ;;
757      *bsd*)
758         GF_HOST_OS="GF_BSD_HOST_OS"
759         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS}"
760         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
761         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
762         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
763         GF_LDADD="${ARGP_STANDALONE_LDADD}"
764         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
765            GF_GLUSTERFS_LIBS="-lexecinfo"
766         fi
767         BUILD_FUSE_CLIENT=no
768         ;;
769      darwin*)
770         GF_HOST_OS="GF_DARWIN_HOST_OS"
771         LIBTOOL=glibtool
772         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE"
773         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
774         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
775         GF_GLUSTERFS_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -undefined suppress -flat_namespace"
776         GF_LDADD="${ARGP_STANDALONE_LDADD}"
777         GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse"
778         ;;
779 esac
780
781 # enable debug section
782 AC_ARG_ENABLE([debug],
783               AC_HELP_STRING([--enable-debug],
784                              [Enable debug build options.]))
785
786 # syslog section
787 AC_ARG_ENABLE([syslog],
788               AC_HELP_STRING([--disable-syslog],
789                              [Disable syslog for logging]))
790
791 USE_SYSLOG="yes"
792 if test "x$enable_syslog" != "xno"; then
793   AC_DEFINE(GF_USE_SYSLOG, 1, [Use syslog for logging])
794 else
795   USE_SYSLOG="no"
796 fi
797 AM_CONDITIONAL([ENABLE_SYSLOG], [test x$USE_SYSLOG = xyes])
798 #end syslog section
799
800 BUILD_READLINE=no
801 AC_CHECK_LIB([readline -lcurses],[readline],[RLLIBS="-lreadline -lcurses"])
802 AC_CHECK_LIB([readline -ltermcap],[readline],[RLLIBS="-lreadline -ltermcap"])
803 AC_CHECK_LIB([readline -lncurses],[readline],[RLLIBS="-lreadline -lncurses"])
804
805 if test "x$RLLIBS" != "x"; then
806    AC_DEFINE(HAVE_READLINE, 1, [readline enabled CLI])
807    BUILD_READLINE=yes
808 fi
809
810 BUILD_LIBAIO=no
811 AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"])
812
813 if test "x$LIBAIO" != "x"; then
814    AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled])
815    BUILD_LIBAIO=yes
816 fi
817
818 # glupy section
819 BUILD_GLUPY=no
820 have_python2=no
821 have_Python_h=no
822
823 AM_PATH_PYTHON()
824 if echo $PYTHON_VERSION | grep ^2; then
825   have_python2=yes
826 fi
827
828 # Save flags before testing python
829 saved_CFLAGS=$CFLAGS
830 saved_CPPFLAGS=$CPPFLAGS
831 saved_LDFLAGS=$LDFLAGS
832 CFLAGS=`${PYTHON}-config --cflags`
833 CPPFLAGS=$CFLAGS
834 LDFLAGS="-L`${PYTHON}-config --prefix`/lib `${PYTHON}-config --ldflags`"
835 AC_CHECK_HEADERS([python$PYTHON_VERSION/Python.h],[have_Python_h=yes],[])
836 AC_ARG_ENABLE([glupy],
837               AS_HELP_STRING([--enable-glupy],
838                              [build glupy]))
839 case x$enable_glupy in
840    xyes)
841       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
842          BUILD_GLUPY=yes
843         PYTHONDEV_CFLAGS="$CFLAGS"
844         PYTHONDEV_CPPFLAGS="$CPPFLAGS"
845         PYTHONDEV_LDFLAGS="$LDFLAGS"
846         AC_SUBST(PYTHONDEV_CFLAGS)
847         AC_SUBST(PYTHONDEV_CPPFLAGS)
848         AC_SUBST(PYTHONDEV_LDFLAGS)
849       else
850          AC_MSG_ERROR([glupy requires python-devel/python-dev package and python2.x])
851       fi
852       ;;
853    xno)
854       ;;
855    *)
856       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
857          BUILD_GLUPY=yes
858         PYTHONDEV_CFLAGS="$CFLAGS"
859         PYTHONDEV_CPPFLAGS="$CPPFLAGS"
860         PYTHONDEV_LDFLAGS="$LDFLAGS"
861         AC_SUBST(PYTHONDEV_CFLAGS)
862         AC_SUBST(PYTHONDEV_CPPFLAGS)
863         AC_SUBST(PYTHONDEV_LDFLAGS)
864       else
865          AC_MSG_WARN([
866         ---------------------------------------------------------------------------------
867          cannot build glupy. python 2.x and python-devel/python-dev package are required.
868         ---------------------------------------------------------------------------------])
869       fi
870       ;;
871 esac
872 # Restore flags
873 CFLAGS=$saved_CFLAGS
874 CPPFLAGS=$saved_CPPFLAGS
875 LDFLAGS=$saved_LDFLAGS
876
877 if test "x$BUILD_GLUPY" = "xyes"; then
878    BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"`
879    BUILD_PYTHON_LIB=python$PYTHON_VERSION
880    GLUPY_SUBDIR=glupy
881    GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile
882    GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile
883    echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB"
884    AC_SUBST(BUILD_PYTHON_INC)
885    AC_SUBST(BUILD_PYTHON_LIB)
886    AC_SUBST(GLUPY_SUBDIR)
887    AC_SUBST(GLUPY_SUBDIR_MAKEFILE)
888    AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE)
889 fi
890 # end glupy section
891
892 AC_SUBST(CFLAGS)
893 # end enable debug section
894
895 AC_SUBST(GF_HOST_OS)
896 AC_SUBST([GF_GLUSTERFS_LIBS])
897 AC_SUBST(GF_GLUSTERFS_CFLAGS)
898 AC_SUBST(GF_CFLAGS)
899 AC_SUBST(GF_LDFLAGS)
900 AC_SUBST(GF_LDADD)
901 AC_SUBST(GF_FUSE_LDADD)
902 AC_SUBST(GF_FUSE_CFLAGS)
903 AC_SUBST(RLLIBS)
904 AC_SUBST(LIBAIO)
905 AC_SUBST(AM_MAKEFLAGS)
906 AC_SUBST(AM_LIBTOOLFLAGS)
907
908 CONTRIBDIR='$(top_srcdir)/contrib'
909 AC_SUBST(CONTRIBDIR)
910
911 GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)'
912 GF_CPPINCLUDES='-I$(top_srcdir)/libglusterfs/src -I$(CONTRIBDIR)/uuid $(UNITTEST_CPPFLAGS)'
913 GF_CPPFLAGS="$GF_CPPDEFINES $GF_CPPINCLUDES"
914 AC_SUBST([GF_CPPFLAGS])
915
916 AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
917
918 AM_CONDITIONAL([GF_INSTALL_VAR_LIB_GLUSTERD], test ! -d ${localstatedir}/lib/glusterd && test -d ${sysconfdir}/glusterd )
919
920 dnl pkg-config versioning
921 GFAPI_VERSION="6.0.0"
922 LIBGFCHANGELOG_VERSION="0.0.1"
923 AC_SUBST(GFAPI_VERSION)
924 AC_SUBST(LIBGFCHANGELOG_VERSION)
925
926 dnl libtool versioning
927 LIBGFXDR_LT_VERSION="0:1:0"
928 LIBGFRPC_LT_VERSION="0:1:0"
929 LIBGLUSTERFS_LT_VERSION="0:1:0"
930 LIBGFCHANGELOG_LT_VERSION="0:1:0"
931 GFAPI_LT_VERSION="6:0:0"
932 AC_SUBST(LIBGFXDR_LT_VERSION)
933 AC_SUBST(LIBGFRPC_LT_VERSION)
934 AC_SUBST(LIBGLUSTERFS_LT_VERSION)
935 AC_SUBST(LIBGFCHANGELOG_LT_VERSION)
936 AC_SUBST(GFAPI_LT_VERSION)
937
938 AC_OUTPUT
939
940 echo
941 echo "GlusterFS configure summary"
942 echo "==========================="
943 echo "FUSE client          : $BUILD_FUSE_CLIENT"
944 echo "Infiniband verbs     : $BUILD_IBVERBS"
945 echo "epoll IO multiplex   : $BUILD_EPOLL"
946 echo "argp-standalone      : $BUILD_ARGP_STANDALONE"
947 echo "fusermount           : $BUILD_FUSERMOUNT"
948 echo "readline             : $BUILD_READLINE"
949 echo "georeplication       : $BUILD_SYNCDAEMON"
950 echo "Linux-AIO            : $BUILD_LIBAIO"
951 echo "Enable Debug         : $BUILD_DEBUG"
952 echo "systemtap            : $BUILD_SYSTEMTAP"
953 echo "Block Device xlator  : $BUILD_BD_XLATOR"
954 echo "glupy                : $BUILD_GLUPY"
955 echo "Use syslog           : $USE_SYSLOG"
956 echo "XML output           : $BUILD_XML_OUTPUT"
957 echo "QEMU Block formats   : $BUILD_QEMU_BLOCK"
958 echo "Encryption xlator    : $BUILD_CRYPT_XLATOR"
959 echo