summaryrefslogtreecommitdiffstats
path: root/configure.in
blob: 0a054067a96103bd7786d30e4047e15524b397af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
###############################################################################
## Copyright (C) 2000-2004 Sistina Software, Inc. All rights reserved.
## Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
##
## This copyrighted material is made available to anyone wishing to use,
## modify, copy, or redistribute it subject to the terms and conditions
## of the GNU General Public License v.2.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software Foundation,
## Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
################################################################################

AC_PREREQ(2.57)
################################################################################
dnl -- Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([lib/device/dev-cache.h])
AC_CONFIG_HEADERS([lib/misc/configure.h])

################################################################################
dnl -- Setup the directory where autoconf has auxilary files
AC_CONFIG_AUX_DIR(autoconf)

################################################################################
dnl -- Get system type
AC_CANONICAL_TARGET([])

case "$host_os" in
	linux*)
		COPTIMISE_FLAG="-O2"
		CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
		CLDWHOLEARCHIVE="-Wl,-whole-archive"
		CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
		LDDEPS="$LDDEPS .export.sym"
		LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
		LIB_SUFFIX=so
		DEVMAPPER=yes
		ODIRECT=yes
		DM_IOCTLS=yes
		SELINUX=yes
		REALTIME=yes
		CLUSTER=internal
		FSADM=yes
		;;
	darwin*)
		CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
		COPTIMISE_FLAG="-O2"
		CLDFLAGS="$CLDFLAGS"
		CLDWHOLEARCHIVE="-all_load"
		CLDNOWHOLEARCHIVE=
		LIB_SUFFIX=dylib
		DEVMAPPER=yes
		ODIRECT=no
		DM_IOCTLS=no
		SELINUX=no
		REALTIME=no
		CLUSTER=none
		FSADM=no
		;;
esac

################################################################################
dnl -- Checks for programs.
AC_PROG_SED
AC_PROG_AWK
AC_PROG_CC

dnl probably no longer needed in 2008, but...
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
AC_PROG_RANLIB
AC_PATH_PROG(CFLOW_CMD, cflow)
AC_PATH_PROG(CSCOPE_CMD, cscope)

################################################################################
dnl -- Check for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME

AC_CHECK_HEADERS([locale.h stddef.h syslog.h sys/file.h sys/time.h assert.h \
  libgen.h signal.h sys/mman.h sys/resource.h sys/utsname.h sys/wait.h time.h], ,
  [AC_MSG_ERROR(bailing out)])

case "$host_os" in
	linux*)
		AC_CHECK_HEADERS(asm/byteorder.h linux/fs.h malloc.h,,AC_MSG_ERROR(bailing out)) ;;
	darwin*)
		AC_CHECK_HEADERS(machine/endian.h sys/disk.h,,AC_MSG_ERROR(bailing out)) ;;
esac

AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h getopt.h inttypes.h limits.h \
  stdarg.h stdio.h stdlib.h string.h sys/ioctl.h sys/param.h sys/stat.h \
  sys/types.h unistd.h], , [AC_MSG_ERROR(bailing out)])
AC_CHECK_HEADERS(termios.h sys/statvfs.h)

################################################################################
dnl -- Check for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_MODE_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_STRUCT_TM

################################################################################
dnl -- Check for functions
AC_CHECK_FUNCS([gethostname getpagesize memset mkdir rmdir munmap setlocale \
  strcasecmp strchr strdup strncasecmp strerror strrchr strstr strtol strtoul \
  uname], , [AC_MSG_ERROR(bailing out)])
AC_FUNC_ALLOCA
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_FORK
AC_FUNC_LSTAT
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_STAT
AC_FUNC_STRTOD
AC_FUNC_VPRINTF

################################################################################
dnl -- Prefix is /usr by default, the exec_prefix default is setup later
AC_PREFIX_DEFAULT(/usr)

################################################################################
dnl -- Setup the ownership of the files
AC_MSG_CHECKING(file owner)
OWNER="root"

