| author | Radek Brich <radek.brich@devl.cz> | 
| Sun, 31 May 2009 23:06:03 +0200 | |
| branch | pyrit | 
| changeset 100 | c005054bf4c1 | 
| parent 99 | f3abdaa2e8fb | 
| child 101 | 50a994a57849 | 
| 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 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 42 | if sys.platform == 'win32': | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 43 | tools = ['mingw'] | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 44 | else: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 45 | tools = ['default'] | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
95diff
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: 
91diff
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: 
95diff
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: 
95diff
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: 
95diff
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: 
66diff
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: 
64diff
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: 
95diff
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: 
94diff
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: 
95diff
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: 
64diff
changeset | 57 | ) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
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: 
95diff
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: 
95diff
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: 
64diff
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: 
64diff
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: 
91diff
changeset | 63 | ) | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
95diff
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: 
95diff
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: 
91diff
changeset | 67 | ) | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 68 | |
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
95diff
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: 
95diff
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: 
95diff
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: 
64diff
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: 
95diff
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: 
95diff
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: 
85diff
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: 
85diff
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: 
85diff
changeset | 78 | |
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 79 | platform = 'unknown' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 80 | def CheckPlatform(context): | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 81 | global platform | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 82 | 	context.Message('Platform is... ')
 | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
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: 
64diff
changeset | 84 | platform = 'linux' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 85 | elif env['PLATFORM'] == 'posix': | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 86 | platform = 'posix' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 87 | elif env['PLATFORM'] == 'win32': | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 88 | platform = 'win32' | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 89 | context.Result(platform) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 90 | return True | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 91 | |
| 93 | 92 | intelcversion = '' | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
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: 
67diff
changeset | 94 | global intelc, intelcversion | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
67diff
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: 
67diff
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: 
67diff
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: 
64diff
changeset | 104 | return intelc | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 105 | |
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 106 | def CheckGCC(context): | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 107 | global gcc, gccversion | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
95diff
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: 
95diff
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: 
64diff
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: 
95diff
changeset | 112 | gccversion = testenv['CCVERSION'] | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 113 | context.Result(gccversion) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 114 | else: | 
| 70 
4b84e90325c5
a fix for CPU and compiler detection
 Radek Brich <radek.brich@devl.cz> parents: 
68diff
changeset | 115 | gccversion = '' | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 116 | context.Result(False) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 117 | return gcc | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 118 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 119 | def CheckMSVC(context): | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 120 | global msvc, msvcversion | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
91diff
changeset | 122 | testenv = Environment() | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 123 | msvc = "msvc" in testenv['TOOLS'] | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 124 | if msvc: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 125 | msvcversion = testenv['MSVS_VERSION'] | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 126 | context.Result(msvcversion) | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 127 | else: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 128 | msvcversion = '' | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 129 | context.Result(False) | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 130 | return msvc | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 131 | |
| 68 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 132 | def CheckCPUFlags(context): | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
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: 
67diff
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: 
67diff
changeset | 135 | 	env.Execute('@$CC tools/cpuflags.c -o tools/cpuflags')
 | 
| 85 
907a634e5c02
implement triangle packet intersection
 Radek Brich <radek.brich@devl.cz> parents: 
