Ab initio optical properties of BN in the cubic and in the layered hexagonal phase