| author | Radek Brich <radek.brich@devl.cz> | 
| Tue, 26 Jul 2016 18:19:37 +0200 | |
| branch | pyrit | 
| changeset 104 | 2274a07510c1 | 
| parent 102 | de3e9ea18f56 | 
| permissions | -rw-r--r-- | 
| 64 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 1 | Help("""
 | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 2 | Targets: | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 3 | all - build everything, | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 4 | |
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 5 | libs - build all libraries | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 6 | demos - build all demos | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 7 | models - download/prepare all models | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 8 | docs - compile doxygen documentation | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 9 | |
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 10 | libs = (static-lib, python-module) | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
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: 
63diff
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: 
63diff
changeset | 13 | |
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 14 | demos = (python-demos, cc-demos) | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
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: 
63diff
changeset | 16 | cc-demos - C++ demos | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 17 | |
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 18 | models = (local-models, download-models) | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 19 | local-models - prepare local models | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
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: 
63diff
changeset | 21 | |
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 22 | no-docs = (libs, demos, models) | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 23 | - everything but docs | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 24 | no-download = (libs, demos, local-models) | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 25 | - everything but docs and downloadable models | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
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: 
99diff
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: 
99diff
changeset | 28 | |
| 64 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
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: 
64diff
changeset | 30 | |
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 31 | Options: | 
| 64 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 32 | """) | 
| 
5785cca4cdb9
add Help with list of targets to SConstruct
 Radek Brich <radek.brich@devl.cz> parents: 
63diff
changeset | 33 | |
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 34 | import os, sys | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 35 | |
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 36 | EnsurePythonVersion(2, 3) | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 37 | EnsureSConsVersion(0, 97) | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 38 | |
| 68 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 39 | Decider('MD5-timestamp')
 | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
