efl
255 строк · 8.0 Кб
1if get_option('native-arch-optimization')
2check_native_header = true
3if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
4native_header = 'immintrin.h'
5elif host_machine.cpu_family() == 'arm'
6native_header = 'arm_neon.h'
7elif host_machine.cpu_family() == 'aarch64'
8native_header = 'arm_neon.h'
9elif host_machine.cpu_family() == 'ppc' or host_machine.cpu_family() == 'ppc64'
10native_header = 'altivec.h'
11else
12check_native_header = false
13endif
14
15if check_native_header
16if cc.has_header(native_header) == false
17error('Error, header '+native_header+' is required')
18endif
19
20config_h.set10('HAVE_'+native_header.underscorify().to_upper(), true)
21endif
22endif
23
24header_checks = [
25'alloca.h',
26'asm/hwcap.h',
27'bsd/string.h',
28'dirent.h',
29'execinfo.h',
30'mcheck.h',
31'netinet/in.h',
32'netinet/ssl.h',
33'netinet/tcp.h',
34'netinet/udp.h',
35'net/if.h',
36'stdlib.h',
37'sys/auxv.h',
38'sys/inotify.h',
39'sys/ioctl.h',
40'sys/mman.h',
41'sys/types.h',
42'sys/socket.h',
43'sys/filio.h',
44'arpa/inet.h',
45'sys/epoll.h',
46'sys/un.h',
47'sys/wait.h',
48'sys/resource.h',
49'sys/times.h',
50'longinfo.h',
51'ieeefp.h',
52'sys/timerfd.h',
53'features.h',
54'langinfo.h',
55'locale.h',
56'crt_externs.h',
57'pthread.h',
58]
59
60#### The below is logically broken
61#### the declaration of symbol + headers when you look the symbols up
62#### in man pages you'll find that, for example, kevent needs you to
63#### include ALL of the headers listed below. same for setxattr,
64#### listxattr, pthread_getcpuclockid ... i stopped looking at this
65#### point because it seems this is the pattern, but the foreach below
66#### does not do this. it includes one header at a time from the list
67#### then checks to see if the symbol exists. this leads to failures
68#### in the checks (specifically i noticed kevent on bsd). so the whole
69#### construct for this is wrong. it needs a rethink. i'm putting this
70#### comment here as a note that this is the case for now as i'm just
71#### trying to fix the meson build on freebsd for now
72
73function_checks = [
74# function name | headers that are needed | libraries to include | Defines that are needed
75['alloca', ['alloca.h']],
76['backtrace', ['execinfo.h']],
77['backtrace_symbols', ['execinfo.h']],
78['chown', ['unistd.h']],
79['clock_gettime', ['time.h']],
80['dirfd', ['dirent.h sys/types.h']],
81['fchmod', ['sys/stat.h']],
82['fcntl', ['fcntl.h']],
83['fork', ['unistd.h']],
84['fpathconf', ['unistd.h']],
85['geteuid', ['unistd.h']],
86['getpagesize', ['unistd.h']],
87['getpwent', ['sys/types.h', 'pwd.h']],
88['getuid', ['unistd.h']],
89['getxattr', ['sys/types.h', 'sys/xattr.h']],
90['iconv', ['iconv.h']],
91['listxattr', ['sys/types.h', 'sys/xattr.h']],
92['malloc_info', ['malloc.h']],
93['malloc_usable_size', ['malloc.h']],
94['mkdirat', ['sys/stat.h']],
95['mmap', ['sys/mman.h']],
96['mtrace', ['mcheck.h']],
97['prctl', ['sys/prctl.h']],
98['procctl', ['sys/procctl.h']],
99['realpath', ['stdlib.h']],
100['setxattr', ['sys/types.h', 'sys/xattr.h']],
101['siglongjmp', ['setjmp.h']],
102['strerror_r', ['string.h']],
103['gettimeofday', ['sys/time.h']],
104['execvp', ['unistd.h']],
105['pause', ['unistd.h']],
106['isfinite', ['math.h']],
107#FIXME strlcpy is detected by meson but drops at compilation time
108# ['strlcpy', ['string.h']],
109['siginfo_t', ['signal.h']],
110['pthread_getcpuclockid', ['pthread.h', 'time.h']],
111['timerfd_create', ['sys/timerfd.h']],
112['kevent', ['sys/types.h', 'sys/event.h', 'sys/time.h']],
113#from here on we specify the dependencies
114['dlopen', ['dlfcn.h'], ['dl']],
115['dlsym', ['dlfcn.h'], ['dl']],
116['lround', ['math.h'], ['m']],
117['mallinfo2', ['malloc.h'], ['malloc']],
118['mallinfo', ['malloc.h'], ['malloc']],
119['shm_open', ['sys/mman.h', 'sys/stat.h', 'fcntl.h'], ['rt']],
120#from here on we specify arguments
121['splice', ['fcntl.h'], [], '-D_GNU_SOURCE=1'],
122['sched_getcpu', ['sched.h'], [], '-D_GNU_SOURCE=1'],
123['dladdr', ['dlfcn.h'], ['dl'], '-D_GNU_SOURCE=1']
124]
125
126open_cloexec = cc.compiles('''#include <sys/types.h>
127#include <sys/stat.h>
128#include <fcntl.h>
129int main(int argc, char **argv) {
130int res = open(argv[0], O_RDONLY | O_CLOEXEC);
131if (res < 0) return 1;
132return 0;
133}
134''',
135name : 'open works with O_CLOEXEC')
136if open_cloexec
137config_h.set10('HAVE_OPEN_CLOEXEC', true)
138endif
139
140strerror_r_char_p = cc.compiles('''#define _GNU_SOURCE
141#include <string.h>
142int func (void)
143{
144char error_string[256];
145char *ptr = strerror_r (-2, error_string, 256);
146char c = *strerror_r (-2, error_string, 256);
147return c != 0 && ptr != (void*) 0L;
148}
149''',
150name : 'strerror_r() returns char *')
151
152if strerror_r_char_p
153config_h.set('STRERROR_R_CHAR_P', '1')
154endif
155
156#for later use, a bunch of librarie findings
157m = cc.find_library('m')
158#just keep this here as required false, if it is not inplace the library rt will just be linked as NOP
159dl = cc.find_library('dl', required: false)
160rt = cc.find_library('rt', required: false)
161
162if sys_sun == true
163malloc = cc.find_library('malloc', required: true)
164socket = cc.find_library('socket', required: true)
165endif
166
167thread_dep = dependency('threads')
168
169#check for the headers
170foreach header : header_checks
171if cc.has_header(header)
172config_h.set10('HAVE_'+header.underscorify().to_upper(), true)
173endif
174endforeach
175
176foreach function : function_checks
177function_name = function[0]
178headers_to_search = function[1]
179dependencies = []
180args = []
181
182# if there is a library, make sure they exist
183if function.length() > 2
184foreach library : function[2]
185lib = cc.find_library(library, required : false)
186if lib.found() == true
187dependencies += lib
188endif
189endforeach
190endif
191
192#check if there are args
193if function.length() > 3
194args = function[3]
195endif
196
197# Only check the header if the dependencies are ready
198foreach header : headers_to_search
199if cc.has_header_symbol(header, function_name,
200dependencies : dependencies,
201args : args)
202config_h.set10('HAVE_'+function_name.to_upper(), true)
203endif
204endforeach
205endforeach
206
207# The next checks are manually for now due to the fact that some names are not within the default pattern
208if (cc.has_header_symbol('sys/stat.h', 'fstatat'))
209config_h.set10('HAVE_ATFILE_SOURCE', true)
210endif
211
212if sys_linux and config_h.has('HAVE_LISTXATTR') and config_h.has('HAVE_SETXATTR') and config_h.has('HAVE_GETXATTR')
213config_h.set10('HAVE_XATTR', true)
214endif
215
216regexp = []
217if sys_windows == true
218regexp = cc.find_library('regex',
219has_headers: ['regex.h'],
220required: true)
221if regexp.found() == false
222error('regex can not be found')
223endif
224else
225if cc.has_header_symbol('regex.h', 'regcomp') == false
226error('regcomp can not be found')
227endif
228endif
229
230config_h.set('VMAJ', version_major)
231config_h.set('VMIN', version_minor)
232config_h.set('VMIC', version_micro)
233config_h.set('VREV', '0')
234
235#jpeg detection ... life is a bit more complex there
236
237jpeg = dependency('libjpeg', required: false)
238if jpeg.found() == false
239jpeg = cc.find_library('jpeg')
240endif
241
242if sys_bsd == true
243config_h.set('HAVE_NOTIFY_KEVENT', '1')
244endif
245
246if sys_osx == true
247config_h.set('HAVE_NOTIFY_COCOA', '1')
248endif
249config_h.set('SIZEOF_INT', cc.sizeof('int'))
250config_h.set('SIZEOF_LONG', cc.sizeof('long'))
251
252if sys_windows == true
253config_h.set('HAVE_NOTIFY_WIN32', '1')
254config_h.set10('HAVE_DDRAW_H', true)
255endif
256