]> git.pld-linux.org Git - packages/parted.git/blame - parted.m4
up to 3.6
[packages/parted.git] / parted.m4
CommitLineData
ab4c0c05
JB
1# library paths for libparted
2# written by Damien Genet <damien.genet@free.fr>
3
4dnl Usage:
5dnl PARTED_CHECK_LIBPARTED([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
6dnl where MINIMUM-VERSION must be >= 1.2.8 and != 1.3.0
7dnl
8dnl Example:
9dnl PARTED_CHECK_LIBPARTED(1.2.8, , [AC_MSG_ERROR([*** libparted >= 1.2.8 not installed - please install first ***])])
10dnl
11dnl Adds the required libraries to $PARTED_LIBS and does an
8e0cde56 12dnl AC_SUBST([PARTED_LIBS])
ab4c0c05
JB
13dnl
14
15
16AC_DEFUN([PARTED_CHECK_LIBPARTED],
17[
18AC_REQUIRE([AC_CANONICAL_HOST])
19
20dnl save LIBS
21saved_LIBS="$LIBS"
22
23dnl Check for headers and library
8e0cde56 24AC_CHECK_HEADER([parted/parted.h], ,
ab4c0c05
JB
25 [AC_MSG_ERROR([<parted/parted.h> not found; install GNU/Parted])]
26 $3)
8e0cde56 27AC_CHECK_LIB([uuid], [uuid_generate], ,
ab4c0c05
JB
28 [AC_MSG_ERROR([libuuid not found; install e2fsprogs available at http://web.mit.edu/tytso/www/linux/e2fsprogs.html])]
29 $3)
8e0cde56 30AC_CHECK_LIB([parted],ped_device_read, ,
ab4c0c05
JB
31 [AC_MSG_ERROR([libparted not found; install GNU/Parted available at http://www.gnu.org/software/parted/parted.html])]
32 $3)
33
34case "$host_os" in
35 gnu*) # The Hurd requires some special system libraries
36 # with very generic names, which is why we special
37 # case these tests.
38
8e0cde56 39 AC_CHECK_LIB([shouldbeinlibc], [lcm], ,
ab4c0c05
JB
40 [AC_MSG_ERROR([libshouldbeinlibc not found; install the Hurd development libraries.])]
41 $3)
42
8e0cde56 43 AC_CHECK_LIB([store], [store_open], ,
ab4c0c05
JB
44 [AC_MSG_ERROR([libstore not found; install the Hurd development libraries.])]
45 $3)
46 ;;
47 *) ;;
48esac
49
8e0cde56 50AC_MSG_CHECKING([for libparted - version >= $1])
ab4c0c05 51
8e0cde56
JB
52AC_TRY_LINK_FUNC([ped_get_version], ,
53 AC_MSG_RESULT([failed])
ab4c0c05
JB
54 AC_MSG_ERROR([*** libparted < 1.2.8 or == 1.3.0 can't execute test ***]))
55
56dnl Get major, minor, and micro version from arg MINIMUM-VERSION
57parted_config_major_version=`echo $1 | \
58 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
59parted_config_minor_version=`echo $1 | \
60 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
61parted_config_micro_version=`echo $1 | \
62 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
63
64dnl Compare MINIMUM-VERSION with libparted version
65AC_TRY_RUN([
66#include <stdio.h>
67#include <stdlib.h>
68#include <parted/parted.h>
69
70int main ()
71{
72 int major, minor, micro;
8e0cde56
JB
73 const char *version;
74
ab4c0c05 75 if ( !(version = ped_get_version ()) )
8e0cde56 76 exit(EXIT_FAILURE);
ab4c0c05
JB
77 if (sscanf(version, "%d.%d.%d", &major, &minor, &micro) != 3) {
78 printf("%s, bad version string\n", version);
8e0cde56 79 exit(EXIT_FAILURE);
ab4c0c05 80 }
8e0cde56 81
ab4c0c05
JB
82 if ((major > $parted_config_major_version) ||
83 ((major == $parted_config_major_version) && (minor > $parted_config_minor_version)) ||
84 ((major == $parted_config_major_version) && (minor == $parted_config_minor_version) && (micro >= $parted_config_micro_version))) {
85 return 0;
86 } else {
87 printf("\n*** An old version of libparted (%s) was found.\n",
88 version);
89 printf("*** You need a version of libparted equal to or newer than %d.%d.%d.\n",
8e0cde56 90 $parted_config_major_version,
ab4c0c05
JB
91 $parted_config_minor_version,
92 $parted_config_micro_version);
93 printf("*** You can get it at - ftp://ftp.gnu.org/gnu/parted/\n");
94 return 1;
95 }
96}
8e0cde56
JB
97],
98 AC_MSG_RESULT([yes]),
99 AC_MSG_RESULT([no]) ; $3,
ab4c0c05
JB
100 [echo $ac_n "cross compiling; assumed OK... $ac_c"])
101
102dnl restore orignial LIBS and set @PARTED_LIBS@
103PARTED_LIBS="$LIBS"
104LIBS="$saved_LIBS"
8e0cde56 105AC_SUBST([PARTED_LIBS])
ab4c0c05
JB
106
107dnl Execute ACTION-IF-FOUND
108$2
109
110])
This page took 0.134154 seconds and 4 git commands to generate.