In openssl 1.0.1e EC_GROUP_new_curve_GF2m function is wrapped by #ifndef OPENSSL_NO_EC2M.
We have to check whether OPENSSL_NO_EC2M is set, and if it is, then we do not have EC_GROUP_new_curve_GF2m function and do not HAVE_EC.