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