- Issue #23968: Rename the platform directory from plat-$(MACHDEP) to
  plat-$(PLATFORM_TRIPLET).
  Rename the config directory (LIBPL) from config-$(LDVERSION) to
  config-$(LDVERSION)-$(PLATFORM_TRIPLET).
  Install the platform specifc _sysconfigdata module into the platform
  directory and rename it to include the ABIFLAGS.
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index f205dca..e9cc4a9 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -242,6 +242,8 @@
         return os.path.join(_sys_home or project_base, "Makefile")
     lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
     config_file = 'config-{}{}'.format(get_python_version(), build_flags)
+    if hasattr(sys.implementation, '_multiarch'):
+        config_file += '-%s' % sys.implementation._multiarch
     return os.path.join(lib_dir, config_file, 'Makefile')
 
 
diff --git a/Lib/plat-linux/regen b/Lib/plat-linux/regen
index c76950e..10633cb 100755
--- a/Lib/plat-linux/regen
+++ b/Lib/plat-linux/regen
@@ -1,8 +1,33 @@
 #! /bin/sh
 case `uname` in
-Linux*)	;;
+Linux*|GNU*)	;;
 *)	echo Probably not on a Linux system 1>&2
 	exit 1;;
 esac
-set -v
-h2py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h
+if [ -z "$CC" ]; then
+    echo >&2 "$(basename $0): CC is not set"
+    exit 1
+fi
+headers="sys/types.h netinet/in.h dlfcn.h"
+incdirs="$(echo $($CC -v -E - < /dev/null 2>&1|awk '/^#include/, /^End of search/' | grep '^ '))"
+if [ -z "$incdirs" ]; then
+    incdirs="/usr/include"
+fi
+for h in $headers; do
+    absh=
+    for d in $incdirs; do
+	if [ -f "$d/$h" ]; then
+	    absh="$d/$h"
+	    break
+	fi
+    done
+    if [ -n "$absh" ]; then
+	absheaders="$absheaders $absh"
+    else
+	echo >&2 "$(basename $0): header $h not found"
+	exit 1
+    fi
+done
+
+set -x
+${H2PY:-h2py} -i '(u_long)' $absheaders
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index f18b1bc..ef53061 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -337,6 +337,8 @@
         config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags)
     else:
         config_dir_name = 'config'
+    if hasattr(sys.implementation, '_multiarch'):
+        config_dir_name += '-%s' % sys.implementation._multiarch
     return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
 
 def _generate_posix_vars():
@@ -379,7 +381,7 @@
     # _sysconfigdata module manually and populate it with the build vars.
     # This is more than sufficient for ensuring the subsequent call to
     # get_platform() succeeds.
-    name = '_sysconfigdata'
+    name = '_sysconfigdata_' + sys.abiflags
     if 'darwin' in sys.platform:
         import types
         module = types.ModuleType(name)
@@ -405,7 +407,9 @@
 def _init_posix(vars):
     """Initialize the module as appropriate for POSIX systems."""
     # _sysconfigdata is generated at build time, see _generate_posix_vars()
-    from _sysconfigdata import build_time_vars
+    name = '_sysconfigdata_' + sys.abiflags
+    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
+    build_time_vars = _temp.build_time_vars
     vars.update(build_time_vars)
 
 def _init_non_posix(vars):