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