1 if get_option('native-arch-optimization')
2 if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
3 native_header = 'immintrin.h'
4 elif host_machine.cpu_family() == 'arm'
5 native_header = 'arm_neon.h'
6 elif host_machine.cpu_family() == 'aarch64'
7 native_header = 'arm_neon.h'
8 elif host_machine.cpu_family() == 'ppc' or host_machine.cpu_family() == 'ppc64'
9 native_header = 'altivec.h'
12 if cc.has_header(native_header) == false
13 error('Error, header '+native_header+' is required')
16 config_h.set10('HAVE_'+native_header.underscorify().to_upper(), true)
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
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 ['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 ['mallinfo', ['malloc.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 ['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 ['strerror_r', ['string.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 ['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']
124 strerror_r_char_p = cc.compiles('''#define _GNU_SOURCE
128 char error_string[256];
129 char *ptr = strerror_r (-2, error_string, 256);
130 char c = *strerror_r (-2, error_string, 256);
131 return c != 0 && ptr != (void*) 0L;
134 name : 'strerror_r() returns char *')
137 config_h.set('STRERROR_R_CHAR_P', '1')
140 #for later use, a bunch of librarie findings
141 m = cc.find_library('m')
142 #just keep this here as required false, if it is not inplace the library rt will just be linked as NOP
143 dl = cc.find_library('dl', required: false)
144 rt = cc.find_library('rt', required: false)
146 thread_dep = dependency('threads')
148 #check for the headers
149 foreach header : header_checks
150 if cc.has_header(header)
151 config_h.set10('HAVE_'+header.underscorify().to_upper(), true)
155 foreach function : function_checks
156 function_name = function[0]
157 headers_to_search = function[1]
161 # if there is a library, make sure they exist
162 if function.length() > 2
163 foreach library : function[2]
164 lib = cc.find_library(library, required : false)
165 if lib.found() == true
171 #check if there are args
172 if function.length() > 3
176 # Only check the header if the dependencies are ready
177 foreach header : headers_to_search
178 if cc.has_header_symbol(header, function_name,
179 dependencies : dependencies,
181 config_h.set10('HAVE_'+function_name.to_upper(), true)
186 # The next checks are manually for now due to the fact that some names are not within the default pattern
187 if (cc.has_header_symbol('sys/stat.h', 'fstatat'))
188 config_h.set10('HAVE_ATFILE_SOURCE', true)
191 if (cc.has_header('sys/mman.h'))
192 config_h.set10('HAVE_MMAN_H', true)
195 config_h.set('VMAJ', version_major)
196 config_h.set('VMIN', version_minor)
197 config_h.set('VMIC', version_micro)
198 config_h.set('VREV', '0')
200 #jpeg detection ... life is a bit more complex there
202 jpeg = dependency('libjpeg', required: false)
203 if jpeg.found() == false
204 jpeg = cc.find_library('jpeg')
208 config_h.set('HAVE_NOTIFY_KEVENT', '1')
212 config_h.set('HAVE_NOTIFY_COCOA', '1')
214 config_h.set('SIZEOF_INT', cc.sizeof('int'))
215 config_h.set('SIZEOF_LONG', cc.sizeof('long'))
217 if sys_windows == true
218 config_h.set('HAVE_DLSYM', '1')
219 config_h.set('HAVE_NOTIFY_WIN32', '1')