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