SConstruct
branchpyrit
changeset 88 f7edb3b90816
parent 85 907a634e5c02
child 91 9d66d323c354
equal deleted inserted replaced
87:1081e3dd3f3e 88:f7edb3b90816
    45 			'C:\\Python%c%c' % (sys.version[0], sys.version[2])),
    45 			'C:\\Python%c%c' % (sys.version[0], sys.version[2])),
    46 		)
    46 		)
    47 opt.Update(env)
    47 opt.Update(env)
    48 opt.Save('.optioncache', env)
    48 opt.Save('.optioncache', env)
    49 Help(opt.GenerateHelpText(env))
    49 Help(opt.GenerateHelpText(env))
       
    50 
       
    51 
       
    52 ### configure
    50 
    53 
    51 platform = 'unknown'
    54 platform = 'unknown'
    52 def CheckPlatform(context):
    55 def CheckPlatform(context):
    53 	global platform
    56 	global platform
    54 	context.Message('Platform is... ')
    57 	context.Message('Platform is... ')
   102 		'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC})
   105 		'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC})
   103 conf.CheckPlatform()
   106 conf.CheckPlatform()
   104 conf.CheckGCC()
   107 conf.CheckGCC()
   105 conf.CheckIntelC()
   108 conf.CheckIntelC()
   106 conf.CheckCPUFlags()
   109 conf.CheckCPUFlags()
   107 env = conf.Finish()
       
   108 
   110 
   109 
   111 if intelc and conf.env['intelc']:
   110 if intelc and env['intelc']:
   112 	Tool("intelc").generate(conf.env)
   111 	Tool("intelc").generate(env)
       
   112 	cc = 'intelc'
   113 	cc = 'intelc'
   113 elif gcc:
   114 elif gcc:
   114 	cc = 'gcc'
   115 	cc = 'gcc'
   115 
   116 
   116 add_flags = ''
   117 add_flags = ''
   117 if cc == 'gcc':
   118 if cc == 'gcc':
   118 	add_flags += cpuflags_gcc + ' -ffast-math '
   119 	add_flags += cpuflags_gcc + ' -ffast-math '
   119 if cc == 'intelc':
   120 if cc == 'intelc':
   120 	add_flags += cpuflags_intelc + ' '
   121 	add_flags += cpuflags_intelc + ' '
   121 
   122 
   122 if env['precision'] == 'double':
   123 if conf.env['precision'] == 'double':
   123 	add_flags += '-DPYRIT_DOUBLE '
   124 	add_flags += '-DPYRIT_DOUBLE '
   124 elif cc == 'gcc':
   125 elif cc == 'gcc':
   125 	add_flags += '-fsingle-precision-constant '
   126 	add_flags += '-fsingle-precision-constant '
   126 
   127 
   127 add_flags += env['flags']
   128 add_flags += conf.env['flags']
   128 
   129 
   129 if cc == 'intelc':
   130 if cc == 'intelc':
   130 	env.Append(CCFLAGS="-O3 -w1 " + add_flags)
   131 	conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags)
   131 elif cc == 'gcc':
   132 elif cc == 'gcc':
   132 	env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags)
   133 	conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags)
   133 	# CCFLAGS= -fno-strict-aliasing
   134 	# CCFLAGS= -fno-strict-aliasing
   134 else:
   135 else:
   135 	print "No supported compiler found."
   136 	print "No supported compiler found."
   136 	Exit(1)
   137 	Exit(1)
   137 
   138 
   138 print "Using compiler: " + cc
   139 print "Using compiler: " + cc
   139 print "Additional flags: " + add_flags
   140 print "Additional flags: " + add_flags
   140 
   141 
   141 # pthread
   142 if conf.CheckLibWithHeader('png', 'png.h', 'C'):
   142 if env['PLATFORM'] == 'win32':
   143 	conf.env.Append(CCFLAGS='-DHAVE_PNG')
   143 	env.Append(LIBS=["pthreadGC2"])
   144 	conf.env.Append(LIBS=['png'])
       
   145 
       
   146 if conf.env['PLATFORM'] == 'win32':
       
   147 	conf.env.Append(LIBS=["pthreadGC2"])
   144 else:
   148 else:
   145 	env.Append(CCFLAGS="-pthread ")
   149 	conf.env.Append(CCFLAGS="-pthread ")
       
   150 
       
   151 env = conf.Finish()
       
   152 
       
   153 
       
   154 ### build targets
   146 
   155 
   147 (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env')
   156 (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env')
   148 
   157 
   149 SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='env lib')
   158 SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='env lib')
   150 SConscript('demos/SConscript', exports='pymodule')
   159 SConscript('demos/SConscript', exports='pymodule')