| author | Radek Brich <radek.brich@devl.cz> | 
| Tue, 26 Jul 2016 17:41:36 +0200 | |
| branch | pyrit | 
| changeset 103 | 3b3257a410fe | 
| parent 102 | de3e9ea18f56 | 
| child 104 | 2274a07510c1 | 
| permissions | -rw-r--r-- | 
| 
64
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
1  | 
Help("""
 | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
2  | 
Targets:  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
3  | 
all - build everything,  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
4  | 
|
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
5  | 
libs - build all libraries  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
6  | 
demos - build all demos  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
7  | 
models - download/prepare all models  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
8  | 
docs - compile doxygen documentation  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
9  | 
|
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
10  | 
libs = (static-lib, python-module)  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
11  | 
static-lib - ray tracer library to link with  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
12  | 
python-module - ray tracer module for Python  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
13  | 
|
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
14  | 
demos = (python-demos, cc-demos)  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
15  | 
python-demos - Python demos, this depends on python-module  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
16  | 
cc-demos - C++ demos  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
17  | 
|
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
18  | 
models = (local-models, download-models)  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
19  | 
local-models - prepare local models  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
20  | 
download-models - download models which are not locally available  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
21  | 
|
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
22  | 
no-docs = (libs, demos, models)  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
23  | 
- everything but docs  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
24  | 
no-download = (libs, demos, local-models)  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
25  | 
- everything but docs and downloadable models  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
26  | 
|
| 
100
 
c005054bf4c1
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
 
Radek Brich <radek.brich@devl.cz> 
parents: 
99 
diff
changeset
 | 
27  | 
vcproj - generate project files for Visual C++ Studio  | 
| 
 
c005054bf4c1
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
 
Radek Brich <radek.brich@devl.cz> 
parents: 
99 
diff
changeset
 | 
28  | 
|
| 
64
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
29  | 
Default target is no-download.  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
30  | 
|
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
31  | 
Options:  | 
| 
64
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
32  | 
""")  | 
| 
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
33  | 
|
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
34  | 
import os, sys  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
35  | 
|
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
36  | 
EnsurePythonVersion(2, 3)  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
37  | 
EnsureSConsVersion(0, 97)  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
38  | 
|
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
39  | 
Decider('MD5-timestamp')
 | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
40  | 
SConsignFile('build/.sconsign.dblite')
 | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
41  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
42  | 
if sys.platform == 'win32':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
43  | 
tools = ['mingw']  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
44  | 
else:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
45  | 
tools = ['default']  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
46  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
47  | 
env = Environment(tools = tools, CPPPATH = ['.','#include','#build/include'])  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
48  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
49  | 
vars = Variables(files=['build/.varscache'])  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
50  | 
vars.AddVariables(  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
51  | 
	BoolVariable('simd', 'allow SSE intrinsics', True),
 | 
| 
67
 
249553e1d4fe
new option to choose single or double precision floats
 
Radek Brich <radek.brich@devl.cz> 
parents: 
66 
diff
changeset
 | 
52  | 
	('precision', 'floating point number precision (single/double)', "single"),
 | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
53  | 
	('flags', 'add additional compiler flags', ""),
 | 
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
54  | 
	BoolVariable('force_flags', "use only flags specified by 'flags' option (do not autodetect arch/sse flags)", False),
 | 
| 
95
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
55  | 
	('ldflags', 'add additional linker flags', ""),
 | 
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
56  | 
	BoolVariable('profile', "enable gcc's profiling support (-pg)", False),
 | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
57  | 
)  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
58  | 
if env['PLATFORM'] == 'win32':  | 
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
59  | 
vars.AddVariables(  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
60  | 
		BoolVariable('mingw', 'use Mingw and GCC compiler, if available', False),
 | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
61  | 
		('pythonpath', 'path to Python installation',
 | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
62  | 
'C:\\Python%c%c' % (sys.version[0], sys.version[2])),  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
63  | 
)  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
64  | 
else:  | 
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
65  | 
vars.AddVariables(  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
66  | 
		BoolVariable('intelc', 'use Intel C++ Compiler, if available', False),
 | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
67  | 
)  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
68  | 
|
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
69  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
70  | 
vars.Update(env)  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
71  | 
vars.Save('build/.varscache', env)
 | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
