--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -43,7 +43,9 @@
 #define PY_OPENSSL_HAS_SCRYPT 1
 #define PY_OPENSSL_HAS_SHA3 1
 #define PY_OPENSSL_HAS_SHAKE 1
+#ifndef OPENSSL_NO_BLAKE2
 #define PY_OPENSSL_HAS_BLAKE2 1
+#endif
 
 static PyModuleDef _hashlibmodule;
 
