You don't need to worry about aligning the rails to the profile, all you need to worry about is that the rails are parallel to each other and on the same Plane.
If you align the rails to the profiles and the frame or the profiles are not perfectly parallel or bent then you will get binding and other issues.

Likewise same with the Gantry, don't square the gantry to the frame or profiles, square it to the Master rail.

The way to approach it is to select one rail as the Master rail, fasten the master rail down roughly parallel to the profile, then using the most accurate straight edge available fasten it down making sure it's perfectly straight. Now you take all measurements and alignments for things like ball screws from this Master rail.

To parallel the other rail to the Master you rail you can do it several ways.
#1 Leave the rail loose and fit the gantry then using the gantry run the carriages up the rail and tighten down as you go feeling for any tight spots, if any tight spots tweak the rail in that spot.
#2 Use a dial indicator on a beam fixed to a carriage on the Master rail.
#3 Use a parallel bar set to the width you want the rails apart and run up the length of the rail tightening as you go, this is similar to using the gantry.

In all 3 cases, a little fine-tuning might be needed to eliminate any tight spots, but the Key is taking all measurements from the Master rail.