Buckling instability of the layers in a smectic-A liquid crystal