Let me add my 2 cents...
For you airline guys, Airport Analysis will have a special departure procedure, if the required climb gradient is too steep, that will give a route that will guarantee obstacle clearance. Even though the Takeoff & Obstacle DP on the back of the Jepp says to climb straight out or make a left or right turn, the Special DP might be an opposite turn. Airport Analysis is specific to each aircraft and takes into account a multitude of factors, like single engine service ceiling, etc.
For us non-airline types, we’ve got to pretty much fend for ourselves when operating at airports whose departure procedures require something other that the standard TERPS gradients. We usually have no choice but to comply with the published SID or Takeoff & Obstacle Procedure. They can be quite complex and convoluted, but it is imperative that they be flown precisely if you want to keep from putting your nose into the dirt when departing these airports under IFR conditions. Typically, our only option is to reduce our weight until we are light enough to meet the published minimum climb gradient.
For those of us operating in the U.S., Canada, Mexico, and (I believe) Chile are fortunate, TERPS takes into account the loss of performance as the result of an engine failure when developing the departure procedures. As far as the rest of the world goes, ICAO does not consider engine failure or any other aircraft emergency after V1 in the construction of departure procedures. Again, you international airline guys have Airport Analysis to bail you out, the rest of us have to work it out for ourselves. But we have help too. There are a couple of takeoff performance calculators on the market that have aircraft specific programing that take the sweat out of working the various performance calculations.