AC_ARG_WITH(user,
  [  --with-user=USER        Set the owner of installed files [[USER=root]] ],
  [ OWNER="$withval" ])
AC_MSG_RESULT($OWNER)

if test x$OWNER != x; then
	OWNER="-o $OWNER"
fi

################################################################################
dnl -- Setup the group ownership of the files
AC_MSG_CHECKING(group owner)
GROUP="root"
AC_ARG_WITH(group,
  [  --with-group=GROUP      Set the group owner of installed files [[GROUP=root]] ],
  [ GROUP="$withval" ])
AC_MSG_RESULT($GROUP)

if test x$GROUP != x; then
	GROUP="-g $GROUP"
fi

################################################################################
dnl -- Setup device node ownership
AC_MSG_CHECKING(device node uid)

AC_ARG_WITH(device-uid,
  [  --with-device-uid=UID   Set the owner used for new device nodes [[UID=0]] ],
  [ DM_DEVICE_UID="$withval" ], [ DM_DEVICE_UID="0" ] )
AC_MSG_RESULT($DM_DEVICE_UID)

################################################################################
dnl -- Setup device group ownership
AC_MSG_CHECKING(device node gid)

AC_ARG_WITH(device-gid,
  [  --with-device-gid=UID   Set the group used for new device nodes [[GID=0]] ],
  [ DM_DEVICE_GID="$withval" ], [ DM_DEVICE_GID="0" ] )
AC_MSG_RESULT($DM_DEVICE_GID)

################################################################################
dnl -- Setup device mode
AC_MSG_CHECKING(device node mode)

AC_ARG_WITH(device-mode,
  [  --with-device-mode=MODE Set the mode used for new device nodes [[MODE=0600]] ],
  [ DM_DEVICE_MODE="$withval" ], [ DM_DEVICE_MODE="0600" ] )
AC_MSG_RESULT($DM_DEVICE_MODE)

################################################################################
dnl -- LVM1 tool fallback option
AC_MSG_CHECKING(whether to enable lvm1 fallback)
AC_ARG_ENABLE(lvm1_fallback, [  --enable-lvm1_fallback  Use this to fall back and use LVM1 binaries if
                          device-mapper is missing from the kernel],  LVM1_FALLBACK=$enableval, LVM1_FALLBACK=no)
AC_MSG_RESULT($LVM1_FALLBACK)

if test x$LVM1_FALLBACK = xyes; then
	AC_DEFINE([LVM1_FALLBACK], 1, [Define to 1 if 'lvm' should fall back to using LVM1 binaries if device-mapper is missing from the kernel])
fi

################################################################################
dnl -- format1 inclusion type
AC_MSG_CHECKING(whether to include support for lvm1 metadata)
AC_ARG_WITH(lvm1,
  [  --with-lvm1=TYPE        LVM1 metadata support: internal/shared/none
                          [TYPE=internal] ],
  [ LVM1="$withval" ],
  [ LVM1="internal" ])
AC_MSG_RESULT($LVM1)

if [[ "x$LVM1" != xnone -a "x$LVM1" != xinternal -a "x$LVM1" != xshared ]];
 then  AC_MSG_ERROR(
--with-lvm1 parameter invalid
)
fi;

if test x$LVM1 = xinternal; then
	AC_DEFINE([LVM1_INTERNAL], 1, [Define to 1 to include built-in support for LVM1 metadata.])
fi

################################################################################
dnl -- format_pool inclusion type
AC_MSG_CHECKING(whether to include support for GFS pool metadata)
AC_ARG_WITH(pool,
  [  --with-pool=TYPE        GFS pool read-only support: internal/shared/none
                          [TYPE=internal] ],
  [ POOL="$withval" ],
  [ POOL="internal" ])
AC_MSG_RESULT($POOL)

if [[ "x$POOL" != xnone -a "x$POOL" != xinternal -a "x$POOL" != xshared ]];
 then  AC_MSG_ERROR(
--with-pool parameter invalid
)
fi;

if test x$POOL = xinternal; then
	AC_DEFINE([POOL_INTERNAL], 1, [Define to 1 to include built-in support for GFS pool metadata.])
