See https://trac.macports.org/ticket/61454

--- configure.orig	2021-03-20 12:08:08.000000000 -0700
+++ configure	2021-03-20 12:08:37.000000000 -0700
@@ -9099,6 +9099,7 @@
   libreplace_cv_HAVE_MMAP=cross
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#include <stdlib.h>
 /* end confdefs.h.  */
 #include "$libreplacedir/test/shared_mmap.c"
 _ACEOF
@@ -9657,6 +9658,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <string.h>
 void foo(const char *format, ...) {
        va_list ap;
        int len;
@@ -10366,6 +10368,7 @@
 
 #include <sys/time.h>
 #include <unistd.h>
+#include <stdlib.h>
 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -11233,6 +11236,7 @@
   libreplace_cv_STRPTIME_OK="assuming not"
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#include <string.h>
 /* end confdefs.h.  */
 
 		#define LIBREPLACE_CONFIGURE_TEST_STRPTIME
@@ -11284,6 +11288,7 @@
 /* end confdefs.h.  */
 
 		#include <stdio.h>
+		#include <sys/stat.h>
 		#ifdef HAVE_DIRECT_H
 		#include <direct.h>
 		#endif
@@ -13159,6 +13164,8 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <netinet/in.h>
+#include <string.h>
+#include <stdlib.h>
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
 #endif
@@ -13717,6 +13724,7 @@
 #include <sys/types.h>
 #include <netdb.h>
 #include <netinet/in.h>
+#include <net/if.h>
 
 int
 main ()
@@ -15484,6 +15492,7 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <errno.h>
+#include <stdlib.h>
 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -15519,6 +15528,7 @@
 /* end confdefs.h.  */
 #include <unistd.h>
 #include <errno.h>
+#include <stdlib.h>
 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21442,6 +21452,7 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdio.h>
+#include <stdlib.h>
 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21534,6 +21545,7 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <time.h>
+#include <stdlib.h>
 main() { exit((sizeof(time_t) == 8) ? 0 : 1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21566,6 +21578,7 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <time.h>
+#include <stdlib.h>
 main() {
 	struct tm *tm;
 	if (sizeof(time_t) == 8) {
@@ -21616,6 +21629,7 @@
 /* end confdefs.h.  */
 #include <stdio.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21653,6 +21667,7 @@
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21690,6 +21705,7 @@
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21727,6 +21743,7 @@
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21764,6 +21781,7 @@
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21801,6 +21819,7 @@
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -22015,6 +22034,7 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdio.h>
+#include <stdlib.h>
 main() { char c; c=250; exit((c > 0)?0:1); }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -22118,6 +22138,7 @@
 /* end confdefs.h.  */
 #include <sys/types.h>
 #include <dirent.h>
+#include <stdlib.h>
 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
 di->d_name[0] == 0) exit(0); exit(1);}
@@ -22150,6 +22171,7 @@
 /* end confdefs.h.  */
 #include <sys/types.h>
 #include <utime.h>
+#include <stdlib.h>
 int
 main ()
 {
@@ -23246,6 +23268,7 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <stdlib.h>
 #ifndef F_NOTIFY
 #define F_NOTIFY 1026
 #endif
@@ -23879,6 +23902,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/file.h>
+#include <stdlib.h>
 #ifndef LOCK_MAND
 #define LOCK_MAND	32
 #define LOCK_READ	64
@@ -24313,6 +24337,7 @@
   samba_cv_HAVE_FTRUNCATE_EXTEND=cross
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#include <stdlib.h>
 /* end confdefs.h.  */
 #include "${srcdir-.}/../tests/ftruncate.c"
 _ACEOF
@@ -24344,6 +24369,7 @@
   samba_cv_HAVE_BROKEN_GETGROUPS=cross
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#include <stdlib.h>
 /* end confdefs.h.  */
 #include "${srcdir-.}/../tests/getgroups.c"
 _ACEOF
@@ -25048,6 +25074,7 @@
 #include <stdio.h>
 #include <limits.h>
 #include <signal.h>
+#include <stdlib.h>
 
 void exit_on_core(int ignored) {
 	exit(1);
@@ -33594,6 +33621,7 @@
 #endif
 #include <sys/types.h>
 #include <sys/statvfs.h>
+#include <stdlib.h>
   main ()
   {
     struct statvfs64 fsd;
@@ -35969,6 +35997,7 @@
   samba_cv_HAVE_BROKEN_READLINK=cross
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#include <stdlib.h>
 /* end confdefs.h.  */
 #include "${srcdir-.}/../tests/readlink.c"
 _ACEOF