72  | 
Help(vars.GenerateHelpText(env))  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
73  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
74  | 
if env.GetOption('help') == True or env.GetOption('clean') == True:
 | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
75  | 
Return()  | 
| 
88
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
76  | 
|
| 
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
77  | 
### configure  | 
| 
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
78  | 
|
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
79  | 
platform = 'unknown'  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
80  | 
def CheckPlatform(context):  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
81  | 
global platform  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
82  | 
	context.Message('Platform is... ')
 | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
83  | 
if sys.platform[:5] == 'linux':  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
84  | 
platform = 'linux'  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
85  | 
elif env['PLATFORM'] == 'posix':  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
86  | 
platform = 'posix'  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
87  | 
elif env['PLATFORM'] == 'win32':  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
88  | 
platform = 'win32'  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
89  | 
context.Result(platform)  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
90  | 
return True  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
91  | 
|
| 93 | 92  | 
intelcversion = ''  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
93  | 
def CheckIntelC(context):  | 
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
94  | 
global intelc, intelcversion  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
95  | 
	context.Message('Checking for IntelC compiler... ')
 | 
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
96  | 
	intelc = Tool("intelc").exists(env) == True
 | 
| 66 | 97  | 
if intelc:  | 
98  | 
testenv = Environment()  | 
|
99  | 
		Tool("intelc").generate(testenv)
 | 
|
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
100  | 
intelcversion = str(testenv['INTEL_C_COMPILER_VERSION']/10.)  | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
101  | 
context.Result(intelcversion)  | 
| 66 | 102  | 
else:  | 
103  | 
context.Result(intelc)  | 
|
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
104  | 
return intelc  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
105  | 
|
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
106  | 
def CheckGCC(context):  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
107  | 
global gcc, gccversion  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
108  | 
	context.Message('Checking for GCC compiler... ')
 | 
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
109  | 
testenv = Environment()  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
110  | 
gcc = "g++" in testenv['TOOLS']  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
111  | 
if gcc:  | 
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
112  | 
gccversion = testenv['CCVERSION']  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
113  | 
context.Result(gccversion)  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
114  | 
else:  | 
| 
70
 
4b84e90325c5
a fix for CPU and compiler detection
 
Radek Brich <radek.brich@devl.cz> 
parents: 
68 
diff
changeset
 | 
115  | 
gccversion = ''  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
116  | 
context.Result(False)  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
117  | 
return gcc  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
118  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
119  | 
def CheckMSVC(context):  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
120  | 
global msvc, msvcversion  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
121  | 
	context.Message('Checking for MSVC compiler... ')
 | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
122  | 
testenv = Environment()  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
123  | 
msvc = "msvc" in testenv['TOOLS']  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
124  | 
if msvc:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
125  | 
msvcversion = testenv['MSVS_VERSION']  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
126  | 
context.Result(msvcversion)  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
127  | 
else:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
128  | 
msvcversion = ''  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
129  | 
context.Result(False)  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
130  | 
return msvc  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
131  | 
|
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
132  | 
def CheckCPUFlags(context):  | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
133  | 
global cpu, cpuflags_gcc, cpuflags_intelc  | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
134  | 
	context.Message('Checking CPU arch and flags... ')
 | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
135  | 
	env.Execute('@$CC tools/cpuflags.c -o tools/cpuflags')
 | 
| 
85
 
907a634e5c02
implement triangle packet intersection
 
Radek Brich <radek.brich@devl.cz> 
parents: 
84 
diff
changeset
 | 
