mirror of https://github.com/lukechilds/node.git
Ryan Dahl
15 years ago
37 changed files with 1046 additions and 455 deletions
@ -0,0 +1,120 @@ |
|||||
|
#!/usr/bin/env python |
||||
|
# encoding: utf-8 |
||||
|
# daniel.svensson at purplescout.se 2008 |
||||
|
|
||||
|
import os |
||||
|
import Task, Options, Utils |
||||
|
from TaskGen import before, feature, after |
||||
|
from Configure import conf |
||||
|
|
||||
|
@feature('rubyext') |
||||
|
@before('apply_incpaths', 'apply_type_vars', 'apply_lib_vars', 'apply_bundle') |
||||
|
@after('default_cc', 'vars_target_cshlib') |
||||
|
def init_rubyext(self): |
||||
|
self.default_install_path = '${ARCHDIR_RUBY}' |
||||
|
self.uselib = self.to_list(getattr(self, 'uselib', '')) |
||||
|
if not 'RUBY' in self.uselib: |
||||
|
self.uselib.append('RUBY') |
||||
|
if not 'RUBYEXT' in self.uselib: |
||||
|
self.uselib.append('RUBYEXT') |
||||
|
|
||||
|
@feature('rubyext') |
||||
|
@before('apply_link') |
||||
|
def apply_ruby_so_name(self): |
||||
|
self.env['shlib_PATTERN'] = self.env['rubyext_PATTERN'] |
||||
|
|
||||
|
@conf |
||||
|
def check_ruby_version(conf, minver=()): |
||||
|
""" |
||||
|
Checks if ruby is installed. |
||||
|
If installed the variable RUBY will be set in environment. |
||||
|
Ruby binary can be overridden by --with-ruby-binary config variable |
||||
|
""" |
||||
|
|
||||
|
if Options.options.rubybinary: |
||||
|
conf.env.RUBY = Options.options.rubybinary |
||||
|
else: |
||||
|
conf.find_program("ruby", var="RUBY", mandatory=True) |
||||
|
|
||||
|
ruby = conf.env.RUBY |
||||
|
|
||||
|
try: |
||||
|
version = Utils.cmd_output([ruby, '-e', 'puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip() |
||||
|
except: |
||||
|
conf.fatal('could not determine ruby version') |
||||
|
conf.env.RUBY_VERSION = version |
||||
|
|
||||
|
try: |
||||
|
ver = tuple(map(int, version.split("."))) |
||||
|
except: |
||||
|
conf.fatal('unsupported ruby version %r' % version) |
||||
|
|
||||
|
cver = '' |
||||
|
if minver: |
||||
|
if ver < minver: |
||||
|
conf.fatal('ruby is too old') |
||||
|
cver = ".".join(str(x) for x in minver) |
||||
|
|
||||
|
conf.check_message('ruby', cver, True, version) |
||||
|
|
||||
|
@conf |
||||
|
def check_ruby_ext_devel(conf): |
||||
|
if not conf.env.RUBY: |
||||
|
conf.fatal('ruby detection is required first') |
||||
|
|
||||
|
if not conf.env.CC_NAME and not conf.env.CXX_NAME: |
||||
|
conf.fatal('load a c/c++ compiler first') |
||||
|
|
||||
|
version = tuple(map(int, conf.env.RUBY_VERSION.split("."))) |
||||
|
|
||||
|
def read_out(cmd): |
||||
|
return Utils.to_list(Utils.cmd_output([conf.env.RUBY, '-rrbconfig', '-e', cmd])) |
||||
|
|
||||
|
def read_config(key): |
||||
|
return read_out('puts Config::CONFIG[%r]' % key) |
||||
|
|
||||
|
ruby = conf.env['RUBY'] |
||||
|
archdir = read_config('archdir') |
||||
|
cpppath = archdir |
||||
|
if version >= (1, 9, 0): |
||||
|
ruby_hdrdir = read_config('rubyhdrdir') |
||||
|
cpppath += ruby_hdrdir |
||||
|
cpppath += [os.path.join(ruby_hdrdir[0], read_config('arch')[0])] |
||||
|
|
||||
|
conf.check(header_name='ruby.h', includes=cpppath, mandatory=True, errmsg='could not find ruby header file') |
||||
|
|
||||
|
conf.env.LIBPATH_RUBYEXT = read_config('libdir') |
||||
|
conf.env.LIBPATH_RUBYEXT += archdir |
||||
|
conf.env.CPPPATH_RUBYEXT = cpppath |
||||
|
conf.env.CCFLAGS_RUBYEXT = read_config("CCDLFLAGS") |
||||
|
conf.env.rubyext_PATTERN = '%s.' + read_config('DLEXT')[0] |
||||
|
|
||||
|
# ok this is really stupid, but the command and flags are combined. |
||||
|
# so we try to find the first argument... |
||||
|
flags = read_config('LDSHARED') |
||||
|
while flags and flags[0][0] != '-': |
||||
|
flags = flags[1:] |
||||
|
|
||||
|
# we also want to strip out the deprecated ppc flags |
||||
|
if len(flags) > 1 and flags[1] == "ppc": |
||||
|
flags = flags[2:] |
||||
|
|
||||
|
conf.env.LINKFLAGS_RUBYEXT = flags |
||||
|
conf.env.LINKFLAGS_RUBYEXT += read_config("LIBS") |
||||
|
conf.env.LINKFLAGS_RUBYEXT += read_config("LIBRUBYARG_SHARED") |
||||
|
|
||||
|
if Options.options.rubyarchdir: |
||||
|
conf.env.ARCHDIR_RUBY = Options.options.rubyarchdir |
||||
|
else: |
||||
|
conf.env.ARCHDIR_RUBY = read_config('sitearchdir')[0] |
||||
|
|
||||
|
if Options.options.rubylibdir: |
||||
|
conf.env.LIBDIR_RUBY = Options.options.rubylibdir |
||||
|
else: |
||||
|
conf.env.LIBDIR_RUBY = read_config('sitelibdir')[0] |
||||
|
|
||||
|
def set_options(opt): |
||||
|
opt.add_option('--with-ruby-archdir', type='string', dest='rubyarchdir', help='Specify directory where to install arch specific files') |
||||
|
opt.add_option('--with-ruby-libdir', type='string', dest='rubylibdir', help='Specify alternate ruby library path') |
||||
|
opt.add_option('--with-ruby-binary', type='string', dest='rubybinary', help='Specify alternate ruby binary') |
||||
|
|
@ -0,0 +1,77 @@ |
|||||
|
#!/usr/bin/env python |
||||
|
# encoding: utf-8 |
||||
|
# Thomas Nagy, 2006-2008 (ita) |
||||
|
# Ralf Habacker, 2006 (rh) |
||||
|
# Yinon Ehrlich, 2009 |
||||
|
# Michael Kuhn, 2009 |
||||
|
|
||||
|
import os, sys |
||||
|
import Configure, Options, Utils |
||||
|
import ccroot, ar |
||||
|
from Configure import conftest |
||||
|
|
||||
|
@conftest |
||||
|
def find_xlc(conf): |
||||
|
cc = conf.find_program(['xlc_r', 'xlc'], var='CC', mandatory=True) |
||||
|
cc = conf.cmd_to_list(cc) |
||||
|
conf.env.CC_NAME = 'xlc' |
||||
|
conf.env.CC = cc |
||||
|
|
||||
|
@conftest |
||||
|
def find_cpp(conf): |
||||
|
v = conf.env |
||||
|
cpp = None |
||||
|
if v['CPP']: cpp = v['CPP'] |
||||
|
elif 'CPP' in conf.environ: cpp = conf.environ['CPP'] |
||||
|
if not cpp: cpp = v['CC'] |
||||
|
v['CPP'] = cpp |
||||
|
|
||||
|
@conftest |
||||
|
def xlc_common_flags(conf): |
||||
|
v = conf.env |
||||
|
|
||||
|
# CPPFLAGS CCDEFINES _CCINCFLAGS _CCDEFFLAGS |
||||
|
v['CCFLAGS_DEBUG'] = ['-g'] |
||||
|
v['CCFLAGS_RELEASE'] = ['-O2'] |
||||
|
|
||||
|
v['CC_SRC_F'] = '' |
||||
|
v['CC_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD |
||||
|
v['CPPPATH_ST'] = '-I%s' # template for adding include paths |
||||
|
|
||||
|
# linker |
||||
|
if not v['LINK_CC']: v['LINK_CC'] = v['CC'] |
||||
|
v['CCLNK_SRC_F'] = '' |
||||
|
v['CCLNK_TGT_F'] = ['-o', ''] # shell hack for -MD |
||||
|
|
||||
|
v['LIB_ST'] = '-l%s' # template for adding libs |
||||
|
v['LIBPATH_ST'] = '-L%s' # template for adding libpaths |
||||
|
v['STATICLIB_ST'] = '-l%s' |
||||
|
v['STATICLIBPATH_ST'] = '-L%s' |
||||
|
v['RPATH_ST'] = '-Wl,-rpath,%s' |
||||
|
v['CCDEFINES_ST'] = '-D%s' |
||||
|
|
||||
|
v['SONAME_ST'] = '' |
||||
|
v['SHLIB_MARKER'] = '' |
||||
|
v['STATICLIB_MARKER'] = '' |
||||
|
v['FULLSTATIC_MARKER'] = '-static' |
||||
|
|
||||
|
# program |
||||
|
v['program_LINKFLAGS'] = ['-Wl,-brtl'] |
||||
|
v['program_PATTERN'] = '%s' |
||||
|
|
||||
|
# shared library |
||||
|
v['shlib_CCFLAGS'] = ['-fPIC', '-DPIC'] # avoid using -DPIC, -fPIC aleady defines the __PIC__ macro |
||||
|
v['shlib_LINKFLAGS'] = ['-G', '-Wl,-brtl,-bexpfull'] |
||||
|
v['shlib_PATTERN'] = 'lib%s.so' |
||||
|
|
||||
|
# static lib |
||||
|
v['staticlib_LINKFLAGS'] = '' |
||||
|
v['staticlib_PATTERN'] = 'lib%s.a' |
||||
|
|
||||
|
def detect(conf): |
||||
|
conf.find_xlc() |
||||
|
conf.find_cpp() |
||||
|
conf.find_ar() |
||||
|
conf.xlc_common_flags() |
||||
|
conf.cc_load_tools() |
||||
|
conf.cc_add_flags() |
@ -0,0 +1,77 @@ |
|||||
|
#!/usr/bin/env python |
||||
|
# encoding: utf-8 |
||||
|
# Thomas Nagy, 2006 (ita) |
||||
|
# Ralf Habacker, 2006 (rh) |
||||
|
# Yinon Ehrlich, 2009 |
||||
|
# Michael Kuhn, 2009 |
||||
|
|
||||
|
import os, sys |
||||
|
import Configure, Options, Utils |
||||
|
import ccroot, ar |
||||
|
from Configure import conftest |
||||
|
|
||||
|
@conftest |
||||
|
def find_xlcxx(conf): |
||||
|
cxx = conf.find_program(['xlc++_r', 'xlc++'], var='CXX', mandatory=True) |
||||
|
cxx = conf.cmd_to_list(cxx) |
||||
|
conf.env.CXX_NAME = 'xlc++' |
||||
|
conf.env.CXX = cxx |
||||
|
|
||||
|
@conftest |
||||
|
def find_cpp(conf): |
||||
|
v = conf.env |
||||
|
cpp = None |
||||
|
if v['CPP']: cpp = v['CPP'] |
||||
|
elif 'CPP' in conf.environ: cpp = conf.environ['CPP'] |
||||
|
if not cpp: cpp = v['CXX'] |
||||
|
v['CPP'] = cpp |
||||
|
|
||||
|
@conftest |
||||
|
def xlcxx_common_flags(conf): |
||||
|
v = conf.env |
||||
|
|
||||
|
# CPPFLAGS CXXDEFINES _CXXINCFLAGS _CXXDEFFLAGS |
||||
|
v['CXXFLAGS_DEBUG'] = ['-g'] |
||||
|
v['CXXFLAGS_RELEASE'] = ['-O2'] |
||||
|
|
||||
|
v['CXX_SRC_F'] = '' |
||||
|
v['CXX_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD |
||||
|
v['CPPPATH_ST'] = '-I%s' # template for adding include paths |
||||
|
|
||||
|
# linker |
||||
|
if not v['LINK_CXX']: v['LINK_CXX'] = v['CXX'] |
||||
|
v['CXXLNK_SRC_F'] = '' |
||||
|
v['CXXLNK_TGT_F'] = ['-o', ''] # shell hack for -MD |
||||
|
|
||||
|
v['LIB_ST'] = '-l%s' # template for adding libs |
||||
|
v['LIBPATH_ST'] = '-L%s' # template for adding libpaths |
||||
|
v['STATICLIB_ST'] = '-l%s' |
||||
|
v['STATICLIBPATH_ST'] = '-L%s' |
||||
|
v['RPATH_ST'] = '-Wl,-rpath,%s' |
||||
|
v['CXXDEFINES_ST'] = '-D%s' |
||||
|
|
||||
|
v['SONAME_ST'] = '' |
||||
|
v['SHLIB_MARKER'] = '' |
||||
|
v['STATICLIB_MARKER'] = '' |
||||
|
v['FULLSTATIC_MARKER'] = '-static' |
||||
|
|
||||
|
# program |
||||
|
v['program_LINKFLAGS'] = ['-Wl,-brtl'] |
||||
|
v['program_PATTERN'] = '%s' |
||||
|
|
||||
|
# shared library |
||||
|
v['shlib_CXXFLAGS'] = ['-fPIC', '-DPIC'] # avoid using -DPIC, -fPIC aleady defines the __PIC__ macro |
||||
|
v['shlib_LINKFLAGS'] = ['-G', '-Wl,-brtl,-bexpfull'] |
||||
|
v['shlib_PATTERN'] = 'lib%s.so' |
||||
|
|
||||
|
# static lib |
||||
|
v['staticlib_LINKFLAGS'] = '' |
||||
|
v['staticlib_PATTERN'] = 'lib%s.a' |
||||
|
|
||||
|
def detect(conf): |
||||
|
conf.find_xlcxx() |
||||
|
conf.find_cpp() |
||||
|
conf.find_ar() |
||||
|
conf.xlcxx_common_flags() |
||||
|
conf.cxx_load_tools() |
||||
|
conf.cxx_add_flags() |
Loading…
Reference in new issue