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