Changeset 756

Show
Ignore:
Timestamp:
12/08/07 12:26:29 (13 years ago)
Author:
ppalmers
Message:

add optimization flags

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r751 r756  
    2828 
    2929/* Define to 1 if SSE assembly is available. */ 
    30 /*#define USE_SSE 1*/ 
     30#define USE_SSE $USE_SSE 
    3131 
    3232#define CACHEDIR "~/.ffado" 
  • trunk/libffado/SConstruct

    r755 r756  
    2323 
    2424import os 
     25import re 
    2526from string import Template 
    2627 
     
    7071""", True ), 
    7172    BoolOption( "BUILD_STATIC_TOOLS", "Build a statically linked version of the FFADO tools.", False ), 
     73    EnumOption('DIST_TARGET', 'Build target for cross compiling packagers', 'auto', allowed_values=('auto', 'i386', 'i686', 'x86_64', 'none' ), ignorecase=2), 
     74    BoolOption( "ENABLE_OPTIMIZATIONS", "Enable optimizations and the use of processor specific extentions (MMX/SSE/...).", False ), 
     75 
    7276        ) 
    7377 
     
    224228env.Alias( "install", env['bindir'] ) 
    225229 
     230# 
     231# shamelessly copied from the Ardour scons file 
     232# 
     233 
     234opt_flags = [] 
     235env['USE_SSE'] = 0 
     236 
     237# guess at the platform, used to define compiler flags 
     238 
     239config_guess = os.popen("admin/config.guess").read()[:-1] 
     240 
     241config_cpu = 0 
     242config_arch = 1 
     243config_kernel = 2 
     244config_os = 3 
     245config = config_guess.split ("-") 
     246 
     247print "system triple: " + config_guess 
     248 
     249# Autodetect 
     250if env['DIST_TARGET'] == 'auto': 
     251    if re.search ("x86_64", config[config_cpu]) != None: 
     252        env['DIST_TARGET'] = 'x86_64' 
     253    elif re.search("i[0-5]86", config[config_cpu]) != None: 
     254        env['DIST_TARGET'] = 'i386' 
     255    else: 
     256        env['DIST_TARGET'] = 'i686' 
     257    print "Detected DIST_TARGET = " + env['DIST_TARGET'] 
     258 
     259if ((re.search ("i[0-9]86", config[config_cpu]) != None) or (re.search ("x86_64", config[config_cpu]) != None)): 
     260     
     261    build_host_supports_sse = 0 
     262 
     263    if config[config_kernel] == 'linux' : 
     264         
     265        if env['DIST_TARGET'] != 'i386': 
     266             
     267            flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1] 
     268            x86_flags = flag_line.split (": ")[1:][0].split () 
     269             
     270            if "mmx" in x86_flags: 
     271                opt_flags.append ("-mmmx") 
     272            if "sse" in x86_flags: 
     273                build_host_supports_sse = 1 
     274            if "3dnow" in x86_flags: 
     275                opt_flags.append ("-m3dnow") 
     276             
     277            if config[config_cpu] == "i586": 
     278                opt_flags.append ("-march=i586") 
     279            elif config[config_cpu] == "i686": 
     280                opt_flags.append ("-march=i686") 
     281     
     282    if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) and build_host_supports_sse: 
     283        opt_flags.extend (["-msse", "-mfpmath=sse"]) 
     284        env['USE_SSE'] = 1 
     285 
     286# end of processor-specific section 
     287if env['ENABLE_OPTIMIZATIONS']: 
     288        env.AppendUnique( CCFLAGS=opt_flags ) 
     289        print "Doing an optimized build..." 
     290 
    226291 
    227292env['REVISION'] = os.popen('svnversion .').read()[:-1]