From 7033794d97ad61529e4211afa256883919ff3c3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 31 May 2021 13:14:00 -0400
Subject: [PATCH] apple: avoid SO_REUSEADDR for upnp

This cause a huge battery drain. Issue reported upstream there:
https://github.com/pupnp/pupnp/issues/328

Change-Id: I739aa6e3929297f2e09b4d37849106ca03c2635e
GitLab: #563
---
 contrib/src/upnp/rules.mak | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/contrib/src/upnp/rules.mak b/contrib/src/upnp/rules.mak
index 87ebd9fe94..4bfd039ba7 100644
--- a/contrib/src/upnp/rules.mak
+++ b/contrib/src/upnp/rules.mak
@@ -20,13 +20,22 @@ endif
 	$(UPDATE_AUTOCONFIG) && cd $(UNPACK_DIR) && mv config.guess config.sub
 	$(MOVE)
 
+PUPNP_OPTIONS=--disable-largefile --disable-samples --disable-device --disable-webserver --without-documentation
+ifdef HAVE_IOS
+PUPNP_OPTIONS+= --disable-reuseaddr
+else
+ifdef HAVE_MACOSX
+PUPNP_OPTIONS+= --disable-reuseaddr
+endif
+endif
+
 .upnp: upnp
 ifdef HAVE_WIN32
 	$(RECONF)
-	cd $< && $(HOSTVARS) CFLAGS="-DUPNP_STATIC_LIB" ./configure --disable-largefile --disable-samples --disable-device --disable-webserver --without-documentation $(HOSTCONF)
+	cd $< && $(HOSTVARS) CFLAGS="-DUPNP_STATIC_LIB" ./configure $(PUPNP_OPTIONS) $(HOSTCONF)
 else
 	$(RECONF)
-	cd $< && $(HOSTVARS) CFLAGS="$(CFLAGS) -DUPNP_STATIC_LIB" ./configure --disable-largefile --disable-samples --disable-device --disable-webserver --without-documentation $(HOSTCONF)
+	cd $< && $(HOSTVARS) CFLAGS="$(CFLAGS) -DUPNP_STATIC_LIB" ./configure $(PUPNP_OPTIONS) $(HOSTCONF)
 endif
 	cd $< && $(MAKE) install
 	touch $@
-- 
GitLab