If you would gain a friend, be one yourself.

Literal

Friend [object-を] gain-[archaic-volitional-ん] [conditional-とすれば] friend [into-と] become-[imperative-なれ].

Classical Japanese throughout: 得ん uses the classical volitional む (contracted to ん) of 得る ('to obtain'). とすれば is 'if one attempts.' なれ is the imperative of なる. A proverb rendered in literary style — its archaic grammar gives it authority and weight.