Setup debian package build environment in 'debian/'
[senf.git] / SConstruct
1 # -*- python -*-
2
3 import sys, glob, os.path, datetime, pwd, time
4 sys.path.append('senfscons')
5 import SENFSCons
6
7 ###########################################################################
8
9 # Load utilities and setup libraries
10 SENFSCons.UseBoost()
11 SENFSCons.UseSTLPort()
12 env = SENFSCons.MakeEnvironment()
13
14 # Configure build
15 env.Append(
16    CPPPATH = [ '#' ],
17    LIBS = [ 'iberty', '$BOOSTREGEXLIB' ],
18    DOXY_XREF_TYPES = [ 'bug', 'fixme', 'todo', 'idea' ],
19    DOXY_HTML_XSL = '#/doclib/html-munge.xsl',
20    ENV = { 'TODAY' : str(datetime.date.today()),
21            'REVISION' : os.popen("svnversion").read().strip(),
22            'LOGNAME' : os.environ['LOGNAME']
23            },
24 )
25
26 Export('env')
27
28 # Build modules (that is, instruct to build ... the build happens later)
29 SConscript(glob.glob("*/SConscript"))
30
31 SENFSCons.StandardTargets(env)
32 SENFSCons.GlobalTargets(env)
33 SENFSCons.Doxygen(env)
34
35 SENFSCons.DoxyXRef(env,
36                    HTML_HEADER = '#/doclib/doxy-header-overview.html',
37                    HTML_FOOTER = '#/doclib/doxy-footer.html')
38
39 def updateRevision(target, source, env):
40     rev = env['ENV']['REVISION']
41     if ':' in rev:
42         print
43         print "Working copy not clean. Run 'svn update'"
44         print
45         return 1
46     if 'M' in rev:
47         print
48         print "Working copy contains local changes. Commit first"
49         print
50         return 1
51     if 'S' in rev or 'M' in rev:
52         rev = rev[:-1]
53     changelog = file('debian/changelog.template').read() % {
54         'rev': rev,
55         'user': pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0].strip(),
56         'date': time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) }
57     file('debian/changelog','w').write(changelog)
58
59 env.AlwaysBuild(
60     env.Alias('deb', [], [ updateRevision,
61                            "dpkg-buildpackage -us -uc -rfakeroot" ]))
62
63 # Create Doxyfile.local if not cleaning and the file does not exist
64 # otherwise doxygen will barf on this non-existent file
65 if not env.GetOption('clean') and not os.path.exists("Doxyfile.local"):
66     Execute(Touch("Doxyfile.local"))