1package {
2    default_applicable_licenses: ["external_mdnsresponder_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18// See: http://go/android-license-faq
19license {
20    name: "external_mdnsresponder_license",
21    visibility: [":__subpackages__"],
22    license_kinds: [
23        "SPDX-license-identifier-Apache-2.0",
24        "SPDX-license-identifier-BSD",
25        "SPDX-license-identifier-NCSA",
26        "SPDX-license-identifier-OpenSSL",
27        "legacy_notice",
28    ],
29    license_text: [
30        "LICENSE",
31    ],
32}
33
34cc_defaults {
35    name: "mdnsresponder_default_cflags",
36
37    cflags: [
38        "-O2",
39        "-g",
40        "-fno-strict-aliasing",
41        "-fwrapv",
42        "-D_GNU_SOURCE",
43        "-DHAVE_IPV6",
44        "-DNOT_HAVE_SA_LEN",
45        "-DPLATFORM_NO_RLIMIT",
46        "-DMDNS_DEBUGMSGS=0",
47        "-DMDNS_UDS_SERVERPATH=\"/dev/socket/mdnsd\"",
48        "-DMDNS_USERNAME=\"mdnsr\"",
49        "-W",
50        "-Wall",
51        "-Wextra",
52        "-Wno-address-of-packed-member",
53        "-Wno-array-bounds",
54        "-Wno-pointer-sign",
55        "-Wno-unused",
56        "-Wno-unused-but-set-variable",
57        "-Wno-unused-parameter",
58        "-Werror=implicit-function-declaration",
59    ],
60    target: {
61        linux: {
62            cflags: [
63                "-DTARGET_OS_LINUX",
64                "-DHAVE_LINUX",
65                "-DUSES_NETLINK",
66                "-Werror",
67            ],
68        },
69        darwin: {
70            cflags: [
71                "-DTARGET_OS_MAC",
72                "-DMDNS_UDS_SERVERPATH=\"/var/run/mDNSResponder\"",
73                "-Wno-error",
74            ],
75        },
76        windows: {
77            enabled: true,
78            cflags: [
79                "-DTARGET_OS_WINDOWS",
80                "-DWIN32",
81                "-DNDEBUG",
82                "-D_WIN32_LEAN_AND_MEAN",
83                "-DUSE_TCP_LOOPBACK",
84                "-D_CRT_SECURE_NO_DEPRECATE",
85                "-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1",
86                "-Wno-error",
87                "-Wno-sign-compare",
88                "-include stdint.h",
89                "-include winsock2.h",
90                "-include ws2ipdef.h",
91                "-include wincrypt.h",
92                "-include netioapi.h",
93            ],
94            local_include_dirs: [
95                "mDNSWindows",
96                "android/caseMapping",
97            ],
98        },
99    },
100}
101
102cc_binary {
103    name: "mdnsd",
104    defaults: ["mdnsresponder_default_cflags"],
105    host_supported: true,
106    srcs: [
107        "mDNSCore/mDNS.c",
108        "mDNSCore/DNSDigest.c",
109        "mDNSCore/uDNS.c",
110        "mDNSCore/DNSCommon.c",
111        "mDNSShared/uds_daemon.c",
112        "mDNSShared/mDNSDebug.c",
113        "mDNSShared/dnssd_ipc.c",
114        "mDNSShared/GenLinkedList.c",
115    ],
116
117    local_include_dirs: [
118        "mDNSCore",
119        "mDNSShared",
120    ],
121    init_rc: ["mdnsd.rc"],
122
123    cflags: ["-DMDNS_VERSIONSTR_NODTS=1"],
124
125    target: {
126        android: {
127            static_executable: true,
128            local_include_dirs: ["mDNSPosix"],
129            srcs: [
130                "mDNSShared/PlatformCommon.c",
131                "mDNSPosix/PosixDaemon.c",
132                "mDNSPosix/mDNSPosix.c",
133                "mDNSPosix/mDNSUNP.c",
134            ],
135        },
136        not_windows: {
137            local_include_dirs: ["mDNSPosix"],
138            srcs: [
139                "mDNSShared/PlatformCommon.c",
140                "mDNSPosix/PosixDaemon.c",
141                "mDNSPosix/mDNSPosix.c",
142                "mDNSPosix/mDNSUNP.c",
143            ],
144        },
145        windows: {
146            cflags: [
147                "-DTARGET_OS_WIN32",
148                "-D_CONSOLE",
149                "-DPLATFORM_NO_STRSEP",
150                "-DPLATFORM_NO_EPIPE",
151                "-DPLATFORM_NO_RLIMIT",
152                "-DPID_FILE=\"\"",
153                "-DUNICODE",
154                "-D_UNICODE",
155                "-D_LEGACY_NAT_TRAVERSAL",
156                "-Wno-empty-body",
157            ],
158
159            ldflags: ["-municode"],
160            host_ldlibs: [
161                "-lws2_32",
162                "-liphlpapi",
163                "-lpowrprof",
164                "-lnetapi32",
165            ],
166
167            srcs: [
168                "mDNSWindows/SystemService/main.c",
169                "mDNSWindows/SystemService/Service.c",
170                "mDNSWindows/SystemService/EventLog.mc",
171                "mDNSWindows/Secret.c",
172                "mDNSWindows/mDNSWin32.c",
173                "mDNSShared/DebugServices.c",
174                "android/windows_firewall_dummy.c",
175            ],
176
177            local_include_dirs: [
178                "mDNSWindows/SystemService",
179            ],
180        },
181    },
182
183    static_libs: [
184        "libcutils",
185        "liblog",
186    ],
187}
188
189//#########################
190
191cc_library {
192    name: "libmdnssd",
193    defaults: ["mdnsresponder_default_cflags"],
194    host_supported: true,
195    recovery_available: true,
196    srcs: [
197        "mDNSShared/dnssd_clientlib.c",
198        "mDNSShared/dnssd_clientstub.c",
199        "mDNSShared/dnssd_ipc.c",
200    ],
201
202    target: {
203        host: {
204            shared: {
205                enabled: false,
206            },
207        },
208        windows: {
209            srcs: ["mDNSWindows/DLL/dllmain.c"],
210
211            cflags: [
212                "-D_WINDOWS",
213                "-D_USERDLL",
214                "-D_MDNS_DEBUGMSGS=0",
215                "-D_SSIZE_T",
216                "-DNOT_HAVE_SA_LENGTH",
217                "-Wno-unknown-pragmas",
218                "-Wno-overflow",
219                "-Wno-pragma-pack",
220                "-include iphlpapi.h",
221                "-include stdlib.h",
222                "-include stdio.h",
223            ],
224        },
225    },
226
227    export_include_dirs: ["mDNSShared"],
228
229    static_libs: ["libcutils"],
230    shared_libs: ["liblog"],
231
232    apex_available: [
233        "//apex_available:platform",
234        "com.android.adbd",
235    ],
236}
237
238//###########################
239
240cc_binary {
241    name: "dnssd",
242    defaults: ["mdnsresponder_default_cflags"],
243    srcs: [
244        "Clients/dns-sd.c",
245        "Clients/ClientCommon.c",
246    ],
247
248    system_shared_libs: ["libc", "libdl"],
249    shared_libs: [
250        "libmdnssd",
251        "libcutils",
252        "liblog",
253    ],
254}
255