The 2006 International Building Code addresses how the code relates to modifications of historic buildings.
The IBC states that “The provisions of this code relating to the construction, repair, alteration, addition, restoration and movement of structures, and change of occupancy shall not be mandatory for historic buildings where such buildings are judged by the building official to not constitute a distinct life safety hazard”
Historic Buildings are defined as “Buildings that are listed or eligible for listing in the National Register of Historic Places, or designated as historic under an appropriate state or local law. ”
That’s a fairly narrow set of buildings, so generally speaking older buildings need to be brought up to code when they are substantially improved. It is generally easier to prove that the cost is prohibitive if the cost of the upgrades are more than 20% the cost of the total project.