Source

gpalign-cpp / SConstruct

# -*- coding: utf-8 -*-
#----------------------------------------------------------------------------#
# SConstruct
# Lars Yencken <lars.yencken@gmail.com>
# vim: ts=4 sw=4 sts=4 et tw=78:
# Thu Nov 30 15:23:25 2006
#
#----------------------------------------------------------------------------#

""" Build instructions for the research codebase.
"""

#----------------------------------------------------------------------------#

import os
from os import path
import sys
from distutils import sysconfig
import py_compile
import re

#----------------------------------------------------------------------------#

def checkLibraries(env):
    """ Check whether the correct libraries exist, and thus whether building
        is possible.
    """
    # Some platform-specific customisations.
    platform = os.uname()[0].lower()
    if platform.endswith('bsd') or platform == 'darwin':
        env.Append(CXXFLAGS='-DBSD ')

    if platform == 'darwin':
        # Extra build parameters for OS X 
        env.Replace(SHLINKFLAGS='$LINKFLAGS -bundle -flat_namespace -undefined suppress')
        env.Replace(SHLIBSUFFIX='.so')

    print 'Configuring for platform: %s' % platform

    # Detect the presence of necessary dependencies.
    conf = Configure(env)

    if not conf.CheckLibWithHeader('m', 'math.h', 'c'):
        print "Can't find standard math libraries."
        Exit(1)

    if not conf.CheckLib('pthread'):
        print "Can't find pthread."
        Exit(1)

    if not conf.CheckLibWithHeader('cppunit', 'cppunit/ui/text/TestRunner.h',
            'c++'):
        print "Can't find cppunit."
        Exit(1)

    if not conf.CheckCXXHeader('boost/shared_ptr.hpp'):
        print "Can't find boost C++ libraries."
        Exit(1)

    env = conf.Finish()

    return env

#----------------------------------------------------------------------------#
# CONFIGURATION
#----------------------------------------------------------------------------#

# Set up the compilation environment.
env = Environment(
        SHLIBPREFIX='',
        LIBS=['gomp', 'pthread'],
    )
env.Append(CXXFLAGS='-DBSD ')

environmentVars = (
        'CPATH',
        'LD_LIBRARY_PATH',
        'LIBRARY_PATH',
    )

envDict = env['ENV']
for var in environmentVars:
    if var in os.environ:
        envDict[var] = os.environ[var]

# Choose between debugging or optimized mode.
if ARGUMENTS.get('debug'):
    print 'Using debug targets'
    env.Append(DEBUG=True, CXXFLAGS='-O0 -g -Wall ', LINKFLAGS='-g')
elif ARGUMENTS.get('profile'):
    print 'Using profiling targets'
    env.Append(DEBUG=True, CXXFLAGS='-O0 -g -pg -Wall', LINKFLAGS='-g -pg')
else:
    print 'Using optimised targets'
    env.Append(DEBUG=False, CXXFLAGS='-O3 -DNDEBUG -Wall -fopenmp')

# Configure the environment.
env = checkLibraries(env)

#----------------------------------------------------------------------------#

SConscript('src/SConscript', exports='env')
SConscript('src/tests/SConscript', exports='env')

#----------------------------------------------------------------------------#
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.