Permalink
Browse files

Adapted SConscript to allow for OpenWRT cross-compilation (#68)

  • Loading branch information...
1 parent 11af1db commit cb80ca9c2d2a864ba5316cb27d85395e2ece74ac @ereOn ereOn committed Apr 19, 2015
Showing with 40 additions and 33 deletions.
  1. +1 −1 BUILD.md
  2. +38 −31 SConstruct
  3. +1 −1 apps/freelan/SConscript
View
@@ -42,7 +42,7 @@ To build everything in the directory (including samples), type instead:
To build then install everything into a specific directory, type instead:
-> scons install --prefix=/usr/local/
+> scons install prefix=/usr/local/
### Debugging
View
@@ -12,18 +12,6 @@ from fnmatch import fnmatch
# This file is local.
from defines import Defines
-
-AddOption(
- '--prefix',
- dest='prefix',
- default='./install',
- type='string',
- nargs=1,
- action='store',
- metavar='DIR',
- help='The installation prefix.',
-)
-
AddOption(
'--mode',
dest='mode',
@@ -49,29 +37,52 @@ class FreelanEnvironment(Environment):
"""
super(FreelanEnvironment, self).__init__(**kwargs)
+ # Inherit the environment from the context.
+ self['ENV'] = os.environ
+
self.defines = Defines()
self.defines.register_into(self)
for flag in [
- 'CXX',
'CC',
+ 'CXX',
'AR',
'LINK',
]:
if flag in os.environ:
self[flag] = os.environ[flag]
for flag in [
+ 'CFLAGS',
'CXXFLAGS',
- 'CCFLAGS',
+ 'CPPFLAGS',
'ARFLAGS',
+ 'LDFLAGS',
'LINKFLAGS',
+ 'LIBS',
]:
if flag in os.environ:
self[flag] = Split(os.environ[flag])
+ #TODO: Remove these lines
+ print '#####################'
+ print '\n'.join("%s: %s" % x for x in os.environ.iteritems())
+ print '#####################'
+
self.mode = mode
self.prefix = prefix
+ self.destdir = self['ENV'].get('DESTDIR', '')
+
+ if self.destdir:
+ self.install_prefix = os.path.normpath(
+ os.path.abspath(self.destdir),
+ ) + self.prefix
+ else:
+ self.install_prefix = self.prefix
+
+ print self.prefix
+ print self.destdir
+ print self.install_prefix
if os.path.basename(self['CXX']) == 'clang++':
self.Append(CXXFLAGS=['-Qunused-arguments'])
@@ -87,21 +98,17 @@ class FreelanEnvironment(Environment):
self.Append(CXXFLAGS=['-Wshadow'])
self.Append(LDFLAGS=['--std=c++11'])
- if 'OPENWRT_BUILD' in os.environ:
- self['ENV'] = os.environ
- self.arch = os.environ['ARCH']
+ if sys.platform.startswith('darwin'):
+ self.Append(CXXFLAGS=['-arch', 'x86_64'])
+ self.Append(CXXFLAGS=['-DBOOST_ASIO_DISABLE_KQUEUE'])
+ self.Append(CXXFLAGS=['--stdlib=libc++'])
+ self.Append(LDFLAGS=['--stdlib=libc++'])
+
+ if self.mode == 'debug':
+ self.Append(CXXFLAGS=['-g'])
+ self.Append(CXXFLAGS='-DFREELAN_DEBUG=1')
else:
- if sys.platform.startswith('darwin'):
- self.Append(CXXFLAGS=['-arch', 'x86_64'])
- self.Append(CXXFLAGS=['-DBOOST_ASIO_DISABLE_KQUEUE'])
- self.Append(CXXFLAGS=['--stdlib=libc++'])
- self.Append(LDFLAGS=['--stdlib=libc++'])
-
- if self.mode == 'debug':
- self.Append(CXXFLAGS=['-g'])
- self.Append(CXXFLAGS='-DFREELAN_DEBUG=1')
- else:
- self.Append(CXXFLAGS='-O3')
+ self.Append(CXXFLAGS='-O3')
self.Append(CPPDEFINES=r'FREELAN_INSTALL_PREFIX="\"%s\""' % self.prefix)
@@ -147,13 +154,13 @@ class FreelanEnvironment(Environment):
mode = GetOption('mode')
-prefix = os.path.abspath(GetOption('prefix'))
+prefix = os.path.normpath(os.path.abspath(ARGUMENTS.get('prefix', './install')))
if mode in ('all', 'release'):
env = FreelanEnvironment(mode='release', prefix=prefix)
libraries, includes, apps, samples, configurations = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode))
- install = env.Install(os.path.join(prefix, 'bin'), apps)
- install.extend(env.Install(os.path.join(prefix, 'etc', 'freelan'), configurations))
+ install = env.Install(os.path.join(env.install_prefix, 'bin'), apps)
+ install.extend(env.Install(os.path.join(env.install_prefix, 'etc', 'freelan'), configurations))
Alias('install', install)
Alias('apps', apps)
@@ -37,7 +37,7 @@ elif sys.platform.startswith('darwin'):
])
env = env.Clone()
-env.Append(LIBS=libraries)
+env.Prepend(LIBS=libraries)
sources = list(sorted(set(env.RGlob('src', '*.cpp')) - set(env.RGlob(os.path.join('src', 'windows'), '*.cpp'))))
app = env.Program(target=os.path.join(str(dirs['bin']), name), source=sources)

0 comments on commit cb80ca9

Please sign in to comment.