Instead of establishing a separate county free library, the board of supervisors may enter into a contract with the board of library trustees or other authority in charge of the free public library of any city and the board of library trustees, or other authority in charge of the free public library, may make such a contract. The contract may provide that the free public library of the city shall assume the functions of a county free library within the county with which the contract is made, including cities in the county. The board of supervisors may agree to pay annually into the library fund of the city such sum as may be agreed upon. Either party to the contract may terminate the contract by giving six months’ notice of intention to do so.