Vehicle manufacturers and trade unions in South Africa have reached a pay deal that has averted a strike.