]> git.draconx.ca Git - dxcommon.git/blob - m4/gtk2.m4
Import GTK2 detection macro.
[dxcommon.git] / m4 / gtk2.m4
1 dnl Copyright © 2010, 2014 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 dnl DX_LIB_GTK2([min-version], [action-if-ok], [action-if-failed])
8 dnl
9 dnl Search for a working GTK+-2 installation.  If such a library is found,
10 dnl appropriate compiler and linker flags are stored in GTK_CFLAGS and
11 dnl GTK_LIBS, respectively, and the action-if-ok is performed (may be empty).
12 dnl If no suitable library is found, then action-if-failed is performed if
13 dnl non-empty, oherwise configure will stop with a fatal error.
14 AC_DEFUN([DX_LIB_GTK2], [dnl
15 DX_LIB_SETUP([gtk], [GTK+])dnl
16 DX_LIB_PKGCONFIG_FLAGS([gtk], [gtk+-2.0])
17 AC_MSG_CHECKING([for GTK+ at least version m4_default([$1], [2.0])])
18 DX_LIB_SEARCH_LINK([gtk],
19         [m4_apply([_DX_LIB_GTK2_TEST], m4_split([$1], [\.]))],
20         [
21                 [[$GTK_CFLAGS], [$GTK_LIBS]],
22                 [[$dx_cv_gtk_pkg_cflags], [$dx_cv_gtk_pkg_libs],
23                         [test x"$dx_cv_gtk_pkg_found" = x"yes"]],
24         ])
25 AS_IF([test x"$dx_cv_gtk_lib_found" = x"yes"], [$2],
26         [m4_default([$3], [AC_MSG_FAILURE([dnl
27 GTK+ version m4_default([$1], [2.0]) or newer is required.  The latest
28 version may be found at <ftp://ftk.gtk.org/>.
29 m4_newline([DX_LIB_USERFLAG_BLURB([gtk], [GTK+])])
30 m4_newline([DX_LIB_PKGCONFIG_BLURB([gtk], [GTK+])])
31 ])])])])
32
33 dnl Internal test program for GTK+.  Check that the version numbers in the
34 dnl header are sufficient and that some important functions are defined.
35 m4_define([_DX_LIB_GTK2_TEST], [AC_LANG_PROGRAM([dnl
36 #include <gtk/gtk.h>
37 @%:@if !GTK_CHECK_VERSION(m4_do(
38         [m4_default([$1], [2]), ],
39         [m4_default([$2], [0]), ],
40         [m4_default([$3], [0]))])
41 DX_LIB_COMPILE_ERROR([insufficient GTK version])
42 #endif
43 ], [dnl
44 int argc = 0;
45 char *arg = NULL;
46 char **argv = &arg;
47 gtk_init(&argc, &argv);
48 gtk_main();
49 ])])