fi

################################################################################
dnl -- cluster_locking inclusion type
AC_MSG_CHECKING(whether to include support for cluster locking)
AC_ARG_WITH(cluster,
  [  --with-cluster=TYPE     Cluster LVM locking support: internal/shared/none
                          [TYPE=internal] ],
  [ CLUSTER="$withval" ])
AC_MSG_RESULT($CLUSTER)

if [[ "x$CLUSTER" != xnone -a "x$CLUSTER" != xinternal -a "x$CLUSTER" != xshared ]];
 then  AC_MSG_ERROR(
--with-cluster parameter invalid
)
fi;

if test x$CLUSTER = xinternal; then
	AC_DEFINE([CLUSTER_LOCKING_INTERNAL], 1, [Define to 1 to include built-in support for clustered LVM locking.])
fi

################################################################################
dnl -- snapshots inclusion type
AC_MSG_CHECKING(whether to include snapshots)
AC_ARG_WITH(snapshots,
  [  --with-snapshots=TYPE   Snapshot support: internal/shared/none
                          [TYPE=internal] ],
  [ SNAPSHOTS="$withval" ],
  [ SNAPSHOTS="internal" ])
AC_MSG_RESULT($SNAPSHOTS)

if [[ "x$SNAPSHOTS" != xnone -a "x$SNAPSHOTS" != xinternal -a "x$SNAPSHOTS" != xshared ]];
 then  AC_MSG_ERROR(
--with-snapshots parameter invalid
)
fi;

if test x$SNAPSHOTS = xinternal; then
	AC_DEFINE([SNAPSHOT_INTERNAL], 1, [Define to 1 to include built-in support for snapshots.])
fi

################################################################################
dnl -- mirrors inclusion type
AC_MSG_CHECKING(whether to include mirrors)
AC_ARG_WITH(mirrors,
  [  --with-mirrors=TYPE     Mirror support: internal/shared/none
                          [TYPE=internal] ],
  [ MIRRORS="$withval" ],
  [ MIRRORS="internal" ])
AC_MSG_RESULT($MIRRORS)

if [[ "x$MIRRORS" != xnone -a "x$MIRRORS" != xinternal -a "x$MIRRORS" != xshared ]];
 then  AC_MSG_ERROR(
--with-mirrors parameter invalid
)
fi;

if test x$MIRRORS = xinternal; then
	AC_DEFINE([MIRRORED_INTERNAL], 1, [Define to 1 to include built-in support for mirrors.])
fi

################################################################################
dnl -- Disable readline
AC_MSG_CHECKING(whether to enable readline)
AC_ARG_ENABLE([readline],
  [  --disable-readline      Disable readline support],
  [READLINE=$enableval], [READLINE=maybe])
AC_MSG_RESULT($READLINE)

################################################################################
dnl -- Disable realtime clock support
AC_MSG_CHECKING(whether to enable realtime support)
AC_ARG_ENABLE(realtime, [  --disable-realtime      Disable realtime clock support],
REALTIME=$enableval)
AC_MSG_RESULT($REALTIME)

################################################################################
dnl -- Build cluster LVM daemon
AC_MSG_CHECKING(whether to build cluster LVM daemon)
AC_ARG_WITH(clvmd,
  [  --with-clvmd=TYPE       Build cluster LVM Daemon: cman/gulm/none/all
                          [TYPE=none] ],
  [ CLVMD="$withval" ],
  [ CLVMD="none" ])
if test x$CLVMD = xyes; then
	CLVMD=all
fi
AC_MSG_RESULT($CLVMD)

dnl -- If clvmd enabled without cluster locking, automagically include it
if  test x$CLVMD != xnone && test x$CLUSTER = xnone; then
	CLUSTER=internal
fi

################################################################################
dnl -- Enable debugging
AC_MSG_CHECKING(whether to enable debugging)
AC_ARG_ENABLE(debug,    [  --enable-debug          Enable debugging],
  DEBUG=$enableval, DEBUG=no)
