efl

Форк
0
/
meson.build 
255 строк · 8.0 Кб
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
  '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

73
function_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

126
open_cloexec = cc.compiles('''#include <sys/types.h>
127
                              #include <sys/stat.h>
128
                              #include <fcntl.h>
129
                              int main(int argc, char **argv) {
130
                                int res = open(argv[0], O_RDONLY | O_CLOEXEC);
131
                                if (res < 0) return 1;
132
                                return 0;
133
                              }
134
                           ''',
135
                           name : 'open works with O_CLOEXEC')
136
if open_cloexec
137
  config_h.set10('HAVE_OPEN_CLOEXEC', true)
138
endif
139

140
strerror_r_char_p = cc.compiles('''#define _GNU_SOURCE
141
                  #include <string.h>
142
                  int func (void)
143
                    {
144
                       char error_string[256];
145
                       char *ptr = strerror_r (-2, error_string, 256);
146
                       char c = *strerror_r (-2, error_string, 256);
147
                       return c != 0 && ptr != (void*) 0L;
148
                    }
149
                 ''',
150
                 name : 'strerror_r() returns char *')
151

152
if strerror_r_char_p
153
  config_h.set('STRERROR_R_CHAR_P', '1')
154
endif
155

156
#for later use, a bunch of librarie findings
157
m = 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
159
dl = cc.find_library('dl', required: false)
160
rt = cc.find_library('rt', required: false)
161

162
if sys_sun == true
163
  malloc = cc.find_library('malloc', required: true)
164
  socket = cc.find_library('socket', required: true)
165
endif
166

167
thread_dep = dependency('threads')
168

169
#check for the headers
170
foreach header : header_checks
171
  if cc.has_header(header)
172
    config_h.set10('HAVE_'+header.underscorify().to_upper(), true)
173
  endif
174
endforeach
175

176
foreach function : function_checks
177
  function_name = function[0]
178
  headers_to_search = function[1]
179
  dependencies = []
180
  args = []
181

182
  # if there is a library, make sure they exist
183
  if function.length() > 2
184
    foreach library : function[2]
185
      lib = cc.find_library(library, required : false)
186
      if lib.found() == true
187
        dependencies += lib
188
      endif
189
    endforeach
190
  endif
191

192
  #check if there are args
193
  if function.length() > 3
194
    args = function[3]
195
  endif
196

197
  # Only check the header if the dependencies are ready
198
  foreach header : headers_to_search
199
    if cc.has_header_symbol(header, function_name,
200
        dependencies : dependencies,
201
        args : args)
202
      config_h.set10('HAVE_'+function_name.to_upper(), true)
203
    endif
204
  endforeach
205
endforeach
206

207
# The next checks are manually for now due to the fact that some names are not within the default pattern
208
if (cc.has_header_symbol('sys/stat.h', 'fstatat'))
209
  config_h.set10('HAVE_ATFILE_SOURCE', true)
210
endif
211

212
if sys_linux and config_h.has('HAVE_LISTXATTR') and config_h.has('HAVE_SETXATTR') and config_h.has('HAVE_GETXATTR')
213
  config_h.set10('HAVE_XATTR', true)
214
endif
215

216
regexp = []
217
if sys_windows == true
218
   regexp = cc.find_library('regex',
219
                            has_headers: ['regex.h'],
220
                            required: true)
221
   if regexp.found() == false
222
      error('regex can not be found')
223
   endif
224
else
225
   if cc.has_header_symbol('regex.h', 'regcomp') == false
226
      error('regcomp can not be found')
227
   endif
228
endif
229

230
config_h.set('VMAJ', version_major)
231
config_h.set('VMIN', version_minor)
232
config_h.set('VMIC', version_micro)
233
config_h.set('VREV', '0')
234

235
#jpeg detection ... life is a bit more complex there
236

237
jpeg = dependency('libjpeg', required: false)
238
if jpeg.found() == false
239
  jpeg = cc.find_library('jpeg')
240
endif
241

242
if sys_bsd == true
243
  config_h.set('HAVE_NOTIFY_KEVENT', '1')
244
endif
245

246
if sys_osx == true
247
  config_h.set('HAVE_NOTIFY_COCOA', '1')
248
endif
249
config_h.set('SIZEOF_INT', cc.sizeof('int'))
250
config_h.set('SIZEOF_LONG', cc.sizeof('long'))
251

252
if sys_windows == true
253
  config_h.set('HAVE_NOTIFY_WIN32', '1')
254
  config_h.set10('HAVE_DDRAW_H', true)
255
endif
256

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.