diff -ruN grass-7.2.0-orig/aclocal.m4 grass-7.2.0/aclocal.m4
--- grass-7.2.0-orig/aclocal.m4	2017-04-22 08:00:46.000000000 +0900
+++ grass-7.2.0/aclocal.m4	2017-04-22 08:01:03.000000000 +0900
@@ -510,7 +510,7 @@
 	*-apple-darwin*)
 	    SHLIB_CFLAGS="-fno-common"
 	    SHLIB_SUFFIX=".dylib"
-	    SHLIB_LD="cc -dynamiclib -compatibility_version \${GRASS_VERSION_MAJOR}.\${GRASS_VERSION_MINOR} -current_version \${GRASS_VERSION_MAJOR}.\${GRASS_VERSION_MINOR} -install_name \${INST_DIR}/lib/lib\${LIB_NAME}\${SHLIB_SUFFIX}"
+	    SHLIB_LD="cc -dynamiclib -compatibility_version \${GRASS_VERSION_MAJOR}.\${GRASS_VERSION_MINOR} -current_version \${GRASS_VERSION_MAJOR}.\${GRASS_VERSION_MINOR} -install_name \${INST_DIR}/lib/lib\${LIB_NAME}\${SHLIB_SUFFIX}":${SHLIB}
 	    LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
 	    ;;
 	*-sun-solaris*)
diff -ruN grass-7.2.0-orig/configure grass-7.2.0/configure
--- grass-7.2.0-orig/configure	2016-03-28 17:19:33.000000000 -0400
+++ grass-7.2.0/configure	2021-07-04 23:29:59.000000000 -0400
@@ -3721,7 +3721,7 @@
 
 if test "$ac_x_includes" = NO; then
   # Guess where to find include files, by looking for this one X11 .h file.
-  test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
+  test -z "$x_direct_test_include" && x_direct_test_include=X11/Xlib.h
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
@@ -3774,6 +3774,7 @@
     /usr/athena/include       \
     /usr/local/x11r5/include  \
     /usr/lpp/Xamples/include  \
+    /opt/X11/include          \
                               \
     /usr/openwin/include      \
     /usr/openwin/share/include \
@@ -3791,8 +3792,8 @@
 if test "$ac_x_libraries" = NO; then
   # Check for the libraries.
 
-  test -z "$x_direct_test_library" && x_direct_test_library=Xt
-  test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
+  test -z "$x_direct_test_library" && x_direct_test_library=X11
+  test -z "$x_direct_test_function" && x_direct_test_function=XrmInitialize
 
   # See if we find them without any special options.
   # Don't add to $LIBS permanently.
@@ -3855,7 +3856,7 @@
     /usr/openwin/share/lib \
     ; \
 do
-  for ac_extension in a so sl; do
+  for ac_extension in dylib a so sl; do
     if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
       ac_x_libraries=$ac_dir
       break 2
@@ -9112,7 +9113,7 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  OPENGLLIB="$OPENGLLIB -lGL "
+  OPENGLLIB="$OPENGLLIB $X_LIBS -lGL "
 else
   echo "$ac_t""no" 1>&6
 
@@ -9148,7 +9149,7 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  OPENGLLIB="$OPENGLLIB -lGL -lXext"
+  OPENGLLIB="$OPENGLLIB $X_LIBS -lGL -lXext"
 else
   echo "$ac_t""no" 1>&6
 
@@ -9184,7 +9185,7 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  OPENGLLIB="$OPENGLLIB -lGL -lpthread"
+  OPENGLLIB="$OPENGLLIB $X_LIBS -lGL -lpthread"
 else
   echo "$ac_t""no" 1>&6
 
@@ -9220,7 +9221,7 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  OPENGLLIB="$OPENGLLIB -lGL -lpthread -lXext"
+  OPENGLLIB="$OPENGLLIB $X_LIBS -lGL -lpthread -lXext"
 else
   echo "$ac_t""no" 1>&6
 
@@ -9299,7 +9300,7 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  OPENGLULIB="$OPENGLULIB -lGLU "
+  OPENGLULIB="$OPENGLULIB $X_LIBS -lGLU "
 else
   echo "$ac_t""no" 1>&6
 
@@ -9335,7 +9336,7 @@
 
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  OPENGLULIB="$OPENGLULIB -lGLU -lstdc++"
+  OPENGLULIB="$OPENGLULIB $X_LIBS -lGLU -lstdc++"
 else
   echo "$ac_t""no" 1>&6
 