AC_MSG_RESULT($DEBUG)

dnl -- Normally turn off optimisation for debug builds
if test x$DEBUG = xyes; then
	COPTIMISE_FLAG=
else
	CSCOPE_CMD=
fi

################################################################################
dnl -- Override optimisation
AC_MSG_CHECKING(for C optimisation flag)
AC_ARG_WITH(optimisation,
  [  --with-optimisation=OPT C optimisation flag [[OPT=-O2]] ],
  [ COPTIMISE_FLAG="$withval" ])
AC_MSG_RESULT($COPTIMISE_FLAG)

################################################################################
dnl -- Enable profiling
AC_MSG_CHECKING(whether to gather gcov profiling data)
AC_ARG_ENABLE(profiling,
  AC_HELP_STRING(--enable-profiling, [Gather gcov profiling data]),
  PROFILING=$enableval, PROFILING=no)
AC_MSG_RESULT($PROFILING)

if test "x$PROFILING" = xyes; then
  COPTIMISE_FLAG="$COPTIMISE_FLAG -fprofile-arcs -ftest-coverage"
  AC_PATH_PROG(LCOV, lcov, no)
  AC_PATH_PROG(GENHTML, genhtml, no)
  if test "$LCOV" = no -o "$GENHTML" = no ; then
    AC_MSG_ERROR([lcov and genhtml are required for profiling])
  fi
fi

################################################################################
dnl -- Disable devmapper
AC_MSG_CHECKING(whether to use device-mapper)
AC_ARG_ENABLE(devmapper, [  --disable-devmapper     Disable LVM2 device-mapper interaction],
DEVMAPPER=$enableval)
AC_MSG_RESULT($DEVMAPPER)

if test x$DEVMAPPER = xyes; then
	AC_DEFINE([DEVMAPPER_SUPPORT], 1, [Define to 1 to enable LVM2 device-mapper interaction.])
fi

################################################################################
dnl -- Compatibility mode
AC_ARG_ENABLE(compat,   [  --enable-compat         Enable support for old device-mapper versions],
  DM_COMPAT=$enableval, DM_COMPAT=no)

################################################################################
dnl -- Disable ioctl
AC_ARG_ENABLE(ioctl,   [  --disable-driver        Disable calls to device-mapper in the kernel],
  DM_IOCTLS=$enableval)

################################################################################
dnl -- Disable O_DIRECT
AC_MSG_CHECKING(whether to enable O_DIRECT)
AC_ARG_ENABLE(o_direct, [  --disable-o_direct      Disable O_DIRECT],
ODIRECT=$enableval)
AC_MSG_RESULT($ODIRECT)

if test x$ODIRECT = xyes; then
	AC_DEFINE([O_DIRECT_SUPPORT], 1, [Define to 1 to enable O_DIRECT support.])
fi

################################################################################
dnl -- Enable cmdlib
AC_MSG_CHECKING(whether to compile liblvm2cmd.so)
AC_ARG_ENABLE(cmdlib, [  --enable-cmdlib         Build shared command library],
CMDLIB=$enableval, CMDLIB=no)
AC_MSG_RESULT($CMDLIB)
AC_SUBST([LVM2CMD_LIB])
test x$CMDLIB = xyes \
  && LVM2CMD_LIB=-llvm2cmd \
  || LVM2CMD_LIB=

################################################################################
dnl -- Enable pkg-config
AC_ARG_ENABLE(pkgconfig,   [  --enable-pkgconfig      Install pkgconfig support],
  PKGCONFIG=$enableval, PKGCONFIG=no)

################################################################################
dnl -- Enable fsadm
AC_MSG_CHECKING(whether to install fsadm)
AC_ARG_ENABLE(fsadm, [  --enable-fsadm          Enable fsadm],
FSADM=$enableval)
AC_MSG_RESULT($FSADM)

################################################################################
dnl -- enable dmeventd handling
AC_MSG_CHECKING(whether to use dmeventd)
AC_ARG_ENABLE(dmeventd, [  --enable-dmeventd       Enable the device-mapper event daemon],
DMEVENTD=$enableval)
AC_MSG_RESULT($DMEVENTD)

