Fejer Kernel for generating Fourier approximations to functions

K[x_,M_]:=(Sin[M x/2]/Sin[x/2])^2/M

Manipulate[Plot[K[x,M],{x,-Pi,Pi},PlotRange->{{-Pi,Pi},{-1,30}}],{M,1,30,1}]

Plot[UnitBox[x-1],{x,-Pi,Pi}]

g5=1/(2Pi)Convolve[K[x,5]UnitBox[x/(2Pi)],UnitBox[x-1]UnitBox[x/(2Pi)],x,y]

g10=1/(2Pi)Convolve[K[x,10]UnitBox[x/(2Pi)],UnitBox[x-1]UnitBox[x/(2Pi)],x,y]

g30=1/(2Pi)Convolve[K[x,30]UnitBox[x/(2Pi)],UnitBox[x-1]UnitBox[x/(2Pi)],x,y];

g100=1/(2Pi)Convolve[K[x,100]UnitBox[x/(2Pi)],UnitBox[x-1]UnitBox[x/(2Pi)],x,y]; (* very slow! *)

Plot[{g5,g10,g30,g100,UnitBox[y-1]},{y,-Pi,Pi}]