Add HAVE_PETSC macro.
use block{} guarantee for if and for statements.
if no petsc installed, we should remove petsc related files from cmake file
list.
add HAVE_PETSC for config.h