Suppose [Formula: see text] is a discrete group, and [Formula: see text], with [Formula: see text] an abelian group. Given a representation [Formula: see text], with [Formula: see text] a closed 3-manifold, put [Formula: see text], where [Formula: see text] is a continuous map inducing [Formula: see text] which is unique up to homotopy, and [Formula: see text] is the pairing. We extend the definition of [Formula: see text] to manifolds with corners, and establish a gluing law. Based on these, we present a practical method for computing [Formula: see text] when [Formula: see text] is given by a surgery along a link [Formula: see text]. In particular, the Chern–Simons invariant can be computed this way.