136  | 
	(cpu, cpuflags_gcc, cpuflags_intelc) = os.popen('tools'+os.sep+'cpuflags %s %s'
 | 
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
137  | 
		% (''.join(gccversion.rsplit('.',1)), intelcversion) ).read().split('\n')[:3]
 | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
138  | 
context.Result(cpu)  | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
139  | 
return True  | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
140  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
141  | 
conf_dir = "#build/.sconf_temp"  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
142  | 
log_file="#build/config.log"  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
143  | 
config_h="#build/include/config.h"  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
144  | 
conf = Configure(env, conf_dir=conf_dir, log_file=log_file, config_h=config_h,  | 
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
145  | 
clean=False, help=False,  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
146  | 
	custom_tests = {
 | 
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
147  | 
'CheckPlatform' : CheckPlatform, 'CheckCPUFlags' : CheckCPUFlags,  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
148  | 
'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC, 'CheckMSVC' : CheckMSVC})  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
149  | 
conf.CheckPlatform()  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
150  | 
|
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
151  | 
conf.CheckGCC()  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
152  | 
if platform == 'win32':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
153  | 
conf.CheckMSVC()  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
154  | 
intelc = False  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
155  | 
else:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
156  | 
conf.CheckIntelC()  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
157  | 
msvc=False  | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
158  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
159  | 
if intelc and (not gcc or conf.env['intelc']):  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
160  | 
	Tool('intelc').generate(conf.env)
 | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
161  | 
cc = 'intelc'  | 
| 94 | 162  | 
elif msvc and (not gcc or not conf.env['mingw']):  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
163  | 
	Tool('default').generate(conf.env)
 | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
164  | 
	conf.Define("MSVC")
 | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
165  | 
cc = 'msvc'  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
166  | 
elif gcc:  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
167  | 
cc = 'gcc'  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
168  | 
else:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
169  | 
cc = 'none'  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
170  | 
|
| 
95
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
171  | 
if cc == 'intelc' or cc == 'gcc':  | 
| 
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
172  | 
conf.CheckCPUFlags()  | 
| 
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
173  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
174  | 
if platform == 'win32' and cc == 'gcc':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
175  | 
conf.env.Append(LIBPATH=["C:/mingw/lib", "C:/msys/mingw/lib"])  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
176  | 
conf.env.Append(CPPPATH=["C:/mingw/include", "C:/msys/mingw/include"])  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
177  | 
|
| 
67
 
249553e1d4fe
new option to choose single or double precision floats
 
Radek Brich <radek.brich@devl.cz> 
parents: 
66 
diff
changeset
 | 
178  | 
add_flags = ''  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
179  | 
if cc == 'gcc':  | 
| 
68
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
180  | 
add_flags += cpuflags_gcc + ' -ffast-math '  | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
181  | 
if cc == 'intelc':  | 
| 
 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 
Radek Brich <radek.brich@devl.cz> 
parents: 
67 
diff
changeset
 | 
182  | 
add_flags += cpuflags_intelc + ' '  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
183  | 
if cc == 'msvc':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
184  | 
add_flags += '/fp:fast '  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
185  | 
if conf.env['simd']:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
186  | 
add_flags += '/arch:SSE '  | 
| 
67
 
249553e1d4fe
new option to choose single or double precision floats
 
Radek Brich <radek.brich@devl.cz> 
parents: 
66 
diff
changeset
 | 
187  | 
|
| 91 | 188  | 
if conf.env['force_flags']:  | 
189  | 
add_flags = conf.env['flags'] + ' '  | 
|
190  | 
else:  | 
|
191  | 
add_flags += conf.env['flags'] + ' '  | 
|
192  | 
||
| 
88
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
193  | 
if conf.env['precision'] == 'double':  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
194  | 
	conf.Define("PYRIT_DOUBLE")
 | 
| 
67
 
249553e1d4fe
new option to choose single or double precision floats
 
Radek Brich <radek.brich@devl.cz> 
parents: 
66 
diff
changeset
 | 
195  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
196  | 
if not conf.env['simd'] or conf.env['precision'] == 'double':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
197  | 
	conf.Define("NO_SIMD")
 | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
198  | 
|
| 66 | 199  | 
if cc == 'intelc':  | 
| 
88
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
200  | 
conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags)  | 
| 66 | 201  | 
elif cc == 'gcc':  | 
| 
88
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
202  | 
conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags)  | 
| 93 | 203  | 
# Other useful flags:  | 
204  | 
# -Wunsafe-loop-optimizations -Wpointer-arith -Wcast-align -Wconversion  | 
|
205  | 
# -Wmissing-noreturn -Winline -Wdisabled-optimization  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
206  | 
elif cc == 'msvc':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
207  | 
conf.env.Append(CCFLAGS="/Ox /Ob2 /GS- /Gy /GF /GR- /Zp16 /MD /EHsc /vmb " + add_flags)  | 
| 
65
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
208  | 
else:  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
209  | 
print "No supported compiler found."  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
210  | 
Exit(1)  | 
| 
 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 
