diff --git a/build.py b/build.py
index 791a2745338f6f869ab0382056d3e3dab736fbb4..3dc73a11d8d8ab9a3e97d243a3ab0284c5fc9cd6 100755
--- a/build.py
+++ b/build.py
@@ -369,10 +369,12 @@ def run_install(args):
         install_args.append('-s')
     if args.global_install:
         install_args.append('-g')
-    if args.prefix is not None:
+    if args.prefix:
         install_args += ('-P', args.prefix)
     if not args.priv_install:
         install_args.append('-u')
+    if args.debug:
+        install_args.append('-d')
 
     if args.distribution == OSX_DISTRIBUTION_NAME:
         # The `universal_newlines` parameter has been renamed to `text` in
@@ -396,6 +398,7 @@ def run_install(args):
             install_args += ("-q", args.qtver)
             install_args += ("-Q", args.qt)
 
+    print(f'info: Invoking scripts/install.sh with arguments: {install_args}')
     return subprocess.run(["./scripts/install.sh"] + install_args, env=environ, check=True)
 
 
@@ -498,8 +501,8 @@ def run_run(args):
 def run_stop(args):
     client_suffix = "qt" if (args.qt is not None) else "gnome"
     STOP_SCRIPT = [
-        'xargs kill < daemon.pid',
-        'xargs kill < jami-' + client_suffix + '.pid'
+        'xargs kill < jami-' + client_suffix + '.pid',
+        'xargs kill < daemon.pid'
     ]
     execute_script(STOP_SCRIPT)
 
@@ -586,7 +589,8 @@ def parse_args():
     ap.add_argument('--prefix')
     ap.add_argument('--static', default=False, action='store_true')
     ap.add_argument('--global-install', default=False, action='store_true')
-    ap.add_argument('--debug', default=False, action='store_true')
+    ap.add_argument('--debug', default=False, action='store_true',
+                    help='Build with debug support; run in GDB')
     ap.add_argument('--background', default=False, action='store_true')
     ap.add_argument('--no-priv-install', dest='priv_install',
                     default=True, action='store_false')
diff --git a/scripts/install.sh b/scripts/install.sh
index 7c4f90c0c9fd1006da361bfb34f0a33e0891ae4e..0a6bc4667d9d94c0c831d1cec7e4734ae2c64ac2 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -16,6 +16,7 @@ set -ex
 # Qt_MIN_VER required for client-qt
 QT5_MIN_VER="5.14"
 
+debug=
 global=false
 static=''
 client=''
@@ -23,7 +24,7 @@ qt5ver=''
 qt5path=''
 proc='1'
 priv_install=true
-while getopts gsc:q:Q:P:p:u OPT; do
+while getopts gsc:dq:Q:P:p:u OPT; do
   case "$OPT" in
     g)
       global='true'
@@ -34,6 +35,9 @@ while getopts gsc:q:Q:P:p:u OPT; do
     c)
       client="${OPTARG}"
     ;;
+    d)
+      debug=true
+    ;;
     q)
       qt5ver="${OPTARG}"
     ;;
@@ -78,22 +82,22 @@ else
 fi
 
 # dring
-cd "${TOP}/daemon"
-DAEMON="$(pwd)"
-cd contrib
-mkdir -p native
-cd native
-if [ "${prefix+set}" ]; then
-    ../bootstrap --prefix="${prefix}"
-else
-    ../bootstrap
-fi
-make
-cd "${DAEMON}"
+DAEMON=${TOP}/daemon
+cd "$DAEMON"
+
+# Build the contribs.
+mkdir -p contrib/native
+(
+    cd contrib/native
+    ../bootstrap ${prefix:+"--prefix=$prefix"} ${debug:+"--enable-debug"}
+    make -j"${proc}"
+)
+
+# Build the daemon itself.
 ./autogen.sh
 
-#keep shared Lib on MAC OSX
 if [[ "$OSTYPE" != "darwin"* ]]; then
+    # Keep the shared libaries on MAC OSX.
     sharedLib="--disable-shared"
 fi
 
@@ -109,7 +113,6 @@ fi
 make -j"${proc}"
 make_install "${global}" "${priv_install}"
 
-
 # For the client-qt, verify system's version if no path provided
 if [ "${client}" = "client-qt" ] && [ -z "$qt5path" ]; then
     sys_qt5ver=""