B4 madara uchiha said that sharingan was given to his ancestor by sage of six path
but b4 that sharingan was told to b the descent of huugas BYAKUGAN
<sigh> No the sharingan wasn't "given" to Madara's ancestors, it was "passed on" to the son of the Rikudo Sennin w, in the form of the Sharingan, and that bloodline formed the Uchiha.
The other son possessed the Rikudo's "body" and vitality, and that bloodline formed the Senju.
About the Byakugan, I think it was once again a mutation in the Uchiha bloodline, as the Older Son's family began to grow, the Byakugan was born, but I have little knowledge of the time-lapse between the SO6P and the Hyuga emerging, since there is little.