diff -ruN grass-7.2.0-orig/gui/wxpython/core/gcmd.py grass-7.2.0/gui/wxpython/core/gcmd.py
--- grass-7.2.0-orig/gui/wxpython/core/gcmd.py	2017-04-22 08:00:46.000000000 +0900
+++ grass-7.2.0/gui/wxpython/core/gcmd.py	2017-04-22 08:04:03.000000000 +0900
@@ -777,9 +777,7 @@
 
     :return: system encoding (can be None)
     """
-    enc = locale.getdefaultlocale()[1]
-    if forceUTF8 and (enc is None or enc == 'UTF8'):
-        return 'UTF-8'
+    return 'UTF-8'
 
     Debug.msg(1, "GetSystemEncoding(): %s" % enc)
     return enc
diff -ruN grass-7.2.0-orig/include/Make/Install.make grass-7.2.0/include/Make/Install.make
--- grass-7.2.0-orig/include/Make/Install.make	2017-04-22 08:00:47.000000000 +0900
+++ grass-7.2.0/include/Make/Install.make	2017-04-22 08:01:03.000000000 +0900
@@ -116,11 +116,6 @@
 	-$(INSTALL) config.status $(INST_DIR)/config.status
 	-$(CHMOD) -R a+rX $(INST_DIR) 2>/dev/null
 
-ifneq ($(findstring darwin,$(ARCH)),)
-	@# enable OSX Help Viewer
-	@/bin/ln -sfh "$(INST_DIR)/docs/html" /Library/Documentation/Help/GRASS-$(GRASS_VERSION_MAJOR).$(GRASS_VERSION_MINOR)
-endif
-
 $(INST_DIR) $(UNIX_BIN):
 	$(MAKE_DIR_CMD) $@
 
diff -ruN grass-7.2.0-orig/include/Make/Platform.make.in grass-7.2.0/include/Make/Platform.make.in
--- grass-7.2.0-orig/include/Make/Platform.make.in	2017-04-22 08:00:47.000000000 +0900
+++ grass-7.2.0/include/Make/Platform.make.in	2017-04-22 08:01:03.000000000 +0900
@@ -51,6 +51,7 @@
 STRIPFLAG           = @STRIPFLAG@
 LD_SEARCH_FLAGS     = @LD_SEARCH_FLAGS@
 LD_LIBRARY_PATH_VAR = @LD_LIBRARY_PATH_VAR@
+GRASS_LD_LIBRARY_PATH_VAR = @LD_LIBRARY_PATH_VAR@
 
 #generate static (ST) or shared (SH)
 GRASS_LIBRARY_TYPE  = @GRASS_LIBRARY_TYPE@
diff -ruN grass-7.2.0-orig/include/Make/Rules.make grass-7.2.0/include/Make/Rules.make
--- grass-7.2.0-orig/include/Make/Rules.make	2017-04-22 08:00:47.000000000 +0900
+++ grass-7.2.0/include/Make/Rules.make	2017-04-22 08:01:03.000000000 +0900
@@ -38,6 +38,7 @@
 	PATH="$(ARCH_DISTDIR)/bin:$(GISBASE)/bin:$(GISBASE)/scripts:$$PATH" \
 	PYTHONPATH="$(GRASS_PYTHONPATH)" \
 	$(LD_LIBRARY_PATH_VAR)="$(BIN):$(GISBASE)/bin:$(GISBASE)/scripts:$(ARCH_LIBDIR):$(BASE_LIBDIR):$($(LD_LIBRARY_PATH_VAR))" \
+	GRASS_LD_LIBRARY_PATH="$(BIN):$(GISBASE)/bin:$(GISBASE)/scripts:$(ARCH_LIBDIR):$(BASE_LIBDIR):$($(LD_LIBRARY_PATH_VAR))" \
 	LC_ALL=C \
 	$(1)
 
diff -ruN grass-7.2.0-orig/lib/init/grass.py grass-7.2.0/lib/init/grass.py
--- grass-7.2.0-orig/lib/init/grass.py	2017-04-22 08:00:47.000000000 +0900
+++ grass-7.2.0/lib/init/grass.py	2017-04-22 08:01:03.000000000 +0900
@@ -1114,8 +1114,7 @@
             ## TOO DRASTIC: sys.exit("Fix system locale settings and then try again.")
             locale.setlocale(locale.LC_ALL, 'C')
             warning(_("Default locale settings are missing. GRASS running with C locale."))
-
-        language, encoding = locale.getdefaultlocale()
+        
         if not language:
             warning(_("Default locale settings are missing. GRASS running with C locale."))
             return
@@ -1131,7 +1130,6 @@
                 # UTF-8 encoding before giving up as on Linux systems
                 # lang.UTF-8 locales are more common than legacy
                 # ISO-8859 ones.
-                encoding = 'UTF-8'
                 normalized = locale.normalize('%s.%s' % (language, encoding))
                 locale.setlocale(locale.LC_ALL, normalized)
             except locale.Error as e:
diff -ruN grass-7.2.0-orig/lib/nviz/Makefile grass-7.2.0/lib/nviz/Makefile
--- grass-7.2.0-orig/lib/nviz/Makefile	2014-07-22 03:23:39.000000000 -0400
+++ grass-7.2.0/lib/nviz/Makefile	2021-07-05 00:32:52.000000000 -0400
@@ -5,13 +5,13 @@
 include $(MODULE_TOPDIR)/include/Make/Lib.make
 include $(MODULE_TOPDIR)/include/Make/Doxygen.make
 
+EXTRA_CFLAGS = $(VECT_CFLAGS)
 ifneq ($(OPENGL_X11),)
 EXTRA_CFLAGS += $(XCFLAGS)
 endif
 
 EXTRA_INC = $(VECT_INC) $(OPENGLINC) $(TIFFINCPATH)
 
-EXTRA_CFLAGS = $(VECT_CFLAGS)
 
 ifneq ($(USE_OPENGL),)
 default: lib
diff -ruN grass-7.2.0-orig/lib/python/ctypes/loader.py grass-7.2.0/lib/python/ctypes/loader.py
--- grass-7.2.0-orig/lib/python/ctypes/loader.py	2017-04-22 08:00:47.000000000 +0900
+++ grass-7.2.0/lib/python/ctypes/loader.py	2017-04-22 08:05:52.000000000 +0900
@@ -143,7 +143,7 @@
                 '..',
                 'Frameworks'))
 
-        dirs.extend(dyld_fallback_library_path)
+        dirs.extend(_environ_path("GRASS_LD_LIBRARY_PATH"))
 
         return dirs
 
diff -ruN grass-7.2.0-orig/lib/python/script/utils.py grass-7.2.0/lib/python/script/utils.py
--- grass-7.2.0-orig/lib/python/script/utils.py	2017-04-22 08:00:47.000000000 +0900
+++ grass-7.2.0/lib/python/script/utils.py	2017-04-27 18:48:04.000000000 +0900
@@ -158,7 +158,10 @@
     :param bytes bytes_: the bytes to decode
     """
     if isinstance(bytes_, bytes):
