]> git.draconx.ca Git - liblbx.git/blob - m4/gtk2.m4
build: Implement a better GTK+ detection macro.
[liblbx.git] / m4 / gtk2.m4
1 dnl Copyright (C) 2010 Nick Bowler
2 dnl Copying and distribution of this file, with or without modification,
3 dnl are permitted in any medium without royalty provided the copyright
4 dnl notice and this notice are preserved.  This file is offered as-is,
5 dnl without any warranty.
6
7 dnl _DX_GTK2_TEST_PROGRAM(major, minor, micro)
8 AC_DEFUN([_DX_GTK2_TEST_PROGRAM], [AC_LANG_PROGRAM([dnl
9 #include <gtk/gtk.h>
10 #if !GTK_CHECK_VERSION( \
11         ifelse([$1], [], [2], [$1]), \
12         ifelse([$2], [], [0], [$2]), \
13         ifelse([$3], [], [0], [$3]))
14 #  error Insufficient GTK version
15 #endif
16 ], [dnl
17 int argc = 0;
18 char *argv[] = {NULL};
19 gtk_init(&argc, &argv);
20 gtk_main();
21 ])])
22
23 dnl DX_CHECK_GTK2([min-version], [action-if-ok], [action-if-fail])
24 AC_DEFUN([DX_CHECK_GTK2],
25 [DX_PKG_CONFIG([gtk], [gtk+-2.0], [GTK+])
26
27 DX_CHECK_LIB([gtk],
28         [for GTK+ version at least ifelse([$1], [], [2.0], [$1])],
29         [m4_apply([_DX_GTK2_TEST_PROGRAM], m4_split([$1], [\.]))], [dnl
30                 [[$GTK_CFLAGS], [$GTK_LIBS]],
31                 [[$pkg_cv_gtk_cflags], [$pkg_cv_gtk_libs],
32                         [test ! x"$pkg_failed" = x"yes"]],
33                 ])
34
35 if test x"$dx_cv_gtk_found" = x"yes"; then
36         ifelse([$2], [], [:], [$2])
37 else
38         ifelse([$3], [], [AC_MSG_FAILURE([dnl
39 GTK+ version at least ifelse([$1], [], [2.0], [$1]) is required.  The latest
40 version can be obtained from ftp://ftk.gtk.org/.
41
42 If GTK+ is installed but was not found by this configure script,
43 consider adjusting GTK_CFLAGS and/or GTK_LIBS as necessary.
44
45 If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
46 if GTK+ is installed in a non-standard prefix.
47 ])], [$3])
48 fi
49 ])