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