diff --git a/build/unix/makelib.sh b/build/unix/makelib.sh
index cfaed3a..cf03bdd 100755
--- a/build/unix/makelib.sh
+++ b/build/unix/makelib.sh
@@ -33,11 +33,7 @@ rm -f $LIB

 if [ $PLATFORM = "macosx" ]; then
    macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
-   if [ $macosx_minor -ge 5 ]; then
-      soext="so"
-   else
-      soext="dylib"
-   fi
+   soext="dylib"
 elif [ $PLATFORM = "aix" ] || [ $PLATFORM = "aix5" ]; then
    soext="a"
 else
@@ -220,7 +216,7 @@ if [ "x$MAJOR" != "x" ]; then
        ln -fs $SONAME.$MAJOR        $LIB
     elif [ -f $LIBVERS ]; then
         # Versioned library has format foo.3.05.so
-        source_file=`echo $SONAME | sed "s/.*\./&${MINOR}./"`
+        source_file=`basename $SONAME | sed "s/.*\./&${MINOR}./"`
         LIBNOMAJORMINOR=`echo $LIB|sed 's,\.'$MAJOR'\.'$MINOR',,'`
         if [ $LIB != $LIBNOMAJORMINOR ]; then
            LIBNOMINOR=`echo $LIB|sed 's,\.'$MINOR',,'`
diff --git a/cint/ROOT/cintdlls.mk b/cint/ROOT/cintdlls.mk
index fb3a6d9..1685d4b 100644
--- a/cint/ROOT/cintdlls.mk
+++ b/cint/ROOT/cintdlls.mk
@@ -141,7 +141,7 @@ ifneq ($(SOEXT),dll)
 CINTDLLSOEXTCMD = mv $(@:.dll=.$(SOEXT)) $@
 ifeq ($(PLATFORM),macosx)
   # On macosx one should change the install_name as well.
-  CINTDLLSOEXTCMD += ;install_name_tool -id `otool -D $@ | tail -1 | sed -e's|:$$||;s|[.]so$$|.dll|'` $@
+  CINTDLLSOEXTCMD += ;install_name_tool -id `otool -D $@ | tail -n 1 | sed -e's|:$$||;s|[.]so$$|.dll|'` $@
   CINTDLLSOEXTCMD += ;rm -f $(@:.dll=.so)
 endif # macosx
 endif # need to mv to .dll
@@ -157,14 +157,14 @@ endif
 $(ALLCINTDLLS): $(ORDER_) $(MAINLIBS)

 $(CINTDLLDIRSTL)/%.dll: $(CINTDLLDIRDLLSTL)/G__cpp_%.o
-	@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" "$(SOFLAGS)" $(notdir $(@:.dll=.$(SOEXT))) $(@:.dll=.$(SOEXT)) "$(filter-out $(MAINLIBS),$^)" "$(CINTDLLLIBLINK)"
+	@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" "$(SOFLAGS)" $(@:.dll=.$(SOEXT)) $(@:.dll=.$(SOEXT)) "$(filter-out $(MAINLIBS),$^)" "$(CINTDLLLIBLINK)"
 	$(CINTDLLSOEXTCMD)
 ifneq ($(subst win,,$(ARCH)),$(ARCH))
 	@rm -f $(@:.dll=.lib) $(@:.dll=.exp) # remove import libs
 endif

 $(CINTDLLDIRDLLS)/stdcxxfunc.dll: $(CINTDLLDIRL)/G__cpp_stdcxxfunc.o
-	@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" "$(SOFLAGS)" $(notdir $(@:.dll=.$(SOEXT))) $(@:.dll=.$(SOEXT)) "$(filter-out $(MAINLIBS),$^)" "$(CINTDLLLIBLINK)"
+	@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" "$(SOFLAGS)" $(@:.dll=.$(SOEXT)) $(@:.dll=.$(SOEXT)) "$(filter-out $(MAINLIBS),$^)" "$(CINTDLLLIBLINK)"
 	$(CINTDLLSOEXTCMD)
 ifneq ($(subst win,,$(ARCH)),$(ARCH))
 	@rm -f $(@:.dll=.lib) $(@:.dll=.exp) # remove import libs
@@ -175,7 +175,7 @@ RemoveLinkerWarning := 2>&1 | grep -v -e 'G__c_stdfunc.o: In function' -e 'warni
 endif

 $(CINTDLLDIRDLLS)/%.dll: $(CINTDLLDIRL)/G__c_%.o
-	@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" "$(SOFLAGS)" $(notdir $(@:.dll=.$(SOEXT))) $(@:.dll=.$(SOEXT)) "$(filter-out $(MAINLIBS),$^)" "$(CINTDLLLIBLINK)" $(RemoveLinkerWarning)
+	@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" "$(SOFLAGS)" $(@:.dll=.$(SOEXT)) $(@:.dll=.$(SOEXT)) "$(filter-out $(MAINLIBS),$^)" "$(CINTDLLLIBLINK)" $(RemoveLinkerWarning)
 	$(CINTDLLSOEXTCMD)

 core/metautils/src/stlLoader_%.cc: $(ROOT_SRCDIR)/core/metautils/src/stlLoader.cc
