-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure
executable file
·118 lines (101 loc) · 3.96 KB
/
configure
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
#!/usr/bin/env python
from optparse import OptionParser
from os.path import abspath, dirname, join
from subprocess import call
from sys import argv, stderr, stdout
from install.util import (
MAJOR_VERSION,
MINOR_VERSION,
PLATFORM_MACX,
PLATFORM_UNIX,
PLATFORM_WIN32,
REVISION,
findExecutable,
getPlatform
)
def main():
parser = OptionParser("usage: %prog [options] [qmake-args]")
parser.add_option("--bin-dir", action="store", default=None, dest="binDir",
help="Install directory for midisnoop executable")
parser.add_option("--build-dir", action="store", default=None,
dest="buildDir", help="Build directory")
parser.add_option("--data-dir", action="store", default=None,
dest="dataDir",
help="Install directory for general data files")
parser.add_option("--data-root-dir", action="store", default=None,
dest="dataRootDir", help="Install root for data files")
parser.add_option("--debug", action="store_true", default=False,
dest="debug", help="Build a debug executable")
parser.add_option("--exec-prefix", action="store", default=None,
dest="execPrefix",
help="Install prefix for executable data")
parser.add_option("--make-dir", action="store", default=None,
dest="makeDir", help="Make directory")
parser.add_option("--prefix", action="store", default=None, dest="prefix",
help="Install prefix")
options, args = parser.parse_args()
pkgConfigPath = findExecutable("pkg-config")
if pkgConfigPath is None:
stderr.write("Warning: pkg-config not found\n")
elif call([pkgConfigPath, "--exists", "rtmidi"]) or \
call([pkgConfigPath, "--atleast-version=2.0.1", "rtmidi"]):
exit("Error: rtmidi version >= 2.0.1 is required for compilation")
qmakePath = findExecutable("qmake")
if qmakePath is None:
exit("Error: qmake is required for build configuration")
platform = getPlatform()
platformArgs = []
if platform == PLATFORM_MACX:
platformArgs += ["-spec", "macx-g++"]
platformStr = "MACX"
elif platform == PLATFORM_WIN32:
platformStr = "WIN32"
else:
platformStr = "UNIX"
scriptDir = abspath(dirname(argv[0]))
buildDir = options.buildDir
if buildDir is None:
buildDir = "build"
buildDir = abspath(join(scriptDir, buildDir))
makeDir = options.makeDir
if makeDir is None:
makeDir = "make"
makeDir = abspath(join(scriptDir, makeDir))
prefix = options.prefix
if prefix is None:
prefix = "/usr/local"
else:
prefix = abspath(prefix)
dataRootDir = options.dataRootDir
if dataRootDir is None:
dataRootDir = "share"
dataRootDir = abspath(join(prefix, dataRootDir))
execPrefix = options.execPrefix
if execPrefix is None:
execPrefix = prefix
else:
execPrefix = abspath(execPrefix)
binDir = options.binDir
if binDir is None:
binDir = "bin"
binDir = abspath(join(execPrefix, binDir))
dataDir = options.dataDir
if dataDir is None:
dataDir = dataRootDir
else:
dataDir = abspath(join(prefix, dataDir))
# Run `qmake`
qmakeArgs = [qmakePath, "-recursive"] + platformArgs + args + \
["MAJOR_VERSION=%d" % MAJOR_VERSION, "MINOR_VERSION=%d" % MINOR_VERSION,
"REVISION=%d" % REVISION, "BUILDDIR=%s" % buildDir,
"MAKEDIR=%s" % makeDir, "PREFIX=%s" % prefix,
"DATAROOTDIR=%s" % dataRootDir, "EXECPREFIX=%s" % execPrefix,
"BINDIR=%s" % binDir, "DATADIR=%s" % dataDir]
if options.debug:
qmakeArgs.append("DEBUG=1")
if call(qmakeArgs):
parser.error("qmake returned an error")
stdout.write("Configure successful. Run `make` to build, and "
"`make install` to install.\n")
if __name__ == "__main__":
main()