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
20 print 'You need to have numpy installed.'
24 SConsignFile() # no .scsonsign into $PREFIX please
26 # Does option parsing really screw up the win32 build? if no, remove comment
27 #if sys.platform == "win32":
28 # env = Environment(ENV=os.environ)
32 opts.Add(PathVariable('prefix', 'autotools-style installation prefix', '/usr/local', validator=PathVariable.PathIsDirCreate))
33 opts.Add(BoolVariable('debug', 'enable HEAVY_DEBUG and disable optimizations', False))
34 env = Environment(ENV=os.environ, options=opts)
37 env.ParseConfig('pkg-config --cflags --libs glib-2.0')
39 env.Append(CXXFLAGS=' -Wall -Wno-sign-compare -Wno-write-strings')
41 # Get the numpy include path (for numpy/arrayobject.h).
42 numpy_path = numpy.get_include()
43 env.Append(CPPPATH=numpy_path)
46 if sys.platform == "win32":
47 env.ParseConfig('pkg-config --cflags --libs python25') # These two '.pc' files you probably have to make for yourself.
48 env.ParseConfig('pkg-config --cflags --libs numpy') # Place them among the other '.pc' files ( where the 'glib-2.0.pc' is located .. probably )
50 # some distros use python2.5-config, others python-config2.5
52 env.ParseConfig(python + '-config --cflags --ldflags')
54 print 'going to try python-config instead'
55 env.ParseConfig('python-config --cflags --ldflags')
57 if env.get('CPPDEFINES'):
58 # make sure assertions are enabled
59 env['CPPDEFINES'].remove('NDEBUG')
62 env.Append(CPPDEFINES='HEAVY_DEBUG')
63 env.Append(CCFLAGS='-O0', LINKFLAGS='-O0')
66 module = SConscript('lib/SConscript')
67 SConscript('brushlib/SConscript')
68 languages = SConscript('po/SConscript')
70 # Build mypaint.exe for running on windows
71 if sys.platform == "win32":
72 env2 = Environment(ENV=os.environ)
73 env2.ParseConfig('pkg-config --cflags --libs python25')
74 env2.Program('mypaint', ['mypaint_exe.c'])
76 def burn_python_version(target, source, env):
77 # make sure we run the python version that we built the extension modules for
78 s = '#!/usr/bin/env ' + python + '\n'
80 s += '# DO NOT EDIT - edit %s instead\n' % source[0]
82 s += open(str(source[0])).read()
83 f = open(str(target[0]), 'w')
87 env.Command('mypaint', 'mypaint.py', [burn_python_version, Chmod('$TARGET', 0755)])
89 env.Alias('install', env['prefix'])
90 def install(dst, pattern):
91 env.Install(join(env['prefix'], dst), Glob(pattern))
92 install('bin', 'mypaint')
93 install('share/mypaint/brushes', 'brushes/*')
94 install('share/mypaint/backgrounds', 'backgrounds/*')
95 install('share/mypaint/pixmaps', 'pixmaps/*')
97 #install('share/mypaint/desktop', 'desktop/*')
98 # scons could recurse with Glob(), but it adds .svn directories when doing so
99 for dirpath, dirnames, filenames in os.walk('desktop'):
100 if '.svn' in dirnames:
101 dirnames.remove('.svn')
102 env.Install(join(env['prefix'], 'share/mypaint', dirpath), [join(dirpath, s) for s in filenames])
104 # mypaint.desktop goes into /usr/share/applications (debian-only or standard?)
105 install('share/applications', 'desktop/mypaint.desktop')
107 # location for achitecture-dependent modules
108 env.Install(join(env['prefix'], 'lib/mypaint'), module)
109 install('share/mypaint/lib', 'lib/*.py')
110 install('share/mypaint/gui', 'gui/*.py')
111 install('share/mypaint/brushlib', 'brushlib/*.py')
114 for lang in languages:
115 install('share/locale/%s/LC_MESSAGES' % lang, 'po/%s/LC_MESSAGES/mypaint.mo' % lang)