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