3 import sys, glob, os.path, datetime, pwd, time, fnmatch, string
4 sys.path.append(Dir('#/senfscons').abspath)
5 sys.path.append(Dir('#/doclib').abspath)
6 import SENFSCons, senfutil
8 ###########################################################################
9 # Load utilities and setup libraries and configure build
12 SENFSCons.UseSTLPort()
13 env = SENFSCons.MakeEnvironment()
16 Additional top-level build targets:
18 prepare Create all source files not part of the repository
19 all_tests Build and run unit tests for all modules
20 all_docs Build documentation for all modules
22 install_all Install SENF into $PREFIX
23 deb Build debian source and binary package
24 debsrc Build debian source package
25 debbin Build debian binary package
26 linklint Check links of doxygen documentation with 'linklint'
27 fixlinks Fix broken links in doxygen documentation
28 valgrind Run all tests under valgrind/memcheck
31 # Options used to debug inlining:
33 # INLINE_OPTS = [ '-finline-limit=20000', '--param','large-function-growth=10000',
34 # '--param', 'large-function-insns=10000', '--param','inline-unit-growth=10000',
35 # '-fvisibility-inlines-hidden', '-fno-inline-functions', '-Winline' ]
37 # BEWARE: You need lots of ram to compile with these settings (approx 1G)
39 INLINE_OPTS = [ '-finline-limit=5000' ]
42 CPPPATH = [ '#/include' ],
43 CXXFLAGS = [ '-Wall', '-Woverloaded-virtual', '-Wno-long-long' ] + INLINE_OPTS,
44 LIBS = [ 'rt', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
46 TEST_EXTRA_LIBS = [ ],
47 ENV = { 'PATH' : os.environ.get('PATH') },
48 CLEAN_PATTERNS = [ '*~', '#*#', '*.pyc', 'semantic.cache', '.sconsign', '.sconsign.dblite' ],
55 # Parse the log option command line parameter into the SENF_LOG_CONF macro
56 senfutil.setLogOption(env)
60 # Create Doxyfile.local otherwise doxygen will barf on this non-existent file
61 # Create it even when cleaning, to silence the doxygen builder warnings
62 if not os.path.exists("Doxyfile.local"):
63 Execute(Touch("Doxyfile.local"))
65 # Create local_config.h
66 if not env.GetOption('clean') and not os.path.exists("local_config.hh"):
67 Execute(Touch("local_config.hh"))
69 ###########################################################################
70 # Define build targets
72 # Before defining any targets, check wether this is the first build in
73 # pristine directory tree. If so, call 'scons prepare' so the dependencies
74 # created later are correct
76 if not env.GetOption('clean') and not os.path.exists(".prepare-stamp") \
77 and not os.environ.get("SCONS") and COMMAND_LINE_TARGETS != [ 'prepare' ]:
78 env.Execute([ "scons prepare" ])
79 env.Clean('all', '.prepare-stamp')
81 # Load SConscripts. Need to load debian and doclib first (they change the global environment)
82 SConscript("debian/SConscript")
83 SConscript("doclib/SConscript")
84 SConscript(list(set(glob.glob("*/SConscript")) - set(("debian/SConscript", "doclib/SConscript"))))
86 # Define the main targets
87 SENFSCons.StandardTargets(env)
88 SENFSCons.GlobalTargets(env)
90 env.Depends( SENFSCons.Doxygen(env), env.Value(env['ENV']['REVISION']) )
92 libsenf = env.Library(env.subst("$LIBSENF$LIBADDSUFFIX"), env['ALLOBJECTS'])
94 env.Clean('all', libsenf)
95 env.Alias('default', libsenf)
97 SENFSCons.InstallIncludeFiles(env, [ 'config.hh' ])
98 env.Alias('install_all', env.Install('$LIBINSTALLDIR', libsenf))
100 if env.GetOption('clean'):
101 env.Clean('all', [ os.path.join(path,f)
102 for path, subdirs, files in os.walk('.')
103 for pattern in env['CLEAN_PATTERNS']
104 for f in fnmatch.filter(files,pattern) ])
106 SENFSCons.PhonyTarget(env, 'prepare', [ 'true' ])
108 SENFSCons.PhonyTarget(env, 'valgrind', [ """
110 | while read test; do
112 echo "Running $$test";
114 valgrind --tool=memcheck --error-exitcode=99 --suppressions=valgrind.sup
115 $$test $BOOSTTESTARGS;
116 [ $$? -ne 99 ] || exit 1;
118 """.replace("\n"," ") ], [ 'all_tests' ])
120 if not env.GetOption('clean') and not os.path.exists(".prepare-stamp"):
121 Execute(Touch(".prepare-stamp"))