-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·258 lines (215 loc) · 7.79 KB
/
configure
File metadata and controls
executable file
·258 lines (215 loc) · 7.79 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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/usr/bin/env python
# Copyright (C) 2017 The Antares Authors
# This file is part of Antares, a tactical space combat game.
# Antares is free software, distributed under the LGPL+. See COPYING.
from __future__ import division, print_function, unicode_literals
import argparse
import collections
import os
import platform
import sys
try:
from shlex import quote
except ImportError:
from pipes import quote
sys.path.append(os.path.join(os.path.dirname(__file__), "scripts"))
import installdeps
sys.path.append(os.path.join(os.path.dirname(__file__), "build", "lib", "scripts"))
try:
import cfg
except ImportError:
pass
str = type("") # For Python2
def main():
os.chdir(os.path.dirname(sys.argv[0]))
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-m",
"--mode",
metavar="MODE",
type=str,
choices="dbg dev opt".split(),
default="opt",
help="set build configuration:\n"
" - opt: compile for fast binaries (default)\n"
" - dev: compile for fast builds\n"
" - dbg: add debugging symbols")
parser.add_argument(
"-o", "--target-os", metavar="OS", type=str, help="target os (default: host os)")
parser.add_argument(
"--prefix",
type=str,
default="/usr/local",
help="installation prefix (default: /usr/local)")
args = parser.parse_args()
check_submodules()
check_host()
check_target(args)
with cfg.step("configure mode") as msg:
msg(args.mode, color="green")
gn_args = {}
gn_args["mode"] = args.mode
gn_args["target_os"] = args.target_os
gn_args["prefix"] = args.prefix
if args.target_os == "mac":
gn_args["macosx_version_min"] = "10.7"
cfg.gn(**gn_args)
print("make(1) it so!")
def check_submodules():
REQUIRED_SUBMODULES = [
"build/lib/BUILD.gn",
"ext/glfw/BUILD.gn",
"ext/gmock/BUILD.gn",
"ext/libmodplug/BUILD.gn",
"ext/libpng/BUILD.gn",
"ext/libsfz/BUILD.gn",
"ext/libsndfile/BUILD.gn",
"ext/libzipxx/BUILD.gn",
"ext/procyon/BUILD.gn",
"data/README.md",
]
missing = False
for module in REQUIRED_SUBMODULES:
if not os.path.exists(os.path.join(module)):
missing = True
break
if missing:
print("Some submodules are missing. Run:")
print("")
print(" $ git submodule update --init build ext data")
print("")
print("Then, try ./configure again")
sys.exit(1)
def check_host():
with cfg.step("checking host os") as msg:
if cfg.host_os() in ["mac", "linux"]:
msg(cfg.host_os(), color="green")
else:
msg(cfg.host_os(), color="red")
print("\nSorry! Antares requires Mac OS X or Linux")
sys.exit(1)
def check_target(args):
with cfg.step("checking target os") as msg:
if args.target_os is None:
args.target_os = cfg.host_os()
checker = {
("mac", "mac"): check_mac,
("linux", "linux"): check_linux_native,
}.get((cfg.host_os(), args.target_os))
if checker is None:
msg(args.target_os, color="red")
sys.exit(1)
msg(args.target_os, color="green")
checker(args)
def check_mac(args):
with cfg.step("checking Mac OS X version") as msg:
ver = platform.mac_ver()[0]
ver = tuple(int(x) for x in ver.split(".")[:2])
if ver < (10, 9):
msg("%d.%d" % ver, color="red")
print("\nSorry! Antares requires Mac OS X 10.9+")
sys.exit(1)
msg("%d.%d" % ver, color="green")
missing = collections.OrderedDict()
if not (check_clang() and check_libcxx()):
missing["xcode"] = ("* To install Xcode, open the App Store:\n"
" https://itunes.apple.com/en/app/xcode/id497799835\n"
" After installing, open it and accept the license agreement\n")
if missing:
print("\nmissing dependencies: %s\n" % " ".join(missing.keys()))
for step in missing.values():
sys.stdout.write(step)
print("")
print("Then, try ./configure again")
sys.exit(1)
def check_linux_native(args):
with cfg.step("checking Linux distro") as msg:
distro = platform.linux_distribution()
if distro[0].lower() in installdeps.COMMAND:
msg(" ".join(distro), color="green")
distro = distro[0]
else:
msg(" ".join(distro) + " (untested)", color="yellow")
distro = "Ubuntu"
command = installdeps.COMMAND[distro.lower()]
package = installdeps.PACKAGE[distro.lower()]
missing_pkgs = []
if not check_clang("clang++"):
missing_pkgs.append("clang")
if not check_libcxx("clang++"):
missing_pkgs.append("libc++")
if not check_libcxxabi("clang++"):
missing_pkgs.append("libc++abi")
if not check_python_gi():
missing_pkgs.append("python-gi")
elif not check_python_gtk():
missing_pkgs.append("python-gtk3")
if check_pkg_config():
libs = """
gl glfw3 glu libmodplug libzip libpng16 neon openal sndfile
x11 xcursor xinerama xrandr xxf86vm zlib
""".split()
for lib in libs:
if not cfg.check_pkg(lib):
missing_pkgs.append(lib)
else:
missing_pkgs.append("pkg-config")
if missing_pkgs:
print("\nmissing dependencies: %s" % " ".join(missing_pkgs))
if len(missing_pkgs) == 1:
print("On %s, you can install it with:\n" % distro)
else:
print("On %s, you can install them with:\n" % distro)
command = ["sudo"] + command + list(package[pkg] for pkg in missing_pkgs)
print(" $ %s\n" % (" ".join(quote(arg) for arg in command)))
print("Then, try ./configure again")
sys.exit(1)
def check_clang(executable=""):
"""Compile a basic C++11 binary."""
executable = executable or "clang++"
return cfg.check_bin(
("%s -x c++ -std=c++11 - -o /dev/null" % executable).split(),
what="clang",
input="int main() { return 1; }")
def check_libcxx(executable=""):
"""Compile a basic C++11, libc++ binary."""
executable = executable or "clang++"
return cfg.check_bin(
("%s -x c++ -std=c++11 -stdlib=libc++ - -o /dev/null" % executable).split(),
what="libc++",
input="#include <chrono>\n\nint main() { return std::chrono::seconds(1).count(); }")
def check_libcxxabi(executable=""):
"""Compile a basic C++11, libc++ binary, including cxxabi.h.
Pass -I/usr/include/libcxxabi explicitly to work around a broken
environment on Ubuntu.
"""
executable = executable or "clang++"
return cfg.check_bin(
("%s -x c++ -std=c++11 -stdlib=libc++ -I/usr/include/libcxxabi - -o /dev/null" % executable).split(),
what="libc++abi",
input="#include <cxxabi.h>\n\nint main() { return 0; }")
def check_pkg_config():
"""Run pkg-config --version."""
return cfg.check_bin("pkg-config --version".split())
def check_python_gi():
"""Check if Python can import python-gi."""
with cfg.step("checking for python-gi") as msg:
try:
import gi
return True
except ImportError:
msg("missing", color="red")
return False
def check_python_gtk():
"""Check if Python can load Gtk 3.0 through python-gi."""
with cfg.step("checking for python Gtk") as msg:
try:
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
return True
except ImportError:
msg("missing", color="red")
return False
if __name__ == "__main__":
main()