1 # Copyright © 2010, 2014, 2024 Nick Bowler
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 # DX_LIB_GTK2([min-version], [action-if-ok], [action-if-failed])
18 # Search for a working GTK+-2 installation. If such a library is found,
19 # appropriate compiler and linker flags are stored in GTK_CFLAGS and
20 # GTK_LIBS, respectively, and the action-if-ok is performed (may be empty).
21 # If no suitable library is found, then action-if-failed is performed if
22 # non-empty, oherwise configure will stop with a fatal error.
23 AC_DEFUN([DX_LIB_GTK2], [dnl
24 DX_LIB_SETUP([gtk], [GTK+])dnl
25 DX_LIB_PKGCONFIG_FLAGS([gtk], [gtk+-2.0])
26 AC_MSG_CHECKING([for GTK+ at least version m4_default([$1], [2.0])])
27 DX_LIB_SEARCH_LINK([gtk],
28 [m4_apply([_DX_LIB_GTK2_TEST], m4_split([$1], [\.]))],
29 [ [[$GTK_CFLAGS], [$GTK_LIBS]],
30 [[$dx_cv_gtk_pkg_cflags], [$dx_cv_gtk_pkg_libs],
31 [test x"$dx_cv_gtk_pkg_found" = x"yes"]] ])
32 AS_IF([test x"$dx_cv_gtk_lib_found" = x"yes"], [$2],
33 [m4_default([$3], [AC_MSG_FAILURE(
34 [GTK+ version m4_default([$1], [2.0]) or newer is required. The latest
35 version may be found at <ftp://ftk.gtk.org/>.
36 m4_newline([DX_LIB_USERFLAG_BLURB([gtk], [GTK+])])
37 m4_newline([DX_LIB_PKGCONFIG_BLURB([gtk], [GTK+])])
40 # Internal test program for GTK+. Check that the version numbers in the
41 # header are sufficient and that some important functions are defined.
42 m4_define([_DX_LIB_GTK2_TEST], [AC_LANG_PROGRAM(
44 @%:@if !GTK_CHECK_VERSION(m4_do(
45 [m4_default([$1], [2]), ],
46 [m4_default([$2], [0]), ],
47 [m4_default([$3], [0]))])
48 DX_LIB_COMPILE_ERROR([insufficient GTK version])
54 gtk_init(&argc, &argv);