Only way to do it right is to use a Z flashing, which will require cutting a thin slot to tuck the upper part of the Z into and then caulk with silicone. On the roof side it will screw down to the high ribs, then squirt some door and window foam under it, once that dries cut any sticking out off...