summaryrefslogtreecommitdiff
path: root/recipes/gtk.recipe
blob: 427e58253b8959923fcbf6b65dca4a47925967fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python


class Recipe(recipe.Recipe):
    name = 'gtk+'
    version = '2.24.11'
    # TODO: check license - some source files are LGPLv2, others LGPLv2+,
    #       others LGPLv2.1+, COPYING is LGPLv2 and the webpage states LGPLv2.1
    licenses = [License.LGPLv2_1Plus]
    configure_options = '--with-included-immodules '
    deps = ['glib', 'atk', 'pango', 'gdk-pixbuf', 'cairo']

    files_libs = ['libgailutil']
    files_bins = ['gtk-update-icon-cache', 'gtk-query-immodules-2.0']
    files_devel = [
        'bin/gtk-demo%(bext)s',
        'bin/gtk-builder-convert',
        'lib/gtk-2.0/include',
        'lib/pkgconfig/gtk+-2.0.pc',
        'lib/pkgconfig/gdk-2.0.pc',
        'lib/pkgconfig/gail.pc',
        'include/gtk-2.0',
        'include/gail-1.0',
        'share/gtk-2.0/demo',
    ]
    files_modules = ['lib/gtk-2.0/modules/libgail%(mext)s']
    platform_files_libs = {
        Platform.WINDOWS: ['libgtk-win32-2.0', 'libgdk-win32-2.0'],
        Platform.DARWIN: ['libgtk-quartz-2.0', 'libgdk-quartz-2.0'],
        Platform.LINUX: ['libgtk-x11-2.0', 'libgdk-x11-2.0'],
        }
    platform_files_devel = {
        Platform.WINDOWS: [
            'lib/pkgconfig/gtk+-win32-2.0.pc', 'lib/pkgconfig/gdk-win32-2.0.pc'],
        Platform.DARWIN: [
            'lib/pkgconfig/gtk+-quartz-2.0.pc', 'lib/pkgconfig/gdk-quartz-2.0.pc'],
        Platform.LINUX: [
            'lib/pkgconfig/gtk+-x11-2.0.pc', 'lib/pkgconfig/gdk-x11-2.0.pc'],
        }
    platform_files_themes = {
        Platform.LINUX: [
            'share/themes/Default/gtk-2.0-key/gtkrc'],
        Platform.WINDOWS: [
            'share/themes/MS-Windows/gtk-2.0/gtkrc',
            'lib/gtk-2.0/2.10.0/engines/libwimp.dll',]
        }
    platform_files_modules = {
        Platform.LINUX: [
            'lib/gtk-2.0/modules/libferret%(mext)s',],
        Platform.DARWIN: [
            'lib/gtk-2.0/modules/libferret%(mext)s',],
        }
    files_lang = ['gtk20', 'gtk20-properties']


    def _set_flags(self, module_path1=None, module_path2=None, theme_path=None):
        self.append_env['CFLAGS'] = self._gtk_flags(module_path1, module_path2, theme_path)

    def _gtk_flags(self, module_path1=None, module_path2=None, theme_path=None):
        flags = ''
        def escape(path):
            return '\\"%s\\"' % path
        if module_path1 is not None:
            flags += ' -DGST_SDK_GTK_DISTRO_GTK_MODULE_PATH=%s' % escape(module_path1)
        if module_path2 is not None:
            flags += ' -DGST_SDK_GTK_DISTRO_GTK_MODULE_PATH2=%s' % escape(module_path2)
        if theme_path is not None:
            flags += ' -DGST_SDK_GTK_DISTRO_GTK_THEME_PATH=%s' % escape(theme_path)
        return flags

    def prepare(self):
        if self.config.target_platform != Platform.LINUX:
            self.configure_options += '--disable-gtk-doc '
        if self.config.target_platform == Platform.WINDOWS:
            self.configure_options += '--disable-papi --disable-cups '
        elif self.config.target_platform == Platform.DARWIN:
            self.configure_options += '--with-gdktarget=quartz '
        elif self.config.target_platform == Platform.LINUX:
            # Can't change CFLAGS and use configure cache
            self.can_use_configure_cache = False
            mod_path1 = '/usr/lib/gtk-2.0'
            mod_path2 = None
            themes_path = '/usr/share/themes'
            # Old Debian/Ubuntu
            if self.config.target_distro_version in [DistroVersion.DEBIAN_SQUEEZE,
                                                     DistroVersion.UBUNTU_LUCID,
                                                     DistroVersion.UBUNTU_MAVERICK]:
                pass
            # Ubuntu
            elif self.config.target_distro_version in [DistroVersion.UBUNTU_NATTY,
                                                       DistroVersion.UBUNTU_ONEIRIC,
                                                       DistroVersion.UBUNTU_PRECISE,
                                                       DistroVersion.UBUNTU_QUANTAL,
                                                       DistroVersion.UBUNTU_RARING]:
                if self.config.target_arch == Architecture.X86:
                    mod_path2 = '/usr/lib/i386-linux-gnu/gtk-2.0'
                elif self.config.target_arch == Architecture.X86_64:
                    mod_path2 = '/usr/lib/x86_64-linux-gnu/gtk-2.0'
            # Debian 
            elif self.config.target_distro_version in [DistroVersion.DEBIAN_WHEEZY,
                                                       DistroVersion.DEBIAN_JESSIE]:
                if self.config.target_arch == Architecture.X86:
                    mod_path1 = '/usr/lib/i386-linux-gnu/gtk-2.0'
                elif self.config.target_arch == Architecture.X86_64:
                    mod_path1 = '/usr/lib/x86_64-linux-gnu/gtk-2.0'
            # RedHat
            elif self.config.target_distro_version in [DistroVersion.FEDORA_16,
                                                       DistroVersion.FEDORA_17,
                                                       DistroVersion.FEDORA_18,
                                                       DistroVersion.FEDORA_19,
                                                       DistroVersion.REDHAT_6,
                                                      ]:
                    if self.config.target_arch == Architecture.X86_64:
                        mod_path1 = '/usr/lib64/gtk-2.0'
            elif self.config.target_distro == Distro.SUSE:
                if self.config.target_arch == Architecture.X86_64:
                    mod_path1 = '/usr/lib64/gtk-2.0'
            else:
                raise FatalError(_("Add specific for other Linux distributions here"))
            self._set_flags(mod_path1, mod_path2, themes_path)