1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
|
#! /usr/bin/env python
# encoding: utf-8
import os, os.path
import intltool
import string
import Utils
import Options
import ccroot
import preproc
preproc.go_absolute=1
preproc.strict_quotes=0
import waffles.misc
import waffles.gnome as gnome
VERSION='4.0.4'
APPNAME='xiphos'
PACKAGE='xiphos'
srcdir = '.'
blddir = 'build'
_tooldir = './waffles/'
ROOTDIR_WIN32 = 'C:\msys'
_headers = '''
dlfcn.h
inttypes.h
locale.h
memory.h
stdint.h
stdlib.h
strings.h
string.h
sys/stat.h
sys/types.h
unistd.h
sys/select.h
sys/socket.h
winsock.h
'''.split()
def set_options(opt):
opt.tool_options('g++ gcc')
maingroup = opt.add_option_group('Main Xiphos Options')
maingroup.add_option('--gtk',
action='store', default='auto', dest='gtkver',
choices=['auto', '3', '2'],
help="Select gtk+ API ['auto', '3', '2']")
miscgroup = opt.add_option_group('Miscellaneous Options')
miscgroup.add_option('-d', '--debug-level',
action = 'store',
default = ccroot.DEBUG_LEVELS.ULTRADEBUG,
help = "Specify the debugging level ['ultradebug', 'debug', 'release', 'optimized']",
choices = ['ultradebug', 'debug', 'release', 'optimized'],
dest = 'debug_level')
miscgroup.add_option('--strip', action='store_true', default=False,
help='Strip resulting binary')
miscgroup.add_option('--enable-delint', action='store_true', default=False,
dest='delint',
help='Use -Wall -Werror [default: disabled]')
miscgroup.add_option('--chatty', action='store_true', default=False,
dest='chatty',
help='Enable lots of tracing [default: disabled]')
miscgroup.add_option('--enable-webkit-editor', action='store_true', default=False,
dest='webkit_editor',
help='Use webkit editor [default: disabled]')
miscgroup.add_option('--enable-webkit2', action='store_true', default=False,
dest='webkit2',
help='Use webkit2 instead of original webkit [default: disabled]')
miscgroup.add_option('--disable-dbus',
action = 'store_true',
default = False,
help = "Disable the Xiphos dbus API [default: enabled]",
dest = 'without_dbus')
### cross compilation from Linux/Unix for win32
w32 = opt.add_option_group ('Windows and Cross-compile Options', '')
w32.add_option('--target-platform-win32', action='store_true', default=False,
dest='cross_win32',
help='Cross-compile for win32 [default: disabled]')
w32.add_option('--disable-console',
action='store_true',
default=False,
help='Disable console window in win32 [default: enabled]',
dest='no_console')
w32.add_option('--pkgconf-libdir',
action = 'store',
default = os.path.join(ROOTDIR_WIN32, 'local', 'lib', 'pkgconfig'),
help = "Specify dir with *.pc files for cross-compilation",
dest = 'pkg_conf_libdir')
w32.add_option('--pkgconf-prefix',
action = 'store',
default = os.path.join(ROOTDIR_WIN32, 'local'),
help = "Specify prefix with folders for headers and libraries for cross-compilation",
dest = 'pkg_conf_prefix')
######### end of windows options.
group = opt.add_option_group ('Localization and documentation')
group.add_option('--helpdir',
action = 'store',
default = '${DATAROOTDIR}/gnome/help/${PACKAGE}',
help = "user documentation [default: ${DATAROOTDIR}/gnome/help/${PACKAGE}]",
dest = 'helpdir')
group.add_option('--disable-help',
action='store_true',
default=False,
help='Disable creating help files',
dest='disable_help')
group.add_option('--no-post-install',
action = 'store_false',
default = True,
help = "Disable post-install tasks",
dest = 'post_install')
def configure(conf):
opt = Options.options
dfn = conf.define
env = conf.env
platform = Utils.detect_platform()
env['IS_WIN32'] = platform == 'win32'
env['IS_LINUX'] = platform == 'linux'
env['IS_CROSS_WIN32'] = Options.options.cross_win32
# cross-compilation for Windows
# behave mostly like on windows platform
if env['IS_CROSS_WIN32']:
env['IS_WIN32'] = True
env['IS_LINUX'] = False
Utils.pprint('CYAN', "Cross-compilation")
env['CROSS'] = os.environ['CROSS']
# IS_WIN32 means compiling for win32, not necessarily compiling on win32
if env['IS_WIN32']:
Utils.pprint('CYAN', "Windows detected")
elif env['IS_LINUX']:
Utils.pprint('CYAN', "Linux detected")
if not (env['IS_LINUX'] or env['IS_WIN32']):
Utils.pprint('RED', "Assuming %s is UNIX like platform" % platform)
env['IS_LINUX'] = True
if env['IS_WIN32']:
env['ROOTDIR'] = ROOTDIR_WIN32
conf.check_tool('nothreads', tooldir=_tooldir)
conf.check_tool('g++ gcc')
# cross compiler
if env['IS_CROSS_WIN32']:
conf.check_tool('cross_linux_win32', tooldir=_tooldir)
conf.check_tool('gnu_dirs misc')
conf.check_tool('intltool')
env['DISABLE_HELP'] = opt.disable_help
if not opt.disable_help:
if env['IS_LINUX']:
conf.check_tool('gnome', tooldir=_tooldir)
else:
conf.check_tool('documentation', tooldir=_tooldir) # stuff to create help files
# DATADIR is defined by intltool in config.h - conflict in win32 (mingw)
conf.undefine('DATADIR')
env['POST_INSTALL']=opt.post_install
# delint flags
env['CXXFLAGS_DELINT'] = ['-Werror', '-Wall']
env['CCFLAGS_DELINT'] = ['-Werror', '-Wall', '-Wmissing-prototypes',
'-Wnested-externs', '-Wpointer-arith', '-Wno-sign-compare']
# gcc compiler debug levels
# msvc has levels predefined
if env['CC_NAME'] == 'gcc':
env['CCFLAGS_SAFE'] = env['CCFLAGS']
env['CCFLAGS'] = []
env['CCFLAGS_OPTIMIZED'] = ['-O2']
env['CCFLAGS_RELEASE'] = ['-O2']
env['CCFLAGS_DEBUG'] = ['-g', '-DDEBUG']
env['CCFLAGS_ULTRADEBUG'] = ['-g3', '-O0', '-DDEBUG']
if env['CXX_NAME'] == 'gcc':
env['CXXFLAGS_SAFE'] = env['CXXFLAGS']
env['CXXFLAGS'] = []
env['CXXFLAGS_OPTIMIZED'] = ['-O2']
env['CXXFLAGS_RELEASE'] = ['-O2']
env['CXXFLAGS_DEBUG'] = ['-g', '-DDEBUG']
env['CXXFLAGS_ULTRADEBUG'] = ['-g3', '-O0', '-DDEBUG']
if env['IS_WIN32']:
## setup for Winsock on Windows (required for read-aloud)
conf.check(lib='ws2_32', uselib='WSOCK', mandatory=True)
conf.check(lib='shell32', uselib='SHELLAPI', mandatory=True)
conf.check(lib='rpcrt4', uselib='RPCRT4', mandatory=True)
# this isn't supposed to be necessary
env['LINKFLAGS'] = ['-lws2_32', '-lrpcrt4']
dfn('WIN32', 1)
# tool to link icon with executable
# use tool modified for cross-compilation support
env['POST_INSTALL']=False
conf.check_tool('winres', tooldir=_tooldir)
# the following line does not work because of a problem with waf
# conf.check_tool('intltool')
#env['POCOM'] = conf.find_program('msgfmt')
#env['INTLTOOL'] = '/usr/local/bin/intltool-merge'
if env['IS_CROSS_WIN32']:
# allows to use linux pkg-config for cross-compilation
os.environ['PKG_CONFIG_PATH'] = opt.pkg_conf_libdir
env['PKG_CONFIG_PREFIX'] = opt.pkg_conf_prefix
# Auto detecting gtk version, if none were specified.
if opt.gtkver == 'auto':
if conf.check_cfg(modversion="gtk+-3.0", okmsg='ok',
msg='Auto detecting gtk 3'):
opt.gtkver = '3'
else:
conf.check_cfg(modversion="gtk+-2.0", okmsg='ok',
msg='Auto detecting gtk 2', mandatory=True)
opt.gtkver = '2'
# FIXME: Find out why we still need this!
dfn('WEBKIT', 1)
#gtk
if opt.gtkver == '2':
env['ENABLE_GTK2'] = True
dfn('GTK2', 1)
# disable console window in win32
if opt.no_console and env['IS_WIN32']:
env.append_value('LINKFLAGS', '-mwindows')
# strip xiphos binary
if env['IS_CROSS_WIN32']:
env['STRIP'] = conf.find_program(env['CROSS'] + 'strip', mandatory=True)
else:
env['STRIP'] = conf.find_program('strip', mandatory=True)
if (not env['IS_LINUX']) and (opt.debug_level in ['release','optimized']):
env['TO_STRIP'] = True
else:
env['TO_STRIP'] = opt.strip
if not opt.without_dbus:
conf.check_pkg('dbus-glib-1', '0.60', True, var='DBUS')
# we need a modified version of dbus.py for running on windows
conf.check_tool('dbus', tooldir=_tooldir)
conf.check_tool('glib2')
### App info, paths
define = conf.define
sub = Utils.subst_vars
env['VERSION'] = VERSION
env['APPNAME'] = APPNAME
env['PACKAGE'] = PACKAGE
env['HELPDIR'] = sub(opt.helpdir, env)
define('VERSION', VERSION)
define('PACKAGE_VERSION', VERSION)
define('GETTEXT_PACKAGE', PACKAGE)
define('PACKAGE', PACKAGE)
define('PACKAGE_NAME', APPNAME)
define('PACKAGE_STRING', '%s %s' % (APPNAME, VERSION))
define('PACKAGE_TARNAME', PACKAGE)
define('INSTALL_PREFIX', conf.escpath(sub('${PREFIX}/', env)))
#dfn('LT_OBJDIR', '.libs') - what's the purpose?
define('PACKAGE_BUGREPORT','http://sourceforge.net/tracker/?group_id=5528&atid=105528' )
define('PACKAGE_DATA_DIR', conf.escpath(sub('${DATAROOTDIR}/${PACKAGE}', env)))
define('PACKAGE_DOC_DIR', conf.escpath(env['DOCDIR']))
define('PACKAGE_HELP_DIR', conf.escpath(sub('${DATAROOTDIR}/gnome/help/${PACKAGE}', env)))
define('PACKAGE_LOCALE_DIR', conf.escpath(env['LOCALEDIR']))
define('PACKAGE_MENU_DIR', conf.escpath(sub('${DATAROOTDIR}/applications', env)))
#define('PACKAGE_PIXMAPS_DIR', conf.escpath(sub('${DATAROOTDIR}/pixmaps/${PACKAGE}', env)))
define('PACKAGE_PIXMAPS_DIR', conf.escpath(sub('${DATAROOTDIR}/${PACKAGE}', env)))
define('PACKAGE_SOURCE_DIR', conf.escpath(os.path.abspath(srcdir))) # folder where was wscript executed
if not env["IS_WIN32"]:
# for installing xiphos.appdata.xml
define('PACKAGE_APPDATA_DIR', conf.escpath(sub('${INSTALL_PREFIX}/share/appdata', env)))
common_libs = string.join(
'''
"gconf-2.0"
"gmodule-2.0"
"glib-2.0"
"libgsf-1 >= 1.14"
"libxml-2.0"
--cflags --libs'''
.split()," ")
if env['ENABLE_GTK2']:
env.append_value('ALL_LIBS', 'LIBGLADE')
# We need to know specific versions of GTK+-2.0
conf.check_cfg(package="gtk+-2.0",
atleast_version = "2.16",
uselib_store="GTK_216")
conf.check_cfg(package="gtk+-2.0",
atleast_version = "2.18",
uselib_store="GTK_218")
conf.check_cfg(package="gtk+-2.0",
atleast_version = "2.20",
uselib_store="GTK_220")
conf.check_cfg(package="gtk+-2.0",
atleast_version = "2.24",
uselib_store="GTK_224")
common_libs += ' libglade-2.0'
common_libs += ' webkit-1.0'
if opt.webkit_editor:
conf.define('USE_WEBKIT_EDITOR', 1)
env['ENABLE_WEBKIT_EDITOR'] = True
common_libs += ' "gtk+-2.0 >= 2.24" '
elif conf.check_cfg(modversion='gtkhtml-editor-3.14',
msg='Checking for GNOME3 gtkhtml-editor',
okmsg='Definitely',
errmsg='Probably not',
mandatory=True
):
common_libs += ' "gtk+-2.0 >= 2.14" '
common_libs += ' "gtkhtml-editor-3.14" '
common_libs += ' "libgtkhtml-3.14 >= 3.23" '
else:
common_libs += ' "gtk+-3.0" '
conf.check_cfg(package="gtk+-3.0",
atleast_version = "3.2",
uselib_store="GTK_32")
conf.check_cfg(package="gtk+-3.0",
atleast_version = "3.4",
uselib_store="GTK_34")
conf.check_cfg(package="gtk+-3.0",
atleast_version = "3.8",
uselib_store="GTK_38")
conf.check_cfg(package="gtk+-3.0",
atleast_version = "3.10",
uselib_store="GTK_310")
conf.check_cfg(package="gtk+-3.0",
atleast_version = "3.12",
uselib_store="GTK_312")
conf.check_cfg(package="gtk+-3.0",
atleast_version = "3.14",
uselib_store="GTK_314")
conf.define('USE_GTK_3', 1)
conf.define('USE_GTKBUILDER', 1)
if opt.webkit_editor:
conf.define('USE_WEBKIT_EDITOR', 1)
env['ENABLE_WEBKIT_EDITOR'] = True
common_libs += ' "webkitgtk-3.0" '
else:
if conf.check_cfg(modversion='libgtkhtml-4.0',
msg='Checking for libgtkhtml4',
okmsg='ok',
errmsg='fail'):
common_libs += ' "libgtkhtml-4.0" '
if conf.check_cfg(modversion="gtkhtml-editor-4.0",
msg="Checking for GtkHTML Editor 4.0",
okmsg='ok',
errmsg='fail',
mandatory=True):
common_libs += ' "gtkhtml-editor-4.0" '
if opt.gtkver == '3' and opt.webkit2 and conf.check_cfg(modversion='webkit2gtk-4.0',
msg='Checking for WebKit2',
okmsg='ok',
errmsg='fail'):
common_libs += ' "webkit2gtk-4.0" '
conf.define('USE_WEBKIT2', 1)
elif conf.check_cfg(modversion='webkitgtk-3.0',
msg='Checking for WebKit',
okmsg='ok',
errmsg='fail'):
common_libs += ' "webkitgtk-3.0" '
conf.check_cfg(atleast_pkgconfig_version='0.9.0')
conf.check_cfg(msg="Checking for GNOME related libs",
package='',
args=common_libs,
uselib_store='GNOME',
mandatory=True)
env.append_value('ALL_LIBS', 'GNOME')
conf.check_cfg(package="gtk+-unix-print-2.0",
uselib_stor='GTKUPRINT')
env.append_value('ALL_LIBS', 'GTKUPRINT')
conf.check_cfg(package='sword',
args='"sword >= 1.7.3" --cflags --libs',
uselib_store='SWORD',
mandatory=True)
env.append_value('ALL_LIBS', 'SWORD')
conf.check_cfg(package='biblesync',
args='"biblesync >= 1.1.2" --cflags --libs',
uselib_store='BIBLESYNC',
errmsg='fail',
mandatory=True)
env.append_value('ALL_LIBS', 'BIBLESYNC')
if not env["IS_WIN32"]:
conf.check_cfg(package='uuid',
args='--cflags --libs',
uselib_store='UUID',
mandatory=True)
env.append_value('ALL_LIBS', 'UUID')
#
# Random defines... legacy from autotools. Can we drop these?
# Define to 1 if you have the ANSI C header files. */
dfn('STDC_HEADERS', 1)
# Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
dfn('TIME_WITH_SYS_TIME', 1)
dfn('ENABLE_NLS', 1)
dfn('HAVE_BIND_TEXTDOMAIN_CODESET', 1)
dfn('HAVE_GETTEXT', 1)
dfn('HAVE_DCGETTEXT', 1)
# Check for header files
for h in _headers:
conf.check(header_name=h)
# Define to 1 if you have the `strcasestr' function.
# this function is part of some glibc, string.h
# could be missing in win32
conf.check_cc(msg='Checking for function strcasestr', define_name="HAVE_STRCASESTR",
fragment='int main() {strcasestr("hello","he");}\n')
# enable the GS_message-style tracing printfs.
if opt.chatty:
dfn('CHATTY', 1)
# appropriate cflags
env.append_value('CXXFLAGS', env['CXXFLAGS_%s' % opt.debug_level.upper()])
env.append_value('CCFLAGS', env['CCFLAGS_%s' % opt.debug_level.upper()])
if opt.delint:
env.append_value('CXXFLAGS', env['CXXFLAGS_DELINT'])
env.append_value('CCFLAGS', env['CCFLAGS_DELINT'])
# portable adding define, should work gcc and msvc
env.append_value('CXXFLAGS', env['CXXDEFINES_ST'] % 'HAVE_CONFIG_H')
env.append_value('CCFLAGS', env['CCDEFINES_ST'] % 'HAVE_CONFIG_H')
conf.write_config_header('config.h')
env.append_value('CCFLAGS', env['CCFLAGS_SAFE'])
env.append_value('CXXFLAGS', env['CXXFLAGS_SAFE'])
def build(bld):
from waffles.hashing import GetHashofDirs
bld.env.CXXDEPS_SWORD = GetHashofDirs(bld.env.CPPPATH_SWORD)
env = bld.env
opt = Options.options
# process subfolders
bld.add_subdirs("""
src/backend
src/editor
src/main
src/gnome2
src/xiphos_html
ui
""")
bld.add_subdirs('src/webkit')
if env['IS-WIN32']:
bld.add_subdirs('win32/include')
if env['HAVE_DBUS']:
import shutil
bld.add_subdirs('src/examples')
# this seems bad, but I don't know how to do it otherwise
shutil.copy('src/gnome2/ipc-interface.xml', 'src/examples')
shutil.copy('src/gnome2/marshal.list', 'src/examples')
bld.install_files('${PACKAGE_DOC_DIR}', """
README
RELEASE-NOTES
COPYING
AUTHORS
ChangeLog
INSTALL
TODO
Xiphos.ogg
""")
bld.install_files('${PACKAGE_PIXMAPS_DIR}',bld.path.ant_glob('pixmaps/*.png'))
bld.install_files('${PACKAGE_PIXMAPS_DIR}',bld.path.ant_glob('pixmaps/*.ico'))
bld.install_files('${PACKAGE_PIXMAPS_DIR}',bld.path.ant_glob('pixmaps/*.xpm'))
bld.install_files('${DATAROOTDIR}/icons/hicolor/scalable/apps','pixmaps/xiphos.svg')
if not env["IS_WIN32"]:
bld.install_files('${PACKAGE_APPDATA_DIR}','xiphos.appdata.xml')
# handle .desktop creation and installation
if not env["IS_WIN32"]:
bld.new_task_gen(
features='subst',
source='xiphos.desktop.in.in',
target='xiphos.desktop.in',
dict={'xiphos_exec': 'xiphos',
'PACKAGE_PIXMAPS_DIR': env['PACKAGE_PIXMAPS_DIR'],
'INSTALL_PREFIX': env['INSTALL_PREFIX']},
)
bld.new_task_gen(
features='intltool_in',
source='xiphos.desktop.in',
target='xiphos.desktop',
install_path='${PACKAGE_MENU_DIR}',
podir='po',
flags=['-d', '-q', '-u', '-c']
)
# Type of help format depends on OS.
# WIN32: chm
# Other OS: just xml
# FIXME create and install help doesnt work yet on windows
if not bld.env['DISABLE_HELP']:
bld.add_subdirs('help')
if bld.env['INTLTOOL']:
bld.add_subdirs('po')
def post(ctx):
if bld.env['POST_INSTALL']:
gnome.postinstall_scrollkeeper('xiphos') # Installing the user docs
gnome.postinstall_icons() # Updating the icon cache
bld.add_post_fun(post)
import shutil
import subprocess
import glob
def dist_hook():
shutil.rmtree('win32')
def run(ctx):
'''Execute xiphos binary from build directory'''
subprocess.call(os.path.join(blddir,'default/src/gnome2/xiphos'))
def test(ctx):
'''Run unit tests'''
subprocess.call(os.path.join(srcdir,'tests/build.py'))
def dist(ctx):
import Scripting
Scripting.dist()
Scripting.g_gz = 'gz'
Scripting.dist()
def dist_dfsg(ctx):
import Scripting
global dist_hook
global VERSION
def dist_hook2():
shutil.rmtree('win32')
shutil.copytree(os.path.join(glob.glob('../.waf-*')[0],'wafadmin'), 'wafadmin', ignore=shutil.ignore_patterns('*.pyc'))
lines = []
with open('waf') as f:
lines = f.readlines()
with open('waf','w') as f:
f.writelines(lines[:-3])
VERSION = VERSION + '+dfsg'
dist_hook=dist_hook2
Scripting.dist()
|