2 from os.path import join, basename
4 EnsureSConsVersion(1, 0)
6 python = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])
7 print 'Building for', python
12 # compatibility with SCons version 0.97
13 from glob import glob as Glob
18 print 'You need to have numpy installed.'
22 SConsignFile() # no .scsonsign into $PREFIX please
24 # Does option parsing really screw up the win32 build? if no, remove comment
25 #if sys.platform == "win32":
26 # env = Environment(ENV=os.environ)
30 opts.Add(PathVariable('prefix', 'autotools-style installation prefix', '/usr/local', validator=PathVariable.PathIsDirCreate))
31 opts.Add(BoolVariable('debug', 'enable HEAVY_DEBUG and disable optimizations', False))
32 env = Environment(ENV=os.environ, options=opts)
35 env.ParseConfig('pkg-config --cflags --libs glib-2.0')
37 env.Append(CXXFLAGS=' -Wall -Wno-sign-compare -Wno-write-strings')
39 # Get the numpy include path (for numpy/arrayobject.h).
40 numpy_path = numpy.get_include()
41 env.Append(CPPPATH=numpy_path)
44 if sys.platform == "win32":
45 env.ParseConfig('pkg-config --cflags --libs python25') # These two '.pc' files you probably have to make for yourself.
46 env.ParseConfig('pkg-config --cflags --libs numpy') # Place them among the other '.pc' files ( where the 'glib-2.0.pc' is located .. probably )
48 # some distros use python2.5-config, others python-config2.5
50 env.ParseConfig(python + '-config --cflags --ldflags')
52 print 'going to try python-config instead'
53 env.ParseConfig('python-config --cflags --ldflags')
55 if env.get('CPPDEFINES'):
56 # make sure assertions are enabled
57 env['CPPDEFINES'].remove('NDEBUG')
60 env.Append(CPPDEFINES='HEAVY_DEBUG')
61 env.Append(CCFLAGS='-O0', LINKFLAGS='-O0')
64 module = SConscript('lib/SConscript')
65 SConscript('brushlib/SConscript')
66 languages = SConscript('po/SConscript')
68 # Build mypaint.exe for running on windows
69 if sys.platform == "win32":
70 env2 = Environment(ENV=os.environ)
71 env2.ParseConfig('pkg-config --cflags --libs python25')
72 env2.Program('mypaint', ['mypaint_exe.c'])
74 def burn_python_version(target, source, env):
75 # make sure we run the python version that we built the extension modules for
76 s = '#!/usr/bin/env ' + python + '\n'
78 s += '# DO NOT EDIT - edit %s instead\n' % source[0]
80 s += open(str(source[0])).read()
81 f = open(str(target[0]), 'w')
85 env.Command('mypaint', 'mypaint.py', [burn_python_version, Chmod('$TARGET', 0755)])
87 env.Alias('install', env['prefix'])
88 def install(dst, pattern):
89 env.Install(join(env['prefix'], dst), Glob(pattern))
90 install('bin', 'mypaint')
91 install('share/mypaint/brushes', 'brushes/*')
92 install('share/mypaint/backgrounds', 'backgrounds/*')
93 install('share/mypaint/pixmaps', 'pixmaps/*')
95 install('share', 'desktop/icons')
96 install('share/applications', 'desktop/mypaint.desktop')
98 # location for achitecture-dependent modules
99 env.Install(join(env['prefix'], 'lib/mypaint'), module)
100 install('share/mypaint/lib', 'lib/*.py')
101 install('share/mypaint/gui', 'gui/*.py')
102 install('share/mypaint/gui', 'gui/menu.xml')
103 install('share/mypaint/brushlib', 'brushlib/*.py')
106 for lang in languages:
107 install('share/locale/%s/LC_MESSAGES' % lang, 'po/%s/LC_MESSAGES/mypaint.mo' % lang)