BUILD_DMEVENTD=$DMEVENTD

dnl -- dmeventd currently requires internal mirror support
if test x$DMEVENTD = xyes; then
   if test x$MIRRORS != xinternal; then
      AC_MSG_ERROR(
	--enable-dmeventd currently requires --with-mirrors=internal
      )
   fi
   if test x$CMDLIB = xno; then
      AC_MSG_ERROR(
        --enable-dmeventd requires --enable-cmdlib to be used as well
      )
   fi
fi

if test x$DMEVENTD = xyes; then
	AC_DEFINE([DMEVENTD], 1, [Define to 1 to enable the device-mapper event daemon.])
fi

################################################################################
dnl -- getline included in recent libc

AC_CHECK_LIB(c, getline, AC_DEFINE([HAVE_GETLINE], 1,
  [Define to 1 if getline is available.]))

################################################################################
dnl -- canonicalize_file_name included in recent libc

AC_CHECK_LIB(c, canonicalize_file_name,
  AC_DEFINE([HAVE_CANONICALIZE_FILE_NAME], 1,
    [Define to 1 if canonicalize_file_name is available.]))

################################################################################
dnl -- Clear default exec_prefix - install into /sbin rather than /usr/sbin
if [[ "x$exec_prefix" = xNONE -a "x$prefix" = xNONE ]];
 then  exec_prefix="";
fi;

################################################################################
dnl -- Check for termcap (Shamelessly copied from parted 1.4.17)
if test x$READLINE != xno; then
	AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses termcap termlib],
	  [tg_found=yes], [tg_found=no])
	test x$READLINE:$tg_found = xyes:no &&
	  AC_MSG_ERROR(
termcap could not be found which is required for the
--enable-readline option (which is enabled by default).  Either disable readline
support with --disable-readline or download and install termcap from:
	ftp.gnu.org/gnu/termcap
Note: if you are using precompiled packages you will also need the development
  package as well (which may be called termcap-devel or something similar).
Note: (n)curses also seems to work as a substitute for termcap.  This was
  not found either - but you could try installing that as well.
)
fi

################################################################################
dnl -- Check for dlopen
AC_CHECK_LIB(dl, dlopen, HAVE_LIBDL=yes, HAVE_LIBDL=no)

if [[ "x$HAVE_LIBDL" = xyes ]]; then
	AC_DEFINE([HAVE_LIBDL], 1, [Define to 1 if dynamic libraries are available.])
	LIBS="-ldl $LIBS"
else
	HAVE_LIBDL=no
fi

################################################################################
dnl -- Check for shared/static conflicts
if [[ \( "x$LVM1" = xshared -o "x$POOL" = xshared -o "x$CLUSTER" = xshared \
      -o "x$SNAPSHOTS" = xshared -o "x$MIRRORS" = xshared \
      \) -a "x$STATIC_LINK" = xyes ]];
 then  AC_MSG_ERROR(
Features cannot be 'shared' when building statically
)
fi

################################################################################
dnl -- Enables statically-linked tools
AC_MSG_CHECKING(whether to use static linking)
AC_ARG_ENABLE(static_link,
  [  --enable-static_link    Use this to link the tools to their libraries
                          statically.  Default is dynamic linking],
  STATIC_LINK=$enableval, STATIC_LINK=no)
AC_MSG_RESULT($STATIC_LINK)

################################################################################
dnl -- Disable selinux
AC_MSG_CHECKING(whether to enable selinux support)
AC_ARG_ENABLE(selinux, [  --disable-selinux       Disable selinux support],
  SELINUX=$enableval)
AC_MSG_RESULT($SELINUX)

