SF.net SVN: geany:[5399] trunk/wscript

eht16 at users.sourceforge.net eht16 at xxxxx
Thu Nov 11 13:43:47 UTC 2010


Revision: 5399
          http://geany.svn.sourceforge.net/geany/?rev=5399&view=rev
Author:   eht16
Date:     2010-11-11 13:43:47 +0000 (Thu, 11 Nov 2010)

Log Message:
-----------
Update for Waf 1.6.1 and various cleanups und improvements.

Modified Paths:
--------------
    trunk/wscript

Modified: trunk/wscript
===================================================================
--- trunk/wscript	2010-11-11 13:42:36 UTC (rev 5398)
+++ trunk/wscript	2010-11-11 13:43:47 UTC (rev 5399)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #
 # WAF build script - this file is part of Geany, a fast and lightweight IDE
@@ -33,633 +32,687 @@
 
 Missing features: --enable-binreloc, make targets: dist, pdf (in doc/)
 Known issues: Dependency handling is buggy, e.g. if src/document.h is
-			  changed, depending source files are not rebuilt (maybe Waf bug).
+              changed, depending source files are not rebuilt (maybe Waf bug).
 
 The code of this file itself loosely follows PEP 8 with some exceptions
 (line width 100 characters and some other minor things).
 
-Requires WAF 1.5.7 and Python 2.4 (or later).
+Requires WAF 1.6.1 and Python 2.5 (or later).
 """
 
 
-import Build
-import Configure
-import Options
-import Utils
 import sys
 import os
-import shutil
 import tempfile
 from distutils import version
-from TaskGen import taskgen, feature
+from waflib import Logs, Options, Scripting, Utils
+from waflib.Configure import ConfigurationContext
+from waflib.Errors import WafError
+from waflib.TaskGen import feature
 
 
 APPNAME = 'geany'
 VERSION = '0.20'
+LINGUAS_FILE = 'po/LINGUAS'
 
-srcdir = '.'
-blddir = '_build_'
+top = '.'
+out = '_build_'
 
 
-tagmanager_sources = [
-	'tagmanager/args.c', 'tagmanager/abc.c', 'tagmanager/actionscript.c', 'tagmanager/asm.c',
-	'tagmanager/basic.c', 'tagmanager/c.c',
-	'tagmanager/conf.c', 'tagmanager/css.c', 'tagmanager/ctags.c', 'tagmanager/diff.c',
-	'tagmanager/docbook.c', 'tagmanager/entry.c', 'tagmanager/fortran.c', 'tagmanager/get.c',
-	'tagmanager/haskell.c', 'tagmanager/haxe.c', 'tagmanager/html.c', 'tagmanager/js.c',
-	'tagmanager/keyword.c', 'tagmanager/latex.c', 'tagmanager/lregex.c', 'tagmanager/lua.c',
-	'tagmanager/make.c', 'tagmanager/markdown.c', 'tagmanager/matlab.c', 'tagmanager/nsis.c',
-	'tagmanager/nestlevel.c', 'tagmanager/options.c',
-	'tagmanager/parse.c', 'tagmanager/pascal.c', 'tagmanager/r.c',
-	'tagmanager/perl.c', 'tagmanager/php.c', 'tagmanager/python.c', 'tagmanager/read.c',
-	'tagmanager/rest.c', 'tagmanager/ruby.c', 'tagmanager/sh.c', 'tagmanager/sort.c',
-	'tagmanager/sql.c', 'tagmanager/strlist.c', 'tagmanager/txt2tags.c', 'tagmanager/tcl.c',
-	'tagmanager/tm_file_entry.c',
-	'tagmanager/tm_project.c', 'tagmanager/tm_source_file.c', 'tagmanager/tm_symbol.c',
-	'tagmanager/tm_tag.c', 'tagmanager/tm_tagmanager.c', 'tagmanager/tm_work_object.c',
-	'tagmanager/tm_workspace.c', 'tagmanager/vhdl.c', 'tagmanager/verilog.c', 'tagmanager/vstring.c' ]
+tagmanager_sources = set([
+    'tagmanager/args.c', 'tagmanager/abc.c', 'tagmanager/actionscript.c', 'tagmanager/asm.c',
+    'tagmanager/basic.c', 'tagmanager/c.c',
+    'tagmanager/conf.c', 'tagmanager/css.c', 'tagmanager/ctags.c', 'tagmanager/diff.c',
+    'tagmanager/docbook.c', 'tagmanager/entry.c', 'tagmanager/fortran.c', 'tagmanager/get.c',
+    'tagmanager/haskell.c', 'tagmanager/haxe.c', 'tagmanager/html.c', 'tagmanager/js.c',
+    'tagmanager/keyword.c', 'tagmanager/latex.c', 'tagmanager/lregex.c', 'tagmanager/lua.c',
+    'tagmanager/make.c', 'tagmanager/markdown.c', 'tagmanager/matlab.c', 'tagmanager/nsis.c',
+    'tagmanager/nestlevel.c', 'tagmanager/options.c',
+    'tagmanager/parse.c', 'tagmanager/pascal.c', 'tagmanager/r.c',
+    'tagmanager/perl.c', 'tagmanager/php.c', 'tagmanager/python.c', 'tagmanager/read.c',
+    'tagmanager/rest.c', 'tagmanager/ruby.c', 'tagmanager/sh.c', 'tagmanager/sort.c',
+    'tagmanager/sql.c', 'tagmanager/strlist.c', 'tagmanager/txt2tags.c', 'tagmanager/tcl.c',
+    'tagmanager/tm_file_entry.c',
+    'tagmanager/tm_project.c', 'tagmanager/tm_source_file.c', 'tagmanager/tm_symbol.c',
+    'tagmanager/tm_tag.c', 'tagmanager/tm_tagmanager.c', 'tagmanager/tm_work_object.c',
+    'tagmanager/tm_workspace.c', 'tagmanager/vhdl.c', 'tagmanager/verilog.c', 'tagmanager/vstring.c'])
 
-scintilla_sources = [
-	'scintilla/AutoComplete.cxx', 'scintilla/CallTip.cxx', 'scintilla/CellBuffer.cxx',
-	'scintilla/CharClassify.cxx', 'scintilla/ContractionState.cxx', 'scintilla/Decoration.cxx',
-	'scintilla/DocumentAccessor.cxx', 'scintilla/Document.cxx', 'scintilla/Editor.cxx',
-	'scintilla/ExternalLexer.cxx',  'scintilla/Indicator.cxx',  'scintilla/KeyMap.cxx',
-	'scintilla/KeyWords.cxx',
-	'scintilla/LexAda.cxx', 'scintilla/LexAsm.cxx', 'scintilla/LexBash.cxx',
-	'scintilla/LexBasic.cxx', 'scintilla/LexCaml.cxx', 'scintilla/LexCmake.cxx', 'scintilla/LexCPP.cxx',
-	'scintilla/LexCSS.cxx', 'scintilla/LexD.cxx', 'scintilla/LexErlang.cxx', 'scintilla/LexForth.cxx',
-	'scintilla/LexFortran.cxx', 'scintilla/LexHaskell.cxx', 'scintilla/LexHTML.cxx', 'scintilla/LexLisp.cxx',
-	'scintilla/LexLua.cxx', 'scintilla/LexMarkdown.cxx', 'scintilla/LexMatlab.cxx',
-	'scintilla/LexNsis.cxx', 'scintilla/LexOthers.cxx',
-	'scintilla/LexPascal.cxx', 'scintilla/LexPerl.cxx', 'scintilla/LexPython.cxx',
-	'scintilla/LexR.cxx', 'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx',
-	'scintilla/LexTCL.cxx', 'scintilla/LexTxt2tags.cxx',
-	'scintilla/LexVHDL.cxx', 'scintilla/LexVerilog.cxx', 'scintilla/LexYAML.cxx',
-	'scintilla/LineMarker.cxx', 'scintilla/PerLine.cxx',
-	'scintilla/PlatGTK.cxx',
-	'scintilla/PositionCache.cxx', 'scintilla/PropSet.cxx', 'scintilla/RESearch.cxx',
-	'scintilla/RunStyles.cxx', 'scintilla/ScintillaBase.cxx', 'scintilla/ScintillaGTK.cxx',
-	'scintilla/scintilla-marshal.c', 'scintilla/Selection.cxx', 'scintilla/StyleContext.cxx', 'scintilla/Style.cxx',
-	'scintilla/UniConversion.cxx', 'scintilla/ViewStyle.cxx', 'scintilla/WindowAccessor.cxx',
-	'scintilla/XPM.cxx' ]
+scintilla_sources = set([
+    'scintilla/AutoComplete.cxx', 'scintilla/CallTip.cxx', 'scintilla/CellBuffer.cxx',
+    'scintilla/CharClassify.cxx', 'scintilla/ContractionState.cxx', 'scintilla/Decoration.cxx',
+    'scintilla/DocumentAccessor.cxx', 'scintilla/Document.cxx', 'scintilla/Editor.cxx',
+    'scintilla/ExternalLexer.cxx',  'scintilla/Indicator.cxx',  'scintilla/KeyMap.cxx',
+    'scintilla/KeyWords.cxx',
+    'scintilla/LexAda.cxx', 'scintilla/LexAsm.cxx', 'scintilla/LexBash.cxx',
+    'scintilla/LexBasic.cxx', 'scintilla/LexCaml.cxx', 'scintilla/LexCmake.cxx', 'scintilla/LexCPP.cxx',
+    'scintilla/LexCSS.cxx', 'scintilla/LexD.cxx', 'scintilla/LexErlang.cxx', 'scintilla/LexForth.cxx',
+    'scintilla/LexFortran.cxx', 'scintilla/LexHaskell.cxx', 'scintilla/LexHTML.cxx', 'scintilla/LexLisp.cxx',
+    'scintilla/LexLua.cxx', 'scintilla/LexMarkdown.cxx', 'scintilla/LexMatlab.cxx',
+    'scintilla/LexNsis.cxx', 'scintilla/LexOthers.cxx',
+    'scintilla/LexPascal.cxx', 'scintilla/LexPerl.cxx', 'scintilla/LexPython.cxx',
+    'scintilla/LexR.cxx', 'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx',
+    'scintilla/LexTCL.cxx', 'scintilla/LexTxt2tags.cxx',
+    'scintilla/LexVHDL.cxx', 'scintilla/LexVerilog.cxx', 'scintilla/LexYAML.cxx',
+    'scintilla/LineMarker.cxx', 'scintilla/PerLine.cxx',
+    'scintilla/PlatGTK.cxx',
+    'scintilla/PositionCache.cxx', 'scintilla/PropSet.cxx', 'scintilla/RESearch.cxx',
+    'scintilla/RunStyles.cxx', 'scintilla/ScintillaBase.cxx', 'scintilla/ScintillaGTK.cxx',
+    'scintilla/scintilla-marshal.c', 'scintilla/Selection.cxx', 'scintilla/StyleContext.cxx', 'scintilla/Style.cxx',
+    'scintilla/UniConversion.cxx', 'scintilla/ViewStyle.cxx', 'scintilla/WindowAccessor.cxx',
+    'scintilla/XPM.cxx'])
 
-geany_sources = [
-	'src/about.c', 'src/build.c', 'src/callbacks.c', 'src/dialogs.c', 'src/document.c',
-	'src/editor.c', 'src/encodings.c', 'src/filetypes.c', 'src/geanyentryaction.c',
-	'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c',
-	'src/highlighting.c', 'src/interface.c', 'src/keybindings.c',
-	'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
-	'src/plugins.c', 'src/pluginutils.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
-	'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
-	'src/symbols.c',
-	'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/sidebar.c',
-	'src/ui_utils.c', 'src/utils.c' ]
+geany_sources = set([
+    'src/about.c', 'src/build.c', 'src/callbacks.c', 'src/dialogs.c', 'src/document.c',
+    'src/editor.c', 'src/encodings.c', 'src/filetypes.c', 'src/geanyentryaction.c',
+    'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c',
+    'src/highlighting.c', 'src/interface.c', 'src/keybindings.c',
+    'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
+    'src/plugins.c', 'src/pluginutils.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
+    'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
+    'src/symbols.c',
+    'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/sidebar.c',
+    'src/ui_utils.c', 'src/utils.c'])
 
 
 
 def configure(conf):
-	def in_git():
-		cmd = 'git ls-files >/dev/null 2>&1'
-		return (Utils.exec_command(cmd) == 0)
 
-	def in_svn():
-		return os.path.exists('.svn')
+    conf.check_waf_version(mini='1.6.1')
 
-	def conf_get_svn_rev():
-		# try GIT
-		if in_git():
-			cmds = [ 'git svn find-rev HEAD 2>/dev/null',
-					 'git svn find-rev origin/trunk 2>/dev/null',
-					 'git svn find-rev trunk 2>/dev/null',
-					 'git svn find-rev master 2>/dev/null'
-					]
-			for c in cmds:
-				try:
-					stdout = Utils.cmd_output(c)
-					if stdout:
-						return stdout.strip()
-				except:
-					pass
-		# try SVN
-		elif in_svn():
-			try:
-				_env = None if is_win32 else {'LANG' : 'C'}
-				stdout = Utils.cmd_output(cmd='svn info --non-interactive', silent=True, env=_env)
-				lines = stdout.splitlines(True)
-				for line in lines:
-					if line.startswith('Last Changed Rev'):
-						key, value = line.split(': ', 1)
-						return value.strip()
-			except:
-				pass
-		else:
-			pass
-		return '-1'
+    conf.load('compiler_c')
+    is_win32 = _target_is_win32(conf)
 
-	def conf_define_from_opt(define_name, opt_name, default_value, quote=1):
-		if opt_name:
-			if isinstance(opt_name, bool):
-				opt_name = 1
-			conf.define(define_name, opt_name, quote)
-		elif default_value:
-			conf.define(define_name, default_value, quote)
+    conf.check_cc(header_name='fcntl.h')
+    conf.check_cc(header_name='fnmatch.h')
+    conf.check_cc(header_name='glob.h')
+    conf.check_cc(header_name='sys/time.h')
+    conf.check_cc(header_name='sys/types.h')
+    conf.check_cc(header_name='sys/stat.h')
+    conf.define('HAVE_STDLIB_H', 1) # are there systems without stdlib.h?
+    conf.define('STDC_HEADERS', 1) # an optimistic guess ;-)
 
+    if conf.options.gnu_regex:
+        _add_to_env_and_define(conf, 'HAVE_REGCOMP', 1)
+        _add_to_env_and_define(conf, 'USE_INCLUDED_REGEX', 1)
+    else:
+        conf.check_cc(header_name='regex.h')
+        if conf.env['HAVE_REGEX_H'] == 1:
+            conf.check_cc(function_name='regcomp', header_name='regex.h')
+        # fallback to included regex lib
+        if conf.env['HAVE_REGCOMP'] != 1 or conf.env['HAVE_REGEX_H'] != 1:
+            conf.define('HAVE_REGCOMP', 1)
+            conf.define('USE_INCLUDED_REGEX', 1)
 
-	conf.check_tool('compiler_cc')
-	is_win32 = target_is_win32(conf.env)
+    conf.check_cc(function_name='fgetpos', header_name='stdio.h')
+    conf.check_cc(function_name='ftruncate', header_name='unistd.h')
+    conf.check_cc(function_name='gethostname', header_name='unistd.h')
+    conf.check_cc(function_name='mkstemp', header_name='stdlib.h')
+    conf.check_cc(function_name='strstr', header_name='string.h', mandatory=True)
 
-	conf.check(header_name='fcntl.h')
-	conf.check(header_name='fnmatch.h')
-	conf.check(header_name='glob.h')
-	conf.check(header_name='sys/time.h')
-	conf.check(header_name='sys/types.h')
-	conf.check(header_name='sys/stat.h')
-	conf.define('HAVE_STDLIB_H', 1) # are there systems without stdlib.h?
-	conf.define('STDC_HEADERS', 1) # an optimistic guess ;-)
+    # check sunOS socket support
+    if Options.platform == 'sunos':
+        conf.check_cc(function_name='socket', lib='socket',
+                      header_name='sys/socket.h', uselib_store='SUNOS_SOCKET', mandatory=True)
 
-	if Options.options.gnu_regex:
-		conf.define('HAVE_REGCOMP', 1, 0)
-		conf.define('USE_INCLUDED_REGEX', 1, 0)
-	else:
-		conf.check(header_name='regex.h')
-		if conf.env['HAVE_REGEX_H'] == 1:
-			conf.check(function_name='regcomp', header_name='regex.h')
-		# fallback to included regex lib
-		if conf.env['HAVE_REGCOMP'] != 1 or conf.env['HAVE_REGEX_H'] != 1:
-			conf.define('HAVE_REGCOMP', 1, 0)
-			conf.define('USE_INCLUDED_REGEX', 1, 0)
+    # check for cxx after the header and function checks have been done to ensure they are
+    # checked with cc not cxx
+    conf.load('compiler_cxx')
+    if is_win32:
+        conf.load('winres')
+    _load_intltool_if_available(conf)
 
-	conf.check(function_name='fgetpos', header_name='stdio.h')
-	conf.check(function_name='ftruncate', header_name='unistd.h')
-	conf.check(function_name='gethostname', header_name='unistd.h')
-	conf.check(function_name='mkstemp', header_name='stdlib.h')
-	conf.check(function_name='strstr', header_name='string.h', mandatory=True)
+    # GTK / GIO version check
+    conf.check_cfg(package='gtk+-2.0', atleast_version='2.8.0', uselib_store='GTK',
+        mandatory=True, args='--cflags --libs')
+    have_gtk_210 = False
+    gtk_version = conf.check_cfg(modversion='gtk+-2.0', uselib_store='GTK')
+    if gtk_version:
+        if version.LooseVersion(gtk_version) >= version.LooseVersion('2.10.0'):
+            have_gtk_210 = True
+    else:
+        gtk_version = 'Unknown'
+    conf.check_cfg(package='gio-2.0', uselib_store='GIO', args='--cflags --libs', mandatory=False)
 
-	# check sunOS socket support
-	if Options.platform == 'sunos':
-		conf.check(function_name='socket', lib='socket',
-			header_name='sys/socket.h', uselib_store='SUNOS_SOCKET', mandatory=True)
+    # Windows specials
+    if is_win32:
+        if conf.env['PREFIX'].lower() == tempfile.gettempdir().lower():
+            # overwrite default prefix on Windows (tempfile.gettempdir() is the Waf default)
+            new_prefix = os.path.join(str(conf.root), '%s-%s' % (APPNAME, VERSION))
+            _add_to_env_and_define(conf, 'PREFIX', new_prefix, quote=True)
+        _add_to_env_and_define(conf, 'DOCDIR', os.path.join(conf.env['PREFIX'], 'doc'), quote=True)
+        _add_to_env_and_define(conf, 'LIBDIR', conf.env['PREFIX'], quote=True)
+        conf.define('LOCALEDIR', os.path.join('share' 'locale'), quote=True)
+        # overwrite LOCALEDIR to install message catalogues properly
+        conf.env['LOCALEDIR'] = os.path.join(conf.env['PREFIX'], 'share/locale')
+        # DATADIR is defined in objidl.h, so we remove it from config.h but keep it in env
+        conf.undefine('DATADIR')
+        conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'data')
+        # TODO
+        # hack: we add the parent directory of the first include directory as this is missing in
+        # list returned from pkg-config
+        conf.env['CPPPATH_GTK'].insert(0, os.path.dirname(conf.env['CPPPATH_GTK'][0]))
+        # we don't need -fPIC when compiling on or for Windows
+        if '-fPIC' in conf.env['CFLAGS_cshlib']:
+            conf.env['CFLAGS_cshlib'].remove('-fPIC')
+        if '-fPIC' in conf.env['CXXFLAGS_cxxshlib']:
+            conf.env['CXXFLAGS_cxxshlib'].remove('-fPIC')
+        conf.env.append_value('program_LINKFLAGS', '-mwindows')
+        conf.env.append_value('LIB_WIN32', ['wsock32', 'uuid', 'ole32', 'iberty'])
+        conf.env['cshlib_PATTERN'] = '%s.dll'
+    else:
+        conf.env['cshlib_PATTERN'] = '%s.so'
+        # DATADIR and LOCALEDIR are defined by the intltool tool
+        # but they are not added to the environment, so we need to
+        _add_define_to_env(conf, 'DATADIR')
+        _add_define_to_env(conf, 'LOCALEDIR')
+        docdir = os.path.join(conf.env['DATADIR'], 'doc', 'geany')
+        libdir = os.path.join(conf.env['PREFIX'], 'lib')
+        mandir = os.path.join(conf.env['DATADIR'], 'man')
+        _define_from_opt(conf, 'DOCDIR', conf.options.docdir, docdir)
+        _define_from_opt(conf, 'LIBDIR', conf.options.libdir, libdir)
+        _define_from_opt(conf, 'MANDIR', conf.options.mandir, mandir)
 
-	# check for cxx after the header and function checks have been done to ensure they are
-	# checked with cc not cxx
-	conf.check_tool('compiler_cxx misc')
-	if is_win32:
-		conf.check_tool('winres')
-	# we don't require intltool on Windows (it would require Perl) though it works well
-	try:
-		conf.check_tool('intltool')
-		if 'LINGUAS' in os.environ:
-			conf.env['LINGUAS'] = os.environ['LINGUAS']
-	except Configure.ConfigurationError:
-		if not is_win32:
-			raise
+    svn_rev = _get_svn_rev(conf)
 
-	# GTK / GIO version check
-	conf.check_cfg(package='gtk+-2.0', atleast_version='2.8.0', uselib_store='GTK',
-		mandatory=True, args='--cflags --libs')
-	have_gtk_210 = False
-	gtk_version = conf.check_cfg(modversion='gtk+-2.0', uselib_store='GTK')
-	if gtk_version:
-		if version.LooseVersion(gtk_version) >= version.LooseVersion('2.10.0'):
-			have_gtk_210 = True
-	else:
-		gtk_version = 'Unknown'
-	conf.check_cfg(package='gio-2.0', uselib_store='GIO', args='--cflags --libs', mandatory=False)
+    conf.define('ENABLE_NLS', 1)
+    conf.define('GEANY_LOCALEDIR', '' if is_win32 else conf.env['LOCALEDIR'], quote=True)
+    conf.define('GEANY_DATADIR', 'data' if is_win32 else conf.env['DATADIR'], quote=True)
+    conf.define('GEANY_DOCDIR', conf.env['DOCDIR'], quote=True)
+    conf.define('GEANY_LIBDIR', '' if is_win32 else conf.env['LIBDIR'], quote=True)
+    conf.define('GEANY_PREFIX', '' if is_win32 else conf.env['PREFIX'], quote=True)
+    conf.define('PACKAGE', APPNAME, quote=True)
+    conf.define('VERSION', VERSION, quote=True)
+    conf.define('REVISION', str(svn_rev), quote=True)
 
-	# Windows specials
-	if is_win32:
-		if conf.env['PREFIX'] == tempfile.gettempdir():
-			# overwrite default prefix on Windows (tempfile.gettempdir() is the Waf default)
-			conf.define('PREFIX', os.path.join(conf.srcdir, '%s-%s' % (APPNAME, VERSION)), 1)
-		conf.define('DOCDIR', os.path.join(conf.env['PREFIX'], 'doc'), 1)
-		conf.define('LOCALEDIR', os.path.join(conf.env['PREFIX'], 'share\locale'), 1)
-		conf.define('LIBDIR', conf.env['PREFIX'], 1)
-		# DATADIR is defined in objidl.h, so we remove it from config.h but keep it in env
-		conf.undefine('DATADIR')
-		conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'data')
-		# hack: we add the parent directory of the first include directory as this is missing in
-		# list returned from pkg-config
-		conf.env['CPPPATH_GTK'].insert(0, os.path.dirname(conf.env['CPPPATH_GTK'][0]))
-		# we don't need -fPIC when compiling on or for Windows
-		if '-fPIC' in conf.env['shlib_CCFLAGS']:
-			conf.env['shlib_CCFLAGS'].remove('-fPIC')
-		if '-fPIC' in conf.env['CXXFLAGS']:
-			conf.env['CXXFLAGS'].remove('-fPIC')
-		conf.env.append_value('program_LINKFLAGS', '-mwindows')
-		conf.env.append_value('LIB_WIN32', [ 'wsock32', 'uuid', 'ole32', 'iberty' ])
-		conf.env['shlib_PATTERN'] = '%s.dll'
-		conf.env['program_PATTERN'] = '%s.exe'
-	else:
-		conf.env['shlib_PATTERN'] = '%s.so'
-		conf_define_from_opt('DOCDIR', Options.options.docdir,
-			os.path.join(conf.env['DATADIR'], 'doc/geany'))
-		conf_define_from_opt('LIBDIR', Options.options.libdir,
-			os.path.join(conf.env['PREFIX'], 'lib'))
-		conf_define_from_opt('MANDIR', Options.options.mandir,
-			os.path.join(conf.env['DATADIR'], 'man'))
+    conf.define('GETTEXT_PACKAGE', APPNAME, quote=True)
 
-	svn_rev = conf_get_svn_rev()
-	conf.define('ENABLE_NLS', 1)
-	conf.define('GEANY_LOCALEDIR', '' if is_win32 else conf.env['LOCALEDIR'], 1)
-	conf.define('GEANY_DATADIR', 'data' if is_win32 else conf.env['DATADIR'], 1)
-	conf.define('GEANY_DOCDIR', conf.env['DOCDIR'], 1)
-	conf.define('GEANY_LIBDIR', '' if is_win32 else conf.env['LIBDIR'], 1)
-	conf.define('GEANY_PREFIX', '' if is_win32 else conf.env['PREFIX'], 1)
-	conf.define('PACKAGE', APPNAME, 1)
-	conf.define('VERSION', VERSION, 1)
-	conf.define('REVISION', svn_rev, 1)
+    _define_from_opt(conf, 'HAVE_PLUGINS', not conf.options.no_plugins, None)
+    _define_from_opt(conf, 'HAVE_SOCKET', not conf.options.no_socket, None)
+    _define_from_opt(conf, 'HAVE_VTE', not conf.options.no_vte, None)
 
-	conf.define('GETTEXT_PACKAGE', APPNAME, 1)
+    conf.env['HAVE_VTE'] = 1
+    conf.write_config_header('config.h', remove=False)
 
-	conf_define_from_opt('HAVE_PLUGINS', not Options.options.no_plugins, None, 0)
-	conf_define_from_opt('HAVE_SOCKET', not Options.options.no_socket, None, 0)
-	conf_define_from_opt('HAVE_VTE', not Options.options.no_vte, None, 0)
+    # some more compiler flags
+    conf.env.append_value('CFLAGS', ['-DHAVE_CONFIG_H'])
+    if svn_rev > -1:
+        conf.env.append_value('CFLAGS', ['-g', '-DGEANY_DEBUG'])
+    # Scintilla flags
+    conf.env.append_value('CFLAGS', ['-DGTK'])
+    conf.env.append_value('CXXFLAGS',
+        ['-DNDEBUG', '-DGTK', '-DGTK2', '-DSCI_LEXER', '-DG_THREADS_IMPL_NONE'])
 
-	conf.write_config_header('config.h')
+    # summary
+    Logs.pprint('BLUE', 'Summary:')
+    conf.msg('Install Geany ' + VERSION + ' in', conf.env['PREFIX'])
+    conf.msg('Using GTK version', gtk_version)
+    conf.msg('Build with GTK printing support', have_gtk_210 and 'yes' or 'no')
+    conf.msg('Build with plugin support', conf.options.no_plugins and 'no' or 'yes')
+    conf.msg('Use virtual terminal support', conf.options.no_vte and 'no' or 'yes')
+    conf.msg('GNU regex library', conf.env['USE_INCLUDED_REGEX'] and 'built-in' or 'system')
+    if svn_rev > -1:
+        conf.msg('Compiling Subversion revision', svn_rev)
 
-	Utils.pprint('BLUE', 'Summary:')
-	print_message(conf, 'Install Geany ' + VERSION + ' in', conf.env['PREFIX'])
-	print_message(conf, 'Using GTK version', gtk_version)
-	print_message(conf, 'Build with GTK printing support', have_gtk_210 and 'yes' or 'no')
-	print_message(conf, 'Build with plugin support', Options.options.no_plugins and 'no' or 'yes')
-	print_message(conf, 'Use virtual terminal support', Options.options.no_vte and 'no' or 'yes')
-	print_message(conf, 'GNU regex library', conf.env['USE_INCLUDED_REGEX'] and 'built-in' or 'system')
-	if svn_rev != '-1':
-		print_message(conf, 'Compiling Subversion revision', svn_rev)
-		conf.env.append_value('CCFLAGS', '-g -DGEANY_DEBUG'.split())
 
-	conf.env.append_value('CCFLAGS', '-DHAVE_CONFIG_H')
-	conf.env.append_value('CCFLAGS', '-DGTK') # Scintilla needs this
-	# for now define GEANY_PRIVATE for all files, even though it should just be for src/*.
-	conf.env.append_value('CCFLAGS', '-DGEANY_PRIVATE')
-	# Scintilla flags
-	conf.env.append_value('CXXFLAGS',
-		'-DNDEBUG -DGTK -DGTK2 -DSCI_LEXER -DG_THREADS_IMPL_NONE'.split())
+def options(opt):
+    opt.tool_options('compiler_cc')
+    opt.tool_options('compiler_cxx')
+    opt.tool_options('intltool')
 
+    # Features
+    opt.add_option('--disable-plugins', action='store_true', default=False,
+        help='compile without plugin support [default: No]', dest='no_plugins')
+    opt.add_option('--disable-socket', action='store_true', default=False,
+        help='compile without support to detect a running instance [[default: No]',
+        dest='no_socket')
+    opt.add_option('--disable-vte', action='store_true', default=False,
+        help='compile without support for an embedded virtual terminal [[default: No]',
+        dest='no_vte')
+    opt.add_option('--enable-gnu-regex', action='store_true', default=False,
+        help='compile with included GNU regex library [default: No]', dest='gnu_regex')
+    # Paths
+    opt.add_option('--mandir', type='string', default='',
+        help='man documentation', dest='mandir')
+    opt.add_option('--docdir', type='string', default='',
+        help='documentation root', dest='docdir')
+    opt.add_option('--libdir', type='string', default='',
+        help='object code libraries', dest='libdir')
+    # Actions
+    opt.add_option('--hackingdoc', action='store_true', default=False,
+        help='generate HTML documentation from HACKING file', dest='hackingdoc')
 
-def set_options(opt):
-	opt.tool_options('compiler_cc')
-	opt.tool_options('compiler_cxx')
-	opt.tool_options('intltool')
 
-	if 'configure' in sys.argv:
-		# Features
-		opt.add_option('--disable-plugins', action='store_true', default=False,
-			help='compile without plugin support [default: No]', dest='no_plugins')
-		opt.add_option('--disable-socket', action='store_true', default=False,
-			help='compile without support to detect a running instance [[default: No]',
-			dest='no_socket')
-		opt.add_option('--disable-vte', action='store_true', default=target_is_win32(os.environ),
-			help='compile without support for an embedded virtual terminal [[default: No]',
-			dest='no_vte')
-		opt.add_option('--enable-gnu-regex', action='store_true', default=False,
-			help='compile with included GNU regex library [default: No]', dest='gnu_regex')
-		# Paths
-		opt.add_option('--mandir', type='string', default='',
-			help='man documentation', dest='mandir')
-		opt.add_option('--docdir', type='string', default='',
-			help='documentation root', dest='docdir')
-		opt.add_option('--libdir', type='string', default='',
-			help='object code libraries', dest='libdir')
-	# Actions
-	opt.add_option('--htmldoc', action='store_true', default=False,
-		help='generate HTML documentation', dest='htmldoc')
-	opt.add_option('--hackingdoc', action='store_true', default=False,
-		help='generate HTML documentation from HACKING file', dest='hackingdoc')
-	opt.add_option('--apidoc', action='store_true', default=False,
-		help='generate API reference documentation', dest='apidoc')
-	opt.add_option('--update-po', action='store_true', default=False,
-		help='update the message catalogs for translation', dest='update_po')
+def build(bld):
+    is_win32 = _target_is_win32(bld)
 
+    if bld.cmd == 'clean':
+        _remove_linguas_file()
+    if bld.cmd in ('install', 'uninstall'):
+        bld.add_post_fun(_post_install)
 
-def build(bld):
-	is_win32 = target_is_win32(bld.env)
+    def build_plugin(plugin_name, install=True):
+        if install:
+            instpath = '${PREFIX}/lib' if is_win32 else '${LIBDIR}/geany'
+        else:
+            instpath = None
 
-	def build_plugin(plugin_name, install = True):
-		if install:
-			instpath = '${PREFIX}/lib' if is_win32 else '${LIBDIR}/geany/'
-		else:
-			instpath = None
+        bld.new_task_gen(
+            features                = ['c', 'cshlib'],
+            source                  = 'plugins/%s.c' % plugin_name,
+            includes                = ['.', 'src/', 'scintilla/include', 'tagmanager/include'],
+            defines                 = 'G_LOG_DOMAIN="%s"' % plugin_name,
+            target                  = plugin_name,
+            uselib                  = 'GTK',
+            install_path            = instpath)
 
-		bld.new_task_gen(
-			features				= 'cc cshlib',
-			source					= 'plugins/' + plugin_name + '.c',
-			includes				= '. plugins/ src/ scintilla/include tagmanager/include',
-			defines					= 'G_LOG_DOMAIN="%s"' % plugin_name,
-			target					= plugin_name,
-			uselib					= 'GTK',
-			install_path			= instpath
-		)
 
+    # Tagmanager
+    if bld.env['USE_INCLUDED_REGEX'] == 1:
+        tagmanager_sources.add('tagmanager/regex.c')
+    bld.new_task_gen(
+        features        = ['c', 'cstlib'],
+        source          = tagmanager_sources,
+        name            = 'tagmanager',
+        target          = 'tagmanager',
+        includes        = ['.', 'tagmanager/include/'],
+        defines         = 'G_LOG_DOMAIN="Tagmanager"',
+        uselib          = 'GTK',
+        install_path    = None) # do not install this library
 
-	# Tagmanager
-	if bld.env['USE_INCLUDED_REGEX'] == 1:
-		tagmanager_sources.append('tagmanager/regex.c')
-	bld.new_task_gen(
-		features		= 'cc cstaticlib',
-		source			= tagmanager_sources,
-		name			= 'tagmanager',
-		target			= 'tagmanager',
-		includes		= '. tagmanager/ tagmanager/include/',
-		defines			= 'G_LOG_DOMAIN="Tagmanager"',
-		uselib			= 'GTK',
-		install_path	= None # do not install this library
-	)
 
-	# Scintilla
-	bld.new_task_gen(
-		features		= 'cc cxx cstaticlib',
-		name			= 'scintilla',
-		target			= 'scintilla',
-		source			= scintilla_sources,
-		includes		= 'scintilla/ scintilla/include/',
-		uselib			= 'GTK',
-		install_path	= None, # do not install this library
-	)
+    # Scintilla
+    bld.new_task_gen(
+        features        = ['c', 'cxx', 'cxxstlib'],
+        name            = 'scintilla',
+        target          = 'scintilla',
+        source          = scintilla_sources,
+        includes        = ['.', 'scintilla/include/'],
+        uselib          = 'GTK',
+        install_path    = None) # do not install this library
 
-	# Geany
-	if bld.env['HAVE_VTE'] == 1:
-		geany_sources.append('src/vte.c')
-	if is_win32:
-		geany_sources.append('src/win32.c')
 
-	bld.new_task_gen(
-		features		= 'cc cxx cprogram',
-		name			= 'geany',
-		target			= 'geany',
-		source			= geany_sources,
-		includes		= '. src/ scintilla/include/ tagmanager/include/',
-		defines			= 'G_LOG_DOMAIN="Geany"',
-		uselib			= 'GTK GIO WIN32 SUNOS_SOCKET',
-		uselib_local	= 'scintilla tagmanager',
-		add_objects		= 'geany-rc' if is_win32 else None
-	)
+    # Geany
+    if bld.env['HAVE_VTE'] == 1:
+        geany_sources.add('src/vte.c')
+    if is_win32:
+        geany_sources.add('src/win32.c')
 
-	# geanyfunctions.h
-	bld.new_task_gen(
-		source	= 'plugins/genapi.py src/plugins.c',
-		name	= 'geanyfunctions.h',
-		before	= 'cc cxx',
-		cwd		= '%s/plugins' % bld.path.abspath(),
-		rule	= 'python genapi.py -q'
-	)
+    bld.new_task_gen(
+        features        = ['c', 'cxx', 'cprogram'],
+        name            = 'geany',
+        target          = 'geany',
+        source          = geany_sources,
+        includes        = ['.', 'scintilla/include/', 'tagmanager/include/'],
+        defines         = ['G_LOG_DOMAIN="Geany"', 'GEANY_PRIVATE'],
+        uselib          = ['GTK', 'GIO', 'WIN32', 'SUNOS_SOCKET'],
+        use             = ['scintilla', 'tagmanager'],
+        add_objects     = 'geany-rc' if is_win32 else None)
 
-	# Plugins
-	if bld.env['HAVE_PLUGINS'] == 1:
-		build_plugin('classbuilder')
-		build_plugin('demoplugin', False)
-		build_plugin('export')
-		build_plugin('filebrowser')
-		build_plugin('htmlchars')
-		build_plugin('saveactions')
-		build_plugin('splitwindow', not is_win32)
+    # geanyfunctions.h
+    bld.new_task_gen(
+        source  = ['plugins/genapi.py', 'src/plugins.c'],
+        name    = 'geanyfunctions.h',
+        before  = ['c', 'cxx'],
+        cwd     = '%s/plugins' % bld.path.abspath(),
+        rule    = 'python genapi.py -q')
 
-	# Translations
-	if bld.env['INTLTOOL']:
-		bld.new_task_gen(
-			features		= 'intltool_po',
-			podir			= 'po',
-			install_path	= '${LOCALEDIR}',
-			appname			= 'geany'
-		)
+    # Plugins
+    if bld.env['HAVE_PLUGINS'] == 1:
+        build_plugin('classbuilder')
+        build_plugin('demoplugin', False)
+        build_plugin('export')
+        build_plugin('filebrowser')
+        build_plugin('htmlchars')
+        build_plugin('saveactions')
+        build_plugin('splitwindow', not is_win32)
 
-	# geany.pc
-	bld.new_task_gen(
-		features		= 'subst',
-		source			= 'geany.pc.in',
-		target			= 'geany.pc',
-		dict			= { 'VERSION' : VERSION,
-							'prefix': bld.env['PREFIX'],
-							'exec_prefix': '${prefix}',
-							'libdir': '${exec_prefix}/lib',
-							'includedir': '${prefix}/include',
-							'datarootdir': '${prefix}/share',
-							'datadir': '${datarootdir}',
-							'localedir': '${datarootdir}/locale' },
-		install_path	= None if is_win32 else '${LIBDIR}/pkgconfig'
-	)
+    # Translations
+    if bld.env['INTLTOOL']:
+        bld.new_task_gen(
+            features        = ['linguas', 'intltool_po'],
+            podir           = 'po',
+            install_path    = '${LOCALEDIR}',
+            appname         = 'geany')
 
-	if not is_win32:
-		# geany.desktop
-		if bld.env['INTLTOOL']:
-			bld.new_task_gen(
-				features		= 'intltool_in',
-				source			= 'geany.desktop.in',
-				flags			= [ '-d', '-q', '-u', '-c' ],
-				install_path	= '${DATADIR}/applications'
-			)
+    # geany.pc
+    bld.new_task_gen(
+        source          = 'geany.pc.in',
+        dct             = {'VERSION' : VERSION,
+                           'prefix': bld.env['PREFIX'],
+                           'exec_prefix': '${prefix}',
+                           'libdir': '${exec_prefix}/lib',
+                           'includedir': '${prefix}/include',
+                           'datarootdir': '${prefix}/share',
+                           'datadir': '${datarootdir}',
+                           'localedir': '${datarootdir}/locale'})
+        # TODO test this on win32
+        #install_path    = None if is_win32 else '${LIBDIR}/pkgconfig')
 
-		# geany.1
-		bld.new_task_gen(
-			features		= 'subst',
-			source			= 'doc/geany.1.in',
-			target			= 'geany.1',
-			dict			= { 'VERSION' : VERSION,
-								'GEANY_DATA_DIR': bld.env['DATADIR'] + '/geany' },
-			install_path	= '${MANDIR}/man1'
-		)
+    if is_win32:
+        bld.new_task_gen(
+            features        = 'c',
+            name            = 'geany-rc',
+            source          = 'geany_private.rc')
+    else:
+        # geany.desktop
+        if bld.env['INTLTOOL']:
+            bld.new_task_gen(
+                features        = 'intltool_in',
+                source          = 'geany.desktop.in',
+                flags           = [ '-d', '-q', '-u', '-c' ],
+                install_path    = '${DATADIR}/applications')
 
-		# geany.spec
-		bld.new_task_gen(
-			features		= 'subst',
-			source			= 'geany.spec.in',
-			target			= 'geany.spec',
-			install_path	= None,
-			dict			= { 'VERSION' : VERSION }
-		)
+        # geany.1
+        bld.new_task_gen(
+            features        = 'subst',
+            source          = 'doc/geany.1.in',
+            target          = 'geany.1',
+            dct             = {'VERSION' : VERSION,
+                                'GEANY_DATA_DIR': bld.env['DATADIR'] + '/geany'},
+            install_path    = '${MANDIR}/man1')
 
-		# Doxyfile
-		bld.new_task_gen(
-			features		= 'subst',
-			source			= 'doc/Doxyfile.in',
-			target			= 'doc/Doxyfile',
-			install_path	= None,
-			dict			= { 'VERSION' : VERSION }
-		)
-	else:
-		bld.new_task_gen(
-			features		= 'cc',
-			name			= 'geany-rc',
-			source			= 'geany_private.rc'
-		)
+        # geany.spec
+        bld.new_task_gen(
+            features        = 'subst',
+            source          = 'geany.spec.in',
+            target          = 'geany.spec',
+            install_path    = None,
+            dct             = {'VERSION' : VERSION})
 
-	###
-	# Install files
-	###
-	if not is_win32:
-		# Headers
-		bld.install_files('${PREFIX}/include/geany', '''
-			src/document.h src/editor.h src/encodings.h src/filetypes.h src/geany.h
-			src/highlighting.h src/keybindings.h src/msgwindow.h src/plugindata.h
-			src/prefs.h src/project.h src/search.h src/stash.h src/support.h
-			src/templates.h src/toolbar.h src/ui_utils.h src/utils.h
-			plugins/geanyplugin.h plugins/geanyfunctions.h''')
-		bld.install_files('${PREFIX}/include/geany/scintilla', '''
-			scintilla/include/SciLexer.h scintilla/include/Scintilla.h
-			scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''')
-		bld.install_files('${PREFIX}/include/geany/tagmanager', '''
-			tagmanager/include/tm_file_entry.h tagmanager/include/tm_project.h
-			tagmanager/include/tm_source_file.h
-			tagmanager/include/tm_symbol.h tagmanager/include/tm_tag.h
-			tagmanager/include/tm_tagmanager.h tagmanager/include/tm_work_object.h
-			tagmanager/include/tm_workspace.h ''')
-	# Docs
-	base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
-	ext = '.txt' if is_win32 else ''
-	html_dir = '' if is_win32 else 'html/'
-	html_name = 'Manual.html' if is_win32 else 'index.html'
-	for f in 'AUTHORS ChangeLog COPYING README NEWS THANKS TODO'.split():
-		bld.install_as("%s/%s%s" % (base_dir, uc_first(f, is_win32), ext), f)
-	bld.install_files('${DOCDIR}/%simages' % html_dir, 'doc/images/*.png')
-	bld.install_as('${DOCDIR}/%s' % uc_first('manual.txt', is_win32), 'doc/geany.txt')
-	bld.install_as('${DOCDIR}/%s%s' % (html_dir, html_name), 'doc/geany.html')
-	bld.install_as('${DOCDIR}/ScintillaLicense.txt', 'scintilla/License.txt')
-	if is_win32:
-		bld.install_as('${DOCDIR}/ReadMe.I18n.txt', 'README.I18N')
-		bld.install_as('${DOCDIR}/Hacking.txt', 'HACKING')
-	# Data
-	dir = '' if is_win32 else 'geany'
-	bld.install_files('${DATADIR}/%s' % dir, 'data/filetype*')
-	bld.install_files('${DATADIR}/%s' % dir, 'data/*.tags')
-	bld.install_files('${DATADIR}/%s' % dir, 'data/snippets.conf')
-	bld.install_files('${DATADIR}/%s' % dir, 'data/ui_toolbar.xml')
-	bld.install_files('${DATADIR}/%s/templates' % dir, 'data/templates/*')
-	bld.install_files('${DATADIR}/%s/templates/files' % dir, 'data/templates/files/*.*')
-	bld.install_files('${DATADIR}/%s/colorschemes' % dir, 'data/colorschemes/*.*')
-	bld.install_as('${DATADIR}/%s/GPL-2' % dir, 'COPYING')
-	# Icons
-	bld.install_files('${PREFIX}/share/icons'
-		if is_win32	else '${DATADIR}/icons/hicolor/16x16/apps', 'icons/16x16/*.png')
-	if not is_win32:
-		bld.install_files('${DATADIR}/icons/hicolor/48x48/apps', 'icons/48x48/*.png')
-		bld.install_files('${DATADIR}/icons/hicolor/scalable/apps', 'icons/scalable/*.svg')
+        # Doxyfile
+        bld.new_task_gen(
+            features        = 'subst',
+            source          = 'doc/Doxyfile.in',
+            target          = 'doc/Doxyfile',
+            install_path    = None,
+            dct             = {'VERSION' : VERSION})
 
+    ###
+    # Install files
+    ###
+    if not is_win32:
+        # Headers
+        bld.install_files('${PREFIX}/include/geany', '''
+            src/document.h src/editor.h src/encodings.h src/filetypes.h src/geany.h
+            src/highlighting.h src/keybindings.h src/msgwindow.h src/plugindata.h
+            src/prefs.h src/project.h src/search.h src/stash.h src/support.h
+            src/templates.h src/toolbar.h src/ui_utils.h src/utils.h
+            plugins/geanyplugin.h plugins/geanyfunctions.h''')
+        bld.install_files('${PREFIX}/include/geany/scintilla', '''
+            scintilla/include/SciLexer.h scintilla/include/Scintilla.h
+            scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''')
+        bld.install_files('${PREFIX}/include/geany/tagmanager', '''
+            tagmanager/include/tm_file_entry.h tagmanager/include/tm_project.h
+            tagmanager/include/tm_source_file.h
+            tagmanager/include/tm_symbol.h tagmanager/include/tm_tag.h
+            tagmanager/include/tm_tagmanager.h tagmanager/include/tm_work_object.h
+            tagmanager/include/tm_workspace.h ''')
+    # Docs
+    base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
+    ext = '.txt' if is_win32 else ''
+    html_dir = '' if is_win32 else 'html/'
+    html_name = 'Manual.html' if is_win32 else 'index.html'
+    for filename in 'AUTHORS ChangeLog COPYING README NEWS THANKS TODO'.split():
+        basename = _uc_first(filename, bld)
+        destination_filename = '%s%s' % (basename, ext)
+        destination = os.path.join(base_dir, destination_filename)
+        bld.install_as(destination, filename)
 
- at taskgen
- at feature('intltool_po')
+    start_dir = bld.path.find_dir('doc/images')
+    bld.install_files('${DOCDIR}/%simages' % html_dir, start_dir.ant_glob('*.png'), cwd=start_dir)
+    bld.install_as('${DOCDIR}/%s' % _uc_first('manual.txt', bld), 'doc/geany.txt')
+    bld.install_as('${DOCDIR}/%s%s' % (html_dir, html_name), 'doc/geany.html')
+    bld.install_as('${DOCDIR}/ScintillaLicense.txt', 'scintilla/License.txt')
+    if is_win32:
+        bld.install_as('${DOCDIR}/ReadMe.I18n.txt', 'README.I18N')
+        bld.install_as('${DOCDIR}/Hacking.txt', 'HACKING')
+    # Data
+    data_dir = '' if is_win32 else 'geany'
+    start_dir = bld.path.find_dir('data')
+    bld.install_as('${DATADIR}/%s/GPL-2' % data_dir, 'COPYING')
+    bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('filetype*'), cwd=start_dir)
+    bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('*.tags'), cwd=start_dir)
+    bld.install_files('${DATADIR}/%s' % data_dir, 'data/snippets.conf')
+    bld.install_files('${DATADIR}/%s' % data_dir, 'data/ui_toolbar.xml')
+    start_dir = bld.path.find_dir('data/colorschemes')
+    template_dest = '${DATADIR}/%s/colorschemes' % data_dir
+    bld.install_files(template_dest, start_dir.ant_glob('*'), cwd=start_dir)
+    start_dir = bld.path.find_dir('data/templates')
+    template_dest = '${DATADIR}/%s/templates' % data_dir
+    bld.install_files(template_dest, start_dir.ant_glob('**/*'), cwd=start_dir, relative_trick=True)
+    # Icons
+    icon_dest = '${PREFIX}/share/icons' if is_win32 else '${DATADIR}/icons/hicolor/16x16/apps'
+    start_dir = bld.path.find_dir('icons/16x16')
+    bld.install_files(icon_dest, start_dir.ant_glob('*.png'), cwd=start_dir)
+    if not is_win32:
+        start_dir = bld.path.find_dir('icons/48x48')
+        icon_dest = '${DATADIR}/icons/hicolor/48x48/apps'
+        bld.install_files(icon_dest, start_dir.ant_glob('*.png'), cwd=start_dir)
+        start_dir = bld.path.find_dir('icons/scalable')
+        scalable_dest = '${DATADIR}/icons/hicolor/scalable/apps'
+        bld.install_files(scalable_dest, start_dir.ant_glob('*.svg'), cwd=start_dir)
+
+
+def distclean(ctx):
+    Scripting.distclean(ctx)
+    _remove_linguas_file()
+
+
+def _remove_linguas_file():
+    # remove LINGUAS file as well
+    try:
+        os.unlink(LINGUAS_FILE)
+    except OSError:
+        pass
+
+
+ at feature('linguas')
 def write_linguas_file(self):
-	linguas = ''
-	if 'LINGUAS' in Build.bld.env:
-		files = Build.bld.env['LINGUAS']
-		for po_filename in files.split(' '):
-			if os.path.exists('po/%s.po' % po_filename):
-				linguas += '%s ' % po_filename
-	else:
-		files = os.listdir('%s/po' % self.path.abspath())
-		files.sort()
-		for f in files:
-			if f.endswith('.po'):
-				linguas += '%s ' % f[:-3]
-	f = open("po/LINGUAS", "w")
-	f.write('# This file is autogenerated. Do not edit.\n%s\n' % linguas)
-	f.close()
+    if os.path.exists(LINGUAS_FILE):
+        return
+    linguas = ''
+    if 'LINGUAS' in self.env:
+        files = self.env['LINGUAS']
+        for po_filename in files.split(' '):
+            if os.path.exists ('po/%s.po' % po_filename):
+                linguas += '%s ' % po_filename
+    else:
+        files = os.listdir('%s/po' % self.path.abspath())
+        files.sort()
+        for filename in files:
+            if filename.endswith('.po'):
+                linguas += '%s ' % filename[:-3]
+    file_h = open(LINGUAS_FILE, 'w')
+    file_h.write('# This file is autogenerated. Do not edit.\n%s\n' % linguas)
+    file_h.close()
 
 
-def shutdown():
-	is_win32 = False if not Build.bld else target_is_win32(Build.bld.env)
-	# the following code was taken from midori's WAF script, thanks
-	if not is_win32 and not Options.options.destdir and (Options.commands['install'] or \
-			Options.commands['uninstall']):
-		dir = Build.bld.get_install_path('${DATADIR}/icons/hicolor')
-		icon_cache_updated = False
-		try:
-			Utils.exec_command('gtk-update-icon-cache -q -f -t %s' % dir)
-			Utils.pprint('GREEN', 'GTK icon cache updated.')
-			icon_cache_updated = True
-		except:
-			Utils.pprint('YELLOW', 'Failed to update icon cache for %s.' % dir)
-		if not icon_cache_updated:
-			print 'Icon cache not updated. After install, run this:'
-			print 'gtk-update-icon-cache -q -f -t %s' % dir
+def _post_install(ctx):
+    is_win32 = _target_is_win32(ctx)
+    if is_win32:
+        return
+    theme_dir = Utils.subst_vars('${DATADIR}/icons/hicolor', ctx.env)
+    icon_cache_updated = False
+    if not ctx.options.destdir:
+        ctx.exec_command('gtk-update-icon-cache -q -f -t %s' % theme_dir)
+        Logs.pprint('GREEN', 'GTK icon cache updated.')
+        icon_cache_updated = True
+    if not icon_cache_updated:
+        Logs.pprint('YELLOW', 'Icon cache not updated. After install, run this:')
+        Logs.pprint('YELLOW', 'gtk-update-icon-cache -q -f -t %s' % theme_dir)
 
-	if Options.options.apidoc:
-		doxyfile = os.path.join(Build.bld.srcnode.abspath(Build.bld.env), 'doc', 'Doxyfile')
-		cmd = Configure.find_program_impl(Build.bld.env, 'doxygen')
-		if cmd:
-			os.chdir('doc')
-			ret = launch('%s %s' % (cmd, doxyfile), 'Generating API reference documentation')
-		else:
-			Utils.pprint('RED',
-				'doxygen could not be found. Please install the doxygen package.')
-			sys.exit(1)
 
-	if Options.options.htmldoc or Options.options.hackingdoc:
-		# first try rst2html.py as it is the upstream default, fall back to rst2html
-		cmd = Configure.find_program_impl(Build.bld.env, 'rst2html.py')
-		if not cmd:
-			cmd = Configure.find_program_impl(Build.bld.env, 'rst2html')
-		if cmd:
-			if Options.options.hackingdoc:
-				file_in = '../HACKING'
-				file_out = 'hacking.html'
-				msg = 'HACKING HTML'
-			else:
-				file_in = 'geany.txt'
-				file_out = 'geany.html'
-				msg = 'HTML'
-			os.chdir('doc')
-			ret = launch(cmd + ' -stg --stylesheet=geany.css %s %s' % (file_in, file_out),
-				'Generating %s documentation' % msg)
-		else:
-			Utils.pprint('RED',
-				'rst2html.py could not be found. Please install the Python docutils package.')
-			sys.exit(1)
+def updatepo(ctx):
+    """update the message catalogs for internationalization"""
+    potfile = '%s.pot' % APPNAME
+    os.chdir('%s/po' % top)
+    try:
+        try:
+            old_size = os.stat(potfile).st_size
+        except OSError:
+            old_size = 0
+        ctx.exec_command('intltool-update --pot -g %s' % APPNAME)
+        size_new = os.stat(potfile).st_size
+        if size_new != old_size:
+            Logs.pprint('CYAN', 'Updated POT file.')
+            Logs.pprint('CYAN', 'Updating translations')
+            ret = ctx.exec_command('intltool-update -r -g %s' % APPNAME)
+            if ret != 0:
+                Logs.pprint('RED', 'Updating translations failed')
+        else:
+            Logs.pprint('CYAN', 'POT file is up to date.')
+    except OSError:
+        Logs.pprint('RED', 'Failed to generate pot file.')
 
-	if Options.options.update_po:
-		# the following code was taken from midori's WAF script, thanks
-		os.chdir('%s/po' % srcdir)
-		try:
-			try:
-				size_old = os.stat('geany.pot').st_size
-			except:
-				size_old = 0
-			Utils.exec_command('intltool-update --pot -g %s' % APPNAME)
-			size_new = os.stat('geany.pot').st_size
-			if size_new != size_old:
-				Utils.pprint('CYAN', 'Updated POT file.')
-				launch('intltool-update -r -g %s' % APPNAME, 'Updating translations', 'CYAN')
-			else:
-				Utils.pprint('CYAN', 'POT file is up to date.')
-		except:
-			Utils.pprint('RED', 'Failed to generate pot file.')
-		os.chdir('..')
 
+def apidoc(ctx):
+    """generate API reference documentation"""
+    basedir = ctx.path.abspath()
+    doxygen = _find_program(ctx, 'doxygen')
+    doxyfile = '%s/%s/doc/Doxyfile' % (basedir, out)
+    os.chdir('doc')
+    Logs.pprint('CYAN', 'Generating API documentation')
+    ret = ctx.exec_command('%s %s' % (doxygen, doxyfile))
+    if ret != 0:
+        raise WafError('Generating API documentation failed')
+    # update hacking.html
+    cmd = _find_rst2html(ctx)
+    ctx.exec_command('%s  -stg --stylesheet=geany.css %s %s' % (cmd, '../HACKING', 'hacking.html'))
+    os.chdir('..')
 
-# Simple function to execute a command and print its exit status
-def launch(command, status, success_color='GREEN'):
-	ret = 0
-	Utils.pprint(success_color, status)
-	try:
-		ret = Utils.exec_command(command)
-	except OSError, e:
-		ret = 1
-		print str(e), ":", command
-	except:
-		ret = 1
 
-	if ret != 0:
-		Utils.pprint('RED', status + ' failed')
+def htmldoc(ctx):
+    """generate HTML documentation"""
+    # first try rst2html.py as it is the upstream default, fall back to rst2html
+    cmd = _find_rst2html(ctx)
+    os.chdir('doc')
+    Logs.pprint('CYAN', 'Generating HTML documentation')
+    ctx.exec_command('%s  -stg --stylesheet=geany.css %s %s' % (cmd, 'geany.txt', 'geany.html'))
+    os.chdir('..')
 
-	return ret
 
+def _find_program(ctx, cmd, **kw):
+    def noop(*args):
+        pass
 
-def print_message(conf, msg, result, color = 'GREEN'):
-	conf.check_message_1(msg)
-	conf.check_message_2(result, color)
+    ctx = ConfigurationContext()
+    ctx.to_log = noop
+    ctx.msg = noop
+    return ctx.find_program(cmd, **kw)
 
 
-def uc_first(s, is_win32):
-	if is_win32:
-		return s.title()
-	return s
+def _find_rst2html(ctx):
+    cmds = ['rst2html.py', 'rst2html']
+    for command in cmds:
+        cmd = _find_program(ctx, command, mandatory=False)
+        if cmd:
+            break
+    if not cmd:
+        raise WafError(
+            'rst2html.py could not be found. Please install the Python docutils package.')
+    return cmd
 
 
-def target_is_win32(env):
-	if sys.platform == 'win32':
-		return True
-	if env and 'CC' in env:
-		cc = env['CC']
-		if not isinstance(cc, str):
-			cc = ''.join(cc)
-		return cc.find('mingw') != -1
-	return False
+def _add_define_to_env(conf, key):
+    value = conf.get_define(key)
+    # strip quotes
+    value = value.replace('"', '')
+    conf.env[key] = value
+
+
+def _add_to_env_and_define(conf, key, value, quote=False):
+    conf.define(key, value, quote)
+    conf.env[key] = value
+
+
+def _define_from_opt(conf, define_name, opt_value, default_value, quote=1):
+    value = default_value
+    if opt_value:
+        if isinstance(opt_value, bool):
+            opt_value = 1
+        value = opt_value
+
+    if value is not None:
+        _add_to_env_and_define(conf, define_name, value, quote)
+    else:
+        conf.undefine(define_name)
+
+
+def _get_svn_rev(conf):
+    def in_git():
+        cmd = 'git ls-files >/dev/null 2>&1'
+        return (conf.exec_command(cmd) == 0)
+
+    def in_svn():
+        return os.path.exists('.svn')
+
+    # try GIT
+    if in_git():
+        cmds = [ 'git svn find-rev HEAD 2>/dev/null',
+                 'git svn find-rev origin/trunk 2>/dev/null',
+                 'git svn find-rev trunk 2>/dev/null',
+                 'git svn find-rev master 2>/dev/null'
+                ]
+        for cmd in cmds:
+            try:
+                stdout = conf.cmd_and_log(cmd)
+                if stdout:
+                    return int(stdout.strip())
+            except WafError:
+                pass
+            except ValueError:
+                Logs.pprint('RED', 'Unparseable revision number')
+    # try SVN
+    elif in_svn():
+        try:
+            _env = None if _target_is_win32(conf) else dict(LANG='C')
+            stdout = conf.cmd_and_log(cmd='svn info --non-interactive', env=_env)
+            lines = stdout.splitlines(True)
+            for line in lines:
+                if line.startswith('Last Changed Rev'):
+                    value = line.split(': ', 1)[1]
+                    return int(value.strip())
+        except WafError:
+            pass
+        except (IndexError, ValueError):
+            Logs.pprint('RED', 'Unparseable revision number')
+    return 0
+
+
+def _load_intltool_if_available(conf):
+    try:
+        conf.check_tool('intltool')
+        if 'LINGUAS' in os.environ:
+            conf.env['LINGUAS'] = os.environ['LINGUAS']
+    except WafError:
+        # on Windows, we don't hard depend on intltool, on all other platforms raise an error
+        if not _target_is_win32(conf):
+            raise
+
+
+def _target_is_win32(ctx):
+    if 'is_win32' in ctx.env:
+        # cached
+        return ctx.env['is_win32']
+    is_win32 = None
+    if sys.platform == 'win32':
+        is_win32 = True
+    if is_win32 is None:
+        if ctx.env and 'CC' in ctx.env:
+            env_cc = ctx.env['CC']
+            if not isinstance(env_cc, str):
+                env_cc = ''.join(env_cc)
+            is_win32 = (env_cc.find('mingw') != -1)
+    if is_win32 is None:
+        is_win32 = False
+    # cache for future checks
+    ctx.env['is_win32'] = is_win32
+    return is_win32
+
+
+def _uc_first(string, ctx):
+    if _target_is_win32(ctx):
+        return string.title()
+    return string
+
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list