Be compliant with XDG specifications
[nautilus-actions.git] / m4 / na-check-for-gtk.m4
blobd28b7174b359d349a10ca51f9ad6c2b0ffe90dd3
1 # Nautilus-Actions
2 # A Nautilus extension which offers configurable context menu actions.
4 # Copyright (C) 2005 The GNOME Foundation
5 # Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
6 # Copyright (C) 2009-2014 Pierre Wieser and others (see AUTHORS)
8 # Nautilus-Actions is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version.
13 # Nautilus-Actions is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Nautilus-Actions; see the file COPYING. If not, see
20 # <http://www.gnu.org/licenses/>.
22 # Authors:
23 #   Frederic Ruaudel <grumz@grumz.net>
24 #   Rodrigo Moya <rodrigo@gnome-db.org>
25 #   Pierre Wieser <pwieser@trychlos.org>
26 #   ... and many others (see AUTHORS)
28 # serial 2 review the macro behavior
29 #          add version of selected packages
31 dnl let the user choose the Gtk+ version he wants build against
32 dnl --with-gtk+=[2|3]
33 dnl
34 dnl if the --with-gtk+ option is specified, an argument is required
35 dnl else, Gtk+-3.0 is first tested, then Gtk+-2.0
37 AC_DEFUN([NA_CHECK_FOR_GTK],[
38         AC_REQUIRE([_AC_NA_ARG_GTK])dnl
39         AC_REQUIRE([_AC_NA_CHECK_GTK])dnl
42 AC_DEFUN([_AC_NA_ARG_GTK],[
43         AC_ARG_WITH([gtk],
44                 AC_HELP_STRING(
45                         [--with-gtk=@<:@2|3@:>@],
46                         [the Gtk+ version to build against @<:@auto@:>@]),
47                 [with_gtk=$withval],
48                 [with_gtk="auto"])
51 AC_DEFUN([_AC_NA_CHECK_GTK],[
52         if test "${with_gtk}" = "auto"; then
53                 _AC_NA_CHECK_FOR_GTK3
54                 if test "${have_gtk3}" != "yes"; then
55                         _AC_NA_CHECK_FOR_GTK2
56                         if test "${have_gtk2}" != "yes"; then
57                                 AC_MSG_WARN([unable to find any suitable Gtk+ development library])
58                                 let na_fatal_count+=1
59                         fi
60                 fi
61         else
62                 if test "${with_gtk}" = "2"; then
63                         _AC_NA_CHECK_FOR_GTK2
64                         if test "${have_gtk2}" != "yes"; then
65                                 AC_MSG_WARN([unable to build against Gtk+ v2; try to install gtk2-devel package])
66                                 let na_fatal_count+=1
67                         fi
68                 else
69                         if test "${with_gtk}" = "3"; then
70                                 _AC_NA_CHECK_FOR_GTK3
71                                 if test "${have_gtk3}" != "yes"; then
72                                         AC_MSG_WARN([unable to build against Gtk+ v3; try to install gtk3-devel package])
73                                         let na_fatal_count+=1
74                                 fi
75                         else
76                                 AC_MSG_WARN([--with-gtk=${with_gtk}: invalid argument])
77                                 let na_fatal_count+=1
78                         fi
79                 fi
80         fi
83 dnl test for Gtk+-3.0 and its dependancies
84 dnl set have_gtk3=yes if all is ok
86 AC_DEFUN([_AC_NA_CHECK_FOR_GTK3],[
87         PKG_CHECK_MODULES([GTK3],[gtk+-3.0 >= ${gtk_required}],[have_gtk3=yes],[have_gtk3=no])
89         if test "${have_gtk3}" = "yes"; then
90                 NA_CHECK_MODULE([UNIQUE],[unique-3.0],[no])
91                 if test "${have_UNIQUE}" != "yes"; then
92                         have_gtk3="no"
93                 else
94                         msg_gtk_version=$(pkg-config --modversion gtk+-3.0)
95                         msg_unique_version=$(pkg-config --modversion unique-3.0)
96                         NAUTILUS_ACTIONS_CFLAGS="${NAUTILUS_ACTIONS_CFLAGS} ${GTK3_CFLAGS}"
97                         NAUTILUS_ACTIONS_LIBS="${NAUTILUS_ACTIONS_LIBS} ${GTK3_LIBS}"
98                 fi
99         fi
102 dnl test for Gtk+-2.0 and its dependancies
103 dnl set have_gtk2=yes if all is ok
105 AC_DEFUN([_AC_NA_CHECK_FOR_GTK2],[
106         PKG_CHECK_MODULES([GTK2],[gtk+-2.0 >= ${gtk_required}],[have_gtk2=yes],[have_gtk2=no])
108         if test "${have_gtk2}" = "yes"; then
109                 NA_CHECK_MODULE([UNIQUE],[unique-1.0],[no])
110                 if test "${have_UNIQUE}" != "yes"; then
111                         have_gtk2="no"
112                 else 
113                         msg_gtk_version=$(pkg-config --modversion gtk+-2.0)
114                         msg_unique_version=$(pkg-config --modversion unique-1.0)
115                         NAUTILUS_ACTIONS_CFLAGS="${NAUTILUS_ACTIONS_CFLAGS} ${GTK2_CFLAGS}"
116                         NAUTILUS_ACTIONS_LIBS="${NAUTILUS_ACTIONS_LIBS} ${GTK2_LIBS}"
117                 fi
118         fi