Long waves are generated and transform when short-wave groups propagate into shallow water, but the generation and transformation processes are not fully understood. In this study we develop an analytical solution to the linearized shallow-water equations at the wave-group scale, which decomposes the long waves into a forced solution (a bound long wave) and free solutions (free long waves). The solution relies on the hypothesis that free long waves are continuously generated as short-wave groups propagate over a varying depth. We show that the superposition of free long waves and a bound long wave results in a shift of the phase between the short-wave group and the total long wave, as the depth decreases prior to short-wave breaking. While it is known that short-wave breaking leads to free-long-wave generation, through breakpoint forcing and bound-wave release mechanisms, we highlight the importance of an additional free-long-wave generation mechanism due to depth variations, in the absence of breaking. This mechanism is important because as free long waves of different origins combine, the total free-long-wave amplitude is dependent on their phase relationship. Our free and forced solutions are verified against a linear numerical model, and we show how our solution is consistent with prior theory that does not explicitly decouple free and forced motions. We also validate the results with data from a nonlinear phase-resolving numerical wave model and experimental measurements, demonstrating that our analytical model can explain trends observed in more complete representations of the hydrodynamics.