diff --git a/Makefile b/Makefile
index 771b655ba17d946135325cf891dd957b98e0fdc4..2d1080288eb2145ad9ee1ae1bd97f8868ea00b6c 100644
--- a/Makefile
+++ b/Makefile
@@ -779,9 +779,8 @@ distclean:: clean
 	@rm -f bin/*.dll bin/*.exp bin/*.lib bin/*.pdb \
                lib/*.def lib/*.exp lib/*.lib lib/*.dll.a \
                *.def .def
-ifeq ($(subst $(MACOSX_MINOR),,1234),1234)
+ifeq ($(PLATFORM),macosx)
 	@rm -f lib/*.dylib
-else
 	@rm -f lib/*.so
 endif
 	-@mv -f tutorials/gallery.root tutorials/gallery.root-