Taken from Debian, see
https://salsa.debian.org/debian/daemontools/-/blob/6b5584ccae6bd7c8cb6f47dd71062e3b1cd0a038/debian/patches/0005-fix-ftbfs.patch

From: =?utf-8?b?SmFuIE1vasW+w63FoQ==?= <jan.mojzis@gmail.com>
Date: Sat, 30 Mar 2024 10:15:13 +0100
Subject: fix ftbfs

Forwarded: no
---
 daemontools-0.76/src/chkshsgr.c     |  3 ++-
 daemontools-0.76/src/envdir.c       |  2 +-
 daemontools-0.76/src/envuidgid.c    |  2 +-
 daemontools-0.76/src/fghack.c       |  6 ++++--
 daemontools-0.76/src/matchtest.c    |  1 +
 daemontools-0.76/src/multilog.c     |  3 ++-
 daemontools-0.76/src/pathexec.h     |  4 ++--
 daemontools-0.76/src/pathexec_env.c |  6 +++---
 daemontools-0.76/src/pathexec_run.c |  3 ++-
 daemontools-0.76/src/pgrphack.c     |  2 +-
 daemontools-0.76/src/prot.c         |  4 +++-
 daemontools-0.76/src/seek_set.c     |  1 +
 daemontools-0.76/src/setlock.c      |  2 +-
 daemontools-0.76/src/setuidgid.c    |  2 +-
 daemontools-0.76/src/sgetopt.c      |  2 +-
 daemontools-0.76/src/sgetopt.h      |  2 +-
 daemontools-0.76/src/softlimit.c    |  2 +-
 daemontools-0.76/src/subgetopt.c    |  2 +-
 daemontools-0.76/src/subgetopt.h    |  2 +-
 daemontools-0.76/src/supervise.c    |  6 ++++--
 daemontools-0.76/src/svc.c          |  2 +-
 daemontools-0.76/src/svscan.c       |  2 +-
 daemontools-0.76/src/trycpp.c       |  3 +++
 daemontools-0.76/src/tryflock.c     |  2 +-
 daemontools-0.76/src/trypoll.c      |  1 +
 daemontools-0.76/src/trysgact.c     |  2 +-
 daemontools-0.76/src/trysgprm.c     |  2 +-
 daemontools-0.76/src/tryshsgr.c     | 13 ++++++++-----
 daemontools-0.76/src/tryulong64.c   |  5 ++++-
 daemontools-0.76/src/trywaitp.c     |  2 +-
 daemontools-0.76/src/uint64.h1      |  2 +-
 daemontools-0.76/src/uint64.h2      |  5 +++--
 daemontools-0.76/src/x86cpuid.c     |  2 ++
 33 files changed, 62 insertions(+), 38 deletions(-)

diff --git a/daemontools-0.76/src/chkshsgr.c b/daemontools-0.76/src/chkshsgr.c
index 38c352d..470f565 100644
--- a/daemontools-0.76/src/chkshsgr.c
+++ b/daemontools-0.76/src/chkshsgr.c
@@ -1,12 +1,13 @@
 /* Public domain. */
 
 #include <unistd.h>
+#include <grp.h>
 
 int main()
 {
   short x[4];
 
   x[0] = x[1] = 0;
-  if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
+  if (getgroups(1,(gid_t *)x) == 0) if (setgroups(1,(gid_t *)x) == -1) _exit(1);
   _exit(0);
 }
diff --git a/daemontools-0.76/src/envdir.c b/daemontools-0.76/src/envdir.c
index beb1b1f..d02bc63 100644
--- a/daemontools-0.76/src/envdir.c
+++ b/daemontools-0.76/src/envdir.c
@@ -21,7 +21,7 @@ void nomem(void)
 
 static stralloc sa;
 
