forked from monome/libmonome
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wscript
209 lines (151 loc) · 4.49 KB
/
wscript
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env python
import time
import sys
import os
top = "."
out = "build"
# change this stuff
APPNAME = "libmonome"
VERSION = "1.3.0"
#
# dep checking functions
#
def check_poll(conf):
# borrowed from glib's poll test
code = """
#include <stdlib.h>
#include <poll.h>
int main(int argc, char **argv) {
struct pollfd fds[1];
fds[0].fd = open("/dev/null", 1);
fds[0].events = POLLIN;
if( poll(fds, 1, 0) < 0 || fds[0].revents & POLLNVAL )
exit(1);
exit(0);
}"""
conf.check_cc(
define_name="HAVE_WORKING_POLL",
mandatory=False,
quote=0,
execute=True,
fragment=code,
msg="Checking for working poll()",
errmsg="no (will use select())")
def check_udev(conf):
conf.check_cc(
define_name="HAVE_LIBUDEV",
mandatory=False,
quote=0,
execute=True,
lib="udev",
uselib_store="UDEV",
msg="Checking for libudev",
errmsg="no (will use sysfs)")
def check_liblo(conf):
conf.check_cc(
define_name="HAVE_LO",
mandatory=True,
quote=0,
execute=True,
lib="lo",
uselib_store="LO",
msg="Checking for liblo")
#
# waf stuff
#
def options(opt):
opt.load("compiler_c")
opt.load("cython")
lm_opts = opt.add_option_group("libmonome options")
lm_opts.add_option("--disable-osc", action="store_true",
default=False, help="disable OSC/liblo support [enabled by default]")
lm_opts.add_option("--enable-python", action="store_true",
default=False, help="enable python bindings [disabled by default]")
lm_opts.add_option("--enable-multilib", action="store_true",
default=False, help="on Darwin, build libmonome as a combination 32 and 64 bit library [disabled by default]")
lm_opts.add_option('--enable-debug', action='store_true',
default=False, help="Build debuggable binaries")
lm_opts.add_option('--enable-embedded-protos', action='store_true',
default=False, help="Embed protos in the library")
def configure(conf):
# just for output prettifying
# print() (as a function) ddoesn't work on python <2.7
separator = lambda: sys.stdout.write("\n")
separator()
conf.load("compiler_c")
conf.load("gnu_dirs")
if conf.check_endianness() == "big":
conf.define("LM_BIG_ENDIAN", 1)
#
# conf checks
#
separator()
if conf.env.DEST_OS != "win32":
check_poll(conf)
conf.check_cc(lib='dl', uselib_store='DL', mandatory=True)
if conf.env.DEST_OS == "linux":
check_udev(conf)
if not conf.options.disable_osc:
check_liblo(conf)
separator()
if conf.options.enable_python:
conf.load("python")
conf.check_python_version(minver=(2,7,0))
conf.check_python_headers()
conf.load("cython")
separator()
#
# setting defines, etc
#
conf.env.append_unique("CFLAGS", ["-std=c99", "-Wall", "-Werror"])
if conf.options.enable_multilib:
conf.env.ARCH = ["i386", "x86_64"]
if conf.options.enable_debug:
conf.env.append_unique('CFLAGS', "-g")
conf.env.append_unique('LINKFLAGS', "-g")
if conf.env.DEST_OS == "darwin":
conf.env.append_unique("CFLAGS", ["-mmacosx-version-min=10.5"])
conf.env.append_unique("LINKFLAGS", ["-mmacosx-version-min=10.5"])
if os.path.basename(conf.env.CC[0]) == "clang":
conf.env.append_unique("CFLAGS", ["-Wno-initializer-overrides"])
conf.env.PROTOCOLS = ["40h", "series", "mext", "chronome"]
if conf.env.LIB_LO:
conf.env.PROTOCOLS.append("osc")
conf.define("BUILD_OSC_PROTO", 1)
conf.define("LIBDIR", conf.env.LIBDIR)
conf.define("LIBSUFFIX", "." + conf.env.cshlib_PATTERN.rsplit(".", 1)[-1])
if conf.options.enable_embedded_protos:
conf.define("EMBED_PROTOS", 1)
conf.env.EMBED_PROTOS = conf.options.enable_embedded_protos
conf.env.VERSION = VERSION
conf.define("VERSION", VERSION)
conf.write_config_header("config.h")
def build(bld):
bld.add_post_fun(post)
bld.install_files("${PREFIX}/include", ["public/monome.h"])
bld.recurse("src")
bld.recurse("utils")
# win32 doesn't have nanosleep()
if bld.env.DEST_OS != "win32":
bld.recurse("examples")
# man page
bld(
source="doc/monomeserial.in.1",
target="doc/monomeserial.1",
install_path="${PREFIX}/share/man/man1",
features="subst",
MDOCDATE=time.strftime("%B %d, %Y"))
if bld.env.CYTHON:
bld.recurse("bindings/python")
def post(pst):
if pst.cmd == "install" and \
pst.env.DEST_OS not in ["win32", "darwin"]:
pst.exec_command("ldconfig")
def dist(dst):
pats = [".git*", "**/.git*", ".travis.yml"]
with open(".gitignore") as gitignore:
for l in gitignore.readlines():
if l[0] == "#":
continue
pats.append(l.rstrip("\n"))
dst.excl = " ".join(pats)