diff -Nurd -x'*~' gnokii-0.6.31.orig/common/cfgreader.c gnokii-0.6.31/common/cfgreader.c
--- gnokii-0.6.31.orig/common/cfgreader.c	2011-12-02 09:53:04.000000000 -0500
+++ gnokii-0.6.31/common/cfgreader.c	2012-08-25 13:27:29.000000000 -0400
@@ -1039,7 +1039,7 @@
 	return config_file_locations;
 }
 #else /* WIN32 */
-#  ifdef __MACH__
+#  ifdef __MACH__NO_FINK_USES_XDG_BUT_WILL_ALSO_RESPECT_Library_Preferences
 /* Mac OS X version */
 static char **get_locations(int *retval)
 {
@@ -1069,7 +1069,7 @@
 #  else /* !__MACH__ */
 /* freedesktop.org compliancy: http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html */
 #define XDG_CONFIG_HOME	"/.config"	/* $HOME/.config */
-#define XDG_CONFIG_DIRS "/etc/xdg"
+#define XDG_CONFIG_DIRS "@FINKPREFIX@/etc/xdg"
 static char **get_locations(int *retval)
 {
 	char **config_file_locations = NULL;
@@ -1126,6 +1126,10 @@
 	config_file_locations = calloc(size, sizeof(char *));
 	config_file_locations[(*retval)++] = strdup(path);
 
+	/* 1a. $HOME/Library/Preferences/gnokii/config */
+	snprintf(path, MAX_PATH_LEN, "%s/Library/Preferences/gnokii/config", home);
+	config_file_locations[(*retval)++] = strdup(path);
+
 	/* old gnokii behaviour */
 	/* 2. $HOME/.gnokiirc */
 	snprintf(path, MAX_PATH_LEN, "%s/.gnokiirc", home);
diff -Nurd gnokii-0.6.31.orig/common/data/virtmodem.c gnokii-0.6.31/common/data/virtmodem.c
--- gnokii-0.6.31.orig/common/data/virtmodem.c	2011-12-02 09:53:04.000000000 -0500
+++ gnokii-0.6.31/common/data/virtmodem.c	2021-06-01 14:27:26.000000000 -0400
@@ -60,6 +60,8 @@
 #  include <sys/types.h>
 #endif
 
+/* _XOPEN_SOURCE 500 hides things we need */
+#include <string.h>
 /* This is the correct way to include stdlib with _XOPEN_SOURCE = 500 defined.
  * Needed for clean unlockpt() declaration.
  * msghdr structure in Solaris depends on _XOPEN_SOURCE = 500 too. - bozo
diff -Nurd -x'*~' gnokii-0.6.31.orig/configure gnokii-0.6.31/configure
--- gnokii-0.6.31.orig/configure	2011-12-02 09:54:03.000000000 -0500
+++ gnokii-0.6.31/configure	2012-08-25 15:39:43.000000000 -0400
@@ -17556,7 +17556,7 @@
    fi
 fi
 
- if test "x$_support" = "xyes"; then
+ if test "x$x_support" = "xyes"; then
   XGNOKII_TRUE=
   XGNOKII_FALSE='#'
 else
@@ -17811,6 +17811,7 @@
 fi
 
 have_postgres=no
+if test x$enable_postgres != xno; then
 # Extract the first word of "pg_config", so it can be a program name with args.
 set dummy pg_config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -17850,6 +17851,7 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
+fi
 
 
 if test x$enable_postgres != xno && test x$PGCONFIG != xno ; then
@@ -17972,6 +17974,7 @@
 fi
 
 have_mysql=no
+if test x$enable_mysql != xno; then
 # Extract the first word of "mysql_config5", so it can be a program name with args.
 set dummy mysql_config5; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -18058,6 +18061,7 @@
 else
 	MYSQLCONFIG=$MYSQLCONFIG5
 fi
+fi
 if test x$enable_mysql != xno && test x$MYSQLCONFIG != xno ; then
 	have_mysql=yes
 	MYSQL_LIBS=`$MYSQLCONFIG --libs`
diff -Nurd gnokii-0.6.31.orig/utils/mgnokiidev.c gnokii-0.6.31/utils/mgnokiidev.c
--- gnokii-0.6.31.orig/utils/mgnokiidev.c	2011-12-02 09:53:04.000000000 -0500
+++ gnokii-0.6.31/utils/mgnokiidev.c	2021-06-01 14:27:17.000000000 -0400
@@ -54,13 +54,14 @@
 #  include <sys/types.h>
 #endif
 
+/* _XOPEN_SOURCE 500 hides things we need */
+#include <string.h>
 /* See common/data/virtmodem.c for explanation */
 #define _XOPEN_SOURCE 500
 
 #include "misc.h"
 
 #include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>