64diff
changeset | 41 | |
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 42 | env = Environment(tools = ['default'], CPPPATH = ['.','#include','#build/include']) | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 43 | |
| 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: 
95diff
changeset | 44 | 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: 
95diff
changeset | 45 | 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: 
95diff
changeset | 46 | 	BoolVariable('simd', 'allow SSE intrinsics', True),
 | 
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
changeset | 47 | 	('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: 
64diff
changeset | 48 | 	('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: 
95diff
changeset | 49 | 	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: 
94diff
changeset | 50 | 	('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: 
95diff
changeset | 51 | 	BoolVariable('profile', "enable gcc's profiling support (-pg)", False),
 | 
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 52 | 	BoolVariable('intelc', 'use Intel C++ Compiler, if available', False),
 | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 53 | ) | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 54 | |
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 55 | |
| 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: 
95diff
changeset | 56 | 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: 
95diff
changeset | 57 | 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: 
95diff
changeset | 58 | Help(vars.GenerateHelpText(env)) | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 59 | |
| 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: 
95diff
changeset | 60 | 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: 
95diff
changeset | 61 | 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: 
85diff
changeset | 62 | |
| 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 Radek Brich <radek.brich@devl.cz> parents: 
85diff
changeset | 63 | ### 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: 
85diff
changeset | 64 | |
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 65 | platform = 'unknown' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 66 | def CheckPlatform(context): | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 67 | global platform | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 68 | 	context.Message('Platform is... ')
 | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 69 | if sys.platform[:5] == 'linux': | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 70 | platform = 'linux' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 71 | elif env['PLATFORM'] == 'posix': | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 72 | platform = 'posix' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 73 | context.Result(platform) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 74 | return True | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 75 | |
| 93 | 76 | intelcversion = '' | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 77 | def CheckIntelC(context): | 
| 68 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 78 | global intelc, intelcversion | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 79 | 	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: 
67diff
changeset | 80 | 	intelc = Tool("intelc").exists(env) == True
 | 
| 66 | 81 | if intelc: | 
| 82 | testenv = Environment() | |
| 83 | 		Tool("intelc").generate(testenv)
 | |
| 68 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 84 | 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: 
67diff
changeset | 85 | context.Result(intelcversion) | 
| 66 | 86 | else: | 
| 87 | context.Result(intelc) | |
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 88 | return intelc | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 89 | |
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 90 | def CheckGCC(context): | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 91 | global gcc, gccversion | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 92 | 	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: 
95diff
changeset | 93 | 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: 
95diff
changeset | 94 | gcc = "g++" in testenv['TOOLS'] | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 95 | 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: 
95diff
changeset | 96 | gccversion = testenv['CCVERSION'] | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 97 | context.Result(gccversion) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 98 | else: | 
| 70 
4b84e90325c5
a fix for CPU and compiler detection
 Radek Brich <radek.brich@devl.cz> parents: 
68diff
changeset | 99 | gccversion = '' | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 100 | context.Result(False) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 101 | return gcc | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 102 | |
| 68 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 103 | def CheckCPUFlags(context): | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 104 | 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: 
67diff
changeset | 105 | 	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: 
67diff
changeset | 106 | 	env.Execute('@$CC tools/cpuflags.c -o tools/cpuflags')
 | 
| 85 
907a634e5c02
implement triangle packet intersection
 Radek Brich <radek.brich@devl.cz> parents: 
84diff
changeset | 107 | 	(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: 
67diff
changeset | 108 | 		% (''.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: 
67diff
changeset | 109 | context.Result(cpu) | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 110 | return True | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 111 | |
| 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: 
95diff
changeset | 112 | 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: 
95diff
changeset | 113 | 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: 
95diff
changeset | 114 | config_h="#build/include/config.h" | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 115 | 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: 
95diff
changeset | 116 | clean=False, help=False, | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 117 | 	custom_tests = {
 | 
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 118 | 'CheckPlatform' : CheckPlatform, | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 119 | 'CheckCPUFlags' : CheckCPUFlags, | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 120 | 'CheckIntelC' : CheckIntelC, | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 121 | 'CheckGCC' : CheckGCC, | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 122 | }) | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 123 | conf.CheckPlatform() | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 124 | |
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 125 | conf.CheckGCC() | 
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 126 | conf.CheckIntelC() | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 127 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 128 | 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: 
91diff
changeset | 129 | 	Tool('intelc').generate(conf.env)
 | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 130 | cc = 'intelc' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 131 | elif gcc: | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 132 | cc = 'gcc' | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 133 | else: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 134 | cc = 'none' | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 135 | |
| 95 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 136 | if cc == 'intelc' or cc == 'gcc': | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 137 | conf.CheckCPUFlags() | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 138 | |
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
changeset | 139 | add_flags = '' | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 140 | if cc == 'gcc': | 
| 68 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 141 | 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: 
67diff
changeset | 142 | if cc == 'intelc': | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 143 | add_flags += cpuflags_intelc + ' ' | 
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
changeset | 144 | |
| 91 | 145 | if conf.env['force_flags']: | 
| 146 | add_flags = conf.env['flags'] + ' ' | |
| 147 | else: | |
| 148 | add_flags += conf.env['flags'] + ' ' | |
| 149 | ||
| 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: 
85diff
changeset | 150 | if conf.env['precision'] == 'double': | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 151 | 	conf.Define("PYRIT_DOUBLE")
 | 
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
changeset | 152 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 153 | 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: 
91diff
changeset | 154 | 	conf.Define("NO_SIMD")
 | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 155 | |
| 66 | 156 | 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: 
85diff
changeset | 157 | conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags) | 
| 66 | 158 | 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: 
85diff
changeset | 159 | conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags) | 
| 93 | 160 | # Other useful flags: | 
| 161 | # -Wunsafe-loop-optimizations -Wpointer-arith -Wcast-align -Wconversion | |
| 162 | # -Wmissing-noreturn -Winline -Wdisabled-optimization | |
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 163 | else: | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 164 | print "No supported compiler found." | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 165 | Exit(1) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 166 | |
| 66 | 167 | print "Using compiler: " + cc | 
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
changeset | 168 | print "Additional flags: " + add_flags | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 169 | |
| 93 | 170 | if conf.env['profile'] and cc == 'gcc': | 
| 171 | conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg") | |
| 172 | ||
| 95 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 173 | if conf.env['ldflags']: | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 174 | conf.env.Append(LINKFLAGS=conf.env['ldflags']) | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 175 | |
| 93 | 176 | |
| 177 | # configure pthread | |
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 178 | conf.env.Append(CCFLAGS="-pthread ") | 
| 91 | 179 | |
| 93 | 180 | |
| 181 | # 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: 
99diff
changeset | 182 | 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: 
99diff
changeset | 183 | 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: 
91diff
changeset | 184 | 	conf.Define('HAVE_PNG')
 | 
| 91 | 185 | |
| 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: 
85diff
changeset | 186 | 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: 
85diff
changeset | 187 | |
| 93 | 188 | |
| 189 | # configure Python | |
| 190 | pyenv = env.Clone() | |
| 191 | have_python = True | |
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 192 | try: | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 193 | 	pyenv.ParseConfig('python-config --includes --libs')
 | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 194 | except: | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 195 | have_python = False | 
| 93 | 196 | |
| 197 | if not have_python: | |
| 198 | print "Error: Python is required." | |
| 199 | Exit(1) | |
| 200 | ||
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 201 | # configure SDL | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 202 | sdlenv = env.Clone() | 
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 203 | try: | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 204 | 	sdlenv.ParseConfig('sdl-config --cflags')
 | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 205 | 	sdlenv.ParseConfig('sdl-config --libs')
 | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 206 | except: | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 207 | pass | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 208 | |
| 93 | 209 | def CheckSDL(context): | 
| 210 | global have_sdl | |
| 211 | 	context.Message('Checking for SDL... ')
 | |
| 212 | 	if context.TryLink("#include <SDL.h>\n"+
 | |
| 213 | 		"int main(int argc,char **argv){return 0;}", '.cc'):
 | |
| 214 | context.Result(1) | |
| 215 | return True | |
| 216 | else: | |
| 217 | 		context.Result("no (some demos won't be built)")
 | |
| 218 | return False | |
| 219 | ||
| 220 | 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: 
95diff
changeset | 221 | clean=False, help=False, | 
| 93 | 222 | 	custom_tests = {'CheckSDL' : CheckSDL} )
 | 
