#!/usr/bin/env python import optparse import os import pprint import re import shlex import subprocess import sys root_dir = os.path.dirname(__file__) # parse our options parser = optparse.OptionParser() parser.add_option("--debug", action="store_true", dest="debug", help="Also build debug build") parser.add_option("--node", action="store", dest="node", help="Name of the node executable (defaults to node)") parser.add_option("--pkg-config-root", action="store", dest="pkgconfig_root", help="Path to pkg-config directory") parser.add_option("--boost", action="store", dest="boost_root", help="Path to boost (defaults to /usr/local)") (options, args) = parser.parse_args() def pkg_config(pkg, pkgconfig_root): env = os.environ.copy() if pkgconfig_root: env["PKG_CONFIG_PATH"] = pkgconfig_root env["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "1" env["PKG_CONFIG_ALLOW_SYSTEM_LIBS"] = "1" cmd = subprocess.Popen(['pkg-config', '--static', '--libs', pkg], stdout=subprocess.PIPE, env=env) libs, ret = cmd.communicate() if (ret): return None cmd = subprocess.Popen(['pkg-config', '--static', '--cflags', pkg], stdout=subprocess.PIPE, env=env) cflags, ret = cmd.communicate() if (ret): return None return (libs, cflags) def configure_llmr(o): if options.boost_root: o['variables']['boost_root'] = options.boost_root else: o['variables']['boost_root'] = '/usr/local' if options.node: o['variables']['node'] = options.node else: o['variables']['node'] = 'node' o['target_defaults']['default_configuration'] = 'Debug' if options.debug else 'Release' def fix_frameworks(libs): # don't split "-framework Foo" return re.split('(?