"Fossies" - the Fresh Open Source Software Archive

Member "meson-0.52.1/tools/ac_converter.py" (28 Nov 2019, 19281 Bytes) of package /linux/privat/meson-0.52.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "ac_converter.py" see the Fossies "Dox" file reference documentation.

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