I bought a precision level to do this. The 300 mm square frame type and accurate to something like 0.02 mm per meter?. Cost about £100.
Rest it on any piece of wood or box section that is long enough to touch both surfaces and measure any relative angle differences at any position you like along the beams where the rails will sit. Or start at one point and shim the level until it reads zero and check relative angles at other positions.
You need to do a bit of maths to convert the angle into the exact height differences based on your rail spacing but nothing too complicated. Then you can shim the rails level to each other and on the same flat plane etc.
I did this I one of my videos installing the Y axis onto the gantry. See YouTube channel.