A momentum source function derived from the linear wave theory is introduced into the weakly compressible smoothed particle hydrodynamic (SPH) model for the long-time simulation of regular and irregular wave generation problems. Wave absorption is realized by adding a velocity attenuation term into the governing momentum equation. The performances of the wave maker are tested under different wave conditions. The wave maker is then applied to the study of the challenging processes, such as random wave breaking on the reef-face or the reef-crest, wave setup and spectral transfer of wave energy from the peak frequency to lower frequencies over the reef-flat. The predicted results are compared with the experimental data and a good agreement is obtained. The SPH model with a non-reflective spectral wave maker can be used as a practical tool for studying wave interaction with coastal structures.