forked from jonasfrantz/g3data2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
75 lines (56 loc) · 1.93 KB
/
SConstruct
File metadata and controls
75 lines (56 loc) · 1.93 KB
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
66
67
68
69
70
71
72
73
74
75
import os
from SCons.Variables import BoolVariable
def _check_pkg_config(context, package_spec):
context.Message("Checking for pkg-config package '%s'... " % package_spec)
ok = context.TryAction("pkg-config --exists '%s'" % package_spec)[0]
context.Result(ok)
return ok
def _check_gtk_major_at_least(context, major):
context.Message("Checking GTK major version >= %d... " % major)
code = """
#include <gtk/gtk.h>
#if GTK_MAJOR_VERSION < %d
#error GTK major version is too old
#endif
int main(void) { return 0; }
""" % major
ok = context.TryCompile(code, ".c")
context.Result(ok)
return ok
vars = Variables()
vars.Add(BoolVariable("DEBUG", "Enable debug logging (G3DATA2_DEBUG)", False))
env = Environment(ENV=os.environ, variables=vars)
conf = Configure(
env,
custom_tests={
"CheckPkgConfig": _check_pkg_config,
"CheckGtkMajorAtLeast": _check_gtk_major_at_least,
},
)
if not conf.CheckProg("pkg-config"):
print("Error: pkg-config is required to locate GTK3 build flags.")
Exit(1)
if not conf.CheckPkgConfig("gtk+-3.0 >= 3.0"):
print("Error: gtk+-3.0 (version 3.0 or newer) is required.")
Exit(1)
conf.env.ParseConfig("pkg-config --cflags --libs gtk+-3.0")
if not conf.CheckHeader("gtk/gtk.h"):
print("Error: missing required header <gtk/gtk.h>.")
Exit(1)
if not conf.CheckHeader("gdk/gdk.h"):
print("Error: missing required header <gdk/gdk.h>.")
Exit(1)
if not conf.CheckHeader("cairo.h"):
print("Error: missing required header <cairo.h>.")
Exit(1)
if not conf.CheckGtkMajorAtLeast(3):
print("Error: headers resolve to GTK major version < 3.")
Exit(1)
env = conf.Finish()
env.Append(CCFLAGS=["-Wall"])
env.Append(LIBS=["m"])
if env["DEBUG"]:
env.Append(CPPDEFINES=["G3DATA2_DEBUG"])
print("Build mode: DEBUG (G3DATA2_DEBUG enabled)")
sources = ["main.c", "sort.c", "points.c", "drawing.c"]
env.Program(target="g3data2", source=sources)