1From 22316f200803225f2d375ae5c36ffead59e2f6b8 Mon Sep 17 00:00:00 2001
2From: Alex Kiernan <alex.kiernan@gmail.com>
3Date: Mon, 5 Dec 2022 15:14:26 +0000
4Subject: [PATCH 4/6] make: Separate TLS targets from libraries
5
6There are dependencies on TLSOBJS, which fails when `-lmbedtls` is
7listed as a dependency, so separate it out.
8
9Upstream-Status: Pending
10Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
11---
12 mDNSPosix/Makefile | 14 ++++++++------
13 1 file changed, 8 insertions(+), 6 deletions(-)
14
15Index: mDNSResponder/mDNSPosix/Makefile
16===================================================================
17--- mDNSResponder.orig/mDNSPosix/Makefile
18+++ mDNSResponder/mDNSPosix/Makefile
19@@ -112,9 +112,11 @@ ifeq ($(findstring linux,$(os)),linux)
20 ifeq ($(tls), no)
21 CFLAGS_OS = -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX -ftabstop=4 -Wno-expansion-to-defined
22 TLSOBJS =
23+TLSLIBS =
24 else
25 CFLAGS_OS = -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX -DPOSIX_HAS_TLS -ftabstop=4 -Wno-expansion-to-defined
26-TLSOBJS = $(OBJDIR)/mbedtls.c.o -lmbedtls -lmbedcrypto
27+TLSOBJS = $(OBJDIR)/mbedtls.c.o
28+TLSLIBS = -lmbedtls -lmbedcrypto
29 endif
30 LD = $(CC)
31 SOOPTS = -shared
32@@ -266,7 +268,7 @@ Daemon: setup $(BUILDDIR)/mdnsd
33 	@echo "Responder daemon done"
34
35 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
36-	$(CC) -o $@ $+ $(LINKOPTS)
37+	$(CC) -o $@ $+ $(LINKOPTS) $(TLSLIBS)
38 	$(STRIP) $@
39
40 # libdns_sd target builds the client library
41@@ -485,16 +487,16 @@ dnsextd: setup $(BUILDDIR)/dnsextd
42 	@echo "dnsextd done"
43
44 $(BUILDDIR)/mDNSClientPosix:         $(APPOBJ) $(TLSOBJS)     $(OBJDIR)/Client.c.o
45-	$(CC) $+ -o $@ $(LINKOPTS)
46+	$(CC) $+ -o $@ $(LINKOPTS) $(TLSLIBS)
47
48 $(BUILDDIR)/mDNSResponderPosix:      $(COMMONOBJ) $(TLSOBJS)  $(OBJDIR)/Responder.c.o
49-	$(CC) $+ -o $@ $(LINKOPTS)
50+	$(CC) $+ -o $@ $(LINKOPTS) $(TLSLIBS)
51
52 $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(TLSOBJS)  $(OBJDIR)/ProxyResponder.c.o
53-	$(CC) $+ -o $@ $(LINKOPTS)
54+	$(CC) $+ -o $@ $(LINKOPTS) $(TLSLIBS)
55
56 $(BUILDDIR)/mDNSNetMonitor:          $(SPECIALOBJ) $(TLSOBJS) $(OBJDIR)/NetMonitor.c.o
57-	$(CC) $+ -o $@ $(LINKOPTS)
58+	$(CC) $+ -o $@ $(LINKOPTS) $(TLSLIBS)
59
60 $(OBJDIR)/NetMonitor.c.o:            $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c
61
62