Derivation of linear elasticity for a general class of atomistic energies