summaryrefslogtreecommitdiff
path: root/configure.in
blob: 748eaf70bf8d0539506905c420b8146e1fb26d91 (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
##
##    Copyright 1999-2000 Sistina Software, Inc.
##
##    This is free software released under the GNU General Public License.
##    There is no warranty for this software.  See the file COPYING for
##    details.
##
##    See the file CONTRIBUTORS for a list of contributors.
##
##    This file is maintained by:
##      AJ Lewis <lewis@sistina.com>
## 
##    File name: configure.in
##
##    Description: Input file for autoconf.  Generates the configure script 
##                 that tries to keep everything nice and portable.  It also
##                 simplifies distribution package building considerably.
################################################################################

dnl Process this file with autoconf to produce a configure script.
AC_INIT(lib/device/dev-cache.h)

dnl setup the directory where autoconf has auxilary files
AC_CONFIG_AUX_DIR(autoconf) 

dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h malloc.h sys/ioctl.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_ST_RDEV
AC_HEADER_TIME

dnl Get system type
AC_CANONICAL_SYSTEM

case "$host_os" in
	linux*)
		CFLAGS= 
		CLDFLAGS="-Wl,--version-script,.export.sym"
		CLDWHOLEARCHIVE="-Wl,-whole-archive"
		CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
		LD_DEPS=".export.sym"
		LD_FLAGS="-Wl,--export-dynamic"
		SOFLAG="-shared"
		DEVMAPPER=yes
		ODIRECT=yes ;;
	darwin*)
		CFLAGS="-no-cpp-precomp -fno-common"
		CLDFLAGS=
		CLDWHOLEARCHIVE="-all_load"
		CLDNOWHOLEARCHIVE=
		LD_DEPS=
		LD_FLAGS=
		SOFLAG="-dynamiclib"
		DEVMAPPER=no
		ODIRECT=no ;;
esac

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_ARG_WITH(user,
  [  --with-user=USER        Set the owner of installed files ],
  [ OWNER="$withval" ],
  [ OWNER="root" ])

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

dnl -- LVM1 tool fallback option
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)

if test x$LVM1_FALLBACK = xyes; then
	CFLAGS="$CFLAGS -DLVM1_FALLBACK"
fi

dnl -- format1 inclusion type
AC_ARG_WITH(lvm1,
  [  --with-lvm1=TYPE        LVM1 metadata support: internal/shared/none
                          [TYPE=internal] ],
  [ LVM1="$withval" ],
  [ LVM1="internal" ])

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

if test x$LVM1 = xinternal; then
	CFLAGS="$CFLAGS -DLVM1_INTERNAL"
fi

AC_ARG_ENABLE(jobs, [  --enable-jobs=NUM       Number of jobs to run simultaneously], JOBS=-j$enableval, JOBS=-j2)

dnl Enables staticly-linked tools
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)

dnl Enable readline
AC_ARG_ENABLE(readline, [  --enable-readline       Enable readline support],  \
READLINE=$enableval, READLINE=no)

if test x$READLINE = xyes; then
	CFLAGS="$CFLAGS -DREADLINE_SUPPORT"
fi

echo $ac_n "checking whether to enable debugging""... $ac_c" 1>&6
dnl Enable Debugging
AC_ARG_ENABLE(debug,    [  --enable-debug          Enable debugging],  \
DEBUG=yes, DEBUG=no)
echo "$ac_t""$DEBUG" 1>&6

echo $ac_n "checking whether to enable device-mapper""... $ac_c" 1>&6
dnl Disable devmapper
AC_ARG_ENABLE(devmapper, [  --disable-devmapper     Disable device-mapper interaction],  \
DEVMAPPER=no)
echo "$ac_t""$DEVMAPPER" 1>&6

if test x$DEVMAPPER = xyes; then
	CFLAGS="$CFLAGS -DDEVMAPPER_SUPPORT"
fi

echo $ac_n "checking whether to enable O_DIRECT""... $ac_c" 1>&6
dnl Disable O_DIRECT
AC_ARG_ENABLE(o_direct, [  --disable-o_direct      Disable O_DIRECT],  \
ODIRECT=no)
echo "$ac_t""$ODIRECT" 1>&6

if test x$ODIRECT = xyes; then
	CFLAGS="$CFLAGS -DO_DIRECT_SUPPORT"
fi