| 223 | have_sdl = conf.CheckSDL() | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 224 | sdlenv = conf.Finish() | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 225 | |
| 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: 
85diff
changeset | 226 | |
| 
f7edb3b90816
merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
 Radek Brich <radek.brich@devl.cz> parents: 
85diff
changeset | 227 | ### build targets | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 228 | |
| 95 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 229 | Export('env pyenv sdlenv have_sdl cc')
 | 
| 102 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 Radek Brich <radek.brich@devl.cz> parents: 
101diff
changeset | 230 | 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: 
91diff
changeset | 231 | 	exports={'buildmodule':False})
 | 
| 104 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 232 | pymodule = SConscript('src/SConscript', variant_dir='build/pymodule', duplicate=0,
 | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 233 | 	exports={'buildmodule':True})
 | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 234 | SConscript('ccdemos/SConscript', variant_dir='build/ccdemos', duplicate=0, exports='lib')
 | 
| 
2274a07510c1
Cleanup, dropped Windows support
 Radek Brich <radek.brich@devl.cz> parents: 
102diff
changeset | 235 | SConscript('demos/SConscript', exports='pymodule')
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 236 | |
| 102 
de3e9ea18f56
Migrate sources to Mercurial. Update links etc.
 Radek Brich <radek.brich@devl.cz> parents: 
101diff
changeset | 237 | 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: 
62diff
changeset | 238 | SConscript('models/SConscript')
 | 
| 60 | 239 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 240 | env.Alias('demos', ['cc-demos', 'python-demos'])
 | 
| 91 | 241 | env.Alias('libs', ['static-lib', 'python-module'])
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 242 | env.Alias('docs', Command('docs/html', [], 'doxygen'))
 | 
| 66 | 243 | env.Clean('docs', ['docs/html'])
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 244 | env.Alias('no-docs', ['libs', 'demos', 'models'])
 | 
| 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 245 | 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: 
63diff
changeset | 246 | env.Alias('all', ['no-docs', 'docs'])
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 247 | env.Alias('pyrit', 'no-download')
 | 
| 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 248 | Default('pyrit')
 |