################################################################################
dnl -- Check for selinux
if test x$SELINUX = xyes; then
	AC_CHECK_LIB(sepol, sepol_check_context, HAVE_SEPOL=yes, HAVE_SEPOL=no)

	if test x$HAVE_SEPOL = xyes; then
		AC_DEFINE([HAVE_SEPOL], 1,
		  [Define to 1 if sepol_check_context is available.])
		LIBS="-lsepol $LIBS"
	fi

	AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no)

	if test x$HAVE_SELINUX = xyes; then
		AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
		LIBS="-lselinux $LIBS"
	else
		AC_MSG_WARN(Disabling selinux)
	fi

	# With --enable-static_link and selinux enabled, linking
	# fails on at least Debian unstable due to unsatisfied references
	# to pthread_mutex_lock and _unlock.  See if we need -lpthread.
	if test "$STATIC_LINK-$HAVE_SELINUX" = yes-yes; then
		lvm_saved_libs=$LIBS
		LIBS="$LIBS -static"
		AC_SEARCH_LIBS([pthread_mutex_lock], [pthread],
		  [test "$ac_cv_search_pthread_mutex_lock" = "none required" ||
				LIB_PTHREAD=-lpthread])
		LIBS=$lvm_saved_libs
	fi
fi

################################################################################
dnl -- Check for realtime clock support
if test x$REALTIME = xyes; then
	AC_CHECK_LIB(rt, clock_gettime, HAVE_REALTIME=yes, HAVE_REALTIME=no)

	if test x$HAVE_REALTIME = xyes; then
		AC_DEFINE([HAVE_REALTIME], 1, [Define to 1 to include support for realtime clock.])
		LIBS="-lrt $LIBS"
	else
		AC_MSG_WARN(Disabling realtime clock)
	fi
fi

################################################################################
dnl -- Check for getopt
AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 if getopt_long is available.]))

################################################################################
dnl -- Check for readline (Shamelessly copied from parted 1.4.17)
if test x$READLINE != xno; then
	rl_found=yes
	AC_CHECK_LIB([readline], [readline], , [rl_found=no])
	test x$READLINE:$rl_found = xyes:no &&
	  AC_MSG_ERROR(
GNU Readline could not be found which is required for the
--enable-readline option (which is enabled by default).  Either disable readline
support with --disable-readline or download and install readline from:
	ftp.gnu.org/gnu/readline
Note: if you are using precompiled packages you will also need the development
package as well (which may be called readline-devel or something similar).
)
	if test $rl_found = yes; then
		AC_CHECK_FUNCS([rl_completion_matches])
		AC_DEFINE([READLINE_SUPPORT], 1,
		  [Define to 1 to include the LVM readline shell.])
	fi
fi

################################################################################
dnl -- Internationalisation stuff
AC_MSG_CHECKING(whether to enable internationalisation)
AC_ARG_ENABLE(nls, [  --enable-nls            Enable Native Language Support],
		INTL=$enableval, INTL=no)
AC_MSG_RESULT($INTL)

if test x$INTL = xyes; then
# FIXME - Move this - can be device-mapper too
	INTL_PACKAGE="lvm2"
	AC_PATH_PROG(MSGFMT, msgfmt)
	if [[ "x$MSGFMT" == x ]];
		then  AC_MSG_ERROR(
		msgfmt not found in path $PATH
		)
	fi;

	AC_ARG_WITH(localedir,
		    [  --with-localedir=DIR    Translation files in DIR [[PREFIX/share/locale]] ],
		    [ LOCALEDIR="$withval" ],
		    [ LOCALEDIR='${prefix}/share/locale' ])
fi

################################################################################
AC_ARG_WITH(confdir,
	    [  --with-confdir=DIR      Configuration files in DIR [/etc]],
	    [ CONFDIR="$withval" ],
	    [ CONFDIR='/etc' ])

AC_ARG_WITH(staticdir,
	    [  --with-staticdir=DIR    Static binary in DIR [EXEC_PREFIX/sbin]],
	    [ STATICDIR="$withval" ],
	    [ STATICDIR='${exec_prefix}/sbin' ])

AC_ARG_WITH(usrlibdir,
	    [  --with-usrlibdir=DIR],
	    [ usrlibdir="$withval"],
	    [ usrlibdir='${prefix}/lib' ])

