2009-02-06 15:31:12 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Waf utilities for easily building standard unixey packages/libraries
|
|
|
|
# Licensed under the GNU GPL v2 or later, see COPYING file for details.
|
|
|
|
# Copyright (C) 2008 Dave Robillard
|
|
|
|
# Copyright (C) 2008 Nedko Arnaudov
|
|
|
|
|
|
|
|
import os
|
|
|
|
import misc
|
|
|
|
import Configure
|
|
|
|
import Options
|
|
|
|
import Utils
|
|
|
|
import sys
|
|
|
|
from TaskGen import feature, before, after
|
|
|
|
|
|
|
|
global g_is_child
|
|
|
|
g_is_child = False
|
|
|
|
|
|
|
|
# Only run autowaf hooks once (even if sub projects call several times)
|
|
|
|
global g_step
|
|
|
|
g_step = 0
|
|
|
|
|
|
|
|
# Compute dependencies globally
|
|
|
|
#import preproc
|
|
|
|
#preproc.go_absolute = True
|
|
|
|
|
|
|
|
@feature('cc', 'cxx')
|
|
|
|
@after('apply_lib_vars')
|
|
|
|
@before('apply_obj_vars_cc', 'apply_obj_vars_cxx')
|
|
|
|
def include_config_h(self):
|
|
|
|
self.env.append_value('INC_PATHS', self.bld.srcnode)
|
|
|
|
|
|
|
|
def set_options(opt):
|
|
|
|
"Add standard autowaf options if they havn't been added yet"
|
|
|
|
global g_step
|
|
|
|
if g_step > 0:
|
|
|
|
return
|
|
|
|
opt.tool_options('compiler_cc')
|
|
|
|
opt.tool_options('compiler_cxx')
|
|
|
|
opt.add_option('--debug', action='store_true', default=False, dest='debug',
|
|
|
|
help="Build debuggable binaries [Default: False]")
|
|
|
|
opt.add_option('--strict', action='store_true', default=False, dest='strict',
|
|
|
|
help="Use strict compiler flags and show all warnings [Default: False]")
|
|
|
|
opt.add_option('--build-docs', action='store_true', default=False, dest='build_docs',
|
|
|
|
help="Build documentation - requires doxygen [Default: False]")
|
|
|
|
opt.add_option('--bundle', action='store_true', default=False,
|
|
|
|
help="Build a self-contained bundle [Default: False]")
|
|
|
|
opt.add_option('--bindir', type='string',
|
|
|
|
help="Executable programs [Default: PREFIX/bin]")
|
|
|
|
opt.add_option('--libdir', type='string',
|
|
|
|
help="Libraries [Default: PREFIX/lib]")
|
|
|
|
opt.add_option('--includedir', type='string',
|
|
|
|
help="Header files [Default: PREFIX/include]")
|
|
|
|
opt.add_option('--datadir', type='string',
|
|
|
|
help="Shared data [Default: PREFIX/share]")
|
2009-02-25 16:48:32 -05:00
|
|
|
opt.add_option('--configdir', type='string',
|
|
|
|
help="Configuration data [Default: PREFIX/etc]")
|
2009-02-06 15:31:12 -05:00
|
|
|
opt.add_option('--mandir', type='string',
|
|
|
|
help="Manual pages [Default: DATADIR/man]")
|
|
|
|
opt.add_option('--htmldir', type='string',
|
|
|
|
help="HTML documentation [Default: DATADIR/doc/PACKAGE]")
|
|
|
|
opt.add_option('--lv2-user', action='store_true', default=False, dest='lv2_user',
|
|
|
|
help="Install LV2 bundles to user-local location [Default: False]")
|
|
|
|
if sys.platform == "darwin":
|
|
|
|
opt.add_option('--lv2dir', type='string',
|
|
|
|
help="LV2 bundles [Default: /Library/Audio/Plug-Ins/LV2]")
|
|
|
|
else:
|
|
|
|
opt.add_option('--lv2dir', type='string',
|
|
|
|
help="LV2 bundles [Default: LIBDIR/lv2]")
|
|
|
|
g_step = 1
|
|
|
|
|
|
|
|
def check_header(conf, name, define='', mandatory=False):
|
|
|
|
"Check for a header iff it hasn't been checked for yet"
|
|
|
|
if type(conf.env['AUTOWAF_HEADERS']) != dict:
|
|
|
|
conf.env['AUTOWAF_HEADERS'] = {}
|
|
|
|
|
|
|
|
checked = conf.env['AUTOWAF_HEADERS']
|
|
|
|
if not name in checked:
|
|
|
|
checked[name] = True
|
|
|
|
if define != '':
|
2009-02-14 15:53:51 -05:00
|
|
|
conf.check(header_name=name, define_name=define, mandatory=mandatory)
|
2009-02-06 15:31:12 -05:00
|
|
|
else:
|
2009-02-14 15:53:51 -05:00
|
|
|
conf.check(header_name=name, mandatory=mandatory)
|
2009-02-06 15:31:12 -05:00
|
|
|
|
2009-02-25 14:36:16 -05:00
|
|
|
def nameify(name):
|
2009-07-22 16:51:13 -04:00
|
|
|
return name.replace('/', '_').replace('++', 'PP').replace('-', '_').replace('.', '_')
|
2009-02-25 14:36:16 -05:00
|
|
|
|
2009-02-06 15:31:12 -05:00
|
|
|
def check_pkg(conf, name, **args):
|
2009-02-25 18:21:49 -05:00
|
|
|
if not 'mandatory' in args:
|
|
|
|
args['mandatory'] = True
|
2009-02-06 15:31:12 -05:00
|
|
|
"Check for a package iff it hasn't been checked for yet"
|
2009-02-25 14:36:16 -05:00
|
|
|
var_name = 'HAVE_' + nameify(args['uselib_store'])
|
2009-02-06 15:31:12 -05:00
|
|
|
check = not var_name in conf.env
|
|
|
|
if not check and 'atleast_version' in args:
|
|
|
|
# Re-check if version is newer than previous check
|
|
|
|
checked_version = conf.env['VERSION_' + name]
|
|
|
|
if checked_version and checked_version < args['atleast_version']:
|
|
|
|
check = True;
|
|
|
|
if check:
|
|
|
|
conf.check_cfg(package=name, args="--cflags --libs", **args)
|
2009-02-25 12:51:42 -05:00
|
|
|
found = bool(conf.env[var_name])
|
2009-02-06 15:31:12 -05:00
|
|
|
if found:
|
2009-02-25 12:51:42 -05:00
|
|
|
conf.define(var_name, int(found))
|
2009-02-06 15:31:12 -05:00
|
|
|
if 'atleast_version' in args:
|
|
|
|
conf.env['VERSION_' + name] = args['atleast_version']
|
|
|
|
else:
|
2009-02-25 12:51:42 -05:00
|
|
|
conf.undefine(var_name)
|
2009-02-06 15:31:12 -05:00
|
|
|
if args['mandatory'] == True:
|
|
|
|
conf.fatal("Required package " + name + " not found")
|
|
|
|
|
|
|
|
def chop_prefix(conf, var):
|
|
|
|
name = conf.env[var][len(conf.env['PREFIX']):]
|
|
|
|
if len(name) > 0 and name[0] == '/':
|
|
|
|
name = name[1:]
|
|
|
|
if name == "":
|
|
|
|
name = "/"
|
|
|
|
return name;
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
global g_step
|
|
|
|
if g_step > 1:
|
|
|
|
return
|
2009-02-26 15:49:21 -05:00
|
|
|
def append_cxx_flags(vals):
|
|
|
|
conf.env.append_value('CCFLAGS', vals.split())
|
|
|
|
conf.env.append_value('CXXFLAGS', vals.split())
|
2009-02-25 18:21:49 -05:00
|
|
|
conf.line_just = 43
|
2009-07-22 16:51:13 -04:00
|
|
|
conf.check_tool('misc')
|
|
|
|
conf.check_tool('compiler_cc')
|
|
|
|
conf.check_tool('compiler_cxx')
|
2009-02-06 15:31:12 -05:00
|
|
|
conf.env['BUILD_DOCS'] = Options.options.build_docs
|
|
|
|
conf.env['DEBUG'] = Options.options.debug
|
2009-02-26 12:16:22 -05:00
|
|
|
conf.env['STRICT'] = Options.options.strict
|
2009-02-06 15:31:12 -05:00
|
|
|
conf.env['PREFIX'] = os.path.abspath(os.path.expanduser(os.path.normpath(conf.env['PREFIX'])))
|
2009-08-08 18:36:32 -04:00
|
|
|
|
|
|
|
if sys.platform == 'darwin':
|
|
|
|
#
|
|
|
|
# Define OSX as a uselib to use when compiling
|
|
|
|
# on Darwin to add all applicable flags at once
|
|
|
|
#
|
|
|
|
conf.env.append_value('CXXFLAGS_OSX', "-mmacosx-version-min=10.4")
|
|
|
|
conf.env.append_value('CCFLAGS_OSX', "-mmacosx-version-min=10.4")
|
|
|
|
conf.env.append_value('CXXFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
|
|
|
conf.env.append_value('CCFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
|
|
|
conf.env.append_value('LINKFLAGS_OSX', "-mmacosx-version-min=10.4")
|
|
|
|
conf.env.append_value('LINKFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
|
|
|
|
|
|
|
conf.env.append_value('LINKFLAGS_OSX', "-sysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
|
|
|
conf.env.append_value('LINKFLAGS_OSX', "-F/System/Library/Frameworks")
|
|
|
|
|
|
|
|
conf.env.append_value('CXXFLAGS_OSX', "-msse")
|
|
|
|
conf.env.append_value('CCFLAGS_OSX', "-msse")
|
|
|
|
conf.env.append_value('CXXFLAGS_OSX', "-msse2")
|
|
|
|
conf.env.append_value('CCFLAGS_OSX', "-msse2")
|
|
|
|
#
|
|
|
|
# TODO: The previous sse flags NEED to be based
|
|
|
|
# off processor type. Need to add in a check
|
|
|
|
# for that.
|
|
|
|
#
|
|
|
|
|
|
|
|
conf.env.append_value('LINKFLAGS_OSX', ['-undefined', 'suppress'])
|
|
|
|
conf.env.append_value('LINKFLAGS_OSX', "-flat_namespace")
|
|
|
|
#
|
|
|
|
# The previous 2 flags avoid circular dependencies
|
|
|
|
# between libardour and libardour_cp on OS X.
|
|
|
|
# ld reported -undefined suppress as an unknown option
|
|
|
|
# in one of the tests ran, removing it for the moment
|
|
|
|
#
|
|
|
|
conf.env.append_value('CXXFLAGS_OSX', "-F/System/Library/Frameworks")
|
|
|
|
conf.env.append_value('CCFLAGS_OSX', "-F/System/Library/Frameworks")
|
|
|
|
|
|
|
|
|
|
|
|
if Options.options.gtkosx:
|
|
|
|
#
|
|
|
|
# Define Include Paths for GTKOSX
|
|
|
|
#
|
|
|
|
conf.env.append_value('CPPPATH_GTKOSX', "/usr/include/")
|
|
|
|
conf.env.append_value('CPPPATH_GTKOSX', "/usr/include/c++/4.0.0")
|
|
|
|
conf.env.append_value('CPPPATH_GTKOSX', "/usr/include/c++/4.0.0/i686-apple-darwin8/")
|
|
|
|
#
|
|
|
|
# TODO: Fix the above include path, it needs to be
|
|
|
|
# defined based off what is read in the configuration
|
|
|
|
# stage about the machine(PPC, X86, X86_64, etc.)
|
|
|
|
#
|
|
|
|
conf.env.append_value('CPPPATH_GTKOSX', "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/")
|
|
|
|
#
|
|
|
|
# TODO: Likewise this needs to be defined not only
|
|
|
|
# based off the machine characteristics, but also
|
|
|
|
# based off the version of GCC being used.
|
|
|
|
#
|
|
|
|
conf.env.append_value('CPPPATH_GTKOSX', "/System/Library/Frameworks/")
|
|
|
|
conf.env.append_value('CXXFLAGS_GTKOSX', '-DTOP_MENUBAR')
|
|
|
|
conf.env.append_value('CXXFLAGS_GTKOSX', '-DGTKOSX')
|
|
|
|
conf.env.append_value('LINKFLAGS_GTKOSX', "-framework AppKit")
|
|
|
|
conf.env.append_value('LINKFLAGS_GTKOSX', "-Xlinker -headerpad")
|
|
|
|
conf.env.append_value('LINKFLAGS_GTKOSX', "-Xlinker 2048")
|
|
|
|
conf.env.append_value('CPPPATH_GTKOSX', "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/")
|
|
|
|
#
|
|
|
|
# I had a note the previous was for MacTypes.h
|
|
|
|
#
|
|
|
|
|
|
|
|
if Options.options.coreaudio:
|
|
|
|
#conf.env.append_value('LINKFLAGS_COREAUDIO', "-framework CoreAudioKit")
|
|
|
|
#conf.env.append_value('LINKFLAGS_COREAUDIO', "-framework AudioToolbox")
|
|
|
|
#conf.env.append_value('LINKFLAGS_COREAUDIO', "-framework CoreServices")
|
|
|
|
conf.check_cc (header_name = '/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h',
|
|
|
|
define_name = 'HAVE_COREAUDIO', linkflags = ['-framework', 'CoreAudio'])
|
|
|
|
conf.check_cxx (header_name = '/System/Library/Frameworks/AudioToolbox.framework/Headers/ExtendedAudioFile.h',
|
|
|
|
linkflags = [ '-framework', 'AudioToolbox' ])
|
|
|
|
conf.check_cc (header_name = '/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h',
|
|
|
|
linkflags = ['-framework', 'CoreFoundation'])
|
|
|
|
conf.check_cc (header_name = '/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h',
|
|
|
|
linkflags = ['-framework', 'CoreServices'])
|
|
|
|
#
|
|
|
|
# TODO: For some reason the above doesn't seem to be correctly adding the
|
|
|
|
# the link flags, so we will add them manually.
|
|
|
|
#
|
|
|
|
conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'CoreServices'])
|
|
|
|
conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'CoreFoundation'])
|
|
|
|
conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'AudioToolbox'])
|
|
|
|
conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'CoreAudio'])
|
|
|
|
|
|
|
|
if Options.options.audiounits:
|
|
|
|
#conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DHAVE_AUDIOUNITS")
|
|
|
|
conf.env.append_value('LINKFLAGS_AUDIOUNITS', "-framework AudioToolbox")
|
|
|
|
conf.env.append_value('LINKFLAGS_AUDIOUNITS', "-framework CoreServices")
|
|
|
|
conf.check_cc (header_name = '/System/Library/Frameworks/AudioUnit.framework/Headers/AudioUnit.h',
|
|
|
|
define_name = 'HAVE_AUDIOUNITS', linkflags = [ '-framework', 'AudioUnit' ])
|
|
|
|
|
|
|
|
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.bundle:
|
|
|
|
conf.env['BUNDLE'] = True
|
|
|
|
conf.define('BUNDLE', 1)
|
|
|
|
conf.env['BINDIR'] = conf.env['PREFIX']
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['INCLUDEDIR'] = os.path.join(conf.env['PREFIX'], 'Headers')
|
|
|
|
conf.env['LIBDIR'] = os.path.join(conf.env['PREFIX'], 'Libraries')
|
|
|
|
conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'Resources')
|
|
|
|
conf.env['HTMLDIR'] = os.path.join(conf.env['PREFIX'], 'Resources/Documentation')
|
|
|
|
conf.env['MANDIR'] = os.path.join(conf.env['PREFIX'], 'Resources/Man')
|
|
|
|
conf.env['LV2DIR'] = os.path.join(conf.env['PREFIX'], 'PlugIns')
|
2009-02-06 15:31:12 -05:00
|
|
|
else:
|
|
|
|
conf.env['BUNDLE'] = False
|
|
|
|
if Options.options.bindir:
|
|
|
|
conf.env['BINDIR'] = Options.options.bindir
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['BINDIR'] = os.path.join(conf.env['PREFIX'], 'bin')
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.includedir:
|
|
|
|
conf.env['INCLUDEDIR'] = Options.options.includedir
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['INCLUDEDIR'] = os.path.join(conf.env['PREFIX'], 'include')
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.libdir:
|
|
|
|
conf.env['LIBDIR'] = Options.options.libdir
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['LIBDIR'] = os.path.join(conf.env['PREFIX'], 'lib')
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.datadir:
|
|
|
|
conf.env['DATADIR'] = Options.options.datadir
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'share')
|
2009-02-25 16:48:32 -05:00
|
|
|
if Options.options.configdir:
|
|
|
|
conf.env['CONFIGDIR'] = Options.options.configdir
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['CONFIGDIR'] = os.path.join(conf.env['PREFIX'], 'etc')
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.htmldir:
|
|
|
|
conf.env['HTMLDIR'] = Options.options.htmldir
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['HTMLDIR'] = os.path.join(conf.env['DATADIR'], 'doc', Utils.g_module.APPNAME)
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.mandir:
|
|
|
|
conf.env['MANDIR'] = Options.options.mandir
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['MANDIR'] = os.path.join(conf.env['DATADIR'], 'man')
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.lv2dir:
|
|
|
|
conf.env['LV2DIR'] = Options.options.lv2dir
|
|
|
|
else:
|
|
|
|
if Options.options.lv2_user:
|
|
|
|
if sys.platform == "darwin":
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['LV2DIR'] = os.path.join(os.getenv('HOME'), 'Library/Audio/Plug-Ins/LV2')
|
2009-02-06 15:31:12 -05:00
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['LV2DIR'] = os.path.join(os.getenv('HOME'), '.lv2')
|
2009-02-06 15:31:12 -05:00
|
|
|
else:
|
|
|
|
if sys.platform == "darwin":
|
|
|
|
conf.env['LV2DIR'] = '/Library/Audio/Plug-Ins/LV2'
|
|
|
|
else:
|
2009-02-26 22:21:45 -05:00
|
|
|
conf.env['LV2DIR'] = os.path.join(conf.env['LIBDIR'], 'lv2')
|
2009-02-06 15:31:12 -05:00
|
|
|
|
|
|
|
conf.env['BINDIRNAME'] = chop_prefix(conf, 'BINDIR')
|
|
|
|
conf.env['LIBDIRNAME'] = chop_prefix(conf, 'LIBDIR')
|
|
|
|
conf.env['DATADIRNAME'] = chop_prefix(conf, 'DATADIR')
|
2009-02-25 16:48:32 -05:00
|
|
|
conf.env['CONFIGDIRNAME'] = chop_prefix(conf, 'CONFIGDIR')
|
2009-02-06 15:31:12 -05:00
|
|
|
conf.env['LV2DIRNAME'] = chop_prefix(conf, 'LV2DIR')
|
|
|
|
|
|
|
|
if Options.options.debug:
|
2009-02-26 15:49:21 -05:00
|
|
|
conf.env['CCFLAGS'] = [ '-O0', '-g' ]
|
|
|
|
conf.env['CXXFLAGS'] = [ '-O0', '-g' ]
|
2009-02-26 11:16:28 -05:00
|
|
|
else:
|
|
|
|
append_cxx_flags('-DNDEBUG')
|
2009-02-06 15:31:12 -05:00
|
|
|
if Options.options.strict:
|
2009-02-26 15:49:21 -05:00
|
|
|
conf.env.append_value('CCFLAGS', [ '-std=c99', '-pedantic' ])
|
|
|
|
conf.env.append_value('CXXFLAGS', [ '-ansi', '-Woverloaded-virtual'])
|
2009-02-06 15:31:12 -05:00
|
|
|
append_cxx_flags('-Wall -Wextra -Wno-unused-parameter')
|
2009-02-26 19:09:16 -05:00
|
|
|
append_cxx_flags('-fPIC -DPIC -fshow-column')
|
2009-02-06 15:31:12 -05:00
|
|
|
g_step = 2
|
|
|
|
|
|
|
|
def set_local_lib(conf, name, has_objects):
|
2009-02-25 14:36:16 -05:00
|
|
|
conf.define('HAVE_' + nameify(name.upper()), 1)
|
2009-02-06 15:31:12 -05:00
|
|
|
if has_objects:
|
|
|
|
if type(conf.env['AUTOWAF_LOCAL_LIBS']) != dict:
|
|
|
|
conf.env['AUTOWAF_LOCAL_LIBS'] = {}
|
|
|
|
conf.env['AUTOWAF_LOCAL_LIBS'][name.lower()] = True
|
|
|
|
else:
|
|
|
|
if type(conf.env['AUTOWAF_LOCAL_HEADERS']) != dict:
|
|
|
|
conf.env['AUTOWAF_LOCAL_HEADERS'] = {}
|
|
|
|
conf.env['AUTOWAF_LOCAL_HEADERS'][name.lower()] = True
|
|
|
|
|
|
|
|
def use_lib(bld, obj, libs):
|
|
|
|
abssrcdir = os.path.abspath('.')
|
|
|
|
libs_list = libs.split()
|
|
|
|
for l in libs_list:
|
|
|
|
in_headers = l.lower() in bld.env['AUTOWAF_LOCAL_HEADERS']
|
|
|
|
in_libs = l.lower() in bld.env['AUTOWAF_LOCAL_LIBS']
|
|
|
|
if in_libs:
|
|
|
|
if hasattr(obj, 'uselib_local'):
|
|
|
|
obj.uselib_local += ' lib' + l.lower() + ' '
|
|
|
|
else:
|
|
|
|
obj.uselib_local = 'lib' + l.lower() + ' '
|
|
|
|
|
|
|
|
if in_headers or in_libs:
|
2009-02-26 22:21:45 -05:00
|
|
|
inc_flag = '-iquote ' + os.path.join(abssrcdir, l.lower())
|
2009-02-06 15:31:12 -05:00
|
|
|
for f in ['CCFLAGS', 'CXXFLAGS']:
|
|
|
|
if not inc_flag in bld.env[f]:
|
2009-07-22 16:51:13 -04:00
|
|
|
bld.env.append_value(f, inc_flag)
|
2009-02-06 15:31:12 -05:00
|
|
|
else:
|
|
|
|
if hasattr(obj, 'uselib'):
|
|
|
|
obj.uselib += ' ' + l
|
|
|
|
else:
|
|
|
|
obj.uselib = l
|
|
|
|
|
|
|
|
|
|
|
|
def display_header(title):
|
|
|
|
Utils.pprint('BOLD', title)
|
|
|
|
|
|
|
|
def display_msg(conf, msg, status = None, color = None):
|
|
|
|
color = 'CYAN'
|
|
|
|
if type(status) == bool and status or status == "True":
|
|
|
|
color = 'GREEN'
|
|
|
|
elif type(status) == bool and not status or status == "False":
|
|
|
|
color = 'YELLOW'
|
2009-02-25 11:41:27 -05:00
|
|
|
Utils.pprint('NORMAL', "%s :" % msg.ljust(conf.line_just), sep='')
|
2009-02-06 15:31:12 -05:00
|
|
|
Utils.pprint(color, status)
|
|
|
|
|
|
|
|
def print_summary(conf):
|
|
|
|
global g_step
|
|
|
|
if g_step > 2:
|
|
|
|
print
|
|
|
|
return
|
|
|
|
e = conf.env
|
|
|
|
print
|
|
|
|
display_header('Global configuration')
|
|
|
|
display_msg(conf, "Install prefix", conf.env['PREFIX'])
|
|
|
|
display_msg(conf, "Debuggable build", str(conf.env['DEBUG']))
|
2009-02-26 12:16:22 -05:00
|
|
|
display_msg(conf, "Strict compiler flags", str(conf.env['STRICT']))
|
2009-02-06 15:31:12 -05:00
|
|
|
display_msg(conf, "Build documentation", str(conf.env['BUILD_DOCS']))
|
|
|
|
print
|
|
|
|
g_step = 3
|
|
|
|
|
|
|
|
def link_flags(env, lib):
|
|
|
|
return ' '.join(map(lambda x: env['LIB_ST'] % x, env['LIB_' + lib]))
|
|
|
|
|
|
|
|
def compile_flags(env, lib):
|
|
|
|
return ' '.join(map(lambda x: env['CPPPATH_ST'] % x, env['CPPPATH_' + lib]))
|
|
|
|
|
|
|
|
def set_recursive():
|
|
|
|
global g_is_child
|
|
|
|
g_is_child = True
|
|
|
|
|
|
|
|
def is_child():
|
|
|
|
global g_is_child
|
|
|
|
return g_is_child
|
|
|
|
|
|
|
|
# Pkg-config file
|
|
|
|
def build_pc(bld, name, version, libs):
|
|
|
|
'''Build a pkg-config file for a library.
|
|
|
|
name -- uppercase variable name (e.g. 'SOMENAME')
|
|
|
|
version -- version string (e.g. '1.2.3')
|
|
|
|
libs -- string/list of dependencies (e.g. 'LIBFOO GLIB')
|
|
|
|
'''
|
|
|
|
|
|
|
|
obj = bld.new_task_gen('subst')
|
|
|
|
obj.source = name.lower() + '.pc.in'
|
|
|
|
obj.target = name.lower() + '.pc'
|
|
|
|
obj.install_path = '${PREFIX}/${LIBDIRNAME}/pkgconfig'
|
|
|
|
pkg_prefix = bld.env['PREFIX']
|
|
|
|
if pkg_prefix[-1] == '/':
|
|
|
|
pkg_prefix = pkg_prefix[:-1]
|
|
|
|
obj.dict = {
|
|
|
|
'prefix' : pkg_prefix,
|
|
|
|
'exec_prefix' : '${prefix}',
|
|
|
|
'libdir' : '${exec_prefix}/lib',
|
|
|
|
'includedir' : '${prefix}/include',
|
|
|
|
name + '_VERSION' : version,
|
|
|
|
}
|
|
|
|
if type(libs) != list:
|
|
|
|
libs = libs.split()
|
|
|
|
for i in libs:
|
|
|
|
obj.dict[i + '_LIBS'] = link_flags(bld.env, i)
|
|
|
|
obj.dict[i + '_CFLAGS'] = compile_flags(bld.env, i)
|
|
|
|
|
|
|
|
# Doxygen API documentation
|
|
|
|
def build_dox(bld, name, version, srcdir, blddir):
|
|
|
|
if not bld.env['BUILD_DOCS']:
|
|
|
|
return
|
|
|
|
obj = bld.new_task_gen('subst')
|
|
|
|
obj.source = 'doc/reference.doxygen.in'
|
|
|
|
obj.target = 'doc/reference.doxygen'
|
|
|
|
if is_child():
|
2009-02-26 22:21:45 -05:00
|
|
|
src_dir = os.path.join(srcdir, name.lower())
|
|
|
|
doc_dir = os.path.join(blddir, 'default', name.lower(), 'doc')
|
2009-02-06 15:31:12 -05:00
|
|
|
else:
|
|
|
|
src_dir = srcdir
|
2009-02-26 22:21:45 -05:00
|
|
|
doc_dir = os.path.join(blddir, 'default', 'doc')
|
2009-02-06 15:31:12 -05:00
|
|
|
obj.dict = {
|
|
|
|
name + '_VERSION' : version,
|
|
|
|
name + '_SRCDIR' : os.path.abspath(src_dir),
|
|
|
|
name + '_DOC_DIR' : os.path.abspath(doc_dir)
|
|
|
|
}
|
|
|
|
obj.install_path = ''
|
|
|
|
out1 = bld.new_task_gen('command-output')
|
2009-07-22 16:51:13 -04:00
|
|
|
out1.dependencies = [obj]
|
2009-02-06 15:31:12 -05:00
|
|
|
out1.stdout = '/doc/doxygen.out'
|
|
|
|
out1.stdin = '/doc/reference.doxygen' # whatever..
|
|
|
|
out1.command = 'doxygen'
|
|
|
|
out1.argv = [os.path.abspath(doc_dir) + '/reference.doxygen']
|
|
|
|
out1.command_is_external = True
|
|
|
|
|
2009-02-25 21:24:16 -05:00
|
|
|
# Version code file generation
|
|
|
|
def build_version_files(header_path, source_path, domain, major, minor, micro):
|
|
|
|
header_path = os.path.abspath(header_path)
|
|
|
|
source_path = os.path.abspath(source_path)
|
|
|
|
text = "int " + domain + "_major_version = " + str(major) + ";\n"
|
|
|
|
text += "int " + domain + "_minor_version = " + str(minor) + ";\n"
|
|
|
|
text += "int " + domain + "_micro_version = " + str(micro) + ";\n"
|
|
|
|
try:
|
|
|
|
o = file(source_path, 'w')
|
|
|
|
o.write(text)
|
|
|
|
o.close()
|
|
|
|
except IOError:
|
|
|
|
print "Could not open", source_path, " for writing\n"
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
text = "#ifndef __" + domain + "_version_h__\n"
|
|
|
|
text += "#define __" + domain + "_version_h__\n"
|
|
|
|
text += "extern const char* " + domain + "_revision;\n"
|
|
|
|
text += "extern int " + domain + "_major_version;\n"
|
|
|
|
text += "extern int " + domain + "_minor_version;\n"
|
|
|
|
text += "extern int " + domain + "_micro_version;\n"
|
|
|
|
text += "#endif /* __" + domain + "_version_h__ */\n"
|
|
|
|
try:
|
|
|
|
o = file(header_path, 'w')
|
|
|
|
o.write(text)
|
|
|
|
o.close()
|
|
|
|
except IOError:
|
|
|
|
print "Could not open", header_path, " for writing\n"
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
2009-02-06 15:31:12 -05:00
|
|
|
def shutdown():
|
|
|
|
# This isn't really correct (for packaging), but people asking is annoying
|
|
|
|
if Options.commands['install']:
|
|
|
|
try: os.popen("/sbin/ldconfig")
|
|
|
|
except: pass
|
|
|
|
|