ac_converter.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. #!/usr/bin/env python3
  2. # Copyright 2015 The Meson development team
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. help_message = """Usage: %s <config.h.meson>
  13. This script reads config.h.meson, looks for header
  14. checks and writes the corresponding meson declaration.
  15. Copy config.h.in to config.h.meson, replace #undef
  16. with #mesondefine and run this. We can't do this automatically
  17. because some configure scripts have #undef statements
  18. that are unrelated to configure checks.
  19. """
  20. import sys
  21. # Add stuff here as it is encountered.
  22. function_data = \
  23. {'HAVE_FEENABLEEXCEPT': ('feenableexcept', 'fenv.h'),
  24. 'HAVE_FECLEAREXCEPT': ('feclearexcept', 'fenv.h'),
  25. 'HAVE_FEDISABLEEXCEPT': ('fedisableexcept', 'fenv.h'),
  26. 'HAVE_MMAP': ('mmap', 'sys/mman.h'),
  27. 'HAVE_GETPAGESIZE': ('getpagesize', 'unistd.h'),
  28. 'HAVE_GETISAX': ('getisax', 'sys/auxv.h'),
  29. 'HAVE_GETTIMEOFDAY': ('gettimeofday', 'sys/time.h'),
  30. 'HAVE_MPROTECT': ('mprotect', 'sys/mman.h'),
  31. 'HAVE_POSIX_MEMALIGN': ('posix_memalign', 'stdlib.h'),
  32. 'HAVE_SIGACTION': ('sigaction', 'signal.h'),
  33. 'HAVE_ALARM': ('alarm', 'unistd.h'),
  34. 'HAVE_CTIME_R': ('ctime_r', 'time.h'),
  35. 'HAVE_DRAND48': ('drand48', 'stdlib.h'),
  36. 'HAVE_FLOCKFILE': ('flockfile', 'stdio.h'),
  37. 'HAVE_FORK': ('fork', 'unistd.h'),
  38. 'HAVE_FUNLOCKFILE': ('funlockfile', 'stdio.h'),
  39. 'HAVE_GETLINE': ('getline', 'stdio.h'),
  40. 'HAVE_LINK': ('link', 'unistd.h'),
  41. 'HAVE_RAISE': ('raise', 'signal.h'),
  42. 'HAVE_STRNDUP': ('strndup', 'string.h'),
  43. 'HAVE_SCHED_GETAFFINITY': ('sched_getaffinity', 'sched.h'),
  44. 'HAVE_WAITPID': ('waitpid', 'sys/wait.h'),
  45. 'HAVE_XRENDERCREATECONICALGRADIENT': ('XRenderCreateConicalGradient', 'xcb/render.h'),
  46. 'HAVE_XRENDERCREATELINEARGRADIENT': ('XRenderCreateLinearGradient', 'xcb/render.h'),
  47. 'HAVE_XRENDERCREATERADIALGRADIENT': ('XRenderCreateRadialGradient', 'xcb/render.h'),
  48. 'HAVE_XRENDERCREATESOLIDFILL': ('XRenderCreateSolidFill', 'xcb/render.h'),
  49. 'HAVE_DCGETTEXT': ('dcgettext', 'libintl.h'),
  50. 'HAVE_ENDMNTENT': ('endmntent', 'mntent.h'),
  51. 'HAVE_ENDSERVENT': ('endservent', 'netdb.h'),
  52. 'HAVE_EVENTFD': ('eventfd', 'sys/eventfd.h'),
  53. 'HAVE_FALLOCATE': ('fallocate', 'fcntl.h'),
  54. 'HAVE_FCHMOD': ('fchmod', 'sys/stat.h'),
  55. 'HAVE_FCHOWN': ('fchown', 'unistd.h'),
  56. 'HAVE_FDWALK': ('fdwalk', 'stdlib.h'),
  57. 'HAVE_FSYNC': ('fsync', 'unistd.h'),
  58. 'HAVE_GETC_UNLOCKED': ('getc_unlocked', 'stdio.h'),
  59. 'HAVE_GETFSSTAT': ('getfsstat', 'sys/mount.h'),
  60. 'HAVE_GETMNTENT_R': ('getmntent_r', 'mntent.h'),
  61. 'HAVE_GETPROTOBYNAME_R': ('getprotobyname_r', 'netdb.h'),
  62. 'HAVE_GETRESUID': ('getresuid', 'unistd.h'),
  63. 'HAVE_GETVFSSTAT': ('getvfsstat', 'sys/statvfs.h'),
  64. 'HAVE_GMTIME_R': ('gmtime_r', 'time.h'),
  65. 'HAVE_HASMNTOPT': ('hasmntopt', 'mntent.h'),
  66. 'HAVE_IF_INDEXTONAME': ('if_indextoname', 'net/if.h'),
  67. 'HAVE_IF_NAMETOINDEX': ('if_nametoindex', 'net/if.h'),
  68. 'HAVE_INOTIFY_INIT1': ('inotify_init1', 'sys/inotify.h'),
  69. 'HAVE_ISSETUGID': ('issetugid', 'unistd.h'),
  70. 'HAVE_KEVENT': ('kevent', 'sys/event.h'),
  71. 'HAVE_KQUEUE': ('kqueue', 'sys/event.h'),
  72. 'HAVE_LCHMOD': ('lchmod', 'sys/stat.h'),
  73. 'HAVE_LCHOWN': ('lchown', 'unistd.h'),
  74. 'HAVE_LSTAT': ('lstat', 'sys/stat.h'),
  75. 'HAVE_MEMCPY': ('memcpy', 'string.h'),
  76. 'HAVE_MEMALIGN': ('memalign', 'stdlib.h'),
  77. 'HAVE_MEMMEM': ('memmem', 'string.h'),
  78. 'HAVE_NEWLOCALE': ('newlocale', 'locale.h'),
  79. 'HAVE_PIPE2': ('pipe2', 'fcntl.h'),
  80. 'HAVE_POLL': ('poll', 'poll.h'),
  81. 'HAVE_PRLIMIT': ('prlimit', 'sys/resource.h'),
  82. 'HAVE_PTHREAD_ATTR_SETSTACKSIZE': ('pthread_attr_setstacksize', 'pthread.h'),
  83. 'HAVE_PTHREAD_CONDATTR_SETCLOCK': ('pthread_condattr_setclock', 'pthread.h'),
  84. 'HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP': ('pthread_cond_timedwait_relative_np', 'pthread.h'),
  85. 'HAVE_READLINK': ('readlink', 'unistd.h'),
  86. 'HAVE_RES_INIT': ('res_init', 'resolv.h'),
  87. 'HAVE_SENDMMSG': ('sendmmsg', 'sys/socket.h'),
  88. 'HAVE_SOCKET': ('socket', 'sys/socket.h'),
  89. 'HAVE_GETENV': ('getenv', 'stdlib.h'),
  90. 'HAVE_SETENV': ('setenv', 'stdlib.h'),
  91. 'HAVE_PUTENV': ('putenv', 'stdlib.h'),
  92. 'HAVE_UNSETENV': ('unsetenv', 'stdlib.h'),
  93. 'HAVE_SETMNTENT': ('setmntent', 'mntent.h'),
  94. 'HAVE_SNPRINTF': ('snprintf', 'stdio.h'),
  95. 'HAVE_SPLICE': ('splice', 'fcntl.h'),
  96. 'HAVE_STATFS': ('statfs', 'mount.h'),
  97. 'HAVE_STATVFS': ('statvfs', 'sys/statvfs.h'),
  98. 'HAVE_STPCOPY': ('stpcopy', 'string.h'),
  99. 'HAVE_STRCASECMP': ('strcasecmp', 'strings.h'),
  100. 'HAVE_STRLCPY': ('strlcpy', 'string.h'),
  101. 'HAVE_STRNCASECMP': ('strncasecmp', 'strings.h'),
  102. 'HAVE_STRSIGNAL': ('strsignal', 'signal.h'),
  103. 'HAVE_STRTOD_L': ('strtod_l', 'stdlib.h'),
  104. 'HAVE_STRTOLL_L': ('strtoll_l', 'stdlib.h'),
  105. 'HAVE_STRTOULL_L': ('strtoull_l', 'stdlib.h'),
  106. 'HAVE_SYMLINK': ('symlink', 'unistd.h'),
  107. 'HAVE_SYSCTLBYNAME': ('sysctlbyname', 'sys/sysctl.h'),
  108. 'HAVE_TIMEGM': ('timegm', 'time.h'),
  109. 'HAVE_USELOCALE': ('uselocale', 'xlocale.h'),
  110. 'HAVE_UTIMES': ('utimes', 'sys/time.h'),
  111. 'HAVE_VALLOC': ('valloc', 'stdlib.h'),
  112. 'HAVE_VASPRINTF': ('vasprintf', 'stdio.h'),
  113. 'HAVE_VSNPRINTF': ('vsnprintf', 'stdio.h'),
  114. 'HAVE_BCOPY': ('bcopy', 'strings.h'),
  115. 'HAVE_STRERROR': ('strerror', 'string.h'),
  116. 'HAVE_MEMMOVE': ('memmove', 'string.h'),
  117. 'HAVE_STRTOIMAX': ('strtoimax', 'inttypes.h'),
  118. 'HAVE_STRTOLL': ('strtoll', 'stdlib.h'),
  119. 'HAVE_STRTOQ': ('strtoq', 'stdlib.h'),
  120. 'HAVE_ACCEPT4': ('accept4', 'sys/socket.h'),
  121. 'HAVE_CHMOD': ('chmod', 'sys/stat.h'),
  122. 'HAVE_CHOWN': ('chown', 'unistd.h'),
  123. 'HAVE_FSTAT': ('fstat', 'sys/stat.h'),
  124. 'HAVE_GETADDRINFO': ('getaddrinfo', 'netdb.h'),
  125. 'HAVE_GETGRGID_R': ('getgrgid_r', 'grp.h'),
  126. 'HAVE_GETGRNAM_R': ('getgrnam_r', 'grp.h'),
  127. 'HAVE_GETGROUPS': ('getgroups', 'grp.h'),
  128. 'HAVE_GETOPT_LONG': ('getopt_long', 'getopt.h'),
  129. 'HAVE_GETPWNAM_R': ('getpwnam', 'pwd.h'),
  130. 'HAVE_GETPWUID_R': ('getpwuid_r', 'pwd.h'),
  131. 'HAVE_GETUID': ('getuid', 'unistd.h'),
  132. 'HAVE_LRINTF': ('lrintf', 'math.h'),
  133. 'HAVE_DECL_ISNAN': ('isnan', 'math.h'),
  134. 'HAVE_DECL_ISINF': ('isinf', 'math.h'),
  135. 'HAVE_ROUND': ('round', 'math.h'),
  136. 'HAVE_NEARBYINT': ('nearbyint', 'math.h'),
  137. 'HAVE_RINT': ('rint', 'math.h'),
  138. 'HAVE_MKFIFO': ('mkfifo', 'sys/stat.h'),
  139. 'HAVE_MLOCK': ('mlock', 'sys/mman.h'),
  140. 'HAVE_NANOSLEEP': ('nanosleep', 'time.h'),
  141. 'HAVE_PIPE': ('pipe', 'unistd.h'),
  142. 'HAVE_PPOLL': ('ppoll', 'poll.h'),
  143. 'HAVE_REGEXEC': ('regexec', 'regex.h'),
  144. 'HAVE_SETEGID': ('setegid', 'unistd.h'),
  145. 'HAVE_SETEUID': ('seteuid', 'unistd.h'),
  146. 'HAVE_SETPGID': ('setpgid', 'unistd.h'),
  147. 'HAVE_SETREGID': ('setregid', 'unistd.h'),
  148. 'HAVE_SETRESGID': ('setresgid', 'unistd.h'),
  149. 'HAVE_SETRESUID': ('setresuid', 'unistd.h'),
  150. 'HAVE_SHM_OPEN': ('shm_open', 'fcntl.h'),
  151. 'HAVE_SLEEP': ('sleep', 'unistd.h'),
  152. 'HAVE_STRERROR_R': ('strerror_r', 'string.h'),
  153. 'HAVE_STRTOF': ('strtof', 'stdlib.h'),
  154. 'HAVE_SYSCONF': ('sysconf', 'unistd.h'),
  155. 'HAVE_USLEEP': ('usleep', 'unistd.h'),
  156. 'HAVE_VFORK': ('vfork', 'unistd.h'),
  157. 'HAVE_MALLOC': ('malloc', 'stdlib.h'),
  158. 'HAVE_CALLOC': ('calloc', 'stdlib.h'),
  159. 'HAVE_REALLOC': ('realloc', 'stdlib.h'),
  160. 'HAVE_FREE': ('free', 'stdlib.h'),
  161. 'HAVE_ALLOCA': ('alloca', 'alloca.h'),
  162. 'HAVE_QSORT': ('qsort', 'stdlib.h'),
  163. 'HAVE_ABS': ('abs', 'stdlib.h'),
  164. 'HAVE_MEMSET': ('memset', 'string.h'),
  165. 'HAVE_MEMCMP': ('memcmp', 'string.h'),
  166. 'HAVE_STRLEN': ('strlen', 'string.h'),
  167. 'HAVE_STRLCAT': ('strlcat', 'string.h'),
  168. 'HAVE_STRDUP': ('strdup', 'string.h'),
  169. 'HAVE__STRREV': ('_strrev', 'string.h'),
  170. 'HAVE__STRUPR': ('_strupr', 'string.h'),
  171. 'HAVE__STRLWR': ('_strlwr', 'string.h'),
  172. 'HAVE_INDEX': ('index', 'strings.h'),
  173. 'HAVE_RINDEX': ('rindex', 'strings.h'),
  174. 'HAVE_STRCHR': ('strchr', 'string.h'),
  175. 'HAVE_STRRCHR': ('strrchr', 'string.h'),
  176. 'HAVE_STRSTR': ('strstr', 'string.h'),
  177. 'HAVE_STRTOL': ('strtol', 'stdlib.h'),
  178. 'HAVE_STRTOUL': ('strtoul', 'stdlib.h'),
  179. 'HAVE_STRTOULL': ('strtoull', 'stdlib.h'),
  180. 'HAVE_STRTOD': ('strtod', 'stdlib.h'),
  181. 'HAVE_ATOI': ('atoi', 'stdlib.h'),
  182. 'HAVE_ATOF': ('atof', 'stdlib.h'),
  183. 'HAVE_STRCMP': ('strcmp', 'string.h'),
  184. 'HAVE_STRNCMP': ('strncmp', 'string.h'),
  185. 'HAVE_VSSCANF': ('vsscanf', 'stdio.h'),
  186. 'HAVE_CHROOT': ('chroot', 'unistd.h'),
  187. 'HAVE_CLOCK': ('clock', 'time.h'),
  188. 'HAVE_CLOCK_GETRES': ('clock_getres', 'time.h'),
  189. 'HAVE_CLOCK_GETTIME': ('clock_gettime', 'time.h'),
  190. 'HAVE_CLOCK_SETTIME': ('clock_settime', 'time.h'),
  191. 'HAVE_CONFSTR': ('confstr', 'time.h'),
  192. 'HAVE_CTERMID': ('ctermid', 'stdio.h'),
  193. 'HAVE_DIRFD': ('dirfd', 'dirent.h'),
  194. 'HAVE_DLOPEN': ('dlopen', 'dlfcn.h'),
  195. 'HAVE_DUP2': ('dup2', 'unistd.h'),
  196. 'HAVE_DUP3': ('dup3', 'unistd.h'),
  197. 'HAVE_EPOLL_CREATE1': ('epoll_create1', 'sys/epoll.h'),
  198. 'HAVE_ERF': ('erf', 'math.h'),
  199. 'HAVE_ERFC': ('erfc', 'math.h'),
  200. 'HAVE_EXECV': ('execv', 'unistd.h'),
  201. 'HAVE_FACCESSAT': ('faccessat', 'unistd.h'),
  202. 'HAVE_FCHDIR': ('fchdir', 'unistd.h'),
  203. 'HAVE_FCHMODAT': ('fchmodat', 'sys/stat.h'),
  204. 'HAVE_FDATASYNC': ('fdatasync', 'unistd.h'),
  205. 'HAVE_FDOPENDIR': ('fdopendir', 'dirent.h'),
  206. 'HAVE_FEXECVE': ('fexecve', 'unistd.h'),
  207. 'HAVE_FLOCK': ('flock', 'sys/file.h'),
  208. 'HAVE_FORKPTY': ('forkpty', 'pty.h'),
  209. 'HAVE_FPATHCONF': ('fpathconf', 'unistd.h'),
  210. 'HAVE_FSTATAT': ('fstatat', 'unistd.h'),
  211. 'HAVE_FSTATVFS': ('fstatvfs', 'sys/statvfs.h'),
  212. 'HAVE_FTELLO': ('ftello', 'stdio.h'),
  213. 'HAVE_FTIME': ('ftime', 'sys/timeb.h'),
  214. 'HAVE_FTRUNCATE': ('ftruncate', 'unistd.h'),
  215. 'HAVE_FUTIMENS': ('futimens', 'sys/stat.h'),
  216. 'HAVE_FUTIMES': ('futimes', 'sys/time.h'),
  217. 'HAVE_GAI_STRERROR': ('gai_strerror', 'netdb.h'),
  218. 'HAVE_GETGROUPLIST': ('getgrouplist', 'grp.h'),
  219. 'HAVE_GETHOSTBYNAME': ('gethostbyname', 'netdb.h'),
  220. 'HAVE_GETHOSTBYNAME_R': ('gethostbyname_r', 'netdb.h'),
  221. 'HAVE_GETITIMER': ('getitimer', 'sys/time.h'),
  222. 'HAVE_GETLOADAVG': ('getloadavg', 'stdlib.h'),
  223. 'HAVE_GETLOGIN': ('getlogin', 'unistd.h'),
  224. 'HAVE_GETNAMEINFO': ('getnameinfo', 'netdb.h'),
  225. 'HAVE_GETPEERNAME': ('getpeername', 'sys/socket.h'),
  226. 'HAVE_GETPGID': ('getpgid', 'unistd.h'),
  227. 'HAVE_GETPGRP': ('getpgrp', 'unistd.h'),
  228. 'HAVE_GETPID': ('getpid', 'unistd.h'),
  229. 'HAVE_GETPRIORITY': ('getpriority', 'sys/resource.h'),
  230. 'HAVE_GETPWENT': ('getpwent', 'pwd.h'),
  231. 'HAVE_GETRANDOM': ('getrandom', 'linux/random.h'),
  232. 'HAVE_GETRESGID': ('getresgid', 'unistd.h'),
  233. 'HAVE_GETSID': ('getsid', 'unistd.h'),
  234. 'HAVE_GETSPENT': ('getspent', 'shadow.h'),
  235. 'HAVE_GETSPNAM': ('getspnam', 'shadow.h'),
  236. 'HAVE_GETWD': ('getwd', 'unistd.h'),
  237. 'HAVE_HSTRERROR': ('hstrerror', 'netdb.h'),
  238. 'HAVE_HTOLE64': ('htole64', 'endian.h'),
  239. 'HAVE_IF_NAMEINDEX': ('if_nameindex', 'net/if.h'),
  240. 'HAVE_INET_ATON': ('inet_aton', 'arpa/inet.h'),
  241. 'HAVE_INET_PTON': ('inet_pton', 'arpa/inet.h'),
  242. 'HAVE_INITGROUPS': ('initgroups', 'grp.h'),
  243. 'HAVE_KILL': ('kill', 'signal.h'),
  244. 'HAVE_KILLPG': ('killpg', 'signal.h'),
  245. 'HAVE_LINKAT': ('linkat', 'unistd.h'),
  246. 'HAVE_LOCKF': ('lockf', 'unistd.h'),
  247. 'HAVE_LUTIMES': ('lutimes', 'sys/time.h'),
  248. 'HAVE_MAKEDEV': ('makedev', 'sys/sysmacros.h'),
  249. 'HAVE_MBRTOWC': ('mbrtowc', 'wchar.h'),
  250. 'HAVE_MEMRCHR': ('memrchr', 'string.h'),
  251. 'HAVE_MKDIRAT': ('mkdirat', 'sys/stat.h'),
  252. 'HAVE_MKFIFOAT': ('mkfifoat', 'sys/stat.h'),
  253. 'HAVE_MKNOD': ('mknod', 'unistd.h'),
  254. 'HAVE_MKNODAT': ('mknodat', 'unistd.h'),
  255. 'HAVE_MKTIME': ('mktime', 'unistd.h'),
  256. 'HAVE_MKREMAP': ('mkremap', 'sys/mman.h'),
  257. 'HAVE_NICE': ('nice', 'unistd.h'),
  258. 'HAVE_OPENAT': ('openat', 'fcntl.h'),
  259. 'HAVE_OPENPTY': ('openpty', 'pty.h'),
  260. 'HAVE_PATHCONF': ('pathconf', 'unistd.h'),
  261. 'HAVE_PAUSE': ('pause', 'unistd.h'),
  262. 'HAVE_PREAD': ('pread', 'unistd.h'),
  263. 'HAVE_PTHREAD_KILL': ('pthread_kill', 'signal.h'),
  264. 'HAVE_PTHREAD_SIGMASK': ('pthread_sigmask', 'signal.h'),
  265. 'HAVE_PWRITE': ('pwrite', 'unistd.h'),
  266. 'HAVE_READLINKAT': ('readlinkat', 'unistd.h'),
  267. 'HAVE_READV': ('readv', 'sys/uio.h'),
  268. 'HAVE_RENAMEAT': ('renamat', 'stdio.h'),
  269. 'HAVE_SCHED_GET_PRIORITY_MAX': ('sched_get_priority_max', 'sched.h'),
  270. 'HAVE_SCHED_RR_GET_INTERVAL': ('sched_rr_get_interval', 'sched.h'),
  271. 'HAVE_SCHED_SETAFFINITY': ('sched_setaffinity', 'sched.h'),
  272. 'HAVE_SCHED_SETPARAM': ('sched_setparam', 'sched.h'),
  273. 'HAVE_SCHED_SETSCHEDULER': ('sched_setscheduler', 'sched.h'),
  274. 'HAVE_SELECT': ('select', 'sys/select.h'),
  275. 'HAVE_SEM_GETVALUE': ('sem_getvalue', 'semaphore.h'),
  276. 'HAVE_SEM_OPEN': ('sem_open', 'semaphore.h'),
  277. 'HAVE_SEM_TIMEDWAIT': ('sem_timedwait', 'semaphore.h'),
  278. 'HAVE_SEM_UNLINK': ('sem_unlink', 'semaphore.h'),
  279. 'HAVE_SENDFILE': ('sendfile', 'sys/sendfile.h'),
  280. 'HAVE_SETGID': ('setgid', 'unistd.h'),
  281. 'HAVE_SETGROUPS': ('setgroups', 'grp.h'),
  282. 'HAVE_SETHOSTNAME': ('sethostname', 'unistd.h'),
  283. 'HAVE_SETITIMER': ('setitimer', 'sys/time.h'),
  284. 'HAVE_SETLOCALE': ('setlocale', 'locale.h'),
  285. 'HAVE_SETPGRP': ('setpgrp', 'unistd.h'),
  286. 'HAVE_SETPRIORITY': ('setpriority', 'sys/resource.h'),
  287. 'HAVE_SETREUID': ('setreuid', 'unistd.h'),
  288. 'HAVE_SETSID': ('setsid', 'unistd.h'),
  289. 'HAVE_SETUID': ('setuid', 'unistd.h'),
  290. 'HAVE_SETVBUF': ('setvbuf', 'unistd.h'),
  291. 'HAVE_SIGALTSTACK': ('sigaltstack', 'signal.h'),
  292. 'HAVE_SIGINTERRUPT': ('siginterrupt', 'signal.h'),
  293. 'HAVE_SIGPENDING': ('sigpending', 'signal.h'),
  294. 'HAVE_SIGRELSE': ('sigrelse', 'signal.h'),
  295. 'HAVE_SIGTIMEDWAIT': ('sigtimedwait', 'signal.h'),
  296. 'HAVE_SIGWAIT': ('sigwait', 'signal.h'),
  297. 'HAVE_SIGWAITINFO': ('sigwaitinfo', 'signal.h'),
  298. 'HAVE_SOCKETPAIR': ('socketpair', 'sys/socket.h'),
  299. 'HAVE_STRFTIME': ('strftime', 'time.h'),
  300. 'HAVE_SYMLINKAT': ('symlinkat', 'unistd.h'),
  301. 'HAVE_SYNC': ('sync', 'unistd.h'),
  302. 'HAVE_TCGETPGRP': ('tcgetpgrp', 'unistd.h'),
  303. 'HAVE_TCSETPGRP': ('tcsetpgrp', 'unistd.h'),
  304. 'HAVE_TEMPNAM': ('tempnam', 'stdio.h'),
  305. 'HAVE_TIMES': ('times', 'sys/times.h'),
  306. 'HAVE_TEMPFILE': ('tempfile', 'stdio.h'),
  307. 'HAVE_TMPNAM': ('tmpnam', 'stdio.h'),
  308. 'HAVE_TMPNAM_R': ('tmpnam_r', 'stdio.h'),
  309. 'HAVE_TRUNCATE': ('truncate', 'unistd.h'),
  310. 'HAVE_TZNAME': ('tzname', 'time.h'),
  311. 'HAVE_UNAME': ('uname', 'sys/utsname.h'),
  312. 'HAVE_UNLINKAT': ('unlinkat', 'unistd.h'),
  313. 'HAVE_UTIMENSAT': ('utimensat', 'sys/stat.h'),
  314. 'HAVE_WAIT3': ('wait3', 'sys/wait.h'),
  315. 'HAVE_WAIT4': ('wait4', 'sys/wait.h'),
  316. 'HAVE_WAITID': ('waitid', 'sys/wait.h'),
  317. 'HAVE_WRITEV': ('writev', 'sys/uio.h'),
  318. 'HAVE_WMEMCMP': ('wmemcmp', 'wchar.h'),
  319. 'HAVE_ATAN': ('atan', 'math.h'),
  320. 'HAVE_ATAN2': ('atan2', 'math.h'),
  321. 'HAVE_ACOS': ('acos', 'math.h'),
  322. 'HAVE_ACOSH': ('acosh', 'math.h'),
  323. 'HAVE_ASIN': ('asin', 'math.h'),
  324. 'HAVE_ASINH': ('asinh', 'math.h'),
  325. 'HAVE_ATANH': ('atanh', 'math.h'),
  326. 'HAVE_CEIL': ('ceil', 'math.h'),
  327. 'HAVE_COPYSIGN': ('copysign', 'math.h'),
  328. 'HAVE_COS': ('cos', 'math.h'),
  329. 'HAVE_COSH': ('cosh', 'math.h'),
  330. 'HAVE_COSF': ('cosf', 'math.h'),
  331. 'HAVE_EXPM1': ('expm1', 'math.h'),
  332. 'HAVE_FABS': ('fabs', 'math.h'),
  333. 'HAVE_FINITE': ('finite', 'math.h'),
  334. 'HAVE_FLOOR': ('floor', 'math.h'),
  335. 'HAVE_GAMMA': ('gamma', 'math.h'),
  336. 'HAVE_HYPOT': ('hypot', 'math.h'),
  337. 'HAVE_ISINF': ('isinf', 'math.h'),
  338. 'HAVE_LOG': ('log', 'math.h'),
  339. 'HAVE_LOG1P': ('log1p', 'math.h'),
  340. 'HAVE_LOG2': ('log2', 'math.h'),
  341. 'HAVE_LGAMMA': ('lgamma', 'math.h'),
  342. 'HAVE_POW': ('pow', 'math.h'),
  343. 'HAVE_SCALBN': ('scalbn', 'math.h'),
  344. 'HAVE_SIN': ('sin', 'math.h'),
  345. 'HAVE_SINF': ('sinf', 'math.h'),
  346. 'HAVE_SINH': ('sinh', 'math.h'),
  347. 'HAVE_SQRT': ('sqrt', 'math.h'),
  348. 'HAVE_TGAMMA': ('tgamma', 'math.h'),
  349. 'HAVE_FSEEKO': ('fseeko', 'stdio.h'),
  350. 'HAVE_FSEEKO64': ('fseeko64', 'stdio.h'),
  351. 'HAVE_SETJMP': ('setjmp', 'setjmp.h'),
  352. 'HAVE_PTHREAD_SETNAME_NP': ('pthread_setname_np', 'pthread.h'),
  353. 'HAVE_PTHREAD_SET_NAME_NP': ('pthread_set_name_np', 'pthread.h'),
  354. }
  355. headers = []
  356. functions = []
  357. sizes = []
  358. if len(sys.argv) != 2:
  359. print(help_message % sys.argv[0])
  360. sys.exit(0)
  361. with open(sys.argv[1]) as f:
  362. for line in f:
  363. line = line.strip()
  364. arr = line.split()
  365. # Check for headers.
  366. if line.startswith('#mesondefine') and line.endswith('_H'):
  367. token = line.split()[1]
  368. tarr = token.split('_')[1:-1]
  369. tarr = [x.lower() for x in tarr]
  370. hname = '/'.join(tarr) + '.h'
  371. headers.append((token, hname))
  372. # Check for functions.
  373. try:
  374. token = arr[1]
  375. if token in function_data:
  376. fdata = function_data[token]
  377. functions.append((token, fdata[0], fdata[1]))
  378. elif token.startswith('HAVE_') and not token.endswith('_H'):
  379. functions.append((token, ))
  380. except Exception:
  381. pass
  382. # Check for sizeof tests.
  383. if len(arr) != 2:
  384. continue
  385. elem = arr[1]
  386. if elem.startswith('SIZEOF_'):
  387. typename = elem.split('_', 1)[1] \
  388. .replace('_P', '*') \
  389. .replace('_', ' ') \
  390. .lower() \
  391. .replace('size t', 'size_t')
  392. sizes.append((elem, typename))
  393. print('''cc = meson.get_compiler('c')
  394. cdata = configuration_data()''')
  395. # Convert header checks.
  396. print('check_headers = [')
  397. for token, hname in headers:
  398. print(" ['%s', '%s']," % (token, hname))
  399. print(']\n')
  400. print('''foreach h : check_headers
  401. if cc.has_header(h.get(1))
  402. cdata.set(h.get(0), 1)
  403. endif
  404. endforeach
  405. ''')
  406. # Convert function checks.
  407. print('check_functions = [')
  408. for token in functions:
  409. if len(token) == 3:
  410. token, fdata0, fdata1 = token
  411. print(" ['%s', '%s', '#include<%s>']," % (token, fdata0, fdata1))
  412. else:
  413. print('# check token', token)
  414. print(']\n')
  415. print('''foreach f : check_functions
  416. if cc.has_function(f.get(1), prefix : f.get(2))
  417. cdata.set(f.get(0), 1)
  418. endif
  419. endforeach
  420. ''')
  421. # Convert sizeof checks.
  422. for elem, typename in sizes:
  423. print("cdata.set('%s', cc.sizeof('%s'))" % (elem, typename))
  424. print('''
  425. configure_file(input : 'config.h.meson',
  426. output : 'config.h',
  427. configuration : cdata)''')