forked from larsimmisch/capisuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConscript-Config
209 lines (174 loc) · 6.36 KB
/
SConscript-Config
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
# -*- python -*-
"""
Check the build environment for CapiSuite
(c) Copyright 2004 by Hartmut Goebel <[email protected]>
"""
Import(['env'])
headerfilename = 'config.h'
havedict = {}
open(headerfilename, 'w') # clear file contents
###--- hack SCons.SConftest ---###
import SCons.Conftest, string
from types import IntType
transmap = string.maketrans(':./ ', '____')
def _Have(context, key, have):
"""
Slightly modified version of SCons.Conftest._Have which uses
global havedict and headerfilename instead of context.*. This is
necessary until SCons support a way to actually use this feature.
In addition this writes '#define ... 1'.
"""
key_up = string.translate(string.upper(key), transmap)
havedict[key_up] = have
if headerfilename:
f = open(headerfilename, "a")
if have == 1:
f.write("#define %s 1\n" % key_up)
elif have == 0:
f.write("/* #undef %s */\n" % key_up)
elif type(have) == IntType:
f.write("#define %s %d\n" % (key_up, have))
else:
f.write('#define %s "%s"\n' % (key_up, str(have)))
f.close()
# need to monkey-patch it into SCons.Conftest :-(
SCons.Conftest._Have = _Have
_Have(None, 'PACKAGE', env['PACKAGE'])
_Have(None, 'VERSION', env['VERSION'])
## these were defined by auto-rools but are unused:
## #define PACKAGE_BUGREPORT ""
## #define PACKAGE_NAME ""
## #define PACKAGE_STRING ""
## #define PACKAGE_TARNAME ""
## #define PACKAGE_VERSION ""
###--- autoconf-like checks ---###
### these tests are build like the corresponding autoconf tests
def CheckHeadersStdC(context):
context.Message("Checking for ANSI C header files ... ")
text = """
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <float.h>
\n"""
# Some tests for SunOS 4.x, ISC 2.0.2 and Irix-4.0.5 skipped here,
# since CapiSuite requires Linux anway.
ret = context.CompileProg(text, '.cpp')
SCons.Conftest._YesNoResult(context, ret, "STDC_HEADERS", text)
context.did_show_result = 1
return ret
def CheckHeaderTime(context):
context.Display("Checking whether time.h and sys/time.h may both be "
"included ... ")
text = """
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
int main() {
if ((struct tm *) 0) return 0;
return 0;
}
\n"""
ret = context.CompileProg(text, '.cpp')
SCons.Conftest._YesNoResult(context, ret, "TIME_WITH_SYS_TIME", text)
context.did_show_result = 1
return ret
###--- custom checks for CapiSuite ---###
def CheckStringClear(context):
context.Display('Checking for string::clear method ... ')
text = """
#include <string>
int main() {
std::string a; a.clear();
}
\n"""
ret = context.CompileProg(text, '.cpp')
SCons.Conftest._YesNoResult(context, ret, "HAVE_STRING_CLEAR", text)
context.did_show_result = 1
return ret
# capisuite special test
def CheckCapiALERT_REQ(context):
context.Display('Checking for new ALERT_REQ signature in capiutils.h ... ')
text = """
#include <capiutils.h>
int main() {
ALERT_REQ (NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL);
}
\n"""
ret = context.CompileProg(text, '.cpp')
SCons.Conftest._YesNoResult(context, ret, "HAVE_NEW_CAPI4LINUX", text)
context.did_show_result = 1
return ret
conf = Configure(env,
custom_tests = {'CheckHeadersStdC': CheckHeadersStdC,
'CheckHeaderTime': CheckHeaderTime,
'CheckStringClear': CheckStringClear,
'CheckCapiALERT_REQ': CheckCapiALERT_REQ,
},
conf_dir = '.sconf_temp', # no '#' to build in build-dir
log_file = 'config.log' # no '#' to build in build-dir
)
conf.CheckHeadersStdC()
missing = 0
for h in Split("sys/types.h sys/stat.h stdlib.h string.h "
"memory.h strings.h inttypes.h stdint.h unistd.h"):
missing += not conf.CheckHeader(h, language='C++')
if missing:
print 'Required headers missing - aborting.'
Exit(5)
conf.CheckFunc('gettimeofday', language='C++')
conf.CheckHeader('sys/time.h', language='C++')
conf.CheckHeaderTime()
###--- CapiSuite specials ---###
# CS_TEST_GCC3
# new gcc3 feature: we can #include<ostream> instead of ostream.h
conf.CheckHeader('ostream', language='C++')
conf.CheckStringClear() # checking for string::clear method
conf.CheckCapiALERT_REQ() # CS_TEST_CAPI4LINUX
# CS_TEST_SFFTOBMP is implemented in SConstruct.Get_sfftobmp_Version
# CS_SET_DOCDIR is implemented in SConscript-Options
###--- libs required by CapiSuite ---###
# checking for capi20_register in -lcapi20... yes
if not conf.CheckLib('capi20', 'capi20_register', language='C++'):
print 'libcapi20 not found - aborting'
Exit(5)
# checking for pthread_create in -lpthread... yes
if not conf.CheckLib('pthread', 'pthread_create', language='C++'):
print 'libpthread not found - aborting'
Exit(5)
# todo
# Which(doxygen)
# Which(pychecker)
conf.Finish()
"""
These are the checks 'configure' does
Legende:
- not neccessary
+ Scons build-in
? unsure
~ implemented in SConscript/SConstruct
-checking for a BSD-compatible install... /usr//bin/install -c
-checking whether build environment is sane... yes
-checking for gawk... gawk
-checking whether make sets $(MAKE)... yes
+checking for gcc... gcc
+checking for C compiler default output... a.out
+checking whether the C compiler works... yes
?checking whether we are cross compiling... no
+checking for suffix of executables...
+checking for suffix of object files... o
?checking whether we are using the GNU C compiler... yes
?checking whether gcc accepts -g... yes
?checking for gcc option to accept ANSI C... none needed
-checking for style of include used by make... GNU
-checking dependency style of gcc... gcc3
+checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
-checking dependency style of g++... gcc3
-checking for a BSD-compatible install... /usr//bin/install -c
+checking for ranlib... ranlib
-checking whether make sets $(MAKE)... (cached) yes
+checking how to run the C++ preprocessor... g++ -E
-checking for egrep... grep -E
"""