1LOCAL_PATH := $(call my-dir)
2
3commonSources := \
4    mDNSShared/dnssd_clientlib.c  \
5    mDNSShared/dnssd_clientstub.c \
6    mDNSShared/dnssd_ipc.c
7
8commonLibs := libcutils liblog
9
10commonFlags := \
11    -O2 -g \
12    -fno-strict-aliasing \
13    -D_GNU_SOURCE \
14    -DHAVE_IPV6 \
15    -DHAVE_LINUX \
16    -DNOT_HAVE_SA_LEN \
17    -DPLATFORM_NO_RLIMIT \
18    -DTARGET_OS_LINUX \
19    -DUSES_NETLINK \
20    -DMDNS_DEBUGMSGS=0 \
21    -DMDNS_UDS_SERVERPATH=\"/dev/socket/mdnsd\" \
22    -DMDNS_USERNAME=\"mdnsr\" \
23    -W \
24    -Wall \
25    -Wextra \
26    -Wno-array-bounds \
27    -Wno-pointer-sign \
28    -Wno-unused \
29    -Wno-unused-but-set-variable \
30    -Wno-unused-parameter \
31    -Werror=implicit-function-declaration \
32
33#########################
34
35include $(CLEAR_VARS)
36
37# uds_daemon.c explicitly dereferences a non-volatile null pointer. Clang rather
38# unhelpfully says "I know what you're trying to do, but I'm going to optimize
39# it away anyway". There's no way to disable this behavior, so just stick with
40# gcc.
41LOCAL_CLANG := false
42
43LOCAL_SRC_FILES :=  mDNSPosix/PosixDaemon.c    \
44                    mDNSPosix/mDNSPosix.c      \
45                    mDNSPosix/mDNSUNP.c        \
46                    mDNSCore/mDNS.c            \
47                    mDNSCore/DNSDigest.c       \
48                    mDNSCore/uDNS.c            \
49                    mDNSCore/DNSCommon.c       \
50                    mDNSShared/uds_daemon.c    \
51                    mDNSShared/mDNSDebug.c     \
52                    mDNSShared/dnssd_ipc.c     \
53                    mDNSShared/GenLinkedList.c \
54                    mDNSShared/PlatformCommon.c
55
56LOCAL_MODULE := mdnsd
57LOCAL_MODULE_TAGS := optional
58
59LOCAL_C_INCLUDES := external/mdnsresponder/mDNSPosix \
60                    external/mdnsresponder/mDNSCore  \
61                    external/mdnsresponder/mDNSShared
62
63LOCAL_CFLAGS := $(commonFlags) -DMDNS_VERSIONSTR_NODTS=1
64
65LOCAL_STATIC_LIBRARIES := $(commonLibs) libc
66LOCAL_FORCE_STATIC_EXECUTABLE := true
67LOCAL_INIT_RC := mdnsd.rc
68include $(BUILD_EXECUTABLE)
69
70##########################
71
72include $(CLEAR_VARS)
73LOCAL_SRC_FILES := $(commonSources)
74LOCAL_MODULE := libmdnssd
75LOCAL_MODULE_TAGS := optional
76LOCAL_CFLAGS := $(commonFlags)
77LOCAL_SYSTEM_SHARED_LIBRARIES := libc
78LOCAL_SHARED_LIBRARIES := $(commonLibs)
79LOCAL_EXPORT_C_INCLUDE_DIRS := external/mdnsresponder/mDNSShared
80include $(BUILD_SHARED_LIBRARY)
81
82include $(CLEAR_VARS)
83LOCAL_SRC_FILES := $(commonSources)
84LOCAL_MODULE := libmdnssd
85LOCAL_MODULE_TAGS := optional
86LOCAL_CFLAGS := $(commonFlags)
87LOCAL_STATIC_LIBRARIES := $(commonLibs)
88LOCAL_EXPORT_C_INCLUDE_DIRS := external/mdnsresponder/mDNSShared
89include $(BUILD_STATIC_LIBRARY)
90
91############################
92
93include $(CLEAR_VARS)
94LOCAL_SRC_FILES := Clients/dns-sd.c Clients/ClientCommon.c
95LOCAL_MODULE := dnssd
96LOCAL_MODULE_TAGS := optional
97LOCAL_CFLAGS := $(commonFlags)
98LOCAL_SYSTEM_SHARED_LIBRARIES := libc
99LOCAL_SHARED_LIBRARIES := libmdnssd libcutils liblog
100include $(BUILD_EXECUTABLE)
101
102############################
103# This builds an mDns that is embeddable within GmsCore for the nearby connections API
104
105### STATIC LIB ###
106include $(CLEAR_VARS)
107
108LOCAL_SDK_VERSION := 8
109LOCAL_MODULE    := libmdns_jni_static
110LOCAL_SRC_FILES :=  /mDNSCore/mDNS.c \
111                    /mDNSCore/DNSDigest.c \
112                    /mDNSCore/uDNS.c \
113                    /mDNSCore/DNSCommon.c \
114                    /mDNSPosix/mDNSPosix.c \
115                    /mDNSPosix/mDNSUNP.c \
116                    /mDNSShared/mDNSDebug.c \
117                    /mDNSShared/dnssd_clientlib.c \
118                    /mDNSShared/dnssd_clientshim.c \
119                    /mDNSShared/dnssd_ipc.c \
120                    /mDNSShared/GenLinkedList.c \
121                    /mDNSShared/PlatformCommon.c
122
123LOCAL_C_INCLUDES := external/mdnsresponder/mDNSPosix \
124                    external/mdnsresponder/mDNSCore  \
125                    external/mdnsresponder/mDNSShared
126
127LOCAL_CFLAGS += -Os -fvisibility=hidden
128LOCAL_CFLAGS += $(commonFlags) \
129                -UMDNS_DEBUGMSGS \
130                -DMDNS_DEBUGMSGS=0 \
131                -DSO_REUSEADDR \
132                -DUNICAST_DISABLED
133
134ifeq ($(TARGET_BUILD_TYPE),debug)
135  LOCAL_CFLAGS += -O0 -UNDEBUG -fno-omit-frame-pointer
136endif
137
138include $(BUILD_STATIC_LIBRARY)
139