echo $ac_n "checking whether to compile liblvm2cmd.so""... $ac_c" 1>&6
dnl Enable cmdlib
AC_ARG_ENABLE(cmdlib, [  --enable-cmdlib         Build shared command library],  \
CMDLIB=yes, CMDLIB=no)
echo "$ac_t""$CMDLIB" 1>&6

if test x$CMDLIB = xyes; then
	CFLAGS="$CFLAGS -DCMDLIB"
fi

dnl Mess with default exec_prefix
if [[ "x$exec_prefix" = xNONE -a "x$prefix" = xNONE ]];
 then  exec_prefix="";
fi;

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(mkdir rmdir uname)

dnl check for termcap (Shamelessly copied from parted 1.4.17)
if test x$READLINE = xyes; then
	AC_SEARCH_LIBS(tgetent, ncurses curses termcap termlib, ,
		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.
)
	exit
	)
fi

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

if [[ "x$HAVE_LIBDL" = xyes -a "xSTATIC_LINK" = xno ]]; then
	CFLAGS="$CFLAGS -DHAVE_LIBDL"
	LIBS="-ldl $LIBS"
else
	HAVE_LIBDL=no
fi

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

dnl Check for is_selinux_enabled
AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no)

if test x$HAVE_SELINUX = xyes; then
	CFLAGS="$CFLAGS -DHAVE_SELINUX"
	LIBS="-lselinux $LIBS"
fi

dnl Check for getopt
AC_CHECK_HEADERS(getopt.h, CFLAGS="$CFLAGS -DHAVE_GETOPTLONG")

dnl Check for readline (Shamelessly copied from parted 1.4.17)
if test x$READLINE = xyes; then
	AC_CHECK_LIB(readline, readline, ,
		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).
)
		exit
	)
	AC_CHECK_FUNC(rl_completion_matches, CFLAGS="$CFLAGS -DHAVE_RL_COMPLETION_MATCHES")
		
fi

echo $ac_n "checking whether to enable internationalisation""... $ac_c" 1>&6
dnl Internationalisation stuff
AC_ARG_ENABLE(nls, [  --enable-nls            Enable Native Language Support],\
		INTL=yes, INTL=no)
echo "$ac_t""$INTL" 1>&6

if test x$INTL = xyes; then
	INTL_PACKAGE="lvm2"
	AC_PATH_PROG(MSGFMT, msgfmt)
	if [[ "x$MSGFMT" == x ]];
		then  AC_MSG_ERROR(
		msgfmt not found in path $PATH
		)
		exit  
	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' ])


if test "-f VERSION"; then
  LVM_VERSION="\"`cat VERSION`\""
else
  LVM_VERSION="Unknown"
fi

AC_SUBST(JOBS)
AC_SUBST(STATIC_LINK)
AC_SUBST(LVM1)
AC_SUBST(OWNER)
AC_SUBST(GROUP)
AC_SUBST(CFLAGS)
AC_SUBST(CLDFLAGS)
AC_SUBST(CLDWHOLEARCHIVE)
AC_SUBST(CLDNOWHOLEARCHIVE)
AC_SUBST(LD_DEPS)
AC_SUBST(LD_FLAGS)
AC_SUBST(SOFLAG)
AC_SUBST(LIBS)
AC_SUBST(LVM_VERSION)
AC_SUBST(LVM1_FALLBACK)
AC_SUBST(DEBUG)
AC_SUBST(DEVMAPPER)
AC_SUBST(HAVE_LIBDL)
AC_SUBST(HAVE_SELINUX)
AC_SUBST(CMDLIB)
AC_SUBST(MSGFMT)
AC_SUBST(LOCALEDIR)
AC_SUBST(CONFDIR)
AC_SUBST(STATICDIR)
AC_SUBST(INTL_PACKAGE)
AC_SUBST(INTL)

dnl First and last lines should not contain files to generate in order to 
dnl keep utility scripts running properly
AC_OUTPUT( 								\
Makefile								\
make.tmpl                                                               \
doc/Makefile								\
include/Makefile						 	\
lib/Makefile							 	\
lib/format1/Makefile						 	\
man/Makefile							 	\
po/Makefile								\
tools/Makefile							 	\
tools/version.h								\
test/mm/Makefile							\
test/device/Makefile							\
test/format1/Makefile							\
test/regex/Makefile                                                     \
test/filters/Makefile                                                   \
)

if test x$ODIRECT != xyes; then
  echo
  echo Warning: O_DIRECT disabled.
  echo Use of pvmove may cause machine to lock up under low memory conditions.
  echo
fi