summaryrefslogtreecommitdiffstats
path: root/build/moz.configure/headers.configure
blob: 5332c7365fb279a360c9f18a8fab6197cb8b3f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Check for headers defining standard int types.
check_header("stdint.h")
have_inttypes = check_header("inttypes.h")

# Assume we have ansi C header files available.
set_define("STDC_HEADERS", True)

set_config("HAVE_INTTYPES_H", have_inttypes)

building_linux = depends(target)(lambda target: target.kernel == "Linux")

have_malloc = check_header("malloc.h")

check_header("alloca.h")

add_old_configure_assignment("HAVE_MALLOC_H", have_malloc)

check_headers(
    "sys/byteorder.h",
    "getopt.h",
    "unistd.h",
    "nl_types.h",
    "cpuid.h",
    "fts.h",
)

# These are all the places some variant of statfs can be hiding.
check_headers(
    "sys/statvfs.h",
    "sys/statfs.h",
    "sys/vfs.h",
    "sys/mount.h",
)

# Quota support
# Check for both the header and quotactl() because Android headers can have the
# header but not quotactl().
set_define(
    "HAVE_SYS_QUOTA_H",
    try_compile(
        includes=["sys/quota.h"],
        body="quotactl(0, nullptr, 0, (caddr_t)nullptr);",
        check_msg="for sys/quota.h",
    ),
)
check_header("linux/quota.h", includes=["sys/socket.h"], when=building_linux)

# SCTP support - needs various network include headers
check_headers(
    "linux/if_addr.h",
    "linux/rtnetlink.h",
    includes=["sys/socket.h"],
    when=building_linux,
)

check_header("sys/queue.h")

check_headers(
    "sys/types.h",
    "netinet/in.h",
    "byteswap.h",
)

# memfd_create(2) -- Note that older versions of the Linux man-pages
# project incorrectly cite <sys/memfd.h>, which doesn't exist; this
# was fixed in the man-pages-5.00 release.
set_define(
    "HAVE_MEMFD_CREATE",
    try_compile(
        includes=["sys/mman.h"],
        body='memfd_create("", 0);',
        check_msg="for memfd_create in sys/mman.h",
    ),
)

# TODO: Move these checks to file specific to --enable-project=js.
have_perf_event_h = check_header("linux/perf_event.h", when=building_linux)

option(
    "--with-linux-headers",
    help="location where the Linux kernel headers can be found",
    nargs=1,
)

passed_linux_header_flags = depends_if("--with-linux-headers")(
    lambda v: ["-I%s" % v[0]]
)


@depends(
    try_compile(
        includes=["asm/unistd.h"],
        body="return sizeof(__NR_perf_event_open);",
        flags=passed_linux_header_flags,
        check_msg="for perf_event_open system call",
    ),
    when=have_perf_event_h,
)
def have_perf_event_open(have_perf_event_open):
    if have_perf_event_open:
        return True


set_config("HAVE_LINUX_PERF_EVENT_H", have_perf_event_open)


@depends(passed_linux_header_flags, have_perf_event_open)
def linux_headers_includes(passed_linux_header_flags, have_perf_event_open):
    if have_perf_event_open and passed_linux_header_flags:
        return passed_linux_header_flags[0]


set_config("LINUX_HEADERS_INCLUDES", linux_headers_includes)