2 from os.path import join, basename
4 EnsureSConsVersion(1, 0)
6 # FIXME: sometimes it would be good to build for a different python
7 # version than the one running scons. (But how to find all paths then?)
8 python = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])
9 print 'Building for', python
14 print 'You need to have numpy installed.'
18 SConsignFile() # no .scsonsign into $PREFIX please
20 if sys.platform == "darwin":
21 default_prefix = '/opt/local/'
23 default_prefix = '/usr/local/'
26 opts.Add(PathVariable('prefix', 'autotools-style installation prefix', default_prefix, validator=PathVariable.PathIsDirCreate))
28 opts.Add(BoolVariable('debug', 'enable HEAVY_DEBUG and disable optimizations', False))
29 env = Environment(ENV=os.environ, options=opts)
30 if sys.platform == "win32":
31 env = Environment(tools=['mingw'], ENV=os.environ, options=opts)
34 env.ParseConfig('pkg-config --cflags --libs glib-2.0')
35 env.ParseConfig('pkg-config --cflags --libs libpng')
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 )
47 elif sys.platform == "darwin":
48 env.ParseConfig('python-config --cflags')
49 env.ParseConfig('python-config --ldflags')
51 # some distros use python2.5-config, others python-config2.5
53 env.ParseConfig(python + '-config --cflags')
54 env.ParseConfig(python + '-config --ldflags')
56 print 'going to try python-config instead'
57 env.ParseConfig('python-config --ldflags')
58 env.ParseConfig('python-config --cflags')
60 if env.get('CPPDEFINES'):
61 # make sure assertions are enabled
62 env['CPPDEFINES'].remove('NDEBUG')
65 env.Append(CPPDEFINES='HEAVY_DEBUG')
66 env.Append(CCFLAGS='-O0', LINKFLAGS='-O0')
69 module = SConscript('lib/SConscript')
70 SConscript('brushlib/SConscript')
71 languages = SConscript('po/SConscript')
73 # Build mypaint.exe for running on windows
74 if sys.platform == "win32":
75 env2 = Environment(tools=['mingw'], ENV=os.environ)
76 env2.ParseConfig('pkg-config --cflags --libs python25')
77 env2.Program('mypaint', ['mypaint_exe.c'])
79 def burn_python_version(target, source, env):
80 # make sure we run the python version that we built the extension modules for
81 s = '#!/usr/bin/env ' + python + '\n'
83 s += '# DO NOT EDIT - edit %s instead\n' % source[0]
85 s += open(str(source[0])).read()
86 f = open(str(target[0]), 'w')
90 env.Command('mypaint', 'mypaint.py', [burn_python_version, Chmod('$TARGET', 0755)])
92 env.Clean('.', Glob('*.pyc'))
93 env.Clean('.', Glob('gui/*.pyc'))
94 env.Clean('.', Glob('lib/*.pyc'))
96 env.Alias('install', env['prefix'])
97 def install(dst, pattern):
99 assert files, "Glob expression did not match any files"
100 env.Install(join(env['prefix'], dst), files)
101 install('bin', 'mypaint')
102 install('share/mypaint/brushes', 'brushes/*')
103 install('share/mypaint/backgrounds', 'backgrounds/*')
104 install('share/mypaint/pixmaps', 'pixmaps/*')
106 install('share', 'desktop/icons')
107 install('share/applications', 'desktop/mypaint.desktop')
109 # location for achitecture-dependent modules
110 env.Install(join(env['prefix'], 'lib/mypaint'), module)
111 install('share/mypaint/lib', 'lib/*.py')
112 install('share/mypaint/gui', 'gui/*.py')
113 install('share/mypaint/gui', 'gui/menu.xml')
114 install('share/mypaint/brushlib', 'brushlib/*.py')
117 for lang in languages:
118 install('share/locale/%s/LC_MESSAGES' % lang, 'po/%s/LC_MESSAGES/mypaint.mo' % lang)