-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconfigure
executable file
·227 lines (205 loc) · 9.33 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
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
#!/usr/bin/env python3
# ---------------------------------------------------------------------------
# Copyright (C) 2020-2030, [email protected]
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and / or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions :
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# ---------------------------------------------------------------------------
import sys
import os
from os.path import *
import argparse
import subprocess
project = "zmq-Ada"
def getProjectDir():
projects = False
os.environ["ADA_PROJECT_PATH"] = ""
os.environ["GPR_PROJECT_PATH"] = ""
response = subprocess.Popen(
["gnatls", "-v"],
stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split("\n")
for line in response:
if "Project Search Path" in line:
projects = True
if projects:
if exists(line.strip()):
return line.strip()
def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
def whichzmqversion():
with open("_locate_zmq.c", "w") as outf:
outf.write("#include <zmq.h>\n")
outf.write("#include <stdio.h>\n")
outf.write('int main() { printf("%d.%d.%d",ZMQ_VERSION_MAJOR,ZMQ_VERSION_MINOR,ZMQ_VERSION_PATCH);}')
response = subprocess.Popen(["gcc", "_locate_zmq.c", "-lzmq"],
stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split("\n")
response = subprocess.Popen([join(dirname(__file__),"a.out")],
stdout=subprocess.PIPE).communicate()[0].decode("utf-8")
os.remove("_locate_zmq.c")
os.remove("a.out")
return response
def whichzmq():
ret = "/usr"
with open("_locate_zmq.c", "w") as outf:
outf.write("#include <zmq.h>")
response = subprocess.Popen(["gcc", "-E", "-pipe", "_locate_zmq.c"],
stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split("\n")
os.remove("_locate_zmq.c")
for line in response:
if "/zmq.h" in line:
line = line.split('"')[1]
ret = dirname(dirname(line))
return ret
def parsargs(args):
parser = argparse.ArgumentParser(description='Process some integers.')
fail = False
parser.add_argument('--prefix',
metavar='N',
type=str,
default=dirname(dirname(which("gnatls"))),
help='Install root')
parser.add_argument('--eprefix', metavar='N', type=str,
default=dirname(dirname(which("gnatls"))),
help='system admin root')
parser.add_argument("--bindir", metavar='N', type=str,
help='user executables [EPREFIX/bin]')
parser.add_argument("--sbindir", metavar='N', type=str,
help='system admin executables [EPREFIX/sbin]')
parser.add_argument("--projectdir", metavar='N', type=str,
default=getProjectDir(),
help='Location of gprfiles [%s]' % getProjectDir())
parser.add_argument("--libexecdir", metavar='N', type=str,
help='program executables [EPREFIX/libexec]')
parser.add_argument("--sysconfdir", metavar='N', type=str,
help='read-only single-machine data [PREFIX/etc]')
parser.add_argument("--sharedstatedir", metavar='N', type=str,
help='modifiable architecture-independent data [PREFIX/com]')
parser.add_argument("--localstatedir", metavar='N', type=str,
help='modifiable single-machine data [PREFIX/var]')
parser.add_argument("--libdir", metavar='N', type=str,
help='object code libraries [EPREFIX/lib]')
parser.add_argument("--includedir", metavar='N', type=str,
help='header files [PREFIX/include]')
parser.add_argument("--datarootdir", metavar='N', type=str,
help='read-only arch.-independent data root [PREFIX/share]')
parser.add_argument("--datadir", metavar='N', type=str,
help='read-only architecture-independent data [DATAROOTDIR]')
parser.add_argument("--infodir", metavar='N', type=str,
help='info documentation [DATAROOTDIR/info]')
parser.add_argument("--localedir", metavar='N', type=str,
help='locale-dependent data [DATAROOTDIR/locale]')
parser.add_argument("--mandir", metavar='N', type=str,
help='man documentation [DATAROOTDIR/man]')
parser.add_argument("--docdir", metavar='N', type=str,
help='documentation root [DATAROOTDIR/doc/a-zeromq]')
parser.add_argument("--htmldir", metavar='N', type=str,
help='html documentation [DOCDIR]')
parser.add_argument("--dvidir", metavar='N', type=str,
help='dvi documentation [DOCDIR]')
parser.add_argument("--pdfdir", metavar='N', type=str,
help='pdf documentation [DOCDIR]')
parser.add_argument("--psdir", metavar='N', type=str,
help='ps documentation [DOCDIR]')
parser.add_argument("--withzmq", metavar='N', type=str,
default=whichzmq(), help='location of zmq')
parser.add_argument("--withzmqlib", metavar='N', type=str,
help='location of libzmq.a')
parser.add_argument("--withzmqinclude", metavar='N', type=str,
help='location of zmq.h')
parser.add_argument("--withzmqversion", metavar='N', type=str,
default=whichzmqversion(), help='Version of libzmq')
args = parser.parse_args(args)
if not args.bindir:
args.bindir = join(args.prefix, "bin")
if not args.sbindir:
args.sbindir = join(args.eprefix, "sbin")
if not args.libexecdir:
args.libexecdir = join(args.eprefix, "libexex")
if not args.sysconfdir:
args.sysconfdir = join(args.prefix, "etc")
if not args.libdir:
args.libdir = join(args.prefix, "lib")
if not args.sharedstatedir:
args.sharedstatedir = join(args.prefix, "com")
if not args.localstatedir:
args.localstatedir = join(args.prefix, "var")
if not args.includedir:
args.includedir = join(args.prefix, "include")
if not args.datarootdir:
args.datarootdir = join(args.prefix, "share")
if not args.datadir:
args.datadir = args.datarootdir
if not args.infodir:
args.infodir = join(args.datarootdir, "info")
if not args.localedir:
args.localedir = join(args.datarootdir, "locale")
if not args.mandir:
args.mandir = join(args.datarootdir, "man")
if not args.docdir:
args.docdir = join(args.datarootdir, "doc", project)
if not args.htmldir:
args.htmldir = join(args.docdir, "html")
if not args.dvidir:
args.dvidir = join(args.docdir, "dvi")
if not args.pdfdir:
args.pdfdir = join(args.docdir, "pdf")
if not args.psdir:
args.psdir = join(args.docdir, "ps")
if not args.withzmqlib:
args.withzmqlib = join(args.withzmq, "lib")
if not args.withzmqinclude:
args.withzmqinclude = join(args.withzmq, "include")
if not exists(join(args.withzmqinclude, "zmq.h")):
sys.stderr.write("No zmq.h found\n")
fail = True
# if not exists(join(args.withzmqlib, "libzmq.a")):
# sys.stderr.write("No libzmq found\n")
# fail = True
if fail:
return None
args.__dict__["PATH"] = os.getenv("PATH")
return args
def expand(args):
for root, dirs, files in os.walk("."):
if "libzeromq" not in root:
for f in files:
if splitext(f)[1] == ".in":
src = join(root, f)
tgt = join(root, splitext(f)[0])
with open(src) as inf:
print (src, tgt)
with open(tgt, "w") as outf:
outf.write(inf.read() % args.__dict__)
def main(args):
expand(parsargs(args))
if __name__ == "__main__":
main(sys.argv[1:])