The legs can be any length. I cut mine so they fit within my metal wire shelves in the garage.
Step 1. Cut legs to rough length
Using a table saw
Cut the 2x4s so there are 4 pieces 41 inches long
Cut 2 pieces of 2x4 so they are 17 inches long
Step 2. Remove round over on both sides
I want the legs to be flat. 2x4s have a slightly rounded edge
Using a table saw
Trim off ~1/8 inch on both sides of the 2x4s
Step 3. Drill pilot holes
Each leg consists of two pieces of 2x4 glued together
Mark the legs using something like: Support, [Front Inside, Front Outside] and [Back Inside and Back Outside]
On the Inside 40 inch 2x4s measure and mark 8", 16", 24" and 32"
Drill pilot holes at the marks
Step 4. Drill pilot holes
Each leg consists of two pieces of 2x4 glued together
Mark the legs using something like: Support, [Front Inside, Front Outside] and [Back Inside and Back Outside]
On the Inside 40 inch 2x4s measure and mark 8", 16", 24" and 32"
On one Support measure and mark 5" and 11"
Drill pilot holes with counter sink bit at the marks
Step 5. Glue legs together
On the legs without pilot holes, spread glue
Lay the legs with the pilot holes on the corresponding leg with glue
Align the edges
Insert screws in the pilot holes and tighten - don't over tighten
The screw head should be flush with surface of the wood
Add clamps as required
With a damp rag or paper tool wipe off any glue that oozes out
I put the legs on some wood scraps to dry so they aren't laying on the floor
Wait until the next day for the glue to dry
Step 6. Cut legs to final length
Using a table saw
Cut ~1/2" from each end of the 2x4s
The front and back legs should be 41" long
The support leg should be 16" long
Step 7. Attach fold out support leg
When open, the middle of the support leg should align with the middle of the back leg
Using a metal hinge as a guide
Mark and drill pilot holes on Back Outside Leg and on Support leg
Attached metal hinge to back leg and to support leg
When open the support leg should be flush with back leg