OSDN Git Service

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