summaryrefslogtreecommitdiff
path: root/SConstruct
blob: 7300a299384484053c8fbd4c6aa25d67a2a1c2a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os

AddOption('--release', action = 'store_true')

env = Environment()

conf = Configure(env)
for lib, h in (('glib-2.0', None), ('sqlite3', 'sqlite3.h'), ('gtk-x11-2.0', None), ('gthread-2.0', None)):
	if h:
		libfound = conf.CheckLibWithHeader(lib, h, 'c')
	else:
		libfound = conf.CheckLib(lib)
	if not libfound:
		print 'Can''t find %s' % lib
		Exit(1)
env = conf.Finish()

if 'CCFLAGS' in os.environ:
	env.Append(CCFLAGS = os.environ['CCFLAGS'].split())

if 'LINKFLAGS' in os.environ:
	env.Append(LINKFLAGS = os.environ['LINKFLAGS'].split())

env.Append(CCFLAGS = ['-std=gnu99'])

if GetOption('release'):
	env.Append(CCFLAGS = ['-O2'])
else:
	env.Append(CCFLAGS = ['-g', '-Wall'])

env.Append(LINKFLAGS = ['-Wl,--export-dynamic'])
env.ParseConfig('pkg-config --cflags --libs glib-2.0')
env.ParseConfig('pkg-config --cflags --libs sqlite3')
env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
env.ParseConfig('pkg-config --cflags --libs gthread-2.0')

def build_ui(target, source, env):
	f = open(str(target[0]), 'w')
	uiname = str(target[0]).rsplit('.', 1)[0]
	f.write('#ifndef _%s_H_\n' % uiname.upper())
	f.write('#define _%s_H_\n' % uiname.upper())
	f.write('#include <gtk/gtk.h>\n')
	f.write('gchar *%s_string = \n' % uiname)
	for line in open(str(source[0]), 'r'):
		f.write('"%s"\n' % line.replace('"', '\\"').strip())
	f.write(';\n')
	f.write('#endif\n')

ui_builder = Builder(action = build_ui)

env['BUILDERS']['walls_ui'] = ui_builder
env.walls_ui('walls_ui.h', 'walls.ui')
env.walls_ui('tags_ui.h', 'tags.ui')
env.walls_ui('config_ui.h', 'config.ui')
walls = env.Program('walls', Glob('*.c'))

destdir = ARGUMENTS.get('DESTDIR', '')
prefix = ARGUMENTS.get('PREFIX', '/usr/local')

final_dest = destdir + prefix + '/bin'

env.Install(final_dest, walls)
env.Alias('install', final_dest)

# vim: syn=python