OSDN Git Service

fix mypaint.desktop and installation of icons
[mypaint-anime/master.git] / SConstruct
1 import os, sys
2 from os.path import join, basename
3
4 EnsureSConsVersion(1, 0)
5
6 python = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])
7 print 'Building for', python
8
9 try: 
10     Glob
11 except:
12     # compatibility with SCons version 0.97
13     from glob import glob as Glob
14
15 try: 
16     import numpy
17 except ImportError:
18     print 'You need to have numpy installed.'
19     print
20     raise
21
22 SConsignFile() # no .scsonsign into $PREFIX please
23
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)
27 #else:
28
29 opts = Variables()
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)
33 opts.Update(env)
34
35 env.ParseConfig('pkg-config --cflags --libs glib-2.0')
36
37 env.Append(CXXFLAGS=' -Wall -Wno-sign-compare -Wno-write-strings')
38
39 # Get the numpy include path (for numpy/arrayobject.h).
40 numpy_path = numpy.get_include()
41 env.Append(CPPPATH=numpy_path)
42
43
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 else:
48     # some distros use python2.5-config, others python-config2.5
49     try:
50         env.ParseConfig(python + '-config --cflags --ldflags')
51     except OSError:
52         print 'going to try python-config instead'
53         env.ParseConfig('python-config --cflags --ldflags')
54
55 if env.get('CPPDEFINES'):
56     # make sure assertions are enabled
57     env['CPPDEFINES'].remove('NDEBUG')
58
59 if env['debug']:
60     env.Append(CPPDEFINES='HEAVY_DEBUG')
61     env.Append(CCFLAGS='-O0', LINKFLAGS='-O0')
62
63 Export('env')
64 module = SConscript('lib/SConscript')
65 SConscript('brushlib/SConscript')
66 languages = SConscript('po/SConscript')
67
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'])
73
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'
77     s += 5*'#\n'
78     s += '# DO NOT EDIT - edit %s instead\n' % source[0]
79     s += 5*'#\n'
80     s += open(str(source[0])).read()
81     f = open(str(target[0]), 'w')
82     f.write(s)
83     f.close()
84
85 env.Command('mypaint', 'mypaint.py', [burn_python_version, Chmod('$TARGET', 0755)])
86
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/*')
94
95 install('share', 'desktop/icons')
96 install('share/applications', 'desktop/mypaint.desktop')
97
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')
104
105 # translations
106 for lang in languages:
107     install('share/locale/%s/LC_MESSAGES' % lang, 'po/%s/LC_MESSAGES/mypaint.mo' % lang)