1# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2# vim: set filetype=python:
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7HOST_SOURCES += [
8    "/other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp",
9    "mar.c",
10]
11
12HostProgram("mar")
13
14HOST_USE_LIBS += [
15    "hostmar",
16]
17
18if CONFIG["HOST_OS_ARCH"] == "WINNT":
19    HOST_OS_LIBS += [
20        "ws2_32",
21    ]
22
23# C11 for static_assert
24c11_flags = ["-std=gnu11"]
25if CONFIG["CC_TYPE"] == "clang-cl":
26    c11_flags.insert(0, "-Xclang")
27HOST_CFLAGS += c11_flags
28
29HOST_DEFINES["NO_SIGN_VERIFY"] = True
30
31if CONFIG["MOZ_BUILD_APP"] != "tools/update-packaging":
32    Program("signmar")
33
34    SOURCES += HOST_SOURCES
35
36    CFLAGS += c11_flags
37
38    USE_LIBS += [
39        "mar",
40        "nspr",
41        "nss",
42        "signmar",
43        "verifymar",
44    ]
45
46    if CONFIG["OS_ARCH"] == "WINNT":
47        USE_STATIC_LIBS = True
48
49        OS_LIBS += [
50            "ws2_32",
51            "crypt32",
52            "advapi32",
53        ]
54    elif CONFIG["OS_ARCH"] == "Darwin":
55        OS_LIBS += [
56            "-framework CoreFoundation",
57            "-framework Security",
58        ]
59
60    DisableStlWrapping()
61
62
63for var in ("MAR_CHANNEL_ID", "MOZ_APP_VERSION"):
64    HOST_DEFINES[var] = '"%s"' % CONFIG[var]
65    if SOURCES:
66        DEFINES[var] = HOST_DEFINES[var]
67