-        enc = locale.getdefaultlocale()[1]
+        try:
+            enc = locale.getdefaultlocale()[1]
+        except:
+            enc = 'UTF-8'
         return bytes_.decode(enc) if enc else bytes_.decode()
     return bytes_
 
@@ -173,7 +176,10 @@
     """
     if isinstance(string, bytes):
         return string
-    enc = locale.getdefaultlocale()[1]
+    try:
+        enc = locale.getdefaultlocale()[1]
+    except:
+        enc = 'UTF-8'
     return string.encode(enc) if enc else string.encode()
 
 
diff -ruN grass-7.2.0-orig/macosx/app/grass.sh.in grass-7.2.0/macosx/app/grass.sh.in
--- grass-7.2.0-orig/macosx/app/grass.sh.in	2017-04-22 08:00:47.000000000 +0900
+++ grass-7.2.0/macosx/app/grass.sh.in	2017-04-27 18:47:34.000000000 +0900
@@ -20,6 +20,9 @@
 
 trap "echo 'User break!' ; exit" 2 3 9 15
 
+LC_ALL=$LANG
+export LC_ALL
+
 # dummy for now - just saying we're starting GRASS.app on OSX
 GRASS_OS_STARTUP="Mac.app"
 export GRASS_OS_STARTUP
@@ -32,11 +35,12 @@
 grass_ver=`cut -d . -f 1-2 "$GISBASE/etc/VERSIONNUMBER"`
 
 #override config dir.
-GRASS_CONFIG_DIR="Library/Preferences/GRASS/$grass_Ver"
+GRASS_CONFIG_DIR="Library/Preferences/GRASS/$grass_ver"
 
 GISBASE_USER="$HOME/Library/GRASS/$grass_ver"
 export GISBASE_USER
-GISBASE_SYSTEM="/Library/GRASS/$grass_ver"
+#GISBASE_SYSTEM="/Library/GRASS/$grass_ver"
+GISBASE_SYSTEM="@PREFIX@/Applications/GRASS@GUI@-$grass_ver.app/Contents/MacOS/lib"
 export GISBASE_SYSTEM
 
 # for extra utils
@@ -142,65 +146,18 @@
 # change GRASS_WXBUNDLED and pyver_want here from bundle.make, or manually
 GRASS_WXBUNDLED=
 export GRASS_WXBUNDLED
-pyexe="pythonw"
+#pyexe="pythonw"
 GRASS_PYTHONWX="$pyexe"
-pyver_want="@PYVER@"
+#pyver_want="@PYVER@"
 GRASS_WX64BIT="@WX64BIT@"
 export GRASS_WX64BIT
-# make sure python version used matches what wxpython wants
-py=""
-# did user set GRASS_PYTHON already? check it (must have pythonw)
-if [ "$GRASS_PYTHON" ] ; then
-	py=`echo "$GRASS_PYTHON" | grep pythonw`
-	if [ "$py" ] ; then
-		case $GRASS_PYTHON in
-			/*) py="$GRASS_PYTHON" ;;
-			*) py=`type -p $GRASS_PYTHON`
-		esac
-		pyver=`$py -V 2>&1 | grep " $pyver_want"`
-		if [ ! "$pyver" ] ; then
-			py=""
-		fi
-	else
-		py=""
-	fi
-fi # GRASS_PYTHON
-# try in shell path
-if [ ! "$py" ] ; then
-	py=`type -p pythonw$pyver_want`
-	if [ "$py" ] ; then
-		pyver=`$py -V 2>&1 | grep " $pyver_want"`
-		if [ ! "$pyver" ] ; then
-			py=""
-		fi
-	fi
-fi
-# try standard framework
-if [ ! "$py" ] ; then
-	py="/Library/Frameworks/Python.framework/Versions/$pyver_want/bin/python"
-	if [ ! -x "$py" ] ; then
-		py=""
-	fi
-fi
-# try system (may be the same as in shell path)
-if [ ! "$py" ] ; then
-	py="/usr/bin/pythonw$pyver_want"
-	pyver=`$py -V 2>&1 | grep " $pyver_want"`
-	if [ ! "$pyver" ] ; then
-		py=""
-	fi
-fi
 
-if [ "$py" ] ; then
-	echo "$pyver found."
-	GRASS_PYTHONWX="$py"
-else
-	echo "Warning: No Python $pyver_want found, needed by wxPython."
-	echo "         The wxPython GUI may not work properly."
-fi
+
+
+GRASS_PYTHONWX="@PREFIX@/bin/python@PY_VER@"
 export GRASS_PYTHONWX
 # we will execute python scripts from the python wrapper script
-GRASS_PYTHON="python"
+GRASS_PYTHON="@PREFIX@/bin/python@PY_VER@"
 export GRASS_PYTHON
 
 # if grassrc has text startup, switch back to Terminal (gotta duplicate some init.sh stuff)
diff -ruN grass-7.2.0-orig/misc/m.nviz.image/Makefile grass-7.2.0/misc/m.nviz.image/Makefile
--- grass-7.2.0-orig/misc/m.nviz.image/Makefile	2012-02-11 05:35:07.000000000 -0500
+++ grass-7.2.0/misc/m.nviz.image/Makefile	2021-07-05 01:11:36.000000000 -0400
@@ -1,6 +1,7 @@
 MODULE_TOPDIR = ../..
 
 PGM = m.nviz.image
+include $(MODULE_TOPDIR)/include/Make/Module.make
 
 EXTRA_INC = $(VECT_INC)
 EXTRA_CFLAGS = $(INC) \
@@ -15,7 +16,6 @@
 LIBES = $(GISLIB) $(OGSFLIB) $(NVIZLIB) $(VECTORLIB) $(DBMILIB)
 DEPENDENCIES = $(GISDEP) $(OGSFDEP) $(NVIZDEP) $(VECTORDEP) $(DBMIDEP)
 
-include $(MODULE_TOPDIR)/include/Make/Module.make
 
 ifneq ($(USE_OPENGL),)
 default: cmd