Radek Brich <radek.brich@devl.cz> 
parents: 
64 
diff
changeset
 | 
211  | 
|
| 66 | 212  | 
print "Using compiler: " + cc  | 
| 
67
 
249553e1d4fe
new option to choose single or double precision floats
 
Radek Brich <radek.brich@devl.cz> 
parents: 
66 
diff
changeset
 | 
213  | 
print "Additional flags: " + add_flags  | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
214  | 
|
| 93 | 215  | 
if conf.env['profile'] and cc == 'gcc':  | 
216  | 
conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg")  | 
|
217  | 
||
| 
95
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
218  | 
if conf.env['ldflags']:  | 
| 
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
219  | 
conf.env.Append(LINKFLAGS=conf.env['ldflags'])  | 
| 
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
220  | 
|
| 93 | 221  | 
|
222  | 
# configure pthread  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
223  | 
pthread = True  | 
| 93 | 224  | 
if platform == 'win32':  | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
225  | 
if cc == 'msvc':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
226  | 
		if not conf.CheckLib('pthreadVC2'):
 | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
227  | 
pthread = False  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
228  | 
elif cc == 'gcc':  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
229  | 
		if not conf.CheckLib('pthreadGC2'):
 | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
230  | 
pthread = False  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
231  | 
else:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
232  | 
conf.env.Append(CCFLAGS="-pthread ")  | 
| 
88
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
233  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
234  | 
if not pthread:  | 
| 91 | 235  | 
print 'Error: Cannot build without pthread.'  | 
236  | 
Exit(1)  | 
|
237  | 
||
| 93 | 238  | 
|
239  | 
# configure libpng  | 
|
| 
100
 
c005054bf4c1
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
 
Radek Brich <radek.brich@devl.cz> 
parents: 
99 
diff
changeset
 | 
240  | 
conf.CheckLibWithHeader('zlib', 'zlib.h', 'C')
 | 
| 
 
c005054bf4c1
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
 
Radek Brich <radek.brich@devl.cz> 
parents: 
99 
diff
changeset
 | 
241  | 
if conf.CheckLibWithHeader('libpng', 'png.h', 'C'):
 | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
242  | 
	conf.Define('HAVE_PNG')
 | 
