headers.configure 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. # Check for headers defining standard int types.
  6. check_header('stdint.h')
  7. have_inttypes = check_header('inttypes.h')
  8. # Assume we have ansi C header files available.
  9. set_define('STDC_HEADERS', True)
  10. set_config('HAVE_INTTYPES_H', have_inttypes)
  11. building_linux = depends(target)(lambda target: target.kernel == 'Linux')
  12. have_malloc = check_header('malloc.h')
  13. check_header('alloca.h')
  14. add_old_configure_assignment('HAVE_MALLOC_H', have_malloc)
  15. check_headers(
  16. 'sys/byteorder.h',
  17. 'getopt.h',
  18. 'unistd.h',
  19. 'nl_types.h',
  20. 'cpuid.h',
  21. when=non_msvc_compiler,
  22. )
  23. # These are all the places some variant of statfs can be hiding.
  24. check_headers(
  25. 'sys/statvfs.h',
  26. 'sys/statfs.h',
  27. 'sys/vfs.h',
  28. 'sys/mount.h',
  29. when=non_msvc_compiler,
  30. )
  31. # Quota support
  32. check_header('sys/quota.h',
  33. when=non_msvc_compiler)
  34. check_header('linux/quota.h',
  35. includes=['sys/socket.h'],
  36. when=building_linux)
  37. # SCTP support - needs various network include headers
  38. check_headers(
  39. 'linux/if_addr.h',
  40. 'linux/rtnetlink.h',
  41. includes=['sys/socket.h'],
  42. when=building_linux,
  43. )
  44. check_header('sys/queue.h',
  45. when=non_msvc_compiler)
  46. check_headers(
  47. 'sys/types.h',
  48. 'netinet/in.h',
  49. 'byteswap.h',
  50. when=non_msvc_compiler,
  51. )
  52. # TODO: Move these checks to file specific to --enable-project=js.
  53. have_perf_event_h = check_header('linux/perf_event.h',
  54. when=building_linux)
  55. js_option('--with-linux-headers',
  56. help='location where the Linux kernel headers can be found',
  57. nargs=1)
  58. passed_linux_header_flags = depends_if('--with-linux-headers')(lambda v: ['-I%s' % v[0]])
  59. @depends_when(try_compile(includes=['asm/unistd.h'],
  60. body='return sizeof(__NR_perf_event_open);',
  61. flags=passed_linux_header_flags,
  62. check_msg='for perf_event_open system call'),
  63. when=have_perf_event_h)
  64. def have_perf_event_open(have_perf_event_open):
  65. if have_perf_event_open:
  66. return True
  67. set_config('HAVE_LINUX_PERF_EVENT_H', have_perf_event_open)
  68. @depends(passed_linux_header_flags, have_perf_event_open)
  69. def linux_headers_includes(passed_linux_header_flags, have_perf_event_open):
  70. if have_perf_event_open and passed_linux_header_flags:
  71. return passed_linux_header_flags[0]
  72. set_config('LINUX_HEADERS_INCLUDES', linux_headers_includes)