OSDN Git Service

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