Canonical quantization of macroscopic electromagnetism