5 prefix = ARGUMENTS.get ('prefix', "/usr/local")
6 usr_local_include = os.path.join (prefix, "include")
7 usr_local_lib = os.path.join (prefix, "lib")
8 usr_local_bin = os.path.join (prefix, "bin")
10 current_directory = Dir ('.').abspath
13 target_usr_local_include = os.path.join (usr_local_include, "anna")
14 target_usr_local_lib = os.path.join (usr_local_lib, "anna")
15 #target_usr_local_bin = usr_local_bin
16 target_opt_bin = os.path.join (opt_bin, "anna")
19 release = ARGUMENTS.get ('release', 0)
23 rc = os.system("clang++ --version >/dev/null 2>/dev/null")
25 print "\nDetected clang++ installed in the system"
26 print "\nSelect compiler:\n 1. g++\n 2. clang++"
27 #option = raw_input("\nInput option [1]: ") or "1"
29 print "\nInput option [1]: "
31 i, o, e = select.select( [sys.stdin], [], [], 60 )
32 if (i): option = sys.stdin.readline().strip()
33 else: print "expired! using default ..."
35 env = Environment(CXX = 'clang++')
36 env.Append (CCFLAGS = '-DIS_CLANG')
37 env.Append (CXXFLAGS = '-Wno-parentheses-equality')
43 #oracle_includes = os.environ["ORACLE_HOME"] + "/include"
44 oracle_includes = "/usr/lib/oracle/12.1/client64/include"
47 source_include = os.path.join (current_directory, "include")
49 #"/usr/include/oracle/12.1/client64",
51 "/usr/include/libxml2",
52 #"/usr/include/boost",
53 #"/usr/include/mysql",
54 #"/usr/include/openssl",
62 # CPPPATH will be relative to src/<target>
63 env.Append (CPPPATH = [source_include, usr_local_include, usr_include ])
64 #env.Append (CCFLAGS = '-std=c++0x')
66 env.Append (CXXFLAGS = '-std=c++11')
68 env.Append (LIBS = [''])
72 env.Append (CCFLAGS = '-O3')
73 env.Append (VARIANT = variant)
76 env.Append (CCFLAGS = '-g -O0')
77 env.Append (LIBPATH = os.path.join (current_directory, variant))
78 env.Append (VARIANT = variant)
81 source = os.path.join (current_directory, "source")
82 sources = Glob(source + '/*')
83 for source in sources:
86 compile_library = SConscript (ss, exports='env')
87 libraries.extend (compile_library)
89 env.Default (libraries)
92 ## Run 'scons example' to compile examples
95 example = os.path.join (current_directory, "example")
96 examples = Glob(example + '/*/*')
97 for example in examples:
99 bn_ss = os.path.basename(ss)
100 noExtension = (len(bn_ss.split('.')) == 1)
103 example_program = SConscript (ss, exports='env')
104 example_list.extend (example_program)
105 print example_program [0]
107 #Depends (example_list, compile_library)
109 # In order to remove examples objects with 'scons -c' we need to default them at built ('scons') procedure:
110 env.Default (example_list)
111 #env.Alias ('example', example_list)
115 # Run 'scons test' to compile unit-tests
120 test = os.path.join (current_directory, "test")
121 tests = Glob(test + '/*')
125 test_unit_program = SConscript (ss, exports='env')
126 test_unit_list.extend (test_unit_program)
127 print test_unit_program [0]
128 test_unit = Builder (action = '%s --report_level=short > $TARGET' % test_unit_program [0])
129 env ['BUILDERS']['RunTestUnit'] = test_unit
130 test_unit_result = env.RunTestUnit ('%s.output' % test_unit_program [0], 'SConstruct')
131 run_tests.extend (test_unit_result)
132 Depends (test_unit_result, test_unit_program)
134 env.Alias ('test', run_tests)
135 # In order to remove test objects with 'scons -c' we need to default them at built ('scons') procedure:
136 env.Default (test_unit_list)
139 # Run 'scons doc' to generate documentation
141 # Doxygen Builder does not work properly at the moment. We will use an alias/action
142 #env = Environment(tools = ["default", "doxygen"], toolpath = './docs/doxygen')
143 #env.Doxygen("./docs/doxygen/Doxyfile")
144 # Finally, is enough to execute doxygen which will solve dependences and work for
145 # only modified files:
146 env.Alias('doc', env.Command('doc.dummy', [], 'cd docs/doxygen; doxygen'))
148 # Installation aliases:
150 # 'sudo scons install-include' for only headers
151 # 'sudo scons install-lib' for only libraries
152 # 'sudo scons install-include-and-lib' for headers & libraries
153 # 'sudo scons install-example' for only example binaries/resources
154 # 'sudo scons install' to install the whole suite
156 # Run 'sudo scons uninstall' to uninstall the suite
158 # See http://www.scons.org/wiki/InstallTargets and http://www.scons.org/doc/production/HTML/scons-user/c2938.html
159 install_include = env.Install (target_usr_local_include, Glob("include/anna/*"))
160 install_lib = env.Install (target_usr_local_lib, Glob("source/*/" + variant + "/*.a"))
161 install_example = env.Install (target_opt_bin, Glob("example/*/*/" + variant + "/example_*"))
162 postinstall_example = env.Command('./example/postinstall.out', None, './example/postinstall.sh')
165 Depends (install_include, test_unit_result)
166 Depends (install_lib, test_unit_result)
167 Depends (install_example, test_unit_result)
169 ii = env.Alias('install-include', [target_usr_local_include])
170 il = env.Alias('install-lib', [target_usr_local_lib])
171 iil = env.Alias('install-include-and-lib', [target_usr_local_include, target_usr_local_lib])
172 iex = env.Alias('install-example', [target_opt_bin, postinstall_example])
173 env.Alias('install', [iil, iex])
175 env.Command ("uninstall", None, [ Delete(target_usr_local_include), Delete(target_usr_local_lib), Delete(target_opt_bin) ])