summaryrefslogtreecommitdiffstats
blob: 9a0cecd32364769f7fccd8dcf52012ee6174660d (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
Import(["env", "conf_env"])

if env.get("EXPAT_BUNDLED", False) :
    if env["SCONS_STAGE"] == "flags" :
        env["EXPAT_FLAGS"] = {
                "CPPDEFINES": ["XML_STATIC"],
                "CPPPATH": [Dir("src")],
                "LIBPATH": [Dir(".")],
            }

    def checkBuilds(context, message, source):
        context.Message(message)
        result = context.TryLink(source, '.cpp')
        context.Result(result)
        return result

    if env["SCONS_STAGE"] == "build" :
        myenv = env.Clone()
        myenv.Append(CPPDEFINES = ["XML_STATIC", "HAVE_EXPAT_CONFIG_H"])
        if env.get("BOOST_BUNDLED", False) :
            myenv.Append(CPPPATH = [".", "src", "../Boost/src"])
        else :
            myenv.Append(CPPPATH = [".", "src"])
            myenv.MergeFlags(env["BOOST_FLAGS"])

        conf = Configure(conf_env)
        if conf.CheckFunc('memmove') :
            myenv.Append(CPPDEFINES = ["HAVE_MEMMOVE"])
        conf.Finish()

        if env["PLATFORM"] != "win32" :
            conf = Configure(conf_env, custom_tests = { "CheckBuilds" : checkBuilds})
            if conf.CheckBuilds('Checking for C function getrandom()... ',
                """
                #include <stdlib.h>  /* for NULL */
                #include <sys/random.h>
                int main() {
                    return getrandom(NULL, 0U, 0U);
                }
                """):
                myenv.Append(CPPDEFINES = ["HAVE_GETRANDOM"])
            elif conf.CheckBuilds('Checking for syscall SYS_getrandom... ',
                """
                #include <stdlib.h>  /* for NULL */
                #include <unistd.h>  /* for syscall */
                #include <sys/syscall.h>  /* for SYS_getrandom */
                int main() {
                    syscall(SYS_getrandom, NULL, 0, 0);
                    return 0;
                }
                """):
                myenv.Append(CPPDEFINES = ["HAVE_SYSCALL_GETRANDOM"])
            elif conf.CheckBuilds('Checking for arc4random_buf... ',
                """
                #include <stdlib.h>  /* for arc4random_buf on BSD, for NULL */
                #if defined(HAVE_LIBBSD)
                # include <bsd/stdlib.h>
                #endif
                int main() {
                    arc4random_buf(NULL, 0U);
                    return 0;
                }
                """):
                myenv.Append(CPPDEFINES = ["HAVE_ARC4RANDOM_BUF"])
            elif conf.CheckBuilds('Checking for arc4random... ',
                """
                #if defined(HAVE_LIBBSD)
                # include <bsd/stdlib.h>
                #else
                # include <stdlib.h>
                #endif
                int main() {
                    arc4random();
                    return 0;
                }
                """):
                myenv.Append(CPPDEFINES = ["HAVE_ARC4RANDOM"])
            conf.Finish()

        env["EXPAT_OBJECTS"] = myenv.SwiftenObject([
                "src/xmltok.c",
                "src/xmlparse.c",
                "src/xmlrole.c",
                "src/loadlibrary.c",
            ])