From 08ac33bc5cd801d036512bada7a8a53cd9f83fea Mon Sep 17 00:00:00 2001
From: Chocobo1 <Chocobo1@users.noreply.github.com>
Date: Tue, 28 Sep 2021 17:18:19 +0800
Subject: [PATCH 1/3] Add detection for OpenBSD in configure script

Patch taken from downstream:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/net/qbittorrent/qbittorrent/patches/patch-configure_ac
---
 configure    | 12 ++++++++++++
 configure.ac |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/configure b/configure
index 137d2adde..4e88e2a48 100755
--- a/configure
+++ b/configure
@@ -5200,6 +5200,18 @@ else $as_nop
 printf "%s\n" "no" >&6; }
 fi
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether OS is OpenBSD" >&5
+printf %s "checking whether OS is OpenBSD... " >&6; }
+if expr "$host_os" : ".*openbsd.*" > /dev/null
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+      LIBS="-lexecinfo $LIBS"
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether OS is macOS" >&5
 printf %s "checking whether OS is macOS... " >&6; }
 if expr "$host_os" : ".*darwin.*" > /dev/null
diff --git a/configure.ac b/configure.ac
index 536d7d5eb..34e024fa6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,12 @@ AS_IF([expr "$host_os" : ".*freebsd.*" > /dev/null],
       LIBS="-lexecinfo $LIBS"],
       [AC_MSG_RESULT([no])])
 
+AC_MSG_CHECKING([whether OS is OpenBSD])
+AS_IF([expr "$host_os" : ".*openbsd.*" > /dev/null],
+      [AC_MSG_RESULT([yes])
+      LIBS="-lexecinfo $LIBS"],
+      [AC_MSG_RESULT([no])])
+
 AC_MSG_CHECKING([whether OS is macOS])
 AS_IF([expr "$host_os" : ".*darwin.*" > /dev/null],
       [AC_MSG_RESULT([yes])

From ad8a827c1fc9b3eb55d63d04c4ad5714e797dcc8 Mon Sep 17 00:00:00 2001
From: Chocobo1 <Chocobo1@users.noreply.github.com>
Date: Tue, 28 Sep 2021 17:25:17 +0800
Subject: [PATCH 2/3] Add detection for Haiku in configure script

Patch taken from downstream:
https://github.com/haikuports/haikuports/blob/master/net-p2p/qbittorrent/patches/qbittorrent-4.3.1.patchset
---
 configure    | 12 ++++++++++++
 configure.ac |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/configure b/configure
index 4e88e2a48..938e0a3dd 100755
--- a/configure
+++ b/configure
@@ -5224,6 +5224,18 @@ else $as_nop
 printf "%s\n" "no" >&6; }
 fi
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether OS is Haiku" >&5
+printf %s "checking whether OS is Haiku... " >&6; }
+if expr "$host_os" : ".*haiku.*" > /dev/null
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+      LIBS="-lnetwork $LIBS"
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
 # Require 0.23 pkg-config
 
 
diff --git a/configure.ac b/configure.ac
index 34e024fa6..e480ba7ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,6 +72,12 @@ AS_IF([expr "$host_os" : ".*darwin.*" > /dev/null],
       enable_qt_dbus=no],
       [AC_MSG_RESULT([no])])
 
