3 python = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])
4 print 'Building for', python
9 # compatibility with SCons version 0.97
10 from glob import glob as Glob
14 print 'You need to have numpy installed.'
18 SConsignFile() # no .scsonsign into $PREFIX please
20 # Does option parsing really screw up the win32 build? if no, remove comment
21 #if sys.platform == "win32":
22 # env = Environment(ENV=os.environ)
25 # Warn the user about saved build options.
26 if os.path.exists('options.cache'):
27 optfile = file('options.cache')
28 print "Saved options:", optfile.read().replace("\n", ", ")[:-2]
30 opts = Options('options.cache', ARGUMENTS)
31 opts.Add(PathOption('prefix', 'autotools-style installation prefix', '/usr/local', PathOption.PathAccept))
32 env = Environment(ENV=os.environ, options=opts)
34 opts.Save('options.cache', env)
36 env.ParseConfig('pkg-config --cflags --libs glib-2.0')
38 env.Append(CXXFLAGS=' -Wall -Wno-sign-compare -Wno-write-strings')
39 #env.Append(CXXFLAGS=' -O0', LINKFLAGS=' -O0')
40 #env.Append(CXXFLAGS=' -O3', LINKFLAGS=' -O3')
42 # Get the numpy include path (for numpy/arrayobject.h).
43 numpy_path = numpy.get_include()
44 env.Append(CPPPATH=numpy_path)
47 if sys.platform == "win32":
48 env.ParseConfig('pkg-config --cflags --libs python25') # These two '.pc' files you probably have to make for yourself.
49 env.ParseConfig('pkg-config --cflags --libs numpy') # Place them among the other '.pc' files ( where the 'glib-2.0.pc' is located .. probably )
51 # some distros use python2.5-config, others python-config2.5
53 env.ParseConfig(python + '-config --cflags --ldflags')
55 print 'going to try python-config instead'
56 env.ParseConfig('python-config --cflags --ldflags')
58 if env.get('CPPDEFINES'):
59 # make sure assertions are enabled
60 env['CPPDEFINES'].remove('NDEBUG')
62 module = SConscript('lib/SConscript', 'env')
63 SConscript('brushlib/SConscript', 'env')
65 # Build mypaint.exe for running on windows
66 if sys.platform == "win32":
67 env2 = Environment(ENV=os.environ)
68 env2.ParseConfig('pkg-config --cflags --libs python25')
69 env2.Program('mypaint', ['mypaint_exe.c'])
71 def burn_python_version(target, source, env):
72 # make sure we run the python version that we built the extension modules for
73 s = '#!/usr/bin/env ' + python + '\n'
75 s += '# DO NOT EDIT - edit %s instead\n' % source[0]
77 s += open(str(source[0])).read()
78 f = open(str(target[0]), 'w')
82 env.Command('mypaint', 'mypaint.in.py', [burn_python_version, Chmod('$TARGET', 0755)])
84 env.Alias('install', env['prefix'])
85 def install(dst, pattern):
86 env.Install(os.path.join(env['prefix'], dst), Glob(pattern))
87 install('bin', 'mypaint')
88 install('share/mypaint/brushes', 'brushes/*')
89 install('share/mypaint/backgrounds', 'backgrounds/*')
91 #install('share/mypaint/desktop', 'desktop/*')
92 # scons could recurse with Glob(), but it adds .svn directories when doing so
93 for dirpath, dirnames, filenames in os.walk('desktop'):
94 if '.svn' in dirnames:
95 dirnames.remove('.svn')
96 env.Install(os.path.join(env['prefix'], 'share/mypaint', dirpath), [os.path.join(dirpath, s) for s in filenames])
98 # mypaint.desktop goes into /usr/share/applications (debian-only or standard?)
99 install('share/applications', 'desktop/mypaint.desktop')
101 # location for achitecture-dependent modules
102 env.Install(os.path.join(env['prefix'], 'lib/mypaint'), module)
103 install('share/mypaint/lib', 'lib/*.py')
104 install('share/mypaint/gui', 'gui/*.py')
105 install('share/mypaint/brushlib', 'brushlib/*.py')
107 # debian python policy:
108 # "Private modules are installed in a directory such as /usr/share/packagename or /usr/lib/packagename."
109 # in general /usr/lib is for architecture-dependent stuff (compiled binaries or modules)
110 # and /usr/share for independent
113 # normal python library:
114 # .deb on gettdeb.net: /usr/share/mypaint/python
116 # autotools before: /usr/lib/python2.5/site-packages/mypaint/mydrawwidget.so
117 # .deb on gettdeb.net: /usr/lib/python2.5/site-packages/mypaint/mydrawwidget.so
118 # with foresight linux: /usr/lib64/python2.4/site-packages/mypaint/mydrawwidget.so
119 # (both of them probably just mirror autotools)