Adding ChangeTimeRecorder(CTR) Xlator to GlusterFS
[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],
10         [m4_esyscmd([build-aux/pkg-version --version])],
11         [gluster-users@gluster.org],,[https://github.com/gluster/glusterfs.git])
12
13 AC_SUBST([PACKAGE_RELEASE],
14          [m4_esyscmd([build-aux/pkg-version --release])])
15
16 AM_INIT_AUTOMAKE
17
18 # Removes warnings when using automake 1.14 around (...but option 'subdir-objects' is disabled )
19 #but libglusterfs fails to build with contrib (Then are not set up that way?)
20 #AM_INIT_AUTOMAKE([subdir-objects])
21
22 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
23
24 if make --help 2>&1 | grep -q no-print-directory; then
25    AM_MAKEFLAGS="$AM_MAKEFLAGS --no-print-directory";
26 fi
27
28 if make --help 2>&1 | grep -q quiet; then
29    AM_MAKEFLAGS="$AM_MAKEFLAGS --quiet"
30 fi
31
32 if libtool --help 2>&1 | grep -q quiet; then
33    AM_LIBTOOLFLAGS="--quiet";
34 fi
35
36 AC_CONFIG_HEADERS([config.h])
37
38 AC_CONFIG_FILES([Makefile
39                 libglusterfs/Makefile
40                 libglusterfs/src/Makefile
41                 libglusterfs/src/gfdb/Makefile
42                 geo-replication/src/peer_gsec_create
43                 geo-replication/src/peer_mountbroker
44                 extras/peer_add_secret_pub
45                 geo-replication/syncdaemon/configinterface.py
46                 glusterfsd/Makefile
47                 glusterfsd/src/Makefile
48                 rpc/Makefile
49                 rpc/rpc-lib/Makefile
50                 rpc/rpc-lib/src/Makefile
51                 rpc/rpc-transport/Makefile
52                 rpc/rpc-transport/socket/Makefile
53                 rpc/rpc-transport/socket/src/Makefile
54                 rpc/rpc-transport/rdma/Makefile
55                 rpc/rpc-transport/rdma/src/Makefile
56                 rpc/xdr/Makefile
57                 rpc/xdr/src/Makefile
58                 xlators/Makefile
59                 xlators/meta/Makefile
60                 xlators/meta/src/Makefile
61                 xlators/mount/Makefile
62                 xlators/mount/fuse/Makefile
63                 xlators/mount/fuse/src/Makefile
64                 xlators/mount/fuse/utils/mount.glusterfs
65                 xlators/mount/fuse/utils/mount_glusterfs
66                 xlators/mount/fuse/utils/Makefile
67                 xlators/storage/Makefile
68                 xlators/storage/posix/Makefile
69                 xlators/storage/posix/src/Makefile
70                 xlators/storage/bd/Makefile
71                 xlators/storage/bd/src/Makefile
72                 xlators/cluster/Makefile
73                 xlators/cluster/afr/Makefile
74                 xlators/cluster/afr/src/Makefile
75                 xlators/cluster/stripe/Makefile
76                 xlators/cluster/stripe/src/Makefile
77                 xlators/cluster/dht/Makefile
78                 xlators/cluster/dht/src/Makefile
79                 xlators/cluster/ec/Makefile
80                 xlators/cluster/ec/src/Makefile
81                 xlators/performance/Makefile
82                 xlators/performance/write-behind/Makefile
83                 xlators/performance/write-behind/src/Makefile
84                 xlators/performance/read-ahead/Makefile
85                 xlators/performance/read-ahead/src/Makefile
86                 xlators/performance/readdir-ahead/Makefile
87                 xlators/performance/readdir-ahead/src/Makefile
88                 xlators/performance/io-threads/Makefile
89                 xlators/performance/io-threads/src/Makefile
90                 xlators/performance/io-cache/Makefile
91                 xlators/performance/io-cache/src/Makefile
92                 xlators/performance/symlink-cache/Makefile
93                 xlators/performance/symlink-cache/src/Makefile
94                 xlators/performance/quick-read/Makefile
95                 xlators/performance/quick-read/src/Makefile
96                 xlators/performance/open-behind/Makefile
97                 xlators/performance/open-behind/src/Makefile
98                 xlators/performance/md-cache/Makefile
99                 xlators/performance/md-cache/src/Makefile
100                 xlators/debug/Makefile
101                 xlators/debug/trace/Makefile
102                 xlators/debug/trace/src/Makefile
103                 xlators/debug/error-gen/Makefile
104                 xlators/debug/error-gen/src/Makefile
105                 xlators/debug/io-stats/Makefile
106                 xlators/debug/io-stats/src/Makefile
107                 xlators/protocol/Makefile
108                 xlators/protocol/auth/Makefile
109                 xlators/protocol/auth/addr/Makefile
110                 xlators/protocol/auth/addr/src/Makefile
111                 xlators/protocol/auth/login/Makefile
112                 xlators/protocol/auth/login/src/Makefile
113                 xlators/protocol/client/Makefile
114                 xlators/protocol/client/src/Makefile
115                 xlators/protocol/server/Makefile
116                 xlators/protocol/server/src/Makefile
117                 xlators/features/Makefile
118                 xlators/features/changelog/Makefile
119                 xlators/features/changelog/src/Makefile
120                 xlators/features/changelog/lib/Makefile
121                 xlators/features/changelog/lib/src/Makefile
122                 xlators/features/changetimerecorder/Makefile
123                 xlators/features/changetimerecorder/src/Makefile
124                 xlators/features/glupy/Makefile
125                 xlators/features/glupy/examples/Makefile
126                 xlators/features/glupy/src/Makefile
127                 xlators/features/glupy/src/setup.py
128                 xlators/features/glupy/src/__init__.py
129                 xlators/features/locks/Makefile
130                 xlators/features/locks/src/Makefile
131                 xlators/features/quota/Makefile
132                 xlators/features/quota/src/Makefile
133                 xlators/features/marker/Makefile
134                 xlators/features/marker/src/Makefile
135                 xlators/features/read-only/Makefile
136                 xlators/features/read-only/src/Makefile
137                 xlators/features/compress/Makefile
138                 xlators/features/compress/src/Makefile
139                 xlators/features/mac-compat/Makefile
140                 xlators/features/mac-compat/src/Makefile
141                 xlators/features/quiesce/Makefile
142                 xlators/features/quiesce/src/Makefile
143                 xlators/features/barrier/Makefile
144                 xlators/features/barrier/src/Makefile
145                 xlators/features/ganesha/Makefile
146                 xlators/features/ganesha/src/Makefile
147                 xlators/features/index/Makefile
148                 xlators/features/index/src/Makefile
149                 xlators/features/protect/Makefile
150                 xlators/features/protect/src/Makefile
151                 xlators/features/gfid-access/Makefile
152                 xlators/features/gfid-access/src/Makefile
153                 xlators/features/trash/Makefile
154                 xlators/features/trash/src/Makefile
155                 xlators/features/snapview-server/Makefile
156                 xlators/features/snapview-server/src/Makefile
157                 xlators/features/snapview-client/Makefile
158                 xlators/features/snapview-client/src/Makefile
159                 xlators/features/upcall/Makefile
160                 xlators/features/upcall/src/Makefile
161                 xlators/playground/Makefile
162                 xlators/playground/template/Makefile
163                 xlators/playground/template/src/Makefile
164                 xlators/encryption/Makefile
165                 xlators/encryption/rot-13/Makefile
166                 xlators/encryption/rot-13/src/Makefile
167                 xlators/encryption/crypt/Makefile
168                 xlators/encryption/crypt/src/Makefile
169                 xlators/features/qemu-block/Makefile
170                 xlators/features/qemu-block/src/Makefile
171                 xlators/system/Makefile
172                 xlators/system/posix-acl/Makefile
173                 xlators/system/posix-acl/src/Makefile
174                 xlators/nfs/Makefile
175                 xlators/nfs/server/Makefile
176                 xlators/nfs/server/src/Makefile
177                 xlators/mgmt/Makefile
178                 xlators/mgmt/glusterd/Makefile
179                 xlators/mgmt/glusterd/src/Makefile
180                 cli/Makefile
181                 cli/src/Makefile
182                 doc/Makefile
183                 extras/Makefile
184                 extras/glusterd.vol
185                 extras/init.d/Makefile
186                 extras/init.d/glusterd.plist
187                 extras/init.d/glusterd-Debian
188                 extras/init.d/glusterd-Redhat
189                 extras/init.d/glusterd-FreeBSD
190                 extras/init.d/glusterd-SuSE
191                 extras/ganesha/Makefile
192                 extras/ganesha/config/Makefile
193                 extras/ganesha/scripts/Makefile
194                 extras/ganesha/ocf/Makefile
195                 extras/systemd/Makefile
196                 extras/systemd/glusterd.service
197                 extras/run-gluster.tmpfiles
198                 extras/benchmarking/Makefile
199                 extras/hook-scripts/Makefile
200                 extras/ocf/Makefile
201                 extras/ocf/glusterd
202                 extras/ocf/volume
203                 extras/LinuxRPM/Makefile
204                 extras/geo-rep/Makefile
205                 extras/hook-scripts/add-brick/Makefile
206                 extras/hook-scripts/add-brick/pre/Makefile
207                 extras/hook-scripts/add-brick/post/Makefile
208                 extras/hook-scripts/start/Makefile
209                 extras/hook-scripts/start/post/Makefile
210                 extras/hook-scripts/set/Makefile
211                 extras/hook-scripts/set/post/Makefile
212                 extras/hook-scripts/stop/Makefile
213                 extras/hook-scripts/stop/pre/Makefile
214                 extras/hook-scripts/reset/Makefile
215                 extras/hook-scripts/reset/post/Makefile
216                 extras/hook-scripts/reset/pre/Makefile
217                 extras/snap_scheduler/Makefile
218                 contrib/fuse-util/Makefile
219                 contrib/umountd/Makefile
220                 contrib/uuid/uuid_types.h
221                 glusterfs-api.pc
222                 libgfchangelog.pc
223                 libgfdb.pc
224                 api/Makefile
225                 api/src/Makefile
226                 api/examples/Makefile
227                 geo-replication/Makefile
228                 geo-replication/src/Makefile
229                 geo-replication/syncdaemon/Makefile
230                 tools/Makefile
231                 tools/gfind_missing_files/Makefile
232                 heal/Makefile
233                 heal/src/Makefile
234                 glusterfs.spec
235                 tools/glusterfind/src/tool.conf
236                 tools/glusterfind/glusterfind
237                 tools/glusterfind/Makefile
238                 tools/glusterfind/src/Makefile])
239
240 AC_CANONICAL_HOST
241
242 AC_PROG_CC
243 AC_DISABLE_STATIC
244 AC_PROG_LIBTOOL
245 AC_SUBST([shrext_cmds])
246
247 AC_CHECK_PROG([RPCGEN], [rpcgen], [yes], [no])
248
249 if test "x$RPCGEN" = "xno"; then
250    AC_MSG_ERROR([`rpcgen` not found, glusterfs needs `rpcgen` exiting..])
251 fi
252
253 # Initialize CFLAGS before usage
254 AC_ARG_ENABLE([debug],
255               AC_HELP_STRING([--enable-debug],
256                              [Enable debug build options.]))
257 if test "x$enable_debug" = "xyes"; then
258         BUILD_DEBUG=yes
259         CFLAGS="${CFLAGS} -g -O0 -DDEBUG"
260 else
261         BUILD_DEBUG=no
262         CFLAGS="${CFLAGS} -g -O2"
263 fi
264
265 case $host_os in
266   darwin*)
267     if ! test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -ge 7; then
268        AC_MSG_ERROR([You need at least OS X 10.7 (Lion) to build Glusterfs])
269     fi
270     # OSX version lesser than 9 has llvm/clang optimization issues which leads to various segfaults
271     if test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -lt 9; then
272        CFLAGS="${CFLAGS} -g -O0 -DDEBUG"
273     fi
274     ;;
275 esac
276
277 AC_ARG_WITH([previous-options],
278         [AS_HELP_STRING([--with-previous-options],
279                         [read config.status for configure options])
280         ],
281         [ if test -r ./config.status && \
282              args=$(grep 'ac_cs_config=' config.status | \
283                     sed -e 's/.*"\(.*\)".*/\1/'| sed -e "s/'//g") ; then
284             echo "###"
285             echo "### Rerunning as '$0 $args'"
286             echo "###"
287             exec $0 $args
288           fi
289         ])
290
291 AC_ARG_WITH(pkgconfigdir,
292             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
293             [pkgconfigdir=$withval],
294             [pkgconfigdir='${libdir}/pkgconfig'])
295 AC_SUBST(pkgconfigdir)
296
297 AC_ARG_WITH(mountutildir,
298             [  --with-mountutildir=DIR mount helper utility in DIR @<:@/sbin@:>@],
299             [mountutildir=$withval],
300             [mountutildir='/sbin'])
301 AC_SUBST(mountutildir)
302
303 AC_ARG_WITH(systemddir,
304             [  --with-systemddir=DIR systemd service files in DIR @<:@/usr/lib/systemd/system@:>@],
305             [systemddir=$withval],
306             [systemddir='/usr/lib/systemd/system'])
307 AC_SUBST(systemddir)
308
309 AC_ARG_WITH(initdir,
310             [  --with-initdir=DIR init.d scripts in DIR @<:@/etc/init.d@:>@],
311             [initdir=$withval],
312             [initdir='/etc/init.d'])
313 AC_SUBST(initdir)
314
315 AC_ARG_WITH(launchddir,
316             [  --with-launchddir=DIR launchd services in DIR @<:@/Library/LaunchDaemons@:>@],
317             [launchddir=$withval],
318             [launchddir='/Library/LaunchDaemons'])
319 AC_SUBST(launchddir)
320
321 AC_ARG_WITH(tmpfilesdir,
322             AC_HELP_STRING([--with-tmpfilesdir=DIR],
323                            [tmpfiles config in DIR, disabled by default]),
324             [tmpfilesdir=$withval],
325             [tmpfilesdir=''])
326 AC_SUBST(tmpfilesdir)
327
328 AC_ARG_WITH([ocf],
329             [AS_HELP_STRING([--without-ocf], [build OCF-compliant cluster resource agents])],
330             ,
331             [OCF_SUBDIR='ocf'],
332             )
333 AC_SUBST(OCF_SUBDIR)
334
335 # LEX needs a check
336 AC_PROG_LEX
337 if test  "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then
338    AC_MSG_ERROR([Flex or lex required to build glusterfs.])
339 fi
340
341 dnl
342 dnl Word sizes...
343 dnl
344 AC_CHECK_SIZEOF(short)
345 AC_CHECK_SIZEOF(int)
346 AC_CHECK_SIZEOF(long)
347 AC_CHECK_SIZEOF(long long)
348 SIZEOF_SHORT=$ac_cv_sizeof_short
349 SIZEOF_INT=$ac_cv_sizeof_int
350 SIZEOF_LONG=$ac_cv_sizeof_long
351 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
352 AC_SUBST(SIZEOF_SHORT)
353 AC_SUBST(SIZEOF_INT)
354 AC_SUBST(SIZEOF_LONG)
355 AC_SUBST(SIZEOF_LONG_LONG)
356
357 # YACC needs a check
358 AC_PROG_YACC
359 if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then
360    AC_MSG_ERROR([GNU Bison required to build glusterfs.])
361 fi
362
363 AC_CHECK_TOOL([LD],[ld])
364
365 AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required to build glusterfs]))
366
367 AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs]))
368
369 AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))
370
371 AC_CHECK_LIB([readline], [rl_do_undo], [RL_UNDO="yes"], [RL_UNDO="no"])
372
373 AC_CHECK_LIB([intl], [gettext])
374
375 AC_CHECK_HEADERS([sys/xattr.h])
376
377 AC_CHECK_HEADERS([sys/ioctl.h], AC_DEFINE(HAVE_IOCTL_IN_SYS_IOCTL_H, 1, [have sys/ioctl.h]))
378
379 AC_CHECK_HEADERS([sys/extattr.h])
380
381 dnl Math library
382 case $host_os in
383      linux*)
384         MATH_LIB=''
385         ;;
386      *)
387         MATH_LIB='-lm'
388         ;;
389 esac
390 AC_SUBST(MATH_LIB)
391
392 dnl NetBSD does not support POSIX ACLs :-(
393 case $host_os in
394      *netbsd*)
395         AC_MSG_WARN([NetBSD does not support POSIX ACLs... disabling them])
396         ACL_LIBS=''
397         USE_POSIX_ACLS='0'
398         ;;
399      *)
400         AC_CHECK_HEADERS([sys/acl.h], ,
401                          AC_MSG_ERROR([Support for POSIX ACLs is required]))
402         USE_POSIX_ACLS='1'
403         case $host_os in
404              linux*)
405                 ACL_LIBS='-lacl'
406                 ;;
407              solaris*)
408                 ACL_LIBS='-lsec'
409                 ;;
410              *freebsd*)
411                 ACL_LIBS='-lc'
412                 ;;
413              darwin*)
414                 ACL_LIBS='-lc'
415                 ;;
416         esac
417         if test "x${ACL_LIBS}" = "x-lacl"; then
418           AC_CHECK_HEADERS([acl/libacl.h], , AC_MSG_ERROR([libacl is required for building on ${host_os}]))
419         fi
420         ;;
421 esac
422 AC_SUBST(ACL_LIBS)
423 AC_SUBST(USE_POSIX_ACLS)
424
425 # libglusterfs/checksum
426 AC_CHECK_HEADERS([openssl/md5.h])
427 AC_CHECK_LIB([z], [adler32], [ZLIB_LIBS="-lz"], AC_MSG_ERROR([zlib is required to build glusterfs]))
428 AC_SUBST(ZLIB_LIBS)
429
430 AC_CHECK_HEADERS([linux/falloc.h])
431
432 dnl Mac OS X does not have spinlocks
433 AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
434 if test "x${have_spinlock}" = "xyes"; then
435    AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
436 fi
437 AC_SUBST(HAVE_SPINLOCK)
438
439 dnl some os may not have GNU defined strnlen function
440 AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
441 if test "x${have_strnlen}" = "xyes"; then
442    AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen])
443 fi
444 AC_SUBST(HAVE_STRNLEN)
445
446
447 AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes])
448 AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes])
449
450 if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then
451   AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid])
452 fi
453
454 dnl test umount2 function
455 AC_CHECK_FUNC([umount2], [have_umount2=yes])
456
457 if test "x${have_umount2}" = "xyes"; then
458    AC_DEFINE(HAVE_UMOUNT2, 1, [define if found umount2])
459 fi
460
461 # FUSE section
462 AC_ARG_ENABLE([fuse-client],
463               AC_HELP_STRING([--disable-fuse-client],
464                              [Do not build the fuse client. NOTE: you cannot mount glusterfs without the client]))
465
466 BUILD_FUSE_CLIENT=no
467 if test "x$enable_fuse_client" != "xno"; then
468    FUSE_CLIENT_SUBDIR=fuse
469    BUILD_FUSE_CLIENT="yes"
470 fi
471
472 AC_ARG_ENABLE([bd-xlator],
473               AC_HELP_STRING([--enable-bd-xlator], [Build BD xlator]))
474
475 if test "x$enable_bd_xlator" != "xno"; then
476   AC_CHECK_LIB([lvm2app],
477                [lvm_init,lvm_lv_from_name],
478                [HAVE_BD_LIB="yes"],
479                [HAVE_BD_LIB="no"])
480
481 if test "x$HAVE_BD_LIB" = "xyes"; then
482     # lvm_lv_from_name() has been made public with lvm2-2.02.79
483     AC_CHECK_DECLS(
484                   [lvm_lv_from_name],
485                   [NEED_LVM_LV_FROM_NAME_DECL="no"],
486                   [NEED_LVM_LV_FROM_NAME_DECL="yes"],
487                   [[#include <lvm2app.h>]])
488   fi
489 fi
490
491 if test "x$enable_bd_xlator" = "xyes" -a "x$HAVE_BD_LIB" = "xno"; then
492    echo "BD xlator requested but required lvm2 development library not found."
493    exit 1
494 fi
495
496 BUILD_BD_XLATOR=no
497 if test "x${enable-bd-xlator}" != "xno" -a "x${HAVE_BD_LIB}" = "xyes"; then
498   BUILD_BD_XLATOR=yes
499   AC_DEFINE(HAVE_BD_XLATOR, 1, [define if lvm2app library found and bd xlator
500                             enabled])
501   if test "x$NEED_LVM_LV_FROM_NAME_DECL" = "xyes"; then
502     AC_DEFINE(NEED_LVM_LV_FROM_NAME_DECL, 1, [defined if lvm_lv_from_name()
503                   was not found in the lvm2app.h header, but can be linked])
504   fi
505 fi
506
507 AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes])
508
509 # start encryption/crypt section
510
511 AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no])
512
513 AC_ARG_ENABLE([crypt-xlator],
514         AC_HELP_STRING([--enable-crypt-xlator], [Build crypt encryption xlator]))
515
516 if test "x$enable_crypt_xlator" = "xyes" -a "x$have_cmac_h" = "xno"; then
517    AC_MSG_ERROR([Encryption xlator requires OpenSSL with cmac.h])
518 fi
519
520 BUILD_CRYPT_XLATOR=no
521 if test "x$enable_crypt_xlator" != "xno" -a "x$have_cmac_h" = "xyes"; then
522    BUILD_CRYPT_XLATOR=yes
523    AC_DEFINE(HAVE_CRYPT_XLATOR, 1, [enable building crypt encryption xlator])
524 fi
525
526 AM_CONDITIONAL([ENABLE_CRYPT_XLATOR], [test x$BUILD_CRYPT_XLATOR = xyes])
527
528 AC_SUBST(FUSE_CLIENT_SUBDIR)
529 # end FUSE section
530
531
532 # FUSERMOUNT section
533 AC_ARG_ENABLE([fusermount],
534               AC_HELP_STRING([--disable-fusermount],
535                              [Use system's fusermount]))
536
537 BUILD_FUSERMOUNT="yes"
538 if test "x$enable_fusermount" = "xno"; then
539    BUILD_FUSERMOUNT="no"
540 else
541    AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
542    FUSERMOUNT_SUBDIR="contrib/fuse-util"
543 fi
544
545 AC_SUBST(FUSERMOUNT_SUBDIR)
546 #end FUSERMOUNT section
547
548 # QEMU_BLOCK section
549
550 AC_ARG_ENABLE([qemu-block],
551                 AC_HELP_STRING([--enable-qemu-block],
552                         [Build QEMU Block formats translator]))
553
554 if test "x$enable_qemu_block" != "xno"; then
555   PKG_CHECK_MODULES([GLIB], [glib-2.0],
556                     [HAVE_GLIB_2="yes"],
557                       [HAVE_GLIB_2="no"])
558 fi
559
560 if test "x$enable_qemu_block" = "xyes" -a "x$HAVE_GLIB_2" = "xno"; then
561    echo "QEMU Block formats translator requires libglib-2.0, but missing."
562    exit 1
563 fi
564
565 BUILD_QEMU_BLOCK=no
566 if test "x${enable_qemu_block}" != "xno" -a "x${HAVE_GLIB_2}" = "xyes"; then
567   BUILD_QEMU_BLOCK=yes
568   AC_DEFINE(HAVE_QEMU_BLOCK, 1, [define if libglib-2.0 library found and QEMU
569                                Block translator enabled])
570 fi
571
572
573 # end QEMU_BLOCK section
574
575 # EPOLL section
576 AC_ARG_ENABLE([epoll],
577               AC_HELP_STRING([--disable-epoll],
578                              [Use poll instead of epoll.]))
579
580 BUILD_EPOLL=no
581 if test "x$enable_epoll" != "xno"; then
582    AC_CHECK_HEADERS([sys/epoll.h],
583                     [BUILD_EPOLL=yes],
584                     [BUILD_EPOLL=no])
585 fi
586 # end EPOLL section
587
588
589 # IBVERBS section
590 AC_ARG_ENABLE([ibverbs],
591               AC_HELP_STRING([--disable-ibverbs],
592                              [Do not build the ibverbs transport]))
593
594 if test "x$enable_ibverbs" != "xno"; then
595   AC_CHECK_LIB([ibverbs],
596                [ibv_get_device_list],
597                [HAVE_LIBIBVERBS="yes"],
598                [HAVE_LIBIBVERBS="no"])
599   AC_CHECK_LIB([rdmacm], [rdma_create_id], [HAVE_RDMACM="yes"], [HAVE_RDMACM="no"])
600 fi
601
602 if test "x$enable_ibverbs" = "xyes"; then
603    if test "x$HAVE_LIBIBVERBS" = "xno"; then
604       echo "ibverbs-transport requested, but libibverbs is not present."
605       exit 1
606    fi
607
608    if test "x$HAVE_RDMACM" = "xno"; then
609       echo "ibverbs-transport requested, but librdmacm is not present."
610       exit 1
611    fi
612 fi
613
614 BUILD_RDMA=no
615 BUILD_IBVERBS=no
616 if test "x$enable_ibverbs" != "xno" -a "x$HAVE_LIBIBVERBS" = "xyes" -a "x$HAVE_RDMACM" = "xyes"; then
617   IBVERBS_SUBDIR=ib-verbs
618   BUILD_IBVERBS=yes
619   RDMA_SUBDIR=rdma
620   BUILD_RDMA=yes
621 fi
622
623 AC_SUBST(IBVERBS_SUBDIR)
624 AC_SUBST(RDMA_SUBDIR)
625 # end IBVERBS section
626
627
628 # SYNCDAEMON section
629 AC_ARG_ENABLE([georeplication],
630               AC_HELP_STRING([--disable-georeplication],
631                              [Do not install georeplication components]))
632
633 BUILD_SYNCDAEMON=no
634 case $host_os in
635      linux*)
636 #do nothing
637        ;;
638      netbsd*)
639 #do nothing
640        ;;
641      *)
642 #disabling geo replication for non-linux platforms
643         enable_georeplication=no
644         ;;
645 esac
646 SYNCDAEMON_COMPILE=0
647 if test "x$enable_georeplication" != "xno"; then
648   SYNCDAEMON_SUBDIR=geo-replication
649   SYNCDAEMON_COMPILE=1
650
651   BUILD_SYNCDAEMON="yes"
652   AM_PATH_PYTHON([2.4])
653   echo -n "checking if python is python 2.x... "
654   if echo $PYTHON_VERSION | grep ^2; then
655     :
656   else
657     echo no
658     AC_MSG_ERROR([only python 2.x is supported])
659   fi
660   echo -n "checking if python has ctypes support... "
661   if "$PYTHON" -c 'import ctypes' 2>/dev/null; then
662     echo yes
663   else
664     echo no
665     AC_MSG_ERROR([python does not have ctypes support])
666   fi
667 fi
668 AC_SUBST(SYNCDAEMON_COMPILE)
669 AC_SUBST(SYNCDAEMON_SUBDIR)
670 # end SYNCDAEMON section
671
672 # only install scripts from extras/geo-rep when enabled
673 if test "x$enable_georeplication" != "xno"; then
674   GEOREP_EXTRAS_SUBDIR=geo-rep
675 fi
676 AC_SUBST(GEOREP_EXTRAS_SUBDIR)
677
678 # CDC xlator - check if libz is present if so enable HAVE_LIB_Z
679 BUILD_CDC=yes
680 PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0],,
681                   [AC_CHECK_LIB([z], [deflate], [ZLIB_LIBS="-lz"],
682                                 [BUILD_CDC=no])])
683 echo -n "features requiring zlib enabled: "
684 if test "x$BUILD_CDC" = "xyes" ; then
685   echo "yes"
686   AC_DEFINE(HAVE_LIB_Z, 1, [define if zlib is present])
687 else
688   echo "no"
689 fi
690 AC_SUBST(ZLIB_CFLAGS)
691 AC_SUBST(ZLIB_LIBS)
692 # end CDC xlator secion
693
694 # Data tiering requires sqlite
695 AC_ARG_ENABLE([tiering],
696                AC_HELP_STRING([--disable-tiering],
697                              [Disable data classification/tiering]),
698               [BUILD_GFDB="${enableval}"], [BUILD_GFDB="yes"])
699
700 if test "x${BUILD_GFDB}" = "xyes"; then
701   PKG_CHECK_MODULES([SQLITE], [sqlite3],
702                     AC_DEFINE(USE_GFDB, 1),
703                     AC_MSG_ERROR([pass --disable-tiering to build without sqlite]))
704 else
705   AC_DEFINE(USE_GFDB, 0, [no sqlite, gfdb is disabled])
706 fi
707
708 AC_SUBST(SQLITE_CFLAGS)
709 AC_SUBST(SQLITE_LIBS)
710 AM_CONDITIONAL(BUILD_GFDB, test "x${BUILD_GFDB}" = "xyes")
711 AM_CONDITIONAL(USE_GFDB, test "x${BUILD_GFDB}" = "xyes")
712
713 # check for systemtap/dtrace
714 BUILD_SYSTEMTAP=no
715 AC_MSG_CHECKING([whether to include systemtap tracing support])
716 AC_ARG_ENABLE([systemtap],
717               [AS_HELP_STRING([--enable-systemtap],
718               [Enable inclusion of systemtap trace support])],
719               [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP="def"])
720
721 AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test "x${ENABLE_SYSTEMTAP}" = "xyes"])
722 AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
723
724 if test "x${ENABLE_SYSTEMTAP}" != "xno"; then
725     AC_CHECK_PROG(DTRACE, dtrace, "yes", "no")
726     AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND="yes"],
727                     [SDT_H_FOUND="no"])
728 fi
729
730 if test "x${ENABLE_SYSTEMTAP}" = "xyes"; then
731     if test "x${DTRACE}" = "xno"; then
732         AC_MSG_ERROR([dtrace not found])
733     elif test "$x{SDT_H_FOUND}" = "xno"; then
734         AC_MSG_ERROR([systemtap support needs sys/sdt.h header])
735     fi
736 fi
737
738 if test "x${DTRACE}" = "xyes" -a "x${SDT_H_FOUND}" = "xyes"; then
739     AC_MSG_CHECKING([x"${DTRACE}"xy"${SDT_H_FOUND}"y])
740     AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using  probes.])
741     BUILD_SYSTEMTAP=yes
742 fi
743 # end of systemtap/dtrace
744
745 # xml-output
746 AC_ARG_ENABLE([xml-output],
747               AC_HELP_STRING([--disable-xml-output],
748                              [Disable the xml output]))
749 BUILD_XML_OUTPUT="yes"
750 if test "x$enable_xml_output" != "xno"; then
751     #check if libxml is present if so enable HAVE_LIB_XML
752     m4_ifdef([AM_PATH_XML2],[AM_PATH_XML2([2.6.19])], [no_xml=yes])
753     if test "x${no_xml}" = "x"; then
754         AC_DEFINE([HAVE_LIB_XML], [1], [Define to 1 if using libxml2.])
755     else
756         if test "x$enable_georeplication" != "xno"; then
757            AC_MSG_ERROR([libxml2 devel libraries not found])
758         else
759            AC_MSG_WARN([libxml2 devel libraries not found disabling XML support])
760            BUILD_XML_OUTPUT="no"
761         fi
762
763     fi
764 else
765     if test "x$enable_georeplication" != "xno"; then
766        AC_MSG_ERROR([geo-replication requires xml output])
767     fi
768     BUILD_XML_OUTPUT="no"
769 fi
770 # end of xml-output
771
772 AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes])
773 if test "x${have_backtrace}" = "xyes"; then
774    AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
775 fi
776 AC_SUBST(HAVE_BACKTRACE)
777
778 if test "x${have_backtrace}" != "xyes"; then
779 AC_TRY_COMPILE([#include <math.h>], [double x=0.0; x=ceil(0.0);],
780    [have_math_h=yes],
781    AC_MSG_ERROR([need math library for libexecinfo]))
782 if test "x${have_math_h}" = "xyes"; then
783    LIBS="$LIBS -lm"
784 fi
785 fi
786
787 dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
788 AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes])
789 if test "x${have_malloc_stats}" = "xyes"; then
790    AC_DEFINE(HAVE_MALLOC_STATS, 1, [define if found malloc_stats])
791 fi
792 AC_SUBST(HAVE_MALLOC_STATS)
793
794 dnl Linux, Solaris, Cygwin
795 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
796 dnl FreeBSD, NetBSD
797 AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])
798 case $host_os in
799         *netbsd*)
800         CFLAGS="${CFLAGS} -D_INCOMPLETE_XOPEN_C063 -DCONFIG_MACHINE_BSWAP_H"
801         ;;
802 esac
803 AC_CHECK_FUNC([linkat], [have_linkat=yes])
804 if test "x${have_linkat}" = "xyes"; then
805    AC_DEFINE(HAVE_LINKAT, 1, [define if found linkat])
806 fi
807 AC_SUBST(HAVE_LINKAT)
808
809 dnl check for Monotonic clock
810 AC_CHECK_LIB([rt], [clock_gettime], ,
811              AC_MSG_WARN([System doesn't have monotonic clock using contrib]))
812
813 dnl Check for argp
814 AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
815
816 BUILD_ARGP_STANDALONE=no
817 if test "x${ac_cv_header_argp_h}" = "xno"; then
818    AC_CONFIG_SUBDIRS(contrib/argp-standalone)
819    BUILD_ARGP_STANDALONE=yes
820    ARGP_STANDALONE_CPPFLAGS='-I${top_srcdir}/contrib/argp-standalone'
821    ARGP_STANDALONE_LDADD='${top_builddir}/contrib/argp-standalone/libargp.a'
822    ARGP_STANDALONE_DIR='${top_builddir}/contrib/argp-standalone'
823 fi
824
825 AC_SUBST(ARGP_STANDALONE_CPPFLAGS)
826 AC_SUBST(ARGP_STANDALONE_LDADD)
827 AC_SUBST(ARGP_STANDALONE_DIR)
828
829 AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))
830
831 AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes])
832 if test "x${have_llistxattr}" = "xyes"; then
833    AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists])
834 fi
835
836 AC_CHECK_FUNC([fdatasync], [have_fdatasync=no])
837 if test "x${have_fdatasync}" = "xyes"; then
838    AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists])
839 fi
840
841 AC_CHECK_FUNC([fallocate], [have_fallocate=yes])
842 if test "x${have_fallocate}" = "xyes"; then
843    AC_DEFINE(HAVE_FALLOCATE, 1, [define if fallocate exists])
844 fi
845
846 AC_CHECK_FUNC([posix_fallocate], [have_posix_fallocate=yes])
847 if test "x${have_posix_fallocate}" = "xyes"; then
848    AC_DEFINE(HAVE_POSIX_FALLOCATE, 1, [define if posix_fallocate exists])
849 fi
850
851 # Check the distribution where you are compiling glusterfs on
852
853 GF_DISTRIBUTION=
854 AC_CHECK_FILE([/etc/debian_version])
855 AC_CHECK_FILE([/etc/SuSE-release])
856 AC_CHECK_FILE([/etc/redhat-release])
857
858 if test "x$ac_cv_file__etc_debian_version" = "xyes"; then
859    GF_DISTRIBUTION=Debian
860 fi
861 if test "x$ac_cv_file__etc_SuSE_release" = "xyes"; then
862    GF_DISTRIBUTION=SuSE
863 fi
864 if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then
865    GF_DISTRIBUTION=Redhat
866 fi
867
868 AC_SUBST(GF_DISTRIBUTION)
869
870 GF_HOST_OS=""
871 GF_LDFLAGS="-rdynamic"
872
873 dnl check for gcc -Werror=format-security
874 saved_GF_CFLAGS="-Wformat -Werror=format-security"
875 AC_MSG_CHECKING([whether $CC accepts -Werror=format-security])
876 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no])
877 echo $cc_werror_format_security
878 if test "x$cc_werror_format_security" = "xno"; then
879     GF_CFLAGS="$GF_CFLAGS"
880 else
881     GF_CFLAGS="$saved_GF_CFLAGS $GF_CFLAGS"
882 fi
883
884 dnl check for gcc -Werror=implicit-function-declaration
885 saved_GF_CFLAGS=$GF_CFLAGS
886 GF_CFLAGS="-Werror=implicit-function-declaration"
887 AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration])
888 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no])
889 echo $cc_werror_implicit
890 if test "x$cc_werror_implicit" = "xno"; then
891     GF_CFLAGS="$saved_GF_CFLAGS"
892 else
893     GF_CFLAGS="$saved_GF_CFLAGS $GF_CFLAGS"
894 fi
895
896 dnl clang is mostly GCC-compatible, but its version is much lower,
897 dnl so we have to check for it.
898 AC_MSG_CHECKING([if compiling with clang])
899
900 AC_COMPILE_IFELSE(
901 [AC_LANG_PROGRAM([], [[
902 #ifndef __clang__
903        not clang
904 #endif
905 ]])],
906 [CLANG=yes], [CLANG=no])
907
908 AC_MSG_RESULT([$CLANG])
909
910 if test "x$CLANG" = "xyes"; then
911    GF_COMPILER_FLAGS="-Wno-gnu"
912 fi
913
914 if test "x$ac_cv_header_execinfo_h" = "xno"; then
915    # The reason is that __builtin_frame_address(n) for n > 0 seems
916    # to just crash on most platforms when -fomit-stack-pointer is
917    # specified, which seems to be the default for many platforms on
918    # -O2. The documentation says that __builtin_frame_address()
919    # should return NULL in case it can't get the frame, but it
920    # seems to crash instead.
921
922    # execinfo.c in ./contrib/libexecinfo uses __builtin_frame_address(n)
923    # for providing cross platform backtrace*() functions.
924    if test "x$CLANG" = "xno"; then
925       CFLAGS="$CFLAGS -fno-omit-frame-pointer"
926    fi
927 fi
928
929 old_prefix=$prefix
930 if test "x$prefix" = xNONE; then
931         prefix=$ac_default_prefix
932 fi
933 GLUSTERFS_LIBEXECDIR="$(eval echo $prefix)/libexec/glusterfs"
934 GLUSTERFSD_MISCDIR="$(eval echo $prefix)/var/lib/misc/glusterfsd"
935 prefix=$old_prefix
936
937 ### Dirty hacky stuff to make LOCALSTATEDIR work
938 if test "x$prefix" = xNONE; then
939    test $localstatedir = '${prefix}/var' && localstatedir=$ac_default_prefix/var
940    localstatedir=/var
941    LOCALSTATEDIR=$(eval echo ${localstatedir})
942 else
943    LOCALSTATEDIR=$(eval echo ${localstatedir})
944 fi
945
946 old_prefix=$prefix
947 if test "x$prefix" = xNONE; then
948     prefix=$ac_default_prefix
949 fi
950 GLUSTERD_VOLFILE="$(eval echo ${sysconfdir})/glusterfs/glusterd.vol"
951 prefix=$old_prefix
952
953
954 case $host_os in
955      linux*)
956         GF_HOST_OS="GF_LINUX_HOST_OS"
957         GF_CFLAGS="${GF_COMPILER_FLAGS} ${ARGP_STANDALONE_CPPFLAGS}"
958         GF_LDADD="${ARGP_STANDALONE_LDADD}"
959         GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\""
960         GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd"
961         ;;
962      solaris*)
963         GF_HOST_OS="GF_SOLARIS_HOST_OS"
964         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -m64"
965         GF_LDFLAGS=""
966         GF_LDADD="${ARGP_STANDALONE_LDADD}"
967         BUILD_FUSE_CLIENT=no
968         FUSE_CLIENT_SUBDIR=""
969         GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd"
970         ;;
971      *netbsd*)
972         GF_HOST_OS="GF_BSD_HOST_OS"
973         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_INCOMPLETE_XOPEN_C063"
974         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
975         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
976         GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
977         GF_LDADD="${ARGP_STANDALONE_LDADD}"
978         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
979            GF_LDFLAGS="-lexecinfo"
980         fi
981         GF_FUSE_LDADD="-lperfuse"
982         BUILD_FUSE_CLIENT=yes
983         LEXLIB=""
984         BUILD_FUSERMOUNT=no
985         FUSERMOUNT_SUBDIR=""
986         GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
987         ;;
988      *freebsd*)
989         GF_HOST_OS="GF_BSD_HOST_OS"
990         GF_CFLAGS="${GF_COMPILER_FLAGS} ${ARGP_STANDALONE_CPPFLAGS} -O0"
991         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
992         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
993         GF_CFLAGS="${GF_CFLAGS} -D_LIBGEN_H_"
994         GF_CFLAGS="${GF_CFLAGS} -DO_DSYNC=0"
995         GF_CFLAGS="${GF_CFLAGS} -Dxdr_quad_t=xdr_longlong_t"
996         GF_CFLAGS="${GF_CFLAGS} -Dxdr_u_quad_t=xdr_u_longlong_t"
997         GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
998         GF_LDADD="${ARGP_STANDALONE_LDADD}"
999         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
1000            GF_LDFLAGS="-lexecinfo"
1001         fi
1002         BUILD_FUSE_CLIENT=yes
1003         BUILD_FUSERMOUNT=no
1004         FUSERMOUNT_SUBDIR=""
1005         GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
1006         ;;
1007      darwin*)
1008         GF_HOST_OS="GF_DARWIN_HOST_OS"
1009         LIBTOOL=glibtool
1010         GF_CFLAGS="${GF_COMPILER_FLAGS} ${ARGP_STANDALONE_CPPFLAGS} "
1011         GF_CFLAGS="${GF_CFLAGS} -D_REENTRANT -D_XOPEN_SOURCE "
1012         GF_CFLAGS="${GF_CFLAGS} -D_DARWIN_USE_64_BIT_INODE "
1013         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
1014         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
1015         GF_LDADD="${ARGP_STANDALONE_LDADD}"
1016         GF_LDFLAGS=""
1017         GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse"
1018         BUILD_FUSERMOUNT="no"
1019         FUSERMOUNT_SUBDIR=""
1020         GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
1021         ;;
1022 esac
1023
1024 case $host_os in
1025      darwin*)
1026         GFAPI_EXTRA_LDFLAGS='-Wl,-alias_list,$(top_srcdir)/api/src/gfapi.aliases'
1027         ;;
1028      *)
1029         GFAPI_EXTRA_LDFLAGS='-Wl,--version-script=$(top_srcdir)/api/src/gfapi.map'
1030         ;;
1031 esac
1032
1033 # lazy umount emulation
1034 UMOUNTD_SUBDIR=""
1035 if test "x${GF_HOST_OS}" != "xGF_LINUX_HOST_OS" ; then
1036         UMOUNTD_SUBDIR="contrib/umountd"
1037 fi
1038 AC_SUBST(UMOUNTD_SUBDIR)
1039
1040 # enable/disable QEMU
1041 AM_CONDITIONAL([ENABLE_QEMU_BLOCK], [test x$BUILD_QEMU_BLOCK = xyes])
1042
1043
1044 # enable debug section
1045 AC_ARG_ENABLE([debug],
1046               AC_HELP_STRING([--enable-debug],
1047                              [Enable debug build options.]))
1048
1049
1050 # syslog section
1051 AC_ARG_ENABLE([syslog],
1052               AC_HELP_STRING([--disable-syslog],
1053                              [Disable syslog for logging]))
1054
1055 USE_SYSLOG="yes"
1056 if test "x$enable_syslog" != "xno"; then
1057   AC_DEFINE(GF_USE_SYSLOG, 1, [Use syslog for logging])
1058 else
1059   USE_SYSLOG="no"
1060 fi
1061 AM_CONDITIONAL([ENABLE_SYSLOG], [test x$USE_SYSLOG = xyes])
1062 #end syslog section
1063
1064 BUILD_READLINE=no
1065 AC_CHECK_LIB([readline -lcurses],[readline],[RLLIBS="-lreadline -lcurses"])
1066 AC_CHECK_LIB([readline -ltermcap],[readline],[RLLIBS="-lreadline -ltermcap"])
1067 AC_CHECK_LIB([readline -lncurses],[readline],[RLLIBS="-lreadline -lncurses"])
1068
1069 if test "x$RLLIBS" != "x"; then
1070    if test "x$RL_UNDO" = "xyes"; then
1071       AC_DEFINE(HAVE_READLINE, 1, [readline enabled CLI])
1072       BUILD_READLINE=yes
1073    else
1074       BUILD_READLINE="no (present but missing undo)"
1075    fi
1076
1077 fi
1078
1079 BUILD_LIBAIO=no
1080 AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"])
1081
1082 if test "x$LIBAIO" != "x"; then
1083    AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled])
1084    BUILD_LIBAIO=yes
1085 fi
1086
1087 # glupy section
1088 BUILD_GLUPY=no
1089 have_python2=no
1090 have_Python_h=no
1091
1092 AM_PATH_PYTHON()
1093 if echo $PYTHON_VERSION | grep ^2; then
1094   have_python2=yes
1095 fi
1096
1097 # Save flags before testing python
1098 saved_CFLAGS=$CFLAGS
1099 saved_CPPFLAGS=$CPPFLAGS
1100 saved_LDFLAGS=$LDFLAGS
1101
1102 CFLAGS="`${PYTHON}-config --cflags`"
1103 CPPFLAGS=$CFLAGS
1104 LDFLAGS="-L`${PYTHON}-config --prefix`/lib -L`${PYTHON}-config --prefix`/$libdir `${PYTHON}-config --ldflags`"
1105
1106 AC_CHECK_HEADERS([python$PYTHON_VERSION/Python.h],[have_Python_h=yes],[])
1107 AC_ARG_ENABLE([glupy],
1108               AS_HELP_STRING([--enable-glupy],
1109                              [build glupy]))
1110 case x$enable_glupy in
1111    xyes)
1112       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
1113         BUILD_GLUPY=yes
1114         PYTHONDEV_CFLAGS="$CFLAGS"
1115         PYTHONDEV_CPPFLAGS="$CPPFLAGS"
1116         PYTHONDEV_LDFLAGS="$LDFLAGS"
1117         AC_SUBST(PYTHONDEV_CFLAGS)
1118         AC_SUBST(PYTHONDEV_CPPFLAGS)
1119         AC_SUBST(PYTHONDEV_LDFLAGS)
1120       else
1121         AC_MSG_ERROR([glupy requires python-devel/python-dev package and python2.x])
1122       fi
1123       ;;
1124    xno)
1125       ;;
1126    *)
1127       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
1128         BUILD_GLUPY=yes
1129         PYTHONDEV_CFLAGS="$CFLAGS"
1130         PYTHONDEV_CPPFLAGS="$CPPFLAGS"
1131         PYTHONDEV_LDFLAGS="$LDFLAGS"
1132         AC_SUBST(PYTHONDEV_CFLAGS)
1133         AC_SUBST(PYTHONDEV_CPPFLAGS)
1134         AC_SUBST(PYTHONDEV_LDFLAGS)
1135       else
1136         AC_MSG_WARN([
1137         ---------------------------------------------------------------------------------
1138          cannot build glupy. python 2.x and python-devel/python-dev package are required.
1139         ---------------------------------------------------------------------------------])
1140       fi
1141       ;;
1142 esac
1143 # Restore flags
1144 CFLAGS=$saved_CFLAGS
1145 CPPFLAGS=$saved_CPPFLAGS
1146 LDFLAGS=$saved_LDFLAGS
1147
1148 case $host_os in
1149      darwin*)
1150         BUILD_GLUPY=no
1151         ;;
1152 esac
1153
1154 if test "x$BUILD_GLUPY" = "xyes"; then
1155    BUILD_PYTHON_SITE_PACKAGES=`$PYTHON -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
1156    BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"`
1157    BUILD_PYTHON_LIB=python$PYTHON_VERSION
1158    GLUPY_SUBDIR=glupy
1159    GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile
1160    GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile
1161    echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB"
1162    AC_SUBST(BUILD_PYTHON_SITE_PACKAGES)
1163    AC_SUBST(BUILD_PYTHON_INC)
1164    AC_SUBST(BUILD_PYTHON_LIB)
1165    AC_SUBST(GLUPY_SUBDIR)
1166    AC_SUBST(GLUPY_SUBDIR_MAKEFILE)
1167    AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE)
1168 fi
1169 # end glupy section
1170
1171 dnl Check for userspace-rcu
1172 PKG_CHECK_MODULES([URCU], [liburcu-bp])
1173 PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.8], [],
1174   [PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.7],
1175     [AC_DEFINE(URCU_0_7, 1, [Define if liburcu 0.7 is found])],
1176     [AC_MSG_ERROR([liburcu >= 0.7 required])])])
1177
1178 BUILD_UNITTEST="no"
1179 AC_ARG_ENABLE([cmocka],
1180               AC_HELP_STRING([--enable-cmocka],
1181                              [Enable cmocka build options.]))
1182 if test "x$enable_cmocka" = "xyes"; then
1183     BUILD_UNITTEST="yes"
1184     PKG_CHECK_MODULES([UNITTEST], [cmocka], [],[
1185       AC_CHECK_LIB([cmocka], [mock_assert], [
1186         UNITTEST_LDFLAGS="-lcmocka -lgcov"
1187         UNITTEST_CFLAGS="-Wall -Werror"
1188       ], [
1189         AC_MSG_ERROR([cmocka library is required to build glusterfs])
1190       ])
1191     ])
1192 fi
1193 AM_CONDITIONAL([UNITTEST], [test x$BUILD_UNITTEST = xyes])
1194
1195 dnl Define UNIT_TESTING only for building cmocka binaries.
1196 UNITTEST_CFLAGS="${UNITTEST_CFLAGS} -DUNIT_TESTING=1"
1197
1198 dnl Add cmocka for unit tests
1199 case $host_os in
1200   freebsd*)
1201     dnl remove --coverage on FreeBSD due to a known llvm packaging bug
1202     UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0"
1203     UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}"
1204     ;;
1205   *)
1206     UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0 --coverage"
1207     UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}"
1208     ;;
1209 esac
1210
1211 AC_SUBST(UNITTEST_CFLAGS)
1212 AC_SUBST(UNITTEST_LDFLAGS)
1213
1214 AC_SUBST(CFLAGS)
1215 # end enable debug section
1216
1217 AC_SUBST(GF_HOST_OS)
1218 AC_SUBST(GF_CFLAGS)
1219 AC_SUBST(GF_LDFLAGS)
1220 AC_SUBST(GF_LDADD)
1221 AC_SUBST(GF_FUSE_LDADD)
1222 AC_SUBST(GF_FUSE_CFLAGS)
1223 AC_SUBST(RLLIBS)
1224 AC_SUBST(LIBAIO)
1225 AC_SUBST(AM_MAKEFLAGS)
1226 AC_SUBST(AM_LIBTOOLFLAGS)
1227
1228 CONTRIBDIR='$(top_srcdir)/contrib'
1229 AC_SUBST(CONTRIBDIR)
1230
1231 GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)'
1232 GF_CPPINCLUDES='-I$(top_srcdir)/libglusterfs/src -I$(CONTRIBDIR)/uuid'
1233 GF_CPPFLAGS="$GF_CPPDEFINES $GF_CPPINCLUDES"
1234 AC_SUBST([GF_CPPFLAGS])
1235
1236 AM_CONDITIONAL([GF_LINUX_HOST_OS], test "${GF_HOST_OS}" = "GF_LINUX_HOST_OS")
1237 AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
1238 AM_CONDITIONAL([GF_BSD_HOST_OS], test "${GF_HOST_OS}" = "GF_BSD_HOST_OS")
1239
1240 AC_SUBST(GLUSTERD_WORKDIR)
1241 AM_CONDITIONAL([GF_INSTALL_GLUSTERD_WORKDIR], test ! -d ${GLUSTERD_WORKDIR} && test -d ${sysconfdir}/glusterd )
1242 AC_SUBST(GLUSTERD_VOLFILE)
1243 AC_SUBST(GLUSTERFS_LIBEXECDIR)
1244 AC_SUBST(GLUSTERFSD_MISCDIR)
1245
1246 dnl pkg-config versioning
1247 dnl
1248 dnl Once we released gluster-api.pc with version=4. Since then we undid the
1249 dnl library versioning and replaced it with symbol-versioning. The current
1250 dnl libgfapi.so has version 0, but the symbols have the version from the main
1251 dnl package at the time they were added.
1252 dnl
1253 dnl Because other packages (like samba) use the pkg-config version, we can not
1254 dnl drop it, or decrease the version easily. The simplest solution is to keep
1255 dnl the version=4 and add sub-digits for the actual package/symbol versions.
1256 GFAPI_VERSION="4."${PACKAGE_VERSION}
1257 LIBGFCHANGELOG_VERSION="0.0.1"
1258 AC_SUBST(GFAPI_VERSION)
1259 AC_SUBST(LIBGFCHANGELOG_VERSION)
1260 LIBGFDB_VERSION="0.0.1"
1261 AC_SUBST(LIBGFDB_VERSION)
1262
1263 dnl libtool versioning
1264 LIBGFXDR_LT_VERSION="0:1:0"
1265 LIBGFRPC_LT_VERSION="0:1:0"
1266 LIBGLUSTERFS_LT_VERSION="0:1:0"
1267 LIBGFCHANGELOG_LT_VERSION="0:1:0"
1268 GFAPI_LT_VERSION="0:0:0"
1269 AC_SUBST(LIBGFXDR_LT_VERSION)
1270 AC_SUBST(LIBGFRPC_LT_VERSION)
1271 AC_SUBST(LIBGLUSTERFS_LT_VERSION)
1272 AC_SUBST(LIBGFCHANGELOG_LT_VERSION)
1273 AC_SUBST(GFAPI_LT_VERSION)
1274 AC_SUBST(GFAPI_EXTRA_LDFLAGS)
1275
1276 GFAPI_LIBS="${ACL_LIBS}"
1277 AC_SUBST(GFAPI_LIBS)
1278
1279 dnl this change necessary for run-tests.sh
1280 AC_CONFIG_FILES([tests/env.rc],[ln -s ${ac_abs_builddir}/env.rc ${ac_abs_srcdir}/env.rc 2>/dev/null])
1281
1282 AC_OUTPUT
1283
1284 echo
1285 echo "GlusterFS configure summary"
1286 echo "==========================="
1287 echo "FUSE client          : $BUILD_FUSE_CLIENT"
1288 echo "Infiniband verbs     : $BUILD_IBVERBS"
1289 echo "epoll IO multiplex   : $BUILD_EPOLL"
1290 echo "argp-standalone      : $BUILD_ARGP_STANDALONE"
1291 echo "fusermount           : $BUILD_FUSERMOUNT"
1292 echo "readline             : $BUILD_READLINE"
1293 echo "georeplication       : $BUILD_SYNCDAEMON"
1294 echo "Linux-AIO            : $BUILD_LIBAIO"
1295 echo "Enable Debug         : $BUILD_DEBUG"
1296 ## echo "systemtap            : $BUILD_SYSTEMTAP"
1297 echo "Block Device xlator  : $BUILD_BD_XLATOR"
1298 echo "glupy                : $BUILD_GLUPY"
1299 echo "Use syslog           : $USE_SYSLOG"
1300 echo "XML output           : $BUILD_XML_OUTPUT"
1301 echo "QEMU Block formats   : $BUILD_QEMU_BLOCK"
1302 echo "Encryption xlator    : $BUILD_CRYPT_XLATOR"
1303 echo "Unit Tests           : $BUILD_UNITTEST"
1304 echo "POSIX ACLs           : $USE_POSIX_ACLS"
1305 echo "Data Classification  : $BUILD_GFDB"
1306 echo