Update of Italian translation
[geany-mirror.git] / wscript
blobb9053b051dbcf08d1b8aec729ec50cae8a8bbdc7
1 # -*- coding: utf-8 -*-
3 # WAF build script - this file is part of Geany, a fast and lightweight IDE
5 # Copyright 2008-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
6 # Copyright 2008-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program 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
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 """
23 This is a WAF build script (http://code.google.com/p/waf/).
24 It can be used as an alternative build system to autotools
25 for Geany. It does not (yet) cover all of the autotools tests and
26 configure options but all important things are working.
27 "make dist" should be done with autotools, most other targets and
28 functions should work better (regarding performance and flexibility)
29 or at least equally.
31 Missing features: --enable-binreloc, make targets: dist, pdf (in doc/)
32 Known issues: Dependency handling is buggy, e.g. if src/document.h is
33               changed, depending source files are not rebuilt (maybe Waf bug).
35 The code of this file itself loosely follows PEP 8 with some exceptions
36 (line width 100 characters and some other minor things).
38 Requires WAF 1.6.1 and Python 2.5 (or later).
39 """
42 import sys
43 import os
44 import tempfile
45 from waflib import Logs, Options, Scripting, Utils
46 from waflib.Configure import ConfigurationContext
47 from waflib.Errors import WafError
48 from waflib.TaskGen import feature, before_method
49 from waflib.Tools.compiler_c import c_compiler
52 APPNAME = 'geany'
53 VERSION = '1.24'
54 LINGUAS_FILE = 'po/LINGUAS'
55 MINIMUM_GTK_VERSION = '2.16.0'
56 MINIMUM_GTK3_VERSION = '3.0.0'
57 MINIMUM_GLIB_VERSION = '2.20.0'
59 top = '.'
60 out = '_build_'
63 mio_sources = set(['tagmanager/mio/mio.c'])
65 ctags_sources = set([
66     'tagmanager/ctags/abaqus.c',
67     'tagmanager/ctags/args.c',
68     'tagmanager/ctags/abc.c',
69     'tagmanager/ctags/actionscript.c',
70     'tagmanager/ctags/asciidoc.c',
71     'tagmanager/ctags/asm.c',
72     'tagmanager/ctags/basic.c',
73     'tagmanager/ctags/c.c',
74     'tagmanager/ctags/cobol.c',
75     'tagmanager/ctags/conf.c',
76     'tagmanager/ctags/css.c',
77     'tagmanager/ctags/ctags.c',
78     'tagmanager/ctags/diff.c',
79     'tagmanager/ctags/docbook.c',
80     'tagmanager/ctags/entry.c',
81     'tagmanager/ctags/fortran.c',
82     'tagmanager/ctags/get.c',
83     'tagmanager/ctags/haskell.c',
84     'tagmanager/ctags/haxe.c',
85     'tagmanager/ctags/html.c',
86     'tagmanager/ctags/js.c',
87     'tagmanager/ctags/keyword.c',
88     'tagmanager/ctags/latex.c',
89     'tagmanager/ctags/lregex.c',
90     'tagmanager/ctags/lua.c',
91     'tagmanager/ctags/make.c',
92     'tagmanager/ctags/markdown.c',
93     'tagmanager/ctags/matlab.c',
94     'tagmanager/ctags/nsis.c',
95     'tagmanager/ctags/nestlevel.c',
96     'tagmanager/ctags/objc.c',
97     'tagmanager/ctags/options.c',
98     'tagmanager/ctags/parse.c',
99     'tagmanager/ctags/pascal.c',
100     'tagmanager/ctags/r.c',
101     'tagmanager/ctags/perl.c',
102     'tagmanager/ctags/php.c',
103     'tagmanager/ctags/python.c',
104     'tagmanager/ctags/read.c',
105     'tagmanager/ctags/rest.c',
106     'tagmanager/ctags/ruby.c',
107     'tagmanager/ctags/sh.c',
108     'tagmanager/ctags/sort.c',
109     'tagmanager/ctags/sql.c',
110     'tagmanager/ctags/strlist.c',
111     'tagmanager/ctags/txt2tags.c',
112     'tagmanager/ctags/tcl.c',
113     'tagmanager/ctags/vhdl.c',
114     'tagmanager/ctags/verilog.c',
115     'tagmanager/ctags/vstring.c'])
117 tagmanager_sources = set([
118     'tagmanager/src/tm_file_entry.c',
119     'tagmanager/src/tm_project.c',
120     'tagmanager/src/tm_source_file.c',
121     'tagmanager/src/tm_symbol.c',
122     'tagmanager/src/tm_tag.c',
123     'tagmanager/src/tm_tagmanager.c',
124     'tagmanager/src/tm_work_object.c',
125     'tagmanager/src/tm_workspace.c'])
127 scintilla_sources = set(['scintilla/gtk/scintilla-marshal.c'])
129 geany_sources = set([
130     'src/about.c', 'src/build.c', 'src/callbacks.c', 'src/dialogs.c', 'src/document.c',
131     'src/editor.c', 'src/encodings.c', 'src/filetypes.c', 'src/geanyentryaction.c',
132     'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c',
133     'src/highlighting.c', 'src/keybindings.c',
134     'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
135     'src/plugins.c', 'src/pluginutils.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
136     'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
137     'src/symbols.c',
138     'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/sidebar.c',
139     'src/ui_utils.c', 'src/utils.c'])
141 geany_icons = {
142     'hicolor/16x16/apps':       ['16x16/classviewer-class.png',
143                                  '16x16/classviewer-macro.png',
144                                  '16x16/classviewer-member.png',
145                                  '16x16/classviewer-method.png',
146                                  '16x16/classviewer-namespace.png',
147                                  '16x16/classviewer-other.png',
148                                  '16x16/classviewer-struct.png',
149                                  '16x16/classviewer-var.png',
150                                  '16x16/geany.png'],
151     'hicolor/16x16/actions':    ['16x16/geany-build.png',
152                                  '16x16/geany-close-all.png',
153                                  '16x16/geany-save-all.png'],
154     'hicolor/24x24/actions':    ['24x24/geany-build.png',
155                                  '24x24/geany-close-all.png',
156                                  '24x24/geany-save-all.png'],
157     'hicolor/32x32/actions':    ['32x32/geany-build.png',
158                                  '32x32/geany-close-all.png',
159                                  '32x32/geany-save-all.png'],
160     'hicolor/48x48/actions':    ['48x48/geany-build.png',
161                                  '48x48/geany-close-all.png',
162                                  '48x48/geany-save-all.png'],
163     'hicolor/48x48/apps':       ['48x48/geany.png'],
164     'hicolor/scalable/apps':    ['scalable/geany.svg'],
165     'hicolor/scalable/actions': ['scalable/geany-build.svg',
166                                  'scalable/geany-close-all.svg',
167                                  'scalable/geany-save-all.svg'],
168     'Tango/16x16/actions':      ['tango/16x16/geany-save-all.png'],
169     'Tango/24x24/actions':      ['tango/24x24/geany-save-all.png'],
170     'Tango/32x32/actions':      ['tango/32x32/geany-save-all.png'],
171     'Tango/48x48/actions':      ['tango/48x48/geany-save-all.png'],
172     'Tango/scalable/actions':   ['tango/scalable/geany-save-all.svg']
174 geany_icons_indexes = {
175     'hicolor':  ['index.theme'],
176     'Tango':    ['tango/index.theme']
180 def configure(conf):
182     conf.check_waf_version(mini='1.6.1')
184     conf.load('compiler_c')
185     is_win32 = _target_is_win32(conf)
187     conf.check_cc(header_name='fcntl.h', mandatory=False)
188     conf.check_cc(header_name='fnmatch.h', mandatory=False)
189     conf.check_cc(header_name='glob.h', mandatory=False)
190     conf.check_cc(header_name='sys/time.h', mandatory=False)
191     conf.check_cc(header_name='sys/types.h', mandatory=False)
192     conf.check_cc(header_name='sys/stat.h', mandatory=False)
193     conf.define('HAVE_STDLIB_H', 1)  # are there systems without stdlib.h?
194     conf.define('STDC_HEADERS', 1)  # an optimistic guess ;-)
195     _add_to_env_and_define(conf, 'HAVE_REGCOMP', 1)  # needed for CTags
197     conf.check_cc(function_name='fgetpos', header_name='stdio.h', mandatory=False)
198     conf.check_cc(function_name='ftruncate', header_name='unistd.h', mandatory=False)
199     conf.check_cc(function_name='gethostname', header_name='unistd.h', mandatory=False)
200     conf.check_cc(function_name='mkstemp', header_name='stdlib.h', mandatory=False)
201     conf.check_cc(function_name='strstr', header_name='string.h')
203     # check sunOS socket support
204     if Options.platform == 'sunos':
205         conf.check_cc(function_name='socket', lib='socket',
206                       header_name='sys/socket.h', uselib_store='SUNOS_SOCKET', mandatory=True)
208     # check for cxx after the header and function checks have been done to ensure they are
209     # checked with cc not cxx
210     conf.load('compiler_cxx')
211     if is_win32:
212         conf.load('winres')
213     _load_intltool_if_available(conf)
215     # GTK / GIO version check
216     gtk_package_name = 'gtk+-3.0' if conf.options.use_gtk3 else 'gtk+-2.0'
217     minimum_gtk_version = MINIMUM_GTK3_VERSION if conf.options.use_gtk3 else MINIMUM_GTK_VERSION
218     conf.check_cfg(package=gtk_package_name, atleast_version=minimum_gtk_version, uselib_store='GTK',
219         mandatory=True, args='--cflags --libs')
220     conf.check_cfg(package='glib-2.0', atleast_version=MINIMUM_GLIB_VERSION, uselib_store='GLIB',
221         mandatory=True, args='--cflags --libs')
222     conf.check_cfg(package='gmodule-2.0', uselib_store='GMODULE',
223         mandatory=True, args='--cflags --libs')
224     conf.check_cfg(package='gio-2.0', uselib_store='GIO', args='--cflags --libs', mandatory=True)
225     gtk_version = conf.check_cfg(modversion=gtk_package_name, uselib_store='GTK') or 'Unknown'
226     conf.check_cfg(package='gthread-2.0', uselib_store='GTHREAD', args='--cflags --libs')
227     # remember GTK version for the build step
228     conf.env['gtk_package_name'] = gtk_package_name
229     conf.env['minimum_gtk_version'] = minimum_gtk_version
230     conf.env['use_gtk3'] = conf.options.use_gtk3
232     # Windows specials
233     if is_win32:
234         if conf.env['PREFIX'].lower() == tempfile.gettempdir().lower():
235             # overwrite default prefix on Windows (tempfile.gettempdir() is the Waf default)
236             new_prefix = os.path.join(str(conf.root), '%s-%s' % (APPNAME, VERSION))
237             _add_to_env_and_define(conf, 'PREFIX', new_prefix, quote=True)
238             _add_to_env_and_define(conf, 'BINDIR', os.path.join(new_prefix, 'bin'), quote=True)
239         _add_to_env_and_define(conf, 'DOCDIR', os.path.join(conf.env['PREFIX'], 'doc'), quote=True)
240         _add_to_env_and_define(conf, 'LIBDIR', conf.env['PREFIX'], quote=True)
241         conf.define('LOCALEDIR', os.path.join('share' 'locale'), quote=True)
242         # overwrite LOCALEDIR to install message catalogues properly
243         conf.env['LOCALEDIR'] = os.path.join(conf.env['PREFIX'], 'share/locale')
244         # DATADIR is defined in objidl.h, so we remove it from config.h but keep it in env
245         conf.undefine('DATADIR')
246         conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'data')
247         conf.env.append_value('LINKFLAGS_cprogram', ['-mwindows'])
248         conf.env.append_value('LIB_WIN32', ['wsock32', 'uuid', 'ole32', 'iberty'])
249     else:
250         conf.env['cshlib_PATTERN'] = '%s.so'
251         # DATADIR and LOCALEDIR are defined by the intltool tool
252         # but they are not added to the environment, so we need to
253         _add_define_to_env(conf, 'DATADIR')
254         _add_define_to_env(conf, 'LOCALEDIR')
255         docdir = os.path.join(conf.env['DATADIR'], 'doc', 'geany')
256         libdir = os.path.join(conf.env['PREFIX'], 'lib')
257         mandir = os.path.join(conf.env['DATADIR'], 'man')
258         _define_from_opt(conf, 'DOCDIR', conf.options.docdir, docdir)
259         _define_from_opt(conf, 'LIBDIR', conf.options.libdir, libdir)
260         _define_from_opt(conf, 'MANDIR', conf.options.mandir, mandir)
262     revision = _get_git_rev(conf)
264     conf.define('ENABLE_NLS', 1)
265     conf.define('GEANY_LOCALEDIR', '' if is_win32 else conf.env['LOCALEDIR'], quote=True)
266     conf.define('GEANY_DATADIR', 'data' if is_win32 else conf.env['DATADIR'], quote=True)
267     conf.define('GEANY_DOCDIR', conf.env['DOCDIR'], quote=True)
268     conf.define('GEANY_LIBDIR', '' if is_win32 else conf.env['LIBDIR'], quote=True)
269     conf.define('GEANY_PREFIX', '' if is_win32 else conf.env['PREFIX'], quote=True)
270     conf.define('PACKAGE', APPNAME, quote=True)
271     conf.define('VERSION', VERSION, quote=True)
272     conf.define('REVISION', revision or '-1', quote=True)
274     conf.define('GETTEXT_PACKAGE', APPNAME, quote=True)
276     # no VTE on Windows
277     if is_win32:
278         conf.options.no_vte = True
280     _define_from_opt(conf, 'HAVE_PLUGINS', not conf.options.no_plugins, None)
281     _define_from_opt(conf, 'HAVE_SOCKET', not conf.options.no_socket, None)
282     _define_from_opt(conf, 'HAVE_VTE', not conf.options.no_vte, None)
284     conf.write_config_header('config.h', remove=False)
286     # some more compiler flags
287     conf.env.append_value('CFLAGS', ['-DHAVE_CONFIG_H'])
288     if revision is not None:
289         conf.env.append_value('CFLAGS', ['-g', '-DGEANY_DEBUG'])
290     # Scintilla flags
291     conf.env.append_value('CFLAGS', ['-DGTK'])
292     conf.env.append_value('CXXFLAGS',
293         ['-DNDEBUG', '-DGTK', '-DSCI_LEXER', '-DG_THREADS_IMPL_NONE'])
295     # summary
296     Logs.pprint('BLUE', 'Summary:')
297     conf.msg('Install Geany ' + VERSION + ' in', conf.env['PREFIX'])
298     conf.msg('Using GTK version', gtk_version)
299     conf.msg('Build with plugin support', conf.options.no_plugins and 'no' or 'yes')
300     conf.msg('Use virtual terminal support', conf.options.no_vte and 'no' or 'yes')
301     if revision is not None:
302         conf.msg('Compiling Git revision', revision)
305 def options(opt):
306     # Disable MSVC detection on win32: building Geany with MSVC is currently not supported
307     # If anyone wants to add support for building with MSVC, this hack should be removed.
308     c_compiler['win32'] = ['gcc']
309     cxx_compiler['win32'] = ['g++']
311     opt.load('compiler_cc')
312     opt.load('compiler_cxx')
313     opt.load('intltool')
315     # Features
316     opt.add_option('--disable-plugins', action='store_true', default=False,
317         help='compile without plugin support [default: No]', dest='no_plugins')
318     opt.add_option('--disable-socket', action='store_true', default=False,
319         help='compile without support to detect a running instance [[default: No]',
320         dest='no_socket')
321     opt.add_option('--disable-vte', action='store_true', default=False,
322         help='compile without support for an embedded virtual terminal [[default: No]',
323         dest='no_vte')
324     opt.add_option('--enable-gtk3', action='store_true', default=False,
325         help='compile with GTK3 support (experimental) [[default: No]',
326         dest='use_gtk3')
327     # Paths
328     opt.add_option('--mandir', type='string', default='',
329         help='man documentation', dest='mandir')
330     opt.add_option('--docdir', type='string', default='',
331         help='documentation root', dest='docdir')
332     opt.add_option('--libdir', type='string', default='',
333         help='object code libraries', dest='libdir')
334     # Actions
335     opt.add_option('--hackingdoc', action='store_true', default=False,
336         help='generate HTML documentation from HACKING file', dest='hackingdoc')
339 def build(bld):
340     is_win32 = _target_is_win32(bld)
342     if bld.cmd == 'clean':
343         _remove_linguas_file()
344     if bld.cmd in ('install', 'uninstall'):
345         bld.add_post_fun(_post_install)
347     def build_plugin(plugin_name, install=True):
348         if install:
349             instpath = '${PREFIX}/lib' if is_win32 else '${LIBDIR}/geany'
350         else:
351             instpath = None
353         bld(
354             features                = ['c', 'cshlib'],
355             source                  = 'plugins/%s.c' % plugin_name,
356             includes                = ['.', 'src/', 'scintilla/include', 'tagmanager/src'],
357             defines                 = 'G_LOG_DOMAIN="%s"' % plugin_name,
358             target                  = plugin_name,
359             uselib                  = ['GTK', 'GLIB', 'GMODULE'],
360             install_path            = instpath)
362     # CTags
363     bld(
364         features        = ['c', 'cstlib'],
365         source          = ctags_sources,
366         name            = 'ctags',
367         target          = 'ctags',
368         includes        = ['.', 'tagmanager', 'tagmanager/ctags'],
369         defines         = 'G_LOG_DOMAIN="CTags"',
370         uselib          = ['GLIB'],
371         install_path    = None)  # do not install this library
373     # Tagmanager
374     bld(
375         features        = ['c', 'cstlib'],
376         source          = tagmanager_sources,
377         name            = 'tagmanager',
378         target          = 'tagmanager',
379         includes        = ['.', 'tagmanager', 'tagmanager/ctags'],
380         defines         = 'G_LOG_DOMAIN="Tagmanager"',
381         uselib          = ['GTK', 'GLIB'],
382         install_path    = None)  # do not install this library
384     # MIO
385     bld(
386         features        = ['c', 'cstlib'],
387         source          = mio_sources,
388         name            = 'mio',
389         target          = 'mio',
390         includes        = ['.', 'tagmanager/mio/'],
391         defines         = 'G_LOG_DOMAIN="MIO"',
392         uselib          = ['GTK', 'GLIB'],
393         install_path    = None)  # do not install this library
395     # Scintilla
396     files = bld.srcnode.ant_glob('scintilla/**/*.cxx', src=True, dir=False)
397     scintilla_sources.update(files)
398     bld(
399         features        = ['c', 'cxx', 'cxxstlib'],
400         name            = 'scintilla',
401         target          = 'scintilla',
402         source          = scintilla_sources,
403         includes        = ['.', 'scintilla/include', 'scintilla/src', 'scintilla/lexlib'],
404         uselib          = ['GTK', 'GLIB', 'GMODULE'],
405         install_path    = None)  # do not install this library
407     # Geany
408     if bld.env['HAVE_VTE'] == 1:
409         geany_sources.add('src/vte.c')
410     if is_win32:
411         geany_sources.add('src/win32.c')
412         geany_sources.add('geany_private.rc')
414     bld(
415         features        = ['c', 'cxx', 'cprogram'],
416         name            = 'geany',
417         target          = 'geany',
418         source          = geany_sources,
419         includes        = ['.', 'scintilla/include', 'tagmanager/src'],
420         defines         = ['G_LOG_DOMAIN="Geany"', 'GEANY_PRIVATE'],
421         uselib          = ['GTK', 'GLIB', 'GMODULE', 'GIO', 'GTHREAD', 'WIN32', 'SUNOS_SOCKET'],
422         use             = ['scintilla', 'ctags', 'tagmanager', 'mio'])
424     # geanyfunctions.h
425     bld(
426         source  = ['plugins/genapi.py', 'src/plugins.c'],
427         name    = 'geanyfunctions.h',
428         before  = ['c', 'cxx'],
429         cwd     = '%s/plugins' % bld.path.abspath(),
430         rule    = '%s genapi.py -q' % sys.executable)
432     # Plugins
433     if bld.env['HAVE_PLUGINS'] == 1:
434         build_plugin('classbuilder')
435         build_plugin('demoplugin', False)
436         build_plugin('export')
437         build_plugin('filebrowser')
438         build_plugin('htmlchars')
439         build_plugin('saveactions')
440         build_plugin('splitwindow')
442     # Translations
443     if bld.env['INTLTOOL']:
444         bld(
445             features        = ['linguas', 'intltool_po'],
446             podir           = 'po',
447             install_path    = '${LOCALEDIR}',
448             appname         = 'geany')
450     # geany.pc
451     bld(
452         source          = 'geany.pc.in',
453         dct             = {'VERSION': VERSION,
454                            'DEPENDENCIES': '%s >= %s glib-2.0 >= %s' % \
455                                 (bld.env['gtk_package_name'],
456                                  bld.env['minimum_gtk_version'],
457                                  MINIMUM_GLIB_VERSION),
458                            'prefix': bld.env['PREFIX'],
459                            'exec_prefix': '${prefix}',
460                            'libdir': '${exec_prefix}/lib',
461                            'includedir': '${prefix}/include',
462                            'datarootdir': '${prefix}/share',
463                            'datadir': '${datarootdir}',
464                            'localedir': '${datarootdir}/locale'})
466     if not is_win32:
467         # geany.desktop
468         if bld.env['INTLTOOL']:
469             bld(
470                 features        = 'intltool_in',
471                 source          = 'geany.desktop.in',
472                 flags           = ['-d', '-q', '-u', '-c'],
473                 install_path    = '${DATADIR}/applications')
475         # geany.1
476         bld(
477             features        = 'subst',
478             source          = 'doc/geany.1.in',
479             target          = 'geany.1',
480             dct             = {'VERSION': VERSION,
481                                 'GEANY_DATA_DIR': bld.env['DATADIR'] + '/geany'},
482             install_path    = '${MANDIR}/man1')
484         # geany.spec
485         bld(
486             features        = 'subst',
487             source          = 'geany.spec.in',
488             target          = 'geany.spec',
489             install_path    = None,
490             dct             = {'VERSION': VERSION})
492         # Doxyfile
493         bld(
494             features        = 'subst',
495             source          = 'doc/Doxyfile.in',
496             target          = 'doc/Doxyfile',
497             install_path    = None,
498             dct             = {'VERSION': VERSION})
500     ###
501     # Install files
502     ###
503     if not is_win32:
504         # Headers
505         bld.install_files('${PREFIX}/include/geany', '''
506             src/document.h src/editor.h src/encodings.h src/filetypes.h src/geany.h
507             src/highlighting.h src/keybindings.h src/msgwindow.h src/plugindata.h
508             src/prefs.h src/project.h src/search.h src/stash.h src/support.h
509             src/templates.h src/toolbar.h src/ui_utils.h src/utils.h src/build.h src/gtkcompat.h
510             plugins/geanyplugin.h plugins/geanyfunctions.h''')
511         bld.install_files('${PREFIX}/include/geany/scintilla', '''
512             scintilla/include/SciLexer.h scintilla/include/Scintilla.h
513             scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''')
514         bld.install_files('${PREFIX}/include/geany/tagmanager', '''
515             tagmanager/src/tm_file_entry.h tagmanager/src/tm_project.h
516             tagmanager/src/tm_source_file.h
517             tagmanager/src/tm_symbol.h tagmanager/src/tm_tag.h
518             tagmanager/src/tm_tagmanager.h tagmanager/src/tm_work_object.h
519             tagmanager/src/tm_workspace.h ''')
520     # Docs
521     base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
522     ext = '.txt' if is_win32 else ''
523     html_dir = '' if is_win32 else 'html/'
524     html_name = 'Manual.html' if is_win32 else 'index.html'
525     for filename in 'AUTHORS ChangeLog COPYING README NEWS THANKS TODO'.split():
526         basename = _uc_first(filename, bld)
527         destination_filename = '%s%s' % (basename, ext)
528         destination = os.path.join(base_dir, destination_filename)
529         bld.install_as(destination, filename)
531     start_dir = bld.path.find_dir('doc/images')
532     bld.install_files('${DOCDIR}/%simages' % html_dir, start_dir.ant_glob('*.png'), cwd=start_dir)
533     bld.install_as('${DOCDIR}/%s' % _uc_first('manual.txt', bld), 'doc/geany.txt')
534     bld.install_as('${DOCDIR}/%s%s' % (html_dir, html_name), 'doc/geany.html')
535     bld.install_as('${DOCDIR}/ScintillaLicense.txt', 'scintilla/License.txt')
536     if is_win32:
537         bld.install_as('${DOCDIR}/ReadMe.I18n.txt', 'README.I18N')
538         bld.install_as('${DOCDIR}/Hacking.txt', 'HACKING')
539     # Data
540     data_dir = '' if is_win32 else 'geany'
541     start_dir = bld.path.find_dir('data')
542     bld.install_as('${DATADIR}/%s/GPL-2' % data_dir, 'COPYING')
543     bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('filetype*'), cwd=start_dir)
544     bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('*.tags'), cwd=start_dir)
545     bld.install_files('${DATADIR}/%s' % data_dir, 'data/geany.glade')
546     bld.install_files('${DATADIR}/%s' % data_dir, 'data/snippets.conf')
547     bld.install_files('${DATADIR}/%s' % data_dir, 'data/ui_toolbar.xml')
548     if bld.env['use_gtk3']:
549         bld.install_files('${DATADIR}/%s' % data_dir, 'data/geany.css')
550     else:
551         bld.install_files('${DATADIR}/%s' % data_dir, 'data/geany.gtkrc')
553     start_dir = bld.path.find_dir('data/colorschemes')
554     template_dest = '${DATADIR}/%s/colorschemes' % data_dir
555     bld.install_files(template_dest, start_dir.ant_glob('*'), cwd=start_dir)
556     start_dir = bld.path.find_dir('data/templates')
557     template_dest = '${DATADIR}/%s/templates' % data_dir
558     bld.install_files(template_dest, start_dir.ant_glob('**/*'), cwd=start_dir, relative_trick=True)
559     # Icons
560     for dest, srcs in geany_icons.items():
561         dest_dir = os.path.join('${PREFIX}/share/icons' if is_win32 else '${DATADIR}/icons', dest)
562         bld.install_files(dest_dir, srcs, cwd=bld.path.find_dir('icons'))
563     # install theme indexes on Windows
564     if is_win32:
565         for dest, srcs in geany_icons_indexes.items():
566             bld.install_files(os.path.join('${PREFIX}/share/icons', dest), srcs, cwd=bld.path.find_dir('icons'))
569 def distclean(ctx):
570     Scripting.distclean(ctx)
571     _remove_linguas_file()
574 def _remove_linguas_file():
575     # remove LINGUAS file as well
576     try:
577         os.unlink(LINGUAS_FILE)
578     except OSError:
579         pass
582 @feature('linguas')
583 @before_method('apply_intltool_po')
584 def write_linguas_file(self):
585     if os.path.exists(LINGUAS_FILE):
586         return
587     linguas = ''
588     if 'LINGUAS' in self.env:
589         files = self.env['LINGUAS']
590         for po_filename in files.split(' '):
591             if os.path.exists('po/%s.po' % po_filename):
592                 linguas += '%s ' % po_filename
593     else:
594         files = os.listdir('%s/po' % self.path.abspath())
595         files.sort()
596         for filename in files:
597             if filename.endswith('.po'):
598                 linguas += '%s ' % filename[:-3]
599     file_h = open(LINGUAS_FILE, 'w')
600     file_h.write('# This file is autogenerated. Do not edit.\n%s\n' % linguas)
601     file_h.close()
604 def _post_install(ctx):
605     is_win32 = _target_is_win32(ctx)
606     if is_win32:
607         return
608     for d in 'hicolor', 'Tango':
609         theme_dir = Utils.subst_vars('${DATADIR}/icons/' + d, ctx.env)
610         icon_cache_updated = False
611         if not ctx.options.destdir:
612             ctx.exec_command('gtk-update-icon-cache -q -f -t %s' % theme_dir)
613             Logs.pprint('GREEN', 'GTK icon cache updated.')
614             icon_cache_updated = True
615         if not icon_cache_updated:
616             Logs.pprint('YELLOW', 'Icon cache not updated. After install, run this:')
617             Logs.pprint('YELLOW', 'gtk-update-icon-cache -q -f -t %s' % theme_dir)
620 def updatepo(ctx):
621     """update the message catalogs for internationalization"""
622     potfile = '%s.pot' % APPNAME
623     os.chdir('%s/po' % top)
624     try:
625         try:
626             old_size = os.stat(potfile).st_size
627         except OSError:
628             old_size = 0
629         ctx.exec_command('intltool-update --pot -g %s' % APPNAME)
630         size_new = os.stat(potfile).st_size
631         if size_new != old_size:
632             Logs.pprint('CYAN', 'Updated POT file.')
633             Logs.pprint('CYAN', 'Updating translations')
634             ret = ctx.exec_command('intltool-update -r -g %s' % APPNAME)
635             if ret != 0:
636                 Logs.pprint('RED', 'Updating translations failed')
637         else:
638             Logs.pprint('CYAN', 'POT file is up to date.')
639     except OSError:
640         Logs.pprint('RED', 'Failed to generate pot file.')
643 def apidoc(ctx):
644     """generate API reference documentation"""
645     basedir = ctx.path.abspath()
646     doxygen = _find_program(ctx, 'doxygen')
647     doxyfile = '%s/%s/doc/Doxyfile' % (basedir, out)
648     os.chdir('doc')
649     Logs.pprint('CYAN', 'Generating API documentation')
650     ret = ctx.exec_command('%s %s' % (doxygen, doxyfile))
651     if ret != 0:
652         raise WafError('Generating API documentation failed')
653     # update hacking.html
654     cmd = _find_rst2html(ctx)
655     ctx.exec_command('%s  -stg --stylesheet=geany.css %s %s' % (cmd, '../HACKING', 'hacking.html'))
656     os.chdir('..')
659 def htmldoc(ctx):
660     """generate HTML documentation"""
661     # first try rst2html.py as it is the upstream default, fall back to rst2html
662     cmd = _find_rst2html(ctx)
663     os.chdir('doc')
664     Logs.pprint('CYAN', 'Generating HTML documentation')
665     ctx.exec_command('%s  -stg --stylesheet=geany.css %s %s' % (cmd, 'geany.txt', 'geany.html'))
666     os.chdir('..')
669 def _find_program(ctx, cmd, **kw):
670     def noop(*args):
671         pass
673     ctx = ConfigurationContext()
674     ctx.to_log = noop
675     ctx.msg = noop
676     return ctx.find_program(cmd, **kw)
679 def _find_rst2html(ctx):
680     cmds = ['rst2html.py', 'rst2html']
681     for command in cmds:
682         cmd = _find_program(ctx, command, mandatory=False)
683         if cmd:
684             break
685     if not cmd:
686         raise WafError(
687             'rst2html.py could not be found. Please install the Python docutils package.')
688     return cmd
691 def _add_define_to_env(conf, key):
692     value = conf.get_define(key)
693     # strip quotes
694     value = value.replace('"', '')
695     conf.env[key] = value
698 def _add_to_env_and_define(conf, key, value, quote=False):
699     conf.define(key, value, quote)
700     conf.env[key] = value
703 def _define_from_opt(conf, define_name, opt_value, default_value, quote=1):
704     value = default_value
705     if opt_value:
706         if isinstance(opt_value, bool):
707             opt_value = 1
708         value = opt_value
710     if value is not None:
711         _add_to_env_and_define(conf, define_name, value, quote)
712     else:
713         conf.undefine(define_name)
716 def _get_git_rev(conf):
717     if not os.path.isdir('.git'):
718         return
720     try:
721         cmd = 'git rev-parse --short --revs-only HEAD'
722         revision = conf.cmd_and_log(cmd).strip()
723     except WafError:
724         return None
725     else:
726         return revision
729 def _load_intltool_if_available(conf):
730     try:
731         conf.load('intltool')
732         if 'LINGUAS' in os.environ:
733             conf.env['LINGUAS'] = os.environ['LINGUAS']
734     except WafError:
735         # on Windows, we don't hard depend on intltool, on all other platforms raise an error
736         if not _target_is_win32(conf):
737             raise
740 def _target_is_win32(ctx):
741     if 'is_win32' in ctx.env:
742         # cached
743         return ctx.env['is_win32']
744     is_win32 = None
745     if sys.platform == 'win32':
746         is_win32 = True
747     if is_win32 is None:
748         if ctx.env and 'CC' in ctx.env:
749             env_cc = ctx.env['CC']
750             if not isinstance(env_cc, str):
751                 env_cc = ''.join(env_cc)
752             is_win32 = (env_cc.find('mingw') != -1)
753     if is_win32 is None:
754         is_win32 = False
755     # cache for future checks
756     ctx.env['is_win32'] = is_win32
757     return is_win32
760 def _uc_first(string, ctx):
761     if _target_is_win32(ctx):
762         return string.title()
763     return string