| 91 | 243  | 
|
| 
88
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
244  | 
env = conf.Finish()  | 
| 
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
245  | 
|
| 93 | 246  | 
|
247  | 
# configure Python  | 
|
248  | 
pyenv = env.Clone()  | 
|
249  | 
have_python = True  | 
|
250  | 
if platform == 'win32':  | 
|
251  | 
pythonver = '%c%c' % (sys.version[0], sys.version[2])  | 
|
252  | 
pythonlib = 'python'+pythonver  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
253  | 
pythonpath = [env['pythonpath']]  | 
| 93 | 254  | 
pyenv.Append(CPPPATH=[s+'\\include' for s in pythonpath])  | 
255  | 
pyenv.Append(LIBPATH=[s+'\\libs' for s in pythonpath])  | 
|
256  | 
pyenv.Replace(SHLIBSUFFIX='.pyd')  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
257  | 
conf = Configure(pyenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h,  | 
| 
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
258  | 
clean=False, help=False)  | 
| 93 | 259  | 
if not conf.CheckLib(pythonlib):  | 
260  | 
have_python = False  | 
|
261  | 
pyenv = conf.Finish()  | 
|
262  | 
else:  | 
|
263  | 
try:  | 
|
264  | 
		pyenv.ParseConfig('python-config --includes --libs')
 | 
|
265  | 
except:  | 
|
266  | 
have_python = False  | 
|
267  | 
||
268  | 
if not have_python:  | 
|
269  | 
print "Error: Python is required."  | 
|
270  | 
Exit(1)  | 
|
271  | 
||
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
272  | 
# configure SDL  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
273  | 
sdlenv = env.Clone()  | 
| 93 | 274  | 
if cc == 'msvc':  | 
275  | 
sdlenv.Append(LIBS=['SDL', 'SDLmain'])  | 
|
276  | 
sdlenv.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS")  | 
|
277  | 
else:  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
278  | 
try:  | 
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
279  | 
		sdlenv.ParseConfig('sdl-config --cflags')
 | 
| 
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
280  | 
		sdlenv.ParseConfig('sdl-config --libs')
 | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
281  | 
except:  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
282  | 
pass  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
283  | 
|
| 93 | 284  | 
def CheckSDL(context):  | 
285  | 
global have_sdl  | 
|
286  | 
	context.Message('Checking for SDL... ')
 | 
|
287  | 
	if context.TryLink("#include <SDL.h>\n"+
 | 
|
288  | 
		"int main(int argc,char **argv){return 0;}", '.cc'):
 | 
|
289  | 
context.Result(1)  | 
|
290  | 
return True  | 
|
291  | 
else:  | 
|
292  | 
		context.Result("no (some demos won't be built)")
 | 
|
293  | 
return False  | 
|
294  | 
||
295  | 
conf = Configure(sdlenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h,  | 
|
| 
99
 
f3abdaa2e8fb
build script: updated for latest SCons, moved config.h to build/, help and clean targets does not run configure any more, fixed GCC check, added check for zlib
 
Radek Brich <radek.brich@devl.cz> 
parents: 
95 
diff
changeset
 | 
296  | 
clean=False, help=False,  | 
| 93 | 297  | 
	custom_tests = {'CheckSDL' : CheckSDL} )
 | 
298  | 
have_sdl = conf.CheckSDL()  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
299  | 
sdlenv = conf.Finish()  | 
| 
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
300  | 
|
| 
88
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
301  | 
|
| 
 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 
Radek Brich <radek.brich@devl.cz> 
parents: 
85 
diff
changeset
 | 
302  | 
### build targets  | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
303  | 
|
| 
95
 
ca7d4c665531
build script fixes, add ldflags build option
 
Radek Brich <radek.brich@devl.cz> 
parents: 
94 
diff
changeset
 | 
304  | 
Export('env pyenv sdlenv have_sdl cc')
 | 
| 
102
 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 
Radek Brich <radek.brich@devl.cz> 
parents: 
101 
diff
changeset
 | 
305  | 
lib = SConscript('src/SConscript', variant_dir='build/lib', duplicate=0,
 | 
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
306  | 
	exports={'buildmodule':False})
 | 
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
307  | 
if cc == 'msvc':  | 
| 
102
 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 
Radek Brich <radek.brich@devl.cz> 
parents: 
101 
diff
changeset
 | 
308  | 
	(pymodule, modvcproj) = SConscript('src/SConscript', variant_dir='build/pymodule', duplicate=0,
 | 
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
309  | 
		exports={'buildmodule':True})
 | 
