OSDN Git Service

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