+AC_MSG_CHECKING([whether OS is Haiku])
+AS_IF([expr "$host_os" : ".*haiku.*" > /dev/null],
+      [AC_MSG_RESULT([yes])
+      LIBS="-lnetwork $LIBS"],
+      [AC_MSG_RESULT([no])])
+
 # Require 0.23 pkg-config
 PKG_PROG_PKG_CONFIG([0.23])
 AS_IF([test "x$PKG_CONFIG" = "x"],

From e236a76d5a4d4385274a92ddc5cfc5af1ecc2477 Mon Sep 17 00:00:00 2001
From: Chocobo1 <Chocobo1@users.noreply.github.com>
Date: Wed, 29 Sep 2021 16:11:57 +0800
Subject: [PATCH 3/3] Use case statement for host OS detection

---
 configure    | 63 ++++++++++++++++++++--------------------------------
 configure.ac | 43 ++++++++++++++++++-----------------
 2 files changed, 47 insertions(+), 59 deletions(-)

diff --git a/configure b/configure
index 938e0a3dd..21a53fa88 100755
--- a/configure
+++ b/configure
@@ -5188,53 +5188,38 @@ fi
 
 
 # Detect OS
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether OS is FreeBSD" >&5
-printf %s "checking whether OS is FreeBSD... " >&6; }
-if expr "$host_os" : ".*freebsd.*" > /dev/null
-then :
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable specific tweaks for current host \"$host_os\"" >&5
+printf %s "checking whether to enable specific tweaks for current host \"$host_os\"... " >&6; }
+case "$host_os" in
+    *darwin*)
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 printf "%s\n" "yes" >&6; }
-      LIBS="-lexecinfo $LIBS"
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
+        enable_qt_dbus=no
+        ;;
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether OS is OpenBSD" >&5
-printf %s "checking whether OS is OpenBSD... " >&6; }
-if expr "$host_os" : ".*openbsd.*" > /dev/null
-then :
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+    *freebsd*)
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 printf "%s\n" "yes" >&6; }
-      LIBS="-lexecinfo $LIBS"
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
+        LIBS="-lexecinfo $LIBS"
+        ;;
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether OS is macOS" >&5
-printf %s "checking whether OS is macOS... " >&6; }
-if expr "$host_os" : ".*darwin.*" > /dev/null
-then :
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+    *haiku*)
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 printf "%s\n" "yes" >&6; }
-      enable_qt_dbus=no
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
+        LIBS="-lnetwork $LIBS"
+        ;;
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether OS is Haiku" >&5
-printf %s "checking whether OS is Haiku... " >&6; }
-if expr "$host_os" : ".*haiku.*" > /dev/null
-then :
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+    *openbsd*)
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 printf "%s\n" "yes" >&6; }
-      LIBS="-lnetwork $LIBS"
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+        LIBS="-lexecinfo $LIBS"
+        ;;
+
+    *)
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
-fi
+        ;;
+esac
 
 # Require 0.23 pkg-config
 
diff --git a/configure.ac b/configure.ac
index e480ba7ef..3a04b82fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,29 +54,32 @@ AC_ARG_ENABLE(qt-dbus,
               [enable_qt_dbus=yes])
 
 # Detect OS
-AC_MSG_CHECKING([whether OS is FreeBSD])
-AS_IF([expr "$host_os" : ".*freebsd.*" > /dev/null],
-      [AC_MSG_RESULT([yes])
-      LIBS="-lexecinfo $LIBS"],
-      [AC_MSG_RESULT([no])])
+AC_MSG_CHECKING([whether to enable specific tweaks for current host "$host_os"])
+case "$host_os" in
+    *darwin*)
+        AC_MSG_RESULT([yes])
+        enable_qt_dbus=no
+        ;;
 
-AC_MSG_CHECKING([whether OS is OpenBSD])
-AS_IF([expr "$host_os" : ".*openbsd.*" > /dev/null],
-      [AC_MSG_RESULT([yes])
-      LIBS="-lexecinfo $LIBS"],
-      [AC_MSG_RESULT([no])])
+    *freebsd*)
+        AC_MSG_RESULT([yes])
+        LIBS="-lexecinfo $LIBS"
+        ;;
 
-AC_MSG_CHECKING([whether OS is macOS])
-AS_IF([expr "$host_os" : ".*darwin.*" > /dev/null],
-      [AC_MSG_RESULT([yes])
-      enable_qt_dbus=no],
-      [AC_MSG_RESULT([no])])
+    *haiku*)
+        AC_MSG_RESULT([yes])
+        LIBS="-lnetwork $LIBS"
+        ;;
 
-AC_MSG_CHECKING([whether OS is Haiku])
-AS_IF([expr "$host_os" : ".*haiku.*" > /dev/null],
-      [AC_MSG_RESULT([yes])
-      LIBS="-lnetwork $LIBS"],
-      [AC_MSG_RESULT([no])])
+    *openbsd*)
+        AC_MSG_RESULT([yes])
+        LIBS="-lexecinfo $LIBS"
+        ;;
+
+    *)
+        AC_MSG_RESULT([no])
+        ;;
+esac
 
 # Require 0.23 pkg-config
 PKG_PROG_PKG_CONFIG([0.23])