AC_ARG_WITH(usrsbindir,
	    [  --with-usrsbindir=DIR],
	    [ usrsbindir="$withval"],
	    [ usrsbindir='${prefix}/sbin' ])

################################################################################
dnl -- Ensure additional headers required
if test x$READLINE = xyes; then
	AC_CHECK_HEADERS(readline/readline.h readline/history.h,,AC_MSG_ERROR(bailing out))
fi

if test x$CLVMD != xnone; then
	AC_CHECK_HEADERS(mntent.h netdb.h netinet/in.h pthread.h search.h sys/mount.h sys/socket.h sys/uio.h sys/un.h utmpx.h,,AC_MSG_ERROR(bailing out))
	AC_CHECK_FUNCS(dup2 getmntent memmove select socket,,AC_MSG_ERROR(bailing out))
	AC_FUNC_GETMNTENT
#	AC_FUNC_REALLOC
	AC_FUNC_SELECT_ARGTYPES
fi

if test x$CLUSTER != xnone; then
	AC_CHECK_HEADERS(sys/socket.h sys/un.h,,AC_MSG_ERROR(bailing out))
	AC_CHECK_FUNCS(socket,,AC_MSG_ERROR(bailing out))
fi

if test x$HAVE_LIBDL = xyes; then
	AC_CHECK_HEADERS(dlfcn.h,,AC_MSG_ERROR(bailing out))
fi

if test x$INTL = xyes; then
	AC_CHECK_HEADERS(libintl.h,,AC_MSG_ERROR(bailing out))
fi

if test x$HAVE_SELINUX = xyes; then
	AC_CHECK_HEADERS(selinux/selinux.h,,AC_MSG_ERROR(bailing out))
fi

################################################################################
AC_PATH_PROG(MODPROBE_CMD, modprobe)

if test x$MODPROBE_CMD != x; then
	AC_DEFINE_UNQUOTED([MODPROBE_CMD], ["$MODPROBE_CMD"], [The path to 'modprobe', if available.])
fi

################################################################################
dnl -- dmeventd pidfile and executable path
AH_TEMPLATE(DMEVENTD_PIDFILE, [Path to dmeventd pidfile.])
if test "$BUILD_DMEVENTD" = yes; then
	AC_ARG_WITH(dmeventd-pidfile,
		    [  --with-dmeventd-pidfile=PATH    dmeventd pidfile [[/var/run/dmeventd.pid]] ],
		    [ AC_DEFINE_UNQUOTED(DMEVENTD_PIDFILE,"$withval") ],
		    [ AC_DEFINE_UNQUOTED(DMEVENTD_PIDFILE,"/var/run/dmeventd.pid") ])
fi

AH_TEMPLATE(DMEVENTD_PATH, [Path to dmeventd binary.])
if test "$BUILD_DMEVENTD" = yes; then
        dmeventd_prefix="$exec_prefix"
        if test "x$dmeventd_prefix" = "xNONE"; then
                dmeventd_prefix="$prefix"
        fi
        if test "x$dmeventd_prefix" = "xNONE"; then
                dmeventd_prefix=""
        fi
	AC_ARG_WITH(dmeventd-path,
		    [  --with-dmeventd-path=PATH       dmeventd path [[${exec_prefix}/sbin/dmeventd]] ],
		    [ AC_DEFINE_UNQUOTED(DMEVENTD_PATH,"$withval") ],
		    [ AC_DEFINE_UNQUOTED(DMEVENTD_PATH,"$dmeventd_prefix/sbin/dmeventd") ])
fi

################################################################################
dnl -- which kernel interface to use (ioctl only)
AC_MSG_CHECKING(for kernel interface choice)
AC_ARG_WITH(interface,
  [  --with-interface=IFACE  Choose kernel interface (ioctl) [[ioctl]] ],
  [ interface="$withval" ],
  [ interface=ioctl ])
if [[ "x$interface" != xioctl ]];
then
  AC_MSG_ERROR(--with-interface=ioctl required. fs no longer supported.)