| 
102
 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 
Radek Brich <radek.brich@devl.cz> 
parents: 
101 
diff
changeset
 | 
310  | 
	ccdemvcproj = SConscript('ccdemos/SConscript', variant_dir='build/ccdemos', duplicate=0, exports='lib')
 | 
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
311  | 
	demosvcproj = SConscript('demos/SConscript', exports='pymodule')
 | 
| 
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
312  | 
else:  | 
| 
102
 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 
Radek Brich <radek.brich@devl.cz> 
parents: 
101 
diff
changeset
 | 
313  | 
	pymodule = SConscript('src/SConscript', variant_dir='build/pymodule', duplicate=0,
 | 
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
314  | 
		exports={'buildmodule':True})
 | 
| 
102
 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 
Radek Brich <radek.brich@devl.cz> 
parents: 
101 
diff
changeset
 | 
315  | 
	SConscript('ccdemos/SConscript', variant_dir='build/ccdemos', duplicate=0, exports='lib')
 | 
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
316  | 
	SConscript('demos/SConscript', exports='pymodule')
 | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
317  | 
|
| 
102
 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 
Radek Brich <radek.brich@devl.cz> 
parents: 
101 
diff
changeset
 | 
318  | 
SConscript('tests/SConscript', variant_dir='build/tests', duplicate=0, exports='lib')
 | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
319  | 
SConscript('models/SConscript')
 | 
| 60 | 320  | 
|
| 
92
 
9af5c039b678
add MSVC compiler support, make it default for Windows
 
Radek Brich <radek.brich@devl.cz> 
parents: 
91 
diff
changeset
 | 
321  | 
env.Alias('demos', ['cc-demos', 'python-demos'])
 | 
| 91 | 322  | 
env.Alias('libs', ['static-lib', 'python-module'])
 | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
323  | 
env.Alias('docs', Command('docs/html', [], 'doxygen'))
 | 
| 66 | 324  | 
env.Clean('docs', ['docs/html'])
 | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
325  | 
env.Alias('no-docs', ['libs', 'demos', 'models'])
 | 
| 
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
326  | 
env.Alias('no-download', ['libs', 'demos', 'local-models'])
 | 
| 
64
 
5785cca4cdb9
add Help with list of targets to SConstruct
 
Radek Brich <radek.brich@devl.cz> 
parents: 
63 
diff
changeset
 | 
327  | 
env.Alias('all', ['no-docs', 'docs'])
 | 
| 
63
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
328  | 
env.Alias('pyrit', 'no-download')
 | 
| 
 
440e1ae80459
add many SCons targets (see DEVNOTES)
 
Radek Brich <radek.brich@devl.cz> 
parents: 
62 
diff
changeset
 | 
329  | 
Default('pyrit')
 | 
| 
100
 
c005054bf4c1
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
 
Radek Brich <radek.brich@devl.cz> 
parents: 
99 
diff
changeset
 | 
330  | 
|
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
331  | 
if cc == 'msvc':  | 
| 
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
332  | 
vcsol = env.MSVSSolution(  | 
| 
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
333  | 
target = 'pyrit' + env['MSVSSOLUTIONSUFFIX'],  | 
| 
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
334  | 
projects = [modvcproj, ccdemvcproj, demosvcproj],  | 
| 
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
335  | 
variant = 'Release')  | 
| 
100
 
c005054bf4c1
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
 
Radek Brich <radek.brich@devl.cz> 
parents: 
99 
diff
changeset
 | 
336  | 
|
| 
101
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
337  | 
env.Depends(vcsol, [modvcproj, ccdemvcproj, demosvcproj]);  | 
| 
 
50a994a57849
vcproj build target only for cc=msvc, fix sdl-config
 
Radek Brich <radek.brich@devl.cz> 
parents: 
100 
diff
changeset
 | 
338  | 
	env.Alias('vcproj', vcsol)
 |