-int main(int argc,const char *const *argv)
+int main(int argc,char **argv)
 {
   int fdorigdir;
   const char *fn;
diff --git a/daemontools-0.76/src/envuidgid.c b/daemontools-0.76/src/envuidgid.c
index 294960a..f097db1 100644
--- a/daemontools-0.76/src/envuidgid.c
+++ b/daemontools-0.76/src/envuidgid.c
@@ -15,7 +15,7 @@ char strnum[FMT_ULONG];
 const char *account;
 struct passwd *pw;
 
-int main(int argc,const char *const *argv)
+int main(int argc,char **argv)
 {
   account = *++argv;
   if (!account || !*++argv)
diff --git a/daemontools-0.76/src/fghack.c b/daemontools-0.76/src/fghack.c
index 34ca1db..262876a 100644
--- a/daemontools-0.76/src/fghack.c
+++ b/daemontools-0.76/src/fghack.c
@@ -9,12 +9,13 @@
 
 int pid;
 
-int main(int argc,const char * const *argv,const char * const *envp)
+int main(int argc,char **argv,char **envp)
 {
   char ch;
   int wstat;
   int pi[2];
   int i;
+  int dummy;
 
   if (!argv[1])
     strerr_die1x(100,"fghack: usage: fghack child");
@@ -28,7 +29,8 @@ int main(int argc,const char * const *argv,const char * const *envp)
     case 0:
       close(pi[0]);
       for (i = 0;i < 30;++i)
-        dup(pi[1]);
+        dummy = dup(pi[1]);
+        (void) dummy;
       pathexec_run(argv[1],argv + 1,envp);
       strerr_die4sys(111,FATAL,"unable to run ",argv[1],": ");
   }
diff --git a/daemontools-0.76/src/matchtest.c b/daemontools-0.76/src/matchtest.c
index 980dd1c..1bd4bbc 100644
--- a/daemontools-0.76/src/matchtest.c
+++ b/daemontools-0.76/src/matchtest.c
@@ -1,3 +1,4 @@
+#include <unistd.h>
 #include "match.h"
 #include "buffer.h"
 #include "str.h"
diff --git a/daemontools-0.76/src/multilog.c b/daemontools-0.76/src/multilog.c
index be27a6a..ea02909 100644
--- a/daemontools-0.76/src/multilog.c
+++ b/daemontools-0.76/src/multilog.c
@@ -1,6 +1,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <stdio.h>
 #include "direntry.h"
 #include "alloc.h"
 #include "buffer.h"
@@ -172,7 +173,7 @@ void finish(struct cyclog *d,const char *file,const char *code)
 
 void startprocessor(struct cyclog *d)
 {
-  const char *args[4];
+  char *args[4];
   int fd;
 
   sig_uncatch(sig_term);
diff --git a/daemontools-0.76/src/pathexec.h b/daemontools-0.76/src/pathexec.h
index 61da922..f984f77 100644
--- a/daemontools-0.76/src/pathexec.h
+++ b/daemontools-0.76/src/pathexec.h
@@ -3,8 +3,8 @@
 #ifndef PATHEXEC_H
 #define PATHEXEC_H
 
-extern void pathexec_run(const char *,const char * const *,const char * const *);
+extern void pathexec_run(const char *,char **,char **);
 extern int pathexec_env(const char *,const char *);
-extern void pathexec(const char * const *);
+extern void pathexec(char **);
 
 #endif
diff --git a/daemontools-0.76/src/pathexec_env.c b/daemontools-0.76/src/pathexec_env.c
index 2cb101c..a1404ad 100644
--- a/daemontools-0.76/src/pathexec_env.c
+++ b/daemontools-0.76/src/pathexec_env.c
@@ -22,9 +22,9 @@ int pathexec_env(const char *s,const char *t)
   return stralloc_cat(&plus,&tmp);
 }
 
-void pathexec(const char *const *argv)
+void pathexec(char **argv)
 {
-  const char **e;
+  char **e;
   unsigned int elen;
   unsigned int i;
   unsigned int j;
@@ -40,7 +40,7 @@ void pathexec(const char *const *argv)
     if (!plus.s[i])
       ++elen;
 
-  e = (const char **) alloc((elen + 1) * sizeof(char *));
+  e = (char **) alloc((elen + 1) * sizeof(char *));
   if (!e) return;
 
   elen = 0;
diff --git a/daemontools-0.76/src/pathexec_run.c b/daemontools-0.76/src/pathexec_run.c
index 1770ac7..7929144 100644
--- a/daemontools-0.76/src/pathexec_run.c
+++ b/daemontools-0.76/src/pathexec_run.c
@@ -1,5 +1,6 @@
 /* Public domain. */
 
+#include <unistd.h>
 #include "error.h"
 #include "stralloc.h"
 #include "str.h"
@@ -8,7 +9,7 @@
 
 static stralloc tmp;
 
-void pathexec_run(const char *file,const char * const *argv,const char * const *envp)
+void pathexec_run(const char *file,char **argv,char **envp)
 {
   const char *path;
   unsigned int split;
diff --git a/daemontools-0.76/src/pgrphack.c b/daemontools-0.76/src/pgrphack.c
index 9aa10dc..6b06a84 100644
--- a/daemontools-0.76/src/pgrphack.c
+++ b/daemontools-0.76/src/pgrphack.c
@@ -4,7 +4,7 @@
 
 #define FATAL "pgrphack: fatal: "
 
-int main(int argc,const char * const *argv,const char * const *envp)
+int main(int argc,char **argv,char **envp)
 {
   if (!argv[1]) strerr_die1x(100,"pgrphack: usage: pgrphack child");
   setsid(); /* shouldn't fail; if it does, too bad */
diff --git a/daemontools-0.76/src/prot.c b/daemontools-0.76/src/prot.c
index 79a88c5..45af0ef 100644
--- a/daemontools-0.76/src/prot.c
+++ b/daemontools-0.76/src/prot.c
@@ -1,5 +1,7 @@
 /* Public domain. */
 
+#include <unistd.h>
+#include <grp.h>
 #include "hasshsgr.h"
 #include "prot.h"
 
@@ -8,7 +10,7 @@ int prot_gid(int gid)
 #ifdef HASSHORTSETGROUPS
   short x[2];
   x[0] = gid; x[1] = 73; /* catch errors */
-  if (setgroups(1,x) == -1) return -1;
+  if (setgroups(1,(gid_t *)x) == -1) return -1;
 #else
   if (setgroups(1,&gid) == -1) return -1;
 #endif
diff --git a/daemontools-0.76/src/seek_set.c b/daemontools-0.76/src/seek_set.c
index 19b8265..5299201 100644
--- a/daemontools-0.76/src/seek_set.c
+++ b/daemontools-0.76/src/seek_set.c
@@ -1,5 +1,6 @@
 /* Public domain. */
 
+#include <unistd.h>
 #include <sys/types.h>
 #include "seek.h"
 
diff --git a/daemontools-0.76/src/setlock.c b/daemontools-0.76/src/setlock.c
index eec2192..d900540 100644
--- a/daemontools-0.76/src/setlock.c
+++ b/daemontools-0.76/src/setlock.c
@@ -14,7 +14,7 @@ void usage() {
 int flagndelay = 0;
 int flagx = 0;
 
-int main(int argc,const char *const *argv,const char *const *envp)
+int main(int argc,char **argv,char **envp)
 {
   int opt;
   int fd;
diff --git a/daemontools-0.76/src/setuidgid.c b/daemontools-0.76/src/setuidgid.c
index 8c683de..90485e9 100644
--- a/daemontools-0.76/src/setuidgid.c
+++ b/daemontools-0.76/src/setuidgid.c
@@ -9,7 +9,7 @@
 const char *account;
 struct passwd *pw;
 
-int main(int argc,const char *const *argv,const char *const *envp)
+int main(int argc,char **argv,char **envp)
 {
   account = *++argv;
   if (!account || !*++argv)
diff --git a/daemontools-0.76/src/sgetopt.c b/daemontools-0.76/src/sgetopt.c
index 8bb608f..1d6d9f4 100644
--- a/daemontools-0.76/src/sgetopt.c
+++ b/daemontools-0.76/src/sgetopt.c
@@ -27,7 +27,7 @@ Documentation in sgetopt.3.
 int opterr = 1;
 const char *optprogname = 0;
 
-int getopt(int argc,const char *const *argv,const char *opts)
+int getopt(int argc,char **argv,const char *opts)
 {
   int c;
   const char *s;
diff --git a/daemontools-0.76/src/sgetopt.h b/daemontools-0.76/src/sgetopt.h
index bf8bce6..6a6e111 100644
--- a/daemontools-0.76/src/sgetopt.h
+++ b/daemontools-0.76/src/sgetopt.h
@@ -16,7 +16,7 @@
 
 #include "subgetopt.h"
 
-extern int sgetoptmine(int,const char *const *,const char *);
+extern int sgetoptmine(int,char **,const char *);
 extern int sgetopterr;
 extern const char *sgetoptprogname;
 
diff --git a/daemontools-0.76/src/softlimit.c b/daemontools-0.76/src/softlimit.c
index 8be40b8..4d9f81e 100644
--- a/daemontools-0.76/src/softlimit.c
+++ b/daemontools-0.76/src/softlimit.c
@@ -36,7 +36,7 @@ void doit(int resource,const char *arg)
     strerr_die2sys(111,FATAL,"setrlimit failed: ");
 }
 
-int main(int argc,const char *const *argv,const char *const *envp)
+int main(int argc,char **argv,char **envp)
 {
   int opt;
 
diff --git a/daemontools-0.76/src/subgetopt.c b/daemontools-0.76/src/subgetopt.c
index 266e72a..bbbbb6c 100644
--- a/daemontools-0.76/src/subgetopt.c
+++ b/daemontools-0.76/src/subgetopt.c
@@ -16,7 +16,7 @@ const char *optarg = 0;
 int optproblem = 0;
 int optdone = SUBGETOPTDONE;
 
-int sgopt(int argc,const char *const *argv,const char *opts)
+int sgopt(int argc,char **argv,const char *opts)
 {
   int c;
   const char *s;
diff --git a/daemontools-0.76/src/subgetopt.h b/daemontools-0.76/src/subgetopt.h
index 41ad26a..7e5636e 100644
--- a/daemontools-0.76/src/subgetopt.h
+++ b/daemontools-0.76/src/subgetopt.h
@@ -15,7 +15,7 @@
 
 #define SUBGETOPTDONE -1
 
-extern int subgetopt(int,const char *const *,const char *);
+extern int subgetopt(int,char **,const char *);
 extern const char *subgetoptarg;
 extern int subgetoptind;
 extern int subgetoptpos;
diff --git a/daemontools-0.76/src/supervise.c b/daemontools-0.76/src/supervise.c
index 483e9a2..3a27f42 100644
--- a/daemontools-0.76/src/supervise.c
+++ b/daemontools-0.76/src/supervise.c
@@ -2,6 +2,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <signal.h>
+#include <stdio.h>
 #include "sig.h"
 #include "strerr.h"
 #include "error.h"
@@ -81,10 +82,11 @@ void announce(void)
 
 void trigger(void)
 {
-  write(selfpipe[1],"",1);
+  int dummy = write(selfpipe[1],"",1);
+  (void) dummy;
 }
 
-const char *run[2] = { "./run", 0 };
+char *run[2] = { "./run", 0 };
 
 int flagfailed = 0;
 
diff --git a/daemontools-0.76/src/svc.c b/daemontools-0.76/src/svc.c
index 08e9a5c..aae2d9d 100644
--- a/daemontools-0.76/src/svc.c
+++ b/daemontools-0.76/src/svc.c
@@ -19,7 +19,7 @@ char bspace[1];
 
 int fdorigdir;
 
-int main(int argc,const char *const *argv)
+int main(int argc,char **argv)
 {
   int opt;
   int fd;
diff --git a/daemontools-0.76/src/svscan.c b/daemontools-0.76/src/svscan.c
index 15a8c89..39b8887 100644
--- a/daemontools-0.76/src/svscan.c
+++ b/daemontools-0.76/src/svscan.c
@@ -36,7 +36,7 @@ void start(char *fn)
   struct stat st;
   int child;
   int i;
-  const char *args[3];
+  char *args[3];
 
   if (fn[0] == '.') return;
 
diff --git a/daemontools-0.76/src/trycpp.c b/daemontools-0.76/src/trycpp.c
index e4503d4..70bc8d6 100644
--- a/daemontools-0.76/src/trycpp.c
+++ b/daemontools-0.76/src/trycpp.c
@@ -1,5 +1,8 @@
 /* Public domain. */
 
+#include <stdio.h>
+#include <stdlib.h>
+
 int main()
 {
 #ifdef NeXT
diff --git a/daemontools-0.76/src/tryflock.c b/daemontools-0.76/src/tryflock.c
index a82ffc2..68599d3 100644
--- a/daemontools-0.76/src/tryflock.c
+++ b/daemontools-0.76/src/tryflock.c
@@ -4,7 +4,7 @@
 #include <sys/file.h>
 #include <fcntl.h>
 
-main()
+int main()
 {
   flock(0,LOCK_EX | LOCK_UN | LOCK_NB);
 }
diff --git a/daemontools-0.76/src/trypoll.c b/daemontools-0.76/src/trypoll.c
index 6506617..a7b26df 100644
--- a/daemontools-0.76/src/trypoll.c
+++ b/daemontools-0.76/src/trypoll.c
@@ -3,6 +3,7 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <poll.h>
+#include <unistd.h>
 
 int main()
 {
diff --git a/daemontools-0.76/src/trysgact.c b/daemontools-0.76/src/trysgact.c
index e264ef2..841b88a 100644
--- a/daemontools-0.76/src/trysgact.c
+++ b/daemontools-0.76/src/trysgact.c
@@ -2,7 +2,7 @@
 
 #include <signal.h>
 
-main()
+int main()
 {
   struct sigaction sa;
   sa.sa_handler = 0;
diff --git a/daemontools-0.76/src/trysgprm.c b/daemontools-0.76/src/trysgprm.c
index a46c82c..3e78a82 100644
--- a/daemontools-0.76/src/trysgprm.c
+++ b/daemontools-0.76/src/trysgprm.c
@@ -2,7 +2,7 @@
 
 #include <signal.h>
 
-main()
+int main()
 {
   sigset_t ss;
  
diff --git a/daemontools-0.76/src/tryshsgr.c b/daemontools-0.76/src/tryshsgr.c
index c5ed6d6..ba298a7 100644
--- a/daemontools-0.76/src/tryshsgr.c
+++ b/daemontools-0.76/src/tryshsgr.c
@@ -1,16 +1,19 @@
 /* Public domain. */
 
+#include <unistd.h>
+#include <grp.h>
+
 int main()
 {
   short x[4];
- 
+
   x[0] = x[1] = 1;
-  if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
- 
-  if (getgroups(1,x) == -1) _exit(1);
+  if (getgroups(1,(gid_t *)x) == 0) if (setgroups(1,(gid_t *)x) == -1) _exit(1);
+
+  if (getgroups(1,(gid_t *)x) == -1) _exit(1);
   if (x[1] != 1) _exit(1);
   x[1] = 2;
-  if (getgroups(1,x) == -1) _exit(1);
+  if (getgroups(1,(gid_t *)x) == -1) _exit(1);
   if (x[1] != 2) _exit(1);
   _exit(0);
 }
diff --git a/daemontools-0.76/src/tryulong64.c b/daemontools-0.76/src/tryulong64.c
index 003548a..f3b111d 100644
--- a/daemontools-0.76/src/tryulong64.c
+++ b/daemontools-0.76/src/tryulong64.c
@@ -1,8 +1,11 @@
 /* Public domain. */
 
+#include <unistd.h>
+#include <stdint.h>
+
 int main()
 {
-  unsigned long u;
+  uint64_t u;
   u = 1;
   u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
   u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
diff --git a/daemontools-0.76/src/trywaitp.c b/daemontools-0.76/src/trywaitp.c
index 319b81f..76b3329 100644
--- a/daemontools-0.76/src/trywaitp.c
+++ b/daemontools-0.76/src/trywaitp.c
@@ -3,7 +3,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-main()
+int main()
 {
   waitpid(0,0,0);
 }
diff --git a/daemontools-0.76/src/uint64.h1 b/daemontools-0.76/src/uint64.h1
index 486a380..fde25ca 100644
--- a/daemontools-0.76/src/uint64.h1
+++ b/daemontools-0.76/src/uint64.h1
@@ -3,7 +3,7 @@
 #ifndef UINT64_H
 #define UINT64_H
 
-/* sysdep: -ulong64 */
+/* sysdep: -uint64_t */
 
 typedef unsigned long long uint64;
 
diff --git a/daemontools-0.76/src/uint64.h2 b/daemontools-0.76/src/uint64.h2
index 8869e43..fd134f2 100644
--- a/daemontools-0.76/src/uint64.h2
+++ b/daemontools-0.76/src/uint64.h2
@@ -3,8 +3,9 @@
 #ifndef UINT64_H
 #define UINT64_H
 
-/* sysdep: +ulong64 */
+/* sysdep: +uint64_t */
 
-typedef unsigned long uint64;
+#include <stdint.h>
+typedef uint64_t uint64;
 
 #endif
diff --git a/daemontools-0.76/src/x86cpuid.c b/daemontools-0.76/src/x86cpuid.c
index f81c593..122eed1 100644
--- a/daemontools-0.76/src/x86cpuid.c
+++ b/daemontools-0.76/src/x86cpuid.c
@@ -1,6 +1,8 @@
 /* Public domain. */
 
 #include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
 
 void nope()
 {