fi
AC_MSG_RESULT($interface)

################################################################################
DM_LIB_VERSION="\"`cat VERSION_DM 2>/dev/null || echo Unknown`\""
AC_DEFINE_UNQUOTED(DM_LIB_VERSION, $DM_LIB_VERSION, [Library version])

DM_LIB_PATCHLEVEL=`cat VERSION_DM | awk -F '[[-. ]]' '{printf "%s.%s.%s",$1,$2,$3}'`

LVM_VERSION="\"`cat VERSION 2>/dev/null || echo Unknown`\""

################################################################################
AC_SUBST(BUILD_DMEVENTD)
AC_SUBST(CFLAGS)
AC_SUBST(CFLOW_CMD)
AC_SUBST(CLDFLAGS)
AC_SUBST(CLDNOWHOLEARCHIVE)
AC_SUBST(CLDWHOLEARCHIVE)
AC_SUBST(CLUSTER)
AC_SUBST(CLVMD)
AC_SUBST(CMDLIB)
AC_SUBST(COPTIMISE_FLAG)
AC_SUBST(CSCOPE_CMD)
AC_SUBST(DEBUG)
AC_SUBST(DEVMAPPER)
AC_SUBST(DMEVENTD)
AC_SUBST(DM_COMPAT)
AC_SUBST(DM_DEVICE_GID)
AC_SUBST(DM_DEVICE_MODE)
AC_SUBST(DM_DEVICE_UID)
AC_SUBST(DM_IOCTLS)
AC_SUBST(DM_LIB_VERSION)
AC_SUBST(DM_LIB_PATCHLEVEL)
AC_SUBST(FSADM)
AC_SUBST(GROUP)
AC_SUBST(HAVE_LIBDL)
AC_SUBST(HAVE_REALTIME)
AC_SUBST(HAVE_SELINUX)
AC_SUBST(INTL)
AC_SUBST(INTL_PACKAGE)
AC_SUBST(JOBS)
AC_SUBST(LDDEPS)
AC_SUBST(LIBS)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(LOCALEDIR)
AC_SUBST(LVM1)
AC_SUBST(LVM1_FALLBACK)
AC_SUBST(CONFDIR)
AC_SUBST(LVM_VERSION)
AC_SUBST(MIRRORS)
AC_SUBST(MSGFMT)
AC_SUBST(OWNER)
AC_SUBST(PKGCONFIG)
AC_SUBST(POOL)
AC_SUBST(SNAPSHOTS)
AC_SUBST(STATICDIR)
AC_SUBST(STATIC_LINK)
AC_SUBST([LIB_PTHREAD])
AC_SUBST(interface)
AC_SUBST(kerneldir)
AC_SUBST(missingkernel)
AC_SUBST(kernelvsn)
AC_SUBST(tmpdir)
AC_SUBST(usrlibdir)
AC_SUBST(usrsbindir)

################################################################################
dnl -- First and last lines should not contain files to generate in order to
dnl -- keep utility scripts running properly
AC_CONFIG_FILES([
Makefile
make.tmpl
daemons/Makefile
daemons/clvmd/Makefile
daemons/dmeventd/Makefile
daemons/dmeventd/libdevmapper-event.pc
daemons/dmeventd/plugins/Makefile
daemons/dmeventd/plugins/mirror/Makefile
daemons/dmeventd/plugins/snapshot/Makefile
doc/Makefile
include/Makefile
lib/Makefile
lib/format1/Makefile
lib/format_pool/Makefile
lib/locking/Makefile
lib/mirror/Makefile
lib/snapshot/Makefile
libdm/Makefile
libdm/libdevmapper.pc
man/Makefile
po/Makefile
scripts/clvmd_init_red_hat
scripts/Makefile
test/Makefile
test/api/Makefile
tools/Makefile
tools/version.h
])
AC_OUTPUT

if test x$ODIRECT != xyes; then
  AC_MSG_WARN(Warning: O_DIRECT disabled: low-memory pvmove may lock up)
fi