-
Notifications
You must be signed in to change notification settings - Fork 31
/
configure
executable file
·188 lines (156 loc) · 5.65 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
#!/usr/bin/python3
import subprocess
import os
import sys
import time;
from optparse import OptionParser
from scripts import version
from scripts import configfile
import re
from scripts.run import run
TARGETS = ['libbirdfont',
'libbirdgems',
'birdfont',
'birdfont-autotrace',
'birdfont-export',
'birdfont-import',
'birdfont-test']
VERSION = version.VERSION
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
gee = '';
def test_program_version (program, a, b, c):
print ('Checking for %s version >= %s.%s.%s' % (program, a, b, c))
process = subprocess.Popen (program + ' --version', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
v = process.stdout.readline().decode('utf-8')
process.communicate()[0]
if not process.returncode == 0:
print (FAIL + 'Not found' + ENDC)
exit (1)
print ('Found ' + v)
o = v.split (' ');
for s in o:
if re.search( r'[0-9]*\.', s):
v = s
break
v = re.sub(r'[a-zA-Z\-].*', '0', v)
version = [int(n) for n in v.split ('.')]
return [a,b,c] <= version
def test_library_version(pkg_config, lib, required=True, version=None):
print ('Looking for library: ' + lib + '\t\t')
process = subprocess.Popen(pkg_config + ' --modversion ' + lib, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
v = process.stdout.readline().decode('utf-8')
process.communicate()[0]
return process.returncode == 0
def has_posixvala ():
posixvala = test_library_version ('posixvala')
if not posixvala:
print (OKGREEN + 'Glib will be used instead of Posix (libc).' + ENDC)
return 'False'
else:
print (OKGREEN + 'Using posix profile.' + ENDC)
return 'True'
def configure(libbgee, valac, pkg_config):
global gee
if not test_program_version(valac, 0, 16, 0):
print (FAIL + 'valac is too old.' + ENDC)
exit (1)
libs = [
'cairo',
'gdk-pixbuf-2.0',
'gio-2.0',
'glib-2.0',
'gtk+-3.0',
'webkit2gtk-4.1',
'libsoup-2.4',
'libnotify',
'sqlite3',
'xmlbird'
]
test_library_version(pkg_config, 'xmlbird', True, '1.2.0')
for lib in libs:
test_library_version(pkg_config, lib)
if libbgee == 'Any':
if test_library_version(pkg_config, 'gee-0.8', False):
gee = 'gee-0.8'
elif test_library_version(pkg_config, 'gee-1.0', False):
gee = 'gee-1.0'
else:
print (FAIL + 'Can not find libgee (version 0.8 or version 1.0).' + ENDC)
exit (1)
else:
if not test_library_version(pkg_config, libbgee):
print (FAIL + 'Can not find lib gee.' + ENDC)
exit (1)
gee = libbgee;
run ('mkdir -p build')
run ('touch build/configured')
print ('');
print (OKGREEN + 'Done' + ENDC);
parser = OptionParser()
parser.add_option('-p', '--prefix', dest='prefix', help='Install prefix', metavar='PREFIX')
parser.add_option('-d', '--dest', dest='dest', help='Install to this directory', metavar='DEST')
parser.add_option('-c', '--cc', dest='cc', help='C compiler', metavar='CC')
parser.add_option('-e', '--gee', dest='gee', help='Version of libgee', metavar='GEE')
parser.add_option('-v', '--valac', dest='valac', help='Vala compiler', metavar='VALAC')
parser.add_option('-P', '--pkg-config', dest='pkg_config', help='Package config tool', metavar='PKG_CONFIG')
parser.add_option('-n', '--nonnull', dest='nonnull', action="store_true", help='Enable compiletime checks for null pointers', metavar='NONNULL')
parser.add_option('', '--valac-flags', dest='valac_flags', help='Vala compiler flags for all targets', metavar='VALAC_FLAGS', default='')
for target in TARGETS:
parser.add_option('', '--valac-flags-' + target, dest='valac_flags_' + target, help='Vala compiler flags for ' + target, metavar='VALAC_FLAGS', default='')
parser.add_option('', '--cflags', dest='cflags', help='C compiler flags for all targets', metavar='CFLAGS', default='')
for target in TARGETS:
parser.add_option('', '--cflags-' + target, dest='cflags_' + target, help='C compiler flags for ' + target, metavar='CFLAGS', default='')
parser.add_option('', '--ldflags', dest='ldflags', help='Linker flags for all targets', metavar='LDFLAGS', default='')
for target in TARGETS:
parser.add_option('', '--ldflags-' + target, dest='ldflags_' + target, help='Linker flags for ' + target, metavar='LDFLAGS', default='')
(options, args) = parser.parse_args()
option_dict = vars(options)
valacflags = dict()
cflags = dict()
ldflags = dict()
for target in TARGETS:
cflags[target] = options.cflags
cflags[target] = cflags[target] + ' ' + option_dict.get('cflags_' + target, "")
cflags[target] = cflags[target].strip()
ldflags[target] = options.ldflags
ldflags[target] = ldflags[target] + ' ' + option_dict.get('ldflags_' + target, "")
ldflags[target] = ldflags[target].strip()
valacflags[target] = options.valac_flags
valacflags[target] = valacflags[target] + ' ' + option_dict.get('valac_flags_' + target, "")
valacflags[target] = valacflags[target].strip()
if not options.prefix:
if 'bsd' in sys.platform:
options.prefix = '${DESTDIR}${PREFIX}'
else:
options.prefix = '/usr'
if not options.dest:
options.dest = ''
if not options.cc:
options.cc = 'gcc'
if not options.gee:
options.gee = 'Any'
if not options.valac:
options.valac = 'valac'
if not options.pkg_config:
options.pkg_config = 'pkg-config'
if not options.nonnull:
options.nonnull = False
else:
options.nonnull = True
configure(options.gee, options.valac, options.pkg_config)
configfile.write_config(options.prefix)
configfile.write_compile_parameters(options.prefix,
options.dest,
options.cc,
gee,
options.valac,
options.pkg_config,
options.nonnull,
valacflags,
cflags,
ldflags)