ronw@666: # CARFAC Open Source C++ Library ronw@666: # ronw@666: # This C++ file is part of an implementation of Lyon's cochlear model: ronw@666: # "Cascade of Asymmetric Resonators with Fast-Acting Compression" ronw@666: # to supplement Lyon's upcoming book "Human and Machine Hearing" ronw@666: # ronw@666: # Licensed under the Apache License, Version 2.0 (the "License"); ronw@666: # you may not use this file except in compliance with the License. ronw@666: # You may obtain a copy of the License at ronw@666: # ronw@666: # http://www.apache.org/licenses/LICENSE-2.0 ronw@666: # ronw@666: # Unless required by applicable law or agreed to in writing, software ronw@666: # distributed under the License is distributed on an "AS IS" BASIS, ronw@666: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ronw@666: # See the License for the specific language governing permissions and ronw@666: # limitations under the License. ronw@666: ronw@666: ## @author Ron Weiss ronw@666: # @date created 2013/05/21 ronw@666: # @version \$Id$ ronw@666: ronw@666: """@package SConstruct ronw@666: SConstruct file for the CARFAC Open Source C++ Library. ronw@666: ronw@673: To install dependencies on Ubuntu, run: ronw@666: ronw@673: sudo apt-get install libeigen3-dev scons \ ronw@673: cmake libgtest-dev libsndfile-dev # For testing. ronw@673: export EIGEN_PATH=/usr/include/eigen3 ronw@673: export GTEST_SOURCE=/usr/src/gtest ronw@673: ronw@673: To build all libraries, run: ronw@666: scons ronw@673: ronw@673: To run unit tests, run: ronw@673: scons test ronw@673: ronw@673: To clean up binaries, run: ronw@673: scons --clean ronw@666: """ ronw@666: ronw@681: import commands ronw@666: import os ronw@666: ronw@666: env = Environment(CPPPATH=[os.environ['EIGEN_PATH']]) ronw@681: GCC_VERSION = commands.getoutput(env['CXX'] + ' -dumpversion') ronw@681: if GCC_VERSION.startswith('4.6'): ronw@681: env.MergeFlags(['-std=c++0x']) ronw@681: else: alexbrandmeyer@682: env.MergeFlags(['-std=c++11']) ronw@681: ronw@684: carfac_sources = [ ronw@686: 'agc.h', ronw@686: 'car.h', ronw@686: 'carfac.cc', ronw@686: 'carfac_output.cc', ronw@686: 'carfac_util.cc', ronw@686: 'common.h', ronw@686: 'ear.cc', alexbrandmeyer@685: 'ihc.h', alexbrandmeyer@685: 'sai.cc' ronw@684: ] ronw@666: env.Library(target = 'carfac', source = carfac_sources) ronw@667: ronw@667: env.Command('tmp/libgtest.a', [], ronw@667: [ ronw@667: Delete('tmp'), ronw@667: Copy('tmp', os.environ['GTEST_SOURCE']), ronw@667: 'cd tmp && cmake . && make', ronw@667: ]) ronw@667: ronw@684: test_sources = [ ronw@684: 'carfac_test.cc', ronw@684: 'sai_test.cc', ronw@684: ] ronw@684: test_program = env.Program(target = 'test', ronw@684: source = test_sources, ronw@673: LIBS = ['carfac', 'gtest', 'gtest_main', 'pthread'], ronw@673: LIBPATH = ['.', 'tmp']) ronw@673: test_alias = Alias('test', [test_program], test_program[0].abspath) ronw@673: AlwaysBuild(test_alias)