In a saucepan, whisk sugar, flour, and salt. Slowly add milk, whisking constantly until smooth.
Cook over medium heat, whisking, until it thickens — 8 to 10 minutes.
Temper egg yolks by whisking a little hot mixture into them, then return yolks to the pan. Cook 2 to 3 minutes more.
Remove from heat; stir in butter and vanilla.
Spread a small amount of pudding in a 9x13 dish.
Add a layer of wafers, a layer of banana slices, and more pudding. Repeat, finishing with pudding.
If using meringue, beat egg whites with cream of tartar to soft peaks. Add sugar gradually, beating to stiff peaks. Spread over pudding.
Bake at 350°F for 10 to 12 minutes, until golden brown.
Cool completely and chill for at least 2 hours before serving.