OSDN Git Service

Don't fail all tests when "." lacks O_DIRECT support.
[android-x86/external-parted.git] / configure.ac
1 dnl GNU Parted - a library and front end for manipulation hard disk partitions
2 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2006, 2007
3 dnl Free Software Foundation, Inc.
4 dnl
5 dnl This file may be modified and/or distributed without restriction.
6
7 AC_PREREQ(2.61)
8 AC_INIT([GNU parted],[1.9.0],[bug-parted@gnu.org])
9
10 AC_CONFIG_SRCDIR(include/parted/parted.h)
11
12 AC_CONFIG_HEADERS([lib/config.h:lib/config.h.in])
13 AC_CONFIG_AUX_DIR(build-aux)
14
15 dnl Versioning
16 dnl Shamelessly pulled straight from glib's configure.in ...
17 dnl Making releases:
18 dnl    PED_MICRO_VERSION += 1;
19 dnl    PED_INTERFACE_AGE += 1;
20 dnl    PED_BINARY_AGE += 1;
21 dnl if any functions have been added, set PED_INTERFACE_AGE to 0.
22 dnl if backwards compatibility has been broken (eg. functions removed,
23 dnl function signatures changed),
24 dnl set PED_BINARY_AGE _and_ PED_INTERFACE_AGE to 0.
25 PED_MAJOR_VERSION=1
26 PED_MINOR_VERSION=9
27 PED_MICRO_VERSION=0
28 PED_INTERFACE_AGE=0
29 PED_BINARY_AGE=0
30 PED_VERSION_SUFFIX=
31 PED_VERSION=$PED_MAJOR_VERSION.$PED_MINOR_VERSION.$PED_MICRO_VERSION$PED_VERSION_SUFFIX
32
33 LT_RELEASE=$PED_MAJOR_VERSION.$PED_MINOR_VERSION
34 LT_CURRENT=`expr $PED_MICRO_VERSION - $PED_INTERFACE_AGE`
35 LT_REVISION=$PED_INTERFACE_AGE
36 LT_AGE=`expr $PED_BINARY_AGE - $PED_INTERFACE_AGE`
37 AC_SUBST(LT_RELEASE)
38 AC_SUBST(LT_CURRENT)
39 AC_SUBST(LT_REVISION)
40 AC_SUBST(LT_AGE)
41
42 # Ensure that the PED_*-specified version is the same as the literal
43 # in the AC_INIT line, above.
44 test $PACKAGE_VERSION = $PED_VERSION ||
45   AC_MSG_ERROR(configure.ac: version mismatch: $PACKAGE_VERSION != $PED_VERSION)
46
47 AM_INIT_AUTOMAKE([1.10 dist-bzip2])
48
49 AC_CANONICAL_HOST
50 case "$host_os" in
51         linux*) OS=linux ;;
52         gnu*)   OS=gnu ;;
53         beos*)  OS=beos ;;
54         *)      AC_MSG_ERROR([Unknown or unsupported OS "$host_os".  Only "linux", "gnu" and "beos" are supported in this version of GNU Parted.]) ;;
55 esac
56 AC_SUBST(OS)
57
58 dnl Command-line options
59 AC_ARG_WITH(readline,
60         [  --with-readline         support fancy command line editing], ,
61         with_readline=yes
62 )
63
64 AC_ARG_ENABLE(mtrace,
65         [  --enable-mtrace         enable malloc() debugging], ,
66         enable_mtrace=no
67 )
68 if test "$enable_mtrace" = yes; then
69         AC_DEFINE(ENABLE_MTRACE, 1, [Mtrace malloc() debugging])
70 fi
71
72 AC_ARG_ENABLE(device-mapper,
73         [  --enable-device-mapper  enable device mapper support [default=no]], ,
74         enable_device_mapper=no
75 )
76 if test "$enable_device_mapper" = yes; then
77         AC_DEFINE(ENABLE_DEVICE_MAPPER, 1, [device mapper (libdevmapper) support])
78 fi
79
80 AC_ARG_ENABLE(selinux,
81         [  --enable-selinux        enable SELinux support [default=no]], ,
82         enable_selinux=no
83 )
84
85 AC_ARG_ENABLE(discover-only,
86         [  --enable-discover-only  support only reading/probing [default=no]], ,
87         enable_discover_only=no
88 )
89 if test "$enable_discover_only" = yes; then
90         AC_DEFINE(DISCOVER_ONLY, 1, [Probing functionality only])
91 fi
92
93 PARTED_LIBS=""
94 AC_ARG_ENABLE(dynamic-loading,
95 [  --enable-dynamic-loading  support dynamic fs libraries [default=yes]], ,
96         if test "$enable_discover_only" = yes; then
97                 enable_dynamic_loading=no
98         else
99                 enable_dynamic_loading=yes
100         fi
101 )
102 if test "$enable_discover_only" = yes -a "$enable_dynamic_loading" = yes; then
103         AC_MSG_ERROR(
104 [You can't use --enable-dynamic-loading and --disable-discover-only together]
105         )
106 fi
107
108 AC_ARG_ENABLE(fs,
109         [  --enable-fs             include filesystem support [default=yes]], ,
110         enable_fs=yes
111 )
112 if test "$enable_fs" = yes; then
113         AC_DEFINE(ENABLE_FS, 1,
114                   [Include file system support.  i.e. libparted/fs_...])
115 fi
116
117 AC_ARG_ENABLE(debug,
118         [  --enable-debug          compile in assertions [default=yes]], ,
119         enable_debug=yes
120 )
121
122 if test "$enable_debug" = yes; then
123         AC_DEFINE(DEBUG, 1, [Enable assertions, etc.])
124 fi
125
126 AC_ARG_ENABLE(read-only,
127         [  --enable-read-only      disable writing (for debugging) [default=no]]
128         , ,
129         enable_read_only=no
130 )
131 if test "$enable_read_only" = yes; then
132         AC_DEFINE(READ_ONLY, 1, [Disable all writing code])
133 fi
134
135 PARTEDLDFLAGS=
136 AC_SUBST(PARTEDLDFLAGS)
137
138 AC_ARG_ENABLE(pc98,
139         [  --enable-pc98          build with pc98 support [default=yes]], ,
140         enable_pc98=yes
141 )
142 if test "$enable_pc98" = yes; then
143         AC_DEFINE(ENABLE_PC98, 1,
144                   [Include PC98 partition tables.  (Sometimes excluded to avoid
145                    collisions with msdos partition tables])
146 fi
147
148 AC_ARG_ENABLE(Werror,
149         [  --enable-Werror         build with gcc -Werror [default=yes]], ,
150         enable_Werror=yes
151 )
152
153 AC_ARG_ENABLE(hfs-extract-fs,
154         [  --enable-hfs-extract-fs Extract special HFS files for debugging [default=no]], ,
155         enable_hfs_extract_fs=no
156 )
157 if test "$enable_hfs_extract_fs" = yes; then
158        AC_DEFINE(HFS_EXTRACT_FS, 1,
159                  [Extract low level special HFS(+) files for debugging purposes
160                   when using the "check" command (NOT FOR PACKAGING)])
161 fi
162
163 dnl make libc threadsafe (not required for us, but useful other users of
164 dnl libparted)
165 AM_CPPFLAGS="$AM_CPPFLAGS -D_REENTRANT"
166
167 dnl Check for programs.
168 AC_ISC_POSIX
169 AC_PROG_CC
170 AC_PROG_GCC_TRADITIONAL
171 AM_PROG_CC_C_O
172
173 gl_EARLY
174 parted_FIND_USABLE_TEST_DIR
175
176 dnl This test must come as early as possible after the compiler configuration
177 dnl tests, because the choice of the file model can (in principle) affect
178 dnl whether functions and headers are available, whether they work, etc.
179 AC_SYS_LARGEFILE
180
181 gl_INIT
182
183 AC_CHECK_SIZEOF(off_t, 64, [
184         #include <stdio.h>
185         #include <sys/types.h>
186         #include <unistd.h>
187 ])
188
189 AM_ENABLE_SHARED
190 if test "$OS" = linux -a $ac_cv_sizeof_off_t -lt 8; then
191         dnl Need to disable shared libraries, to get llseek() to work.  Long
192         dnl story.  The short story is: lseek() isn't in glibc, so a syscall
193         dnl must be made.  syscalls can't be made from within shared libraries,
194         dnl because of a bug (?) in gcc.
195         AC_MSG_WARN(
196 off_t is less than 8 bytes.  Using llseek syscall, and disabling shared
197 libraries.)
198         AM_DISABLE_SHARED
199 fi
200 AM_PROG_LIBTOOL
201
202 AM_GNU_GETTEXT_VERSION([0.15])
203 AM_GNU_GETTEXT([external])
204 if test "$USE_INCLUDED_LIBINTL" = "yes"; then
205         AC_MSG_ERROR(
206 GNU Parted requires gettext to be installed for compilation -
207 if native language support is desired.  Either disable native language support
208 with:
209         $ ./configure --disable-nls
210 Or install gettext.  GNU gettext is available from
211         http://ftp.gnu.org/gnu/gettext
212 )
213         exit
214 fi
215
216 dnl Check for libdl, if we are doing dynamic loading
217 DL_LIBS=""
218 if test "$enable_dynamic_loading" = yes; then
219         AC_CHECK_LIB(dl, dlopen,
220                 DL_LIBS="-ldl"
221                 PARTED_LIBS="$PARTED_LIBS -ldl"
222                 AC_DEFINE(DYNAMIC_LOADING, 1, [Lazy linking to fs libs]),
223                 AC_MSG_ERROR(
224                         [-ldl not found!  Try using --disable-dynamic-loading]
225                 )
226                 exit
227         )
228 fi
229 AC_SUBST(DL_LIBS)
230
231 dnl Check for libuuid
232 UUID_LIBS=""
233 AC_CHECK_LIB(uuid, uuid_generate, UUID_LIBS="-luuid",
234         AC_MSG_ERROR(
235 GNU Parted requires libuuid - a part of the e2fsprogs package (but
236 sometimes distributed separately in uuid-devel or similar)
237 This can probably be found on your distribution's CD or FTP site or at:
238          http://web.mit.edu/tytso/www/linux/e2fsprogs.html
239 Note: if you are using precompiled packages you will also need the development
240 package as well (which may be called e2fsprogs-devel or something similar).
241 If you compile e2fsprogs yourself then you need to do 'make install' and
242 'make install-libs'.
243         )
244         exit
245 )
246 AC_SUBST(UUID_LIBS)
247
248 dnl Check for libdevmapper
249 DM_LIBS=""
250 if test "$enable_device_mapper" = yes; then
251         AC_CHECK_LIB(devmapper, dm_task_create,
252                 DM_LIBS="-ldevmapper",
253                 AC_MSG_ERROR(
254                         [libdevmapper not found!  Try using --disable-device-mapper]
255                 )
256                 exit
257         )
258 fi
259 AC_SUBST(DM_LIBS)
260
261 dnl Check for SELinux
262 SELINUX_LIBS=""
263 if test "$enable_selinux" = yes; then
264         SELINUX_LIBS="-lselinux -lsepol"
265 fi
266 AC_SUBST(SELINUX_LIBS)
267
268 dnl Check for libreiserfs
269 REISER_LIBS=""
270 if test "$enable_dynamic_loading" = no -a "$enable_discover_only" = no; then
271         OLD_LIBS="$LIBS"
272         AC_CHECK_LIB(dal, dal_equals,
273                 LIBS="-ldal"
274                 AC_CHECK_LIB(reiserfs, reiserfs_fs_probe,
275                         REISER_LIBS="-ldal -lreiserfs"
276                         AC_DEFINE(HAVE_LIBREISERFS, 1, [Have libreiserfs])
277                 )
278                 AC_CHECK_LIB(reiserfs, reiserfs_fs_check,
279                         AC_DEFINE(HAVE_REISERFS_FS_CHECK, 1, [Have reiserfs_fs_check()])
280                 )
281         )
282         LIBS="$OLD_LIBS"
283 fi
284 AC_SUBST(REISER_LIBS)
285
286 dnl Check for termcap
287 if test "$with_readline" = yes; then
288         OLD_LIBS="$LIBS"
289         LIBS=""
290         AC_SEARCH_LIBS(tgetent, tinfo ncurses curses termcap termlib,
291                 PARTED_LIBS="$PARTED_LIBS $LIBS",
292                 AC_MSG_ERROR(
293 termcap could not be found which is required for the
294 --with-readline option (which is enabled by default).  Either disable readline
295 support with --without-readline or download and install termcap from:
296         ftp.gnu.org/gnu/termcap
297 Note: if you are using precompiled packages you will also need the development
298   package as well (which may be called termcap-devel or something similar).
299 Note: (n)curses also seems to work as a substitute for termcap.  This was
300   not found either - but you could try installing that as well.
301 )
302         exit
303         )
304         LIBS="$OLD_LIBS"
305 fi
306
307 dnl Check for readline
308 dnl NOTE: We need to remove the gl_cv_ignore_unused_libraries flag if we
309 dnl detected one earlier.  libreadline on some platforms (e.g., RHEL and
310 dnl Fedora) is left with 
311 if test "$with_readline" = yes; then
312         OLD_LIBS="$LIBS"
313         LIBS="$LIBS $PARTED_LIBS"
314         AC_CHECK_LIB(readline, readline,
315                 PARTED_LIBS="-lreadline $PARTED_LIBS"
316                 AC_DEFINE(HAVE_LIBREADLINE, 1, [have readline]),
317                 AC_MSG_ERROR(
318 GNU Readline could not be found which is required for the
319 --with-readline (which is enabled by default).  Either disable readline support with
320 --without-readline or downloaded and install it from:
321         ftp.gnu.org/gnu/readline
322 Note: if you are using precompiled packages you will also need the development
323 package as well (which may be called readline-devel or something similar).
324 )
325                 exit,
326                 $PARTED_LIBS
327         )
328         LIBS="$OLD_LIBS"
329 fi
330
331 AC_SUBST(PARTED_LIBS)
332
333 dnl Check for OS specific libraries
334
335 dnl GNU/Hurd:
336 if test "$OS" = gnu; then
337 dnl libshouldbeinlibc
338         AC_CHECK_LIB(shouldbeinlibc, vm_deallocate,
339                 OS_LIBS="$OS_LIBS -lshouldbeinlibc",
340                 AC_MSG_ERROR(
341 GNU Parted requires libshouldbeinlibc when running on
342 GNU/Hurd systems.  It is a standard part of a GNU/Hurd system.
343                 )
344                 exit
345         )
346
347 dnl libstore may depend on libparted being present.
348 dnl Aren't circular dependencies wonderful?
349         OLD_LIBS="$LIBS"
350         LIBS=
351
352         AC_CHECK_LIB(parted, ped_device_read)
353
354 dnl libstore
355         AC_CHECK_LIB(store, store_open,
356                 OS_LIBS="$OS_LIBS -lstore",
357                 AC_MSG_ERROR(
358 GNU Parted requires libstore when running on GNU/Hurd
359 systems.  It is a standard part of a GNU/Hurd system.
360                 )
361                 exit,
362                 $OS_LIBS $UUID_LIBS $DM_LIBS $LIBS
363         )
364         LIBS="$OLD_LIBS"
365 fi
366
367 dnl BeOS/ZETA/Haiku:
368
369 if test "$OS" = beos; then
370         dnl Include the socket library, as it is a depedency of libuuid
371         dnl and so also of us (due to socket() call in libuuid)
372         OS_LIBS="$OS_LIBS -lsocket"
373 fi
374
375 AC_SUBST(OS_LIBS)
376
377 dnl One day, gettext might support libtool...
378 dnl if test "$USE_INCLUDED_LIBINTL" = "yes"; then
379 dnl     INTLINCS='-I$(top_srcdir)/intl'
380 dnl fi
381 AC_SUBST(INTLINCS)
382
383
384 dnl Checks for header files.
385 AC_CHECK_HEADER(uuid/uuid.h, ,
386         AC_MSG_ERROR(
387 GNU Parted requires libuuid - a part of the e2fsprogs package.
388 You seem to have the library installed but not the headers.  These are usually
389 found in a corresponding development package (usually called e2fsprogs-devel).
390 If you can't find one try:
391         http://web.mit.edu/tytso/www/linux/e2fsprogs.html
392 )
393         exit
394 )
395
396 AC_CHECK_HEADERS(getopt.h)
397
398 dnl required for libparted/llseek.c  (TODO: make linux-x86 only)
399 if test "$OS" = linux; then
400         AC_CHECK_HEADER(linux/unistd.h)
401 fi
402
403 if test "$with_readline" = yes; then
404         AC_CHECK_HEADERS(readline/readline.h readline/history.h, ,
405                 AC_MSG_ERROR(
406 The headers for GNU Readline could not be found which
407 are required for the --with-readline option.  You seem to have the GNU readline
408 library installed but not the headers.  These are usually found in a
409 corresponding development package (usually called readline-devel).  If you can't
410 find one try:
411         ftp.gnu.org/gnu/readline
412 Alternatively you can disable readline support with --without-readline
413 )
414         exit
415         )
416 fi
417
418 AC_CHECK_HEADERS(termcap.h)
419
420 if test "$USE_NLS" = yes; then
421         AC_CHECK_HEADERS(wctype.h, ,
422                 AC_MSG_ERROR(
423 One or more of the header files that are required for
424 native language support (wctype.h) could not be found.  Either get a newer
425 version of GNU libc and its headers - which can be obtained from:
426         ftp.gnu.org/gnu/glibc
427 Or disable native language support with the --disable-nls option
428 )
429         exit
430         )
431 fi
432
433 AC_CHECK_HEADER([execinfo.h], [
434         AC_CHECK_LIB(c, backtrace, [
435                 AC_DEFINE(HAVE_BACKTRACE, 1, [Has backtrace support])
436                 LDFLAGS="$LDFLAGS -rdynamic"
437         ])
438 ])
439
440 dnl Checks for #defines.
441 AC_COMPILE_IFELSE([
442         AC_LANG_PROGRAM([[
443         #if defined __s390__ || defined __s390x__
444         #  message s390 defined
445         #endif
446         ]])], [compile_for_s390="no"], [compile_for_s390="yes"])
447 AM_CONDITIONAL([COMPILE_FOR_S390], [test "$compile_for_s390" = "yes"])
448
449 dnl check for "check", unit testing library/header
450 PKG_CHECK_MODULES([CHECK], [check >= 0.9.3], have_check=yes, have_check=no)
451 if test "$have_check" != "yes"; then
452     AC_MSG_RESULT([Unable to locate check version 0.9.3 or higher: not building])
453 fi
454 AM_CONDITIONAL([HAVE_CHECK], [test "$have_check" = yes])
455
456 dnl Checks for typedefs, structures and compiler characteristics.
457 AC_PROG_LD
458
459 AC_C_BIGENDIAN
460 AC_C_INLINE
461 AC_C_CONST
462 AC_C_RESTRICT
463
464 dnl Checks for library functions.
465 AC_CHECK_FUNCS(sigaction)
466 AC_CHECK_FUNCS(getuid)
467
468 dnl NOTE: We need to remove the gl_cv_ignore_unused_libraries flag if we
469 dnl detected one earlier.  libreadline on some platforms (e.g., RHEL and
470 dnl Fedora) is left with 
471 if test "$with_readline" = yes; then
472         OLD_LIBS="$LIBS"
473         LIBS="$LIBS $PARTED_LIBS -lreadline"
474         AC_CHECK_FUNCS(rl_completion_matches)
475         LIBS="$OLD_LIBS"
476 fi
477
478 AC_CHECK_FUNCS(canonicalize_file_name)
479
480 # CFLAGS="$CFLAGS -W -Wall -Wno-unused -Wno-switch -Wno-format"
481
482 if test "$enable_Werror" = yes; then
483         CFLAGS="$CFLAGS -Werror"
484 fi
485
486 DATE=$(date '+%d %b %Y %H:%M')
487 USER=$(whoami)
488 HOST=$(hostname)
489 BUILDINFO="$USER@$HOST, $DATE"
490 AC_SUBST(BUILDINFO)
491
492 AC_OUTPUT([
493 Makefile
494 lib/Makefile
495 include/Makefile
496 include/parted/Makefile
497 libparted/Makefile
498 libparted/labels/Makefile
499 libparted/fs/Makefile
500 libparted/fs/amiga/Makefile
501 libparted/fs/ext2/Makefile
502 libparted/fs/fat/Makefile
503 libparted/fs/hfs/Makefile
504 libparted/fs/jfs/Makefile
505 libparted/fs/linux_swap/Makefile
506 libparted/fs/ntfs/Makefile
507 libparted/fs/reiserfs/Makefile
508 libparted/fs/ufs/Makefile
509 libparted/fs/xfs/Makefile
510 libparted/tests/Makefile
511 libparted.pc
512 parted/Makefile
513 partprobe/Makefile
514 doc/Makefile
515 doc/C/Makefile
516 doc/pt_BR/Makefile
517 debug/Makefile
518 debug/clearfat/Makefile
519 debug/test/Makefile
520 tests/Makefile
521 po/Makefile.in
522 ])
523
524 echo
525 echo Type \'make\' to compile parted.