84diff
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: 
67diff
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: 
67diff
changeset | 138 | context.Result(cpu) | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 139 | return True | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
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: 
95diff
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: 
95diff
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: 
95diff
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: 
91diff
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: 
95diff
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: 
64diff
changeset | 146 | 	custom_tests = {
 | 
| 68 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 147 | 'CheckPlatform' : CheckPlatform, 'CheckCPUFlags' : CheckCPUFlags, | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
64diff
changeset | 149 | conf.CheckPlatform() | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 150 | |
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 151 | conf.CheckGCC() | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 152 | if platform == 'win32': | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 153 | conf.CheckMSVC() | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 154 | intelc = False | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 155 | else: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 156 | conf.CheckIntelC() | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 157 | msvc=False | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 158 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
91diff
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: 
64diff
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: 
91diff
changeset | 163 | 	Tool('default').generate(conf.env)
 | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 164 | 	conf.Define("MSVC")
 | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 165 | cc = 'msvc' | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 166 | elif gcc: | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
changeset | 167 | cc = 'gcc' | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 168 | else: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 169 | cc = 'none' | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 170 | |
| 95 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 171 | if cc == 'intelc' or cc == 'gcc': | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 172 | conf.CheckCPUFlags() | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 173 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
91diff
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: 
91diff
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: 
64diff
changeset | 177 | |
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
changeset | 178 | add_flags = '' | 
| 65 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
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: 
67diff
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: 
67diff
changeset | 181 | if cc == 'intelc': | 
| 
2c154aad7f33
added detection of optimal CPU flags for both GCC and IntelC
 Radek Brich <radek.brich@devl.cz> parents: 
67diff
changeset | 182 | add_flags += cpuflags_intelc + ' ' | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 183 | if cc == 'msvc': | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 184 | add_flags += '/fp:fast ' | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 185 | if conf.env['simd']: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 186 | add_flags += '/arch:SSE ' | 
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
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: 
85diff
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: 
91diff
changeset | 194 | 	conf.Define("PYRIT_DOUBLE")
 | 
| 67 
249553e1d4fe
new option to choose single or double precision floats
 Radek Brich <radek.brich@devl.cz> parents: 
66diff
changeset | 195 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
91diff
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: 
64diff
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: 
85diff
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: 
85diff
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: 
91diff
changeset | 206 | elif cc == 'msvc': | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
64diff
changeset | 208 | else: | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
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: 
64diff
changeset | 210 | Exit(1) | 
| 
242839c6d27d
basic detection of compiler (GCC or ICC) and CPU capabilities
 Radek Brich <radek.brich@devl.cz> parents: 
64diff
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: 
66diff
changeset | 213 | print "Additional flags: " + add_flags | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
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: 
94diff
changeset | 218 | if conf.env['ldflags']: | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 219 | conf.env.Append(LINKFLAGS=conf.env['ldflags']) | 
| 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
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: 
91diff
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: 
91diff
changeset | 225 | if cc == 'msvc': | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 226 | 		if not conf.CheckLib('pthreadVC2'):
 | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 227 | pthread = False | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 228 | elif cc == 'gcc': | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 229 | 		if not conf.CheckLib('pthreadGC2'):
 | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 230 | pthread = False | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 231 | else: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
85diff
changeset | 233 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
99diff
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: 
99diff
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: 
91diff
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: 
85diff
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: 
85diff
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: 
95diff
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: 
95diff
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: 
95diff
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: 
91diff
changeset | 272 | # configure SDL | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
91diff
changeset | 278 | try: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 279 | 		sdlenv.ParseConfig('sh sdl-config --cflags')
 | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 280 | 		sdlenv.ParseConfig('sh sdl-config --libs')
 | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 281 | except: | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 282 | pass | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
95diff
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: 
91diff
changeset | 299 | sdlenv = conf.Finish() | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
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: 
85diff
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: 
85diff
changeset | 302 | ### build targets | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 303 | |
| 95 
ca7d4c665531
build script fixes, add ldflags build option
 Radek Brich <radek.brich@devl.cz> parents: 
94diff
changeset | 304 | Export('env pyenv sdlenv have_sdl cc')
 | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 305 | lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0,
 | 
| 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 306 | 	exports={'buildmodule':False})
 | 
| 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 | 307 | (pymodule, modvcproj) = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0,
 | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 308 | 	exports={'buildmodule':True})
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 309 | |
| 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 | 310 | ccdemvcproj = SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='lib')
 | 
| 
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 | 311 | demosvcproj = SConscript('demos/SConscript', exports='pymodule')
 | 
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 312 | SConscript('tests/SConscript', build_dir='build/tests', duplicate=0, exports='lib')
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 313 | SConscript('models/SConscript')
 | 
| 60 | 314 | |
| 92 
9af5c039b678
add MSVC compiler support, make it default for Windows
 Radek Brich <radek.brich@devl.cz> parents: 
91diff
changeset | 315 | env.Alias('demos', ['cc-demos', 'python-demos'])
 | 
| 91 | 316 | env.Alias('libs', ['static-lib', 'python-module'])
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 317 | env.Alias('docs', Command('docs/html', [], 'doxygen'))
 | 
| 66 | 318 | env.Clean('docs', ['docs/html'])
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 319 | env.Alias('no-docs', ['libs', 'demos', 'models'])
 | 
| 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 320 | 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 | 321 | env.Alias('all', ['no-docs', 'docs'])
 | 
| 63 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 322 | env.Alias('pyrit', 'no-download')
 | 
| 
440e1ae80459
add many SCons targets (see DEVNOTES)
 Radek Brich <radek.brich@devl.cz> parents: 
62diff
changeset | 323 | 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: 
99diff
changeset | 324 | |
| 
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 | 325 | vcsol = env.MSVSSolution( | 
| 
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 | 326 | target = 'pyrit' + env['MSVSSOLUTIONSUFFIX'], | 
| 
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 | 327 | projects = [modvcproj, ccdemvcproj, demosvcproj], | 
| 
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 | 328 | variant = 'Release') | 
| 
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 | 329 | |
| 
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 | 330 | env.Depends(vcsol, [modvcproj, ccdemvcproj, demosvcproj]); | 
| 
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 | 331 | env.Alias('vcproj', vcsol)
 |