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