Rather than trying to make it square to planet Earth, surely you want the gantry square to whatever the material rests on.

Can't you simply put on a piece to be cut on the machine then adjust until it touches wherever it is supposed to touch?

For flat, a cheap laser pen glued to a flat bottomed lump and resting on the bed should hit the wall at the same height when moved around.

Robin