diff --git a/cint/configure b/cint/configure
index 980bf2d..fb007fd 100755
--- a/cint/configure
+++ b/cint/configure
@@ -165,7 +165,7 @@ function config_macos {
     AR="ar -r -cs "
     IMPLIBEXT=.dylib

-    MAKEIMPLIB="ln -sf @so@ @imp@"
+    MAKEIMPLIB="ln -sf `basename @so@` @imp@"

     EXPLLINK=1

diff --git a/cint/reflex/python/genreflex/genreflex.py b/cint/reflex/python/genreflex/genreflex.py
index c0d03c1..24b3eff 100644
--- a/cint/reflex/python/genreflex/genreflex.py
+++ b/cint/reflex/python/genreflex/genreflex.py
@@ -287,9 +287,9 @@ class genreflex:
         break
     bcomp = os.path.basename(compiler)
     vopt = ''
-    if   bcomp in ('msvc7','msvc71','msvc8')  : return s
-    elif bcomp in ('gcc','g++','c++','icpc') or re.match(r'lcg-g\+\+', bcomp): vopt = '--version'
-    elif bcomp in ('cl.exe','cl')     : vopt = '' # there is no option to print only the version with cl
+    if   bcomp.startswith('msvc') : vopt = 'ms'
+    elif bcomp.startswith('gcc') or bcomp.startswith('g++') or bcomp.startswith('c++') : vopt = '--version'
+    elif bcomp.startswith('cl') : vopt = '' # there is no option to print only the version with cl
     else :
       print '--->> genreflex: WARNING: While trying to retrieve compiler version, found unknown compiler %s' % compiler
       return s
diff --git a/config/Makefile.macosx64 b/config/Makefile.macosx64
index 8ee0d8b..2513ef7 100644
--- a/rooconfig/Makefile.macosx64
+++ b/config/Makefile.macosx64
@@ -76,7 +76,7 @@
 SOFLAGS       = -dynamiclib -single_module -Wl,-dead_strip_dylibs \
                 -install_name $(LIBDIR)/
 endif
-SOEXT         = so
+SOEXT         = dylib
 
 # System libraries:
 SYSLIBS       = -lm $(OSTHREADLIBDIR) \
diff -Nurd root.orig/configure root/configure
--- root.orig/configure	2018-03-12 10:48:57.000000000 -0400
+++ root/configure	2021-01-17 22:32:34.000000000 -0500
@@ -2680,8 +2680,8 @@
         message "Checking for system OSX SDK"
         osxsdk=""
     fi
-    openglincdir=${osxsdk}/System/Library/Frameworks/OpenGL.framework/Headers
-    opengllibdir=${osxsdk}/System/Library/Frameworks/OpenGL.framework/Libraries
+#    openglincdir=${osxsdk}/System/Library/Frameworks/OpenGL.framework/Headers
+#    opengllibdir=${osxsdk}/System/Library/Frameworks/OpenGL.framework/Libraries
     if [ -d $openglincdir ] && [ -d $opengllibdir ]; then
         result "yes"
     else
@@ -2792,12 +2792,6 @@
         result "See http://root.cern.ch/drupal/content/build-prerequisites"
         exit 1
     fi
-    if test "x$platform" = "xmacosx" &&
-       test ! "x$x11libdir" = "x$found_dir" ; then
-        result "`basename $0`: libXft not in same directory as libX11"
-        result "For consistency they should be in the same directory"
-        exit 1
-    fi
 
     check_library "libXext" "$enable_shared" "$xextlibdir" \
         ${finkdir:+$finkdir/lib} \
@@ -2810,12 +2804,6 @@
         result "See http://root.cern.ch/drupal/content/build-prerequisites"
         exit 1
     fi
-    if test "x$platform" = "xmacosx" &&
-       test ! "x$x11libdir" = "x$found_dir" ; then
-        result "`basename $0`: libXext not in same directory as libX11"
-        result "For consistency they should be in the same directory"
-        exit 1
-    fi
 else
     x11libdir=""
     xpmlibdir=""
@@ -3108,7 +3096,7 @@
         enable_builtin_lz4=yes
     else
         lz4inc=$found_hdr
-        lz4incdir+=$lz4incdir:$xxhashincdir
+        lz4incdir="$lz4incdir $xxhashincdir"
     fi
 
     check_library "liblz4" "$enable_shared" "" \
@@ -3200,7 +3188,7 @@
         glewinc="$found_hdr"
         glewincdir="$found_dir"
 
-        check_library "libGLEW" "$enable_shared" "$keep" $opengllibdirs
+        check_library "libGLEW" "$enable_shared" "$glewlibdir" $opengllibdirs
         glewlib="$found_lib"
         glewlibdir=$found_dir
         glewlibs="$glewlib"
@@ -4031,7 +4019,7 @@
 
     # At this time, libfftw3.a should always be prefered over .so,
     # to avoid forcing users to install fftw3.
-    check_library "libfftw3 libfftw3-3" "no" "$fftw3libdir" \
+    check_library "libfftw3 libfftw3-3" "yes" "$fftw3libdir" \
         $FFTW3 ${FFTW3:+$FFTW3/lib} ${FFTW3:+$FFTW3/.libs} \
         ${finkdir:+$finkdir/lib} \
         /usr/local/lib /usr/lib /opt/fftw3/lib
diff --git a/etc/Makefile.arch b/etc/Makefile.arch
index 04c598e..ae9bea6 100644
--- a/etc/Makefile.arch
+++ b/etc/Makefile.arch
@@ -7,8 +7,9 @@
 # Author: Fons Rademakers, 29/2/2000

 RC           := root-config
-ifneq ($(shell which $(RC) 2>&1 | sed -ne "s@.*/$(RC)@$(RC)@p"),$(RC))
-ifneq ($(ROOTSYS),)
+RCCOMMAND    := $(firstword $(RC))
+ifneq ($(shell which $(RCCOMMAND) 2>&1 | sed -ne "s@.*/$(RCCOMMAND)@$(RCCOMMAND)@p"),$(RCCOMMAND))
+ifneq ($(ROOTSYS)
 RC1          := $(ROOTSYS)/bin/root-config
 ifneq ($(shell which $(RC1) 2>&1 | sed -ne "s@.*/$(RC)@$(RC)@p"),$(RC))
 $(error Please make sure $(RC1) can be found in path)
@@ -16,7 +17,7 @@ else
 RC           := $(RC1)
 endif
 else
-$(error Please make sure $(RC) can be found in path)
+$(error Please make sure $(RCCOMMAND) can be found in path)
 endif
 endif

diff --git a/graf3d/gl/Module.mk b/graf3d/gl/Module.mk
index b535978..d27bc35 100644
--- a/graf3d/gl/Module.mk
+++ b/graf3d/gl/Module.mk
@@ -108,8 +108,8 @@ $(GLO) $(GLDO): CXXFLAGS += $(OPENGLINCDIR:%=-I%) -I$(WIN32GDKDIR)/gdk/src \
 $(GLDS):        CINTFLAGS += $(OPENGLINCDIR:%=-I%) -I$(WIN32GDKDIR)/gdk/src \
                              $(GDKDIRI:%=-I%) $(GLIBDIRI:%=-I%)
 else
-$(GLO) $(GLDO): CXXFLAGS += $(OPENGLINCDIR:%=-I%)
-$(GLDS):        CINTFLAGS += $(OPENGLINCDIR:%=-I%)
+$(GLO) $(GLDO): CXXFLAGS += $(OPENGLINCDIR:%=-I%) $(X11INCDIR:%=-I%)
+$(GLDS):        CINTFLAGS += $(OPENGLINCDIR:%=-I%) $(X11INCDIR:%=-I%)
 endif

 $(call stripsrc,$(GLDIRS)/TGLText.o): $(FREETYPEDEP)
diff --git a/graf3d/glew/Module.mk b/graf3d/glew/Module.mk
index fe509b1..f53cb45 100644
--- a/graf3d/glew/Module.mk
+++ b/graf3d/glew/Module.mk
@@ -62,4 +62,4 @@ distclean-$(MODNAME): clean-$(MODNAME)
 distclean::     distclean-$(MODNAME)

 ##### extra rules ######
-$(GLEWO):     CFLAGS += $(OPENGLINCDIR:%=-I%)
+$(GLEWO):     CFLAGS += $(OPENGLINCDIR:%=-I%) $(X11INCDIR:%=-I%)
diff --git a/proof/afdsmgrd/Module.mk b/proof/afdsmgrd/Module.mk
index 9333c9e..3d92790 100644
--- a/proof/afdsmgrd/Module.mk
+++ b/proof/afdsmgrd/Module.mk
@@ -8,7 +8,7 @@ MODDIR       := $(ROOT_SRCDIR)/proof/$(MODNAME)

 AFDSMGRDDIR  := $(MODDIR)
 AFDSMGRDBIN  := bin/afdsmgrd
-AFDSMGRDTAR  := $(shell cd $(AFDSMGRDDIR) && ls -1 afdsmgrd-v*.tar.gz | tail -1)
+AFDSMGRDTAR  := $(shell cd $(AFDSMGRDDIR) && ls -1 afdsmgrd-v*.tar.gz | tail -n 1)

 AFDSMGRDPREP   := $(AFDSMGRDDIR)/afdsmgrdPrepare
 AFDSMGRDINST   := $(AFDSMGRDDIR)/afdsmgrdInstall
