2008-05-31 09:55:54 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# WAF build script for midori
|
2008-10-11 05:27:52 +00:00
|
|
|
# This file is licensed under the terms of the expat license, see the file EXPAT.
|
2008-05-31 09:55:54 +00:00
|
|
|
|
|
|
|
import Params
|
2008-05-31 12:20:36 +00:00
|
|
|
import pproc as subprocess
|
|
|
|
import Common
|
2008-10-25 22:54:57 +00:00
|
|
|
import sys
|
2008-10-03 20:14:14 +00:00
|
|
|
import os
|
2008-11-14 01:46:23 +00:00
|
|
|
import UnitTest
|
2008-05-31 09:55:54 +00:00
|
|
|
|
2008-11-30 00:22:03 +00:00
|
|
|
major = 0
|
|
|
|
minor = 1
|
2008-11-30 00:48:04 +00:00
|
|
|
micro = 1
|
2008-11-30 00:22:03 +00:00
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
APPNAME = 'midori'
|
2008-11-30 00:22:03 +00:00
|
|
|
VERSION = str (major) + '.' + str (minor) + '.' + str (micro)
|
2008-05-31 09:55:54 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
git = subprocess.Popen (['git', 'rev-parse', '--short', 'HEAD'],
|
2008-10-21 21:07:07 +00:00
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
2008-05-31 09:55:54 +00:00
|
|
|
if not git.wait ():
|
|
|
|
VERSION = (VERSION + '-' + git.stdout.read ()).strip ()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
srcdir = '.'
|
|
|
|
blddir = '_build_'
|
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
def option_enabled (option):
|
|
|
|
if eval ('Params.g_options.enable_' + option):
|
|
|
|
return True
|
|
|
|
if eval ('Params.g_options.disable_' + option):
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
def configure (conf):
|
2008-12-07 00:56:42 +00:00
|
|
|
def option_checkfatal (option, desc):
|
|
|
|
if eval ('Params.g_options.enable_' + option):
|
|
|
|
Params.pprint ('RED', desc + ' not available')
|
|
|
|
sys.exit (1)
|
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
conf.check_tool ('compiler_cc')
|
2008-06-14 00:23:33 +00:00
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('user_docs'):
|
2008-10-03 20:14:14 +00:00
|
|
|
conf.find_program ('rst2html.py', var='RST2HTML')
|
|
|
|
# debian renames the executable, check that as well :(
|
|
|
|
if not conf.env['RST2HTML']:
|
|
|
|
conf.find_program ('rst2html', var='RST2HTML')
|
|
|
|
if conf.env['RST2HTML']:
|
2008-12-07 00:56:42 +00:00
|
|
|
user_docs = 'yes'
|
2008-10-03 20:14:14 +00:00
|
|
|
else:
|
2008-12-07 00:56:42 +00:00
|
|
|
option_checkfatal ('user_docs', 'user documentation')
|
|
|
|
user_docs = 'not available'
|
2008-10-03 20:14:14 +00:00
|
|
|
else:
|
2008-12-07 00:56:42 +00:00
|
|
|
user_docs = 'no'
|
|
|
|
conf.check_message_custom ('generate', 'user documentation', user_docs)
|
2008-10-03 20:14:14 +00:00
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('nls'):
|
2008-05-31 09:55:54 +00:00
|
|
|
conf.check_tool ('intltool')
|
2008-06-01 21:47:27 +00:00
|
|
|
if conf.env['INTLTOOL'] and conf.env['POCOM']:
|
2008-05-31 09:55:54 +00:00
|
|
|
nls = 'yes'
|
|
|
|
conf.define ('ENABLE_NLS', 1)
|
|
|
|
conf.define ('MIDORI_LOCALEDIR', 'LOCALEDIR', 0)
|
|
|
|
else:
|
2008-12-07 00:56:42 +00:00
|
|
|
option_checkfatal ('nls', 'localization')
|
2008-05-31 09:55:54 +00:00
|
|
|
nls = 'not available'
|
|
|
|
else:
|
|
|
|
nls = 'no'
|
|
|
|
conf.check_message_custom ('localization', 'support', nls)
|
|
|
|
|
2008-11-18 01:07:53 +00:00
|
|
|
if Params.g_options.libdir == '':
|
|
|
|
libdir = os.path.join (conf.env['PREFIX'], 'lib')
|
|
|
|
else:
|
|
|
|
libdir = Params.g_options.libdir
|
|
|
|
conf.define ('LIBDIR', libdir)
|
|
|
|
|
2008-10-03 20:14:14 +00:00
|
|
|
# We support building without intltool
|
|
|
|
# Therefore datadir may not have been defined
|
|
|
|
if not conf.is_defined ('DATADIR'):
|
|
|
|
if Params.g_options.datadir != '':
|
|
|
|
conf.define ('DATADIR', Params.g_options.datadir)
|
|
|
|
else:
|
|
|
|
conf.define ('DATADIR', os.path.join (conf.env['PREFIX'], 'share'))
|
|
|
|
|
|
|
|
if Params.g_options.docdir == '':
|
|
|
|
docdir = "%s/doc" % conf.env['DATADIR']
|
|
|
|
else:
|
|
|
|
docdir = Params.g_options.docdir
|
|
|
|
conf.define ('DOCDIR', docdir)
|
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('api_docs'):
|
2008-09-07 19:48:04 +00:00
|
|
|
conf.find_program ('gtkdoc-scan', var='GTKDOC_SCAN')
|
|
|
|
conf.find_program ('gtkdoc-mktmpl', var='GTKDOC_MKTMPL')
|
|
|
|
conf.find_program ('gtkdoc-mkdb', var='GTKDOC_MKDB')
|
|
|
|
conf.find_program ('gtkdoc-mkhtml', var='GTKDOC_MKHTML')
|
|
|
|
if conf.env['GTKDOC_SCAN'] and conf.env['GTKDOC_MKTMPL'] \
|
|
|
|
and conf.env['GTKDOC_MKDB'] and conf.env['GTKDOC_MKHTML']:
|
|
|
|
api_docs = 'yes'
|
|
|
|
else:
|
2008-12-07 00:56:42 +00:00
|
|
|
option_checkfatal ('api_docs', 'API documentation')
|
2008-09-07 19:48:04 +00:00
|
|
|
api_docs = 'not available'
|
|
|
|
else:
|
|
|
|
api_docs = 'no'
|
|
|
|
conf.check_message_custom ('generate', 'API documentation', api_docs)
|
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('unique'):
|
2008-08-26 22:44:21 +00:00
|
|
|
conf.check_pkg ('unique-1.0', destvar='UNIQUE', vnum='0.9', mandatory=False)
|
|
|
|
single_instance = ['not available','yes'][conf.env['HAVE_UNIQUE'] == 1]
|
|
|
|
else:
|
2008-12-07 00:56:42 +00:00
|
|
|
option_checkfatal ('unique', 'single instance')
|
2008-08-26 22:44:21 +00:00
|
|
|
single_instance = 'no'
|
2008-08-22 01:59:07 +00:00
|
|
|
conf.check_message_custom ('single instance', 'support', single_instance)
|
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('libsoup'):
|
2008-10-19 20:18:07 +00:00
|
|
|
conf.check_pkg ('libsoup-2.4', destvar='LIBSOUP', mandatory=False)
|
2008-12-06 03:40:10 +00:00
|
|
|
conf.check_pkg ('libsoup-2.4', destvar='LIBSOUP_2_25_2',
|
|
|
|
vnum='2.25.2', mandatory=False)
|
2008-10-19 20:18:07 +00:00
|
|
|
libsoup = ['not available','yes'][conf.env['HAVE_LIBSOUP'] == 1]
|
|
|
|
else:
|
2008-12-07 00:56:42 +00:00
|
|
|
option_checkfatal ('libsoup', 'libsoup')
|
2008-10-19 20:18:07 +00:00
|
|
|
libsoup = 'no'
|
|
|
|
conf.check_message_custom ('libsoup', 'support', libsoup)
|
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('sqlite'):
|
2008-10-13 15:50:07 +00:00
|
|
|
conf.check_pkg ('sqlite3', destvar='SQLITE', vnum='3.0', mandatory=False)
|
|
|
|
sqlite = ['not available','yes'][conf.env['HAVE_SQLITE'] == 1]
|
|
|
|
else:
|
2008-12-07 00:56:42 +00:00
|
|
|
option_checkfatal ('sqlite', 'history database')
|
2008-10-13 15:50:07 +00:00
|
|
|
sqlite = 'no'
|
|
|
|
conf.check_message_custom ('history database', 'support', sqlite)
|
|
|
|
|
2008-11-18 01:07:53 +00:00
|
|
|
conf.check_pkg ('gmodule-2.0', destvar='GMODULE', vnum='2.8.0', mandatory=False)
|
2008-10-23 22:19:04 +00:00
|
|
|
conf.check_pkg ('gio-2.0', destvar='GIO', vnum='2.16.0', mandatory=False)
|
2008-10-19 22:41:52 +00:00
|
|
|
conf.check_pkg ('gtk+-2.0', destvar='GTK', vnum='2.10.0', mandatory=True)
|
2008-05-31 10:43:37 +00:00
|
|
|
conf.check_pkg ('webkit-1.0', destvar='WEBKIT', vnum='0.1', mandatory=True)
|
|
|
|
conf.check_pkg ('libxml-2.0', destvar='LIBXML', vnum='2.6', mandatory=True)
|
2008-05-31 09:55:54 +00:00
|
|
|
|
2008-06-01 13:16:40 +00:00
|
|
|
conf.check_header ('unistd.h', 'HAVE_UNISTD_H')
|
2008-10-25 22:54:57 +00:00
|
|
|
if sys.platform == 'darwin':
|
|
|
|
conf.define ('HAVE_OSX', 1)
|
2008-06-01 13:16:40 +00:00
|
|
|
|
2008-08-10 13:53:07 +00:00
|
|
|
if conf.find_program ('rsvg-convert', var='RSVG_CONVERT'):
|
2008-05-31 09:55:54 +00:00
|
|
|
icons = 'yes'
|
|
|
|
else:
|
|
|
|
icons = 'no'
|
|
|
|
conf.check_message_custom ('icon optimization', 'support', icons)
|
|
|
|
|
|
|
|
conf.define ('PACKAGE_VERSION', VERSION)
|
|
|
|
conf.define ('PACKAGE_NAME', APPNAME)
|
2008-08-22 01:59:07 +00:00
|
|
|
conf.define ('PACKAGE_BUGREPORT', 'http://www.twotoasts.de/bugs')
|
2008-05-31 09:55:54 +00:00
|
|
|
conf.define ('GETTEXT_PACKAGE', APPNAME)
|
|
|
|
|
2008-11-30 00:22:03 +00:00
|
|
|
conf.define ('MIDORI_MAJOR_VERSION', major)
|
|
|
|
conf.define ('MIDORI_MINOR_VERSION', minor)
|
|
|
|
conf.define ('MIDORI_MICRO_VERSION', micro)
|
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
conf.write_config_header ('config.h')
|
2008-06-19 22:28:33 +00:00
|
|
|
conf.env.append_value ('CCFLAGS', '-DHAVE_CONFIG_H')
|
2008-05-31 09:55:54 +00:00
|
|
|
|
2008-11-10 21:18:35 +00:00
|
|
|
print
|
|
|
|
if single_instance == 'not available':
|
|
|
|
print "Single instance support is unavailable in this build."
|
|
|
|
print " Install libUnique and reconfigure to enable it."
|
|
|
|
print
|
|
|
|
if libsoup == 'not available':
|
|
|
|
print "Icons, view source and Save as are unavailable in this build."
|
|
|
|
print " Install libSoup and reconfigure to enable these features."
|
|
|
|
print
|
|
|
|
if sqlite == 'not available':
|
|
|
|
print "History storage on disk is unavailable in this build."
|
|
|
|
print " Install sqlite3 and reconfigure to enable it."
|
|
|
|
print
|
|
|
|
|
2008-05-31 12:20:36 +00:00
|
|
|
def set_options (opt):
|
2008-12-07 00:56:42 +00:00
|
|
|
def add_enable_option (option, desc):
|
|
|
|
option_ = option.replace ('-', '_')
|
|
|
|
opt.add_option ('--enable-' + option, action='store_true',
|
|
|
|
default=False, help='Enable ' + desc, dest='enable_' + option_)
|
|
|
|
opt.add_option ('--disable-' + option, action='store_true',
|
|
|
|
default=False, help='Disable ' + desc, dest='disable_' + option_)
|
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
opt.tool_options ('compiler_cc')
|
|
|
|
opt.tool_options ('intltool')
|
2008-12-07 00:56:42 +00:00
|
|
|
add_enable_option ('nls', 'native language support')
|
|
|
|
opt.add_option ('--update-po', action='store_true', default=False,
|
|
|
|
help='Update localization files', dest='update_po')
|
|
|
|
|
2008-10-03 20:14:14 +00:00
|
|
|
opt.add_option ('--docdir', type='string', default='',
|
2008-11-18 01:07:53 +00:00
|
|
|
help='Documentation root', dest='docdir')
|
2008-12-07 00:56:42 +00:00
|
|
|
add_enable_option ('docs', 'informational text files')
|
|
|
|
add_enable_option ('user-docs', 'user documentation')
|
|
|
|
add_enable_option ('api-docs', 'API documentation')
|
2008-05-31 09:55:54 +00:00
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
add_enable_option ('unique', 'single instance support')
|
|
|
|
add_enable_option ('libsoup', 'libSoup support')
|
|
|
|
add_enable_option ('sqlite', 'history database support')
|
2008-11-10 00:08:38 +00:00
|
|
|
|
2008-11-18 01:07:53 +00:00
|
|
|
opt.add_option ('--libdir', type='string', default='',
|
|
|
|
help='Library root', dest='libdir')
|
2008-12-07 00:56:42 +00:00
|
|
|
add_enable_option ('extensions', 'building of extensions')
|
2008-11-18 01:07:53 +00:00
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
def build (bld):
|
2008-10-16 01:51:39 +00:00
|
|
|
def mkdir (path):
|
|
|
|
if not os.access (path, os.F_OK):
|
|
|
|
os.mkdir (path)
|
|
|
|
|
|
|
|
def _install_files (folder, destination, source):
|
|
|
|
try:
|
|
|
|
install_files (folder, destination, source)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2008-07-27 05:39:39 +00:00
|
|
|
bld.add_subdirs ('katze midori icons')
|
2008-05-31 09:55:54 +00:00
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('extensions'):
|
2008-11-18 01:07:53 +00:00
|
|
|
bld.add_subdirs ('extensions')
|
|
|
|
|
2008-12-07 00:56:42 +00:00
|
|
|
if option_enabled ('docs'):
|
|
|
|
install_files ('DOCDIR', '/' + APPNAME + '/', \
|
|
|
|
'AUTHORS ChangeLog COPYING EXPAT README TRANSLATE')
|
2008-10-03 20:14:14 +00:00
|
|
|
|
|
|
|
if bld.env ()['RST2HTML']:
|
|
|
|
# FIXME: Build only if needed
|
|
|
|
if not os.access (blddir, os.F_OK):
|
|
|
|
os.mkdir (blddir)
|
|
|
|
if not os.access (blddir + '/docs', os.F_OK):
|
|
|
|
os.mkdir (blddir + '/docs')
|
|
|
|
if not os.access (blddir + '/docs/user', os.F_OK):
|
|
|
|
os.mkdir (blddir + '/docs/user')
|
|
|
|
os.chdir (blddir + '/docs/user')
|
|
|
|
subprocess.call ([bld.env ()['RST2HTML'], '-stg',
|
|
|
|
'--stylesheet=../../../docs/user/midori.css',
|
|
|
|
'../../../docs/user/midori.txt',
|
|
|
|
'midori.html',])
|
|
|
|
os.chdir ('../../..')
|
|
|
|
install_files ('DOCDIR', '/midori/user/', blddir + '/docs/user/midori.html')
|
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
if bld.env ()['INTLTOOL']:
|
2008-11-10 00:08:38 +00:00
|
|
|
obj = bld.create_obj ('intltool_po')
|
|
|
|
obj.podir = 'po'
|
|
|
|
obj.appname = APPNAME
|
2008-05-31 09:55:54 +00:00
|
|
|
|
2008-09-07 19:48:04 +00:00
|
|
|
if bld.env ()['GTKDOC_SCAN'] and Params.g_commands['build']:
|
|
|
|
bld.add_subdirs ('docs/api')
|
|
|
|
|
2008-05-31 09:55:54 +00:00
|
|
|
if bld.env ()['INTLTOOL']:
|
|
|
|
obj = bld.create_obj ('intltool_in')
|
2008-10-25 22:54:57 +00:00
|
|
|
obj.source = APPNAME + '.desktop.in'
|
2008-06-07 09:54:40 +00:00
|
|
|
obj.inst_var = 'DATADIR'
|
|
|
|
obj.inst_dir = 'applications'
|
|
|
|
obj.flags = '-d'
|
2008-05-31 09:55:54 +00:00
|
|
|
else:
|
|
|
|
# FIXME: process desktop.in without intltool
|
2008-10-25 22:54:57 +00:00
|
|
|
Params.pprint ('BLUE', "File " + APPNAME + ".desktop not generated")
|
2008-05-31 09:55:54 +00:00
|
|
|
if bld.env ()['INTLTOOL']:
|
2008-10-25 22:54:57 +00:00
|
|
|
install_files ('DATADIR', 'applications', APPNAME + '.desktop')
|
2008-05-31 12:20:36 +00:00
|
|
|
|
2008-10-16 01:51:39 +00:00
|
|
|
if bld.env ()['RSVG_CONVERT']:
|
|
|
|
mkdir (blddir + '/data')
|
|
|
|
convert = subprocess.Popen ([bld.env ()['RSVG_CONVERT'],
|
|
|
|
'-o', blddir + '/data/logo-shade.png',
|
|
|
|
srcdir + '/data/logo-shade.svg'],
|
|
|
|
stderr=subprocess.PIPE)
|
|
|
|
if not convert.wait ():
|
|
|
|
_install_files ('DATADIR', APPNAME,
|
|
|
|
blddir + '/data/logo-shade.png')
|
|
|
|
else:
|
|
|
|
Params.pprint ('BLUE', "logo-shade could not be rasterized.")
|
|
|
|
|
2008-11-14 01:46:23 +00:00
|
|
|
if Params.g_commands['check']:
|
|
|
|
bld.add_subdirs ('tests')
|
|
|
|
|
2008-05-31 12:20:36 +00:00
|
|
|
def shutdown ():
|
2008-06-01 13:16:40 +00:00
|
|
|
if Params.g_commands['install'] or Params.g_commands['uninstall']:
|
|
|
|
dir = Common.path_install ('DATADIR', 'icons/hicolor')
|
|
|
|
icon_cache_updated = False
|
|
|
|
if not Params.g_options.destdir:
|
|
|
|
# update the pixmap cache directory
|
|
|
|
try:
|
2008-12-06 04:43:24 +00:00
|
|
|
uic = subprocess.Popen (['gtk-update-icon-cache',
|
|
|
|
'-q', '-f', '-t', dir], stderr=subprocess.PIPE)
|
2008-07-27 05:39:39 +00:00
|
|
|
if not uic.wait ():
|
|
|
|
Params.pprint ('YELLOW', "Updated Gtk icon cache.")
|
|
|
|
icon_cache_updated = True
|
2008-06-01 13:16:40 +00:00
|
|
|
except:
|
|
|
|
Params.pprint ('RED', "Failed to update icon cache.")
|
|
|
|
if not icon_cache_updated:
|
2008-12-06 04:43:24 +00:00
|
|
|
Params.pprint ('YELLOW', "Icon cache not updated. "
|
|
|
|
"After install, run this:")
|
2008-06-01 13:16:40 +00:00
|
|
|
Params.pprint ('YELLOW', "gtk-update-icon-cache -q -f -t %s" % dir)
|
2008-11-10 00:08:38 +00:00
|
|
|
|
2008-11-14 01:46:23 +00:00
|
|
|
elif Params.g_commands['check']:
|
|
|
|
test = UnitTest.unit_test ()
|
|
|
|
test.change_to_testfile_dir = True
|
|
|
|
test.want_to_see_test_output = True
|
|
|
|
test.want_to_see_test_error = True
|
|
|
|
test.run ()
|
|
|
|
test.print_results ()
|
|
|
|
|
2008-11-10 00:08:38 +00:00
|
|
|
elif Params.g_options.update_po:
|
|
|
|
os.chdir('./po')
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
size_old = os.stat (APPNAME + '.pot').st_size
|
|
|
|
except:
|
|
|
|
size_old = 0
|
2008-12-06 04:34:33 +00:00
|
|
|
subprocess.call (['intltool-update', '-p', '-g', APPNAME])
|
2008-11-10 00:08:38 +00:00
|
|
|
size_new = os.stat (APPNAME + '.pot').st_size
|
|
|
|
if size_new <> size_old:
|
|
|
|
Params.pprint ('YELLOW', "Updated po template.")
|
|
|
|
try:
|
2008-12-06 04:43:24 +00:00
|
|
|
intltool_update = subprocess.Popen (['intltool-update',
|
|
|
|
'-r', '-g', APPNAME], stderr=subprocess.PIPE)
|
2008-11-10 00:08:38 +00:00
|
|
|
intltool_update.wait ()
|
|
|
|
Params.pprint ('YELLOW', "Updated translations.")
|
|
|
|
except:
|
|
|
|
Params.pprint ('RED', "Failed to update translations.")
|
|
|
|
except:
|
|
|
|
Params.pprint ('RED', "Failed to generate po template.")
|
|
|
|
Params.pprint ('RED', "Make sure intltool is installed.")
|
|
|
|
os.chdir ('..')
|