Its cheaper to go buy a 4.0 jeep, swap anything off your old jeep that's too cool to lose and sell whats left of the old one...
97 is OBDII, But you likely need the entire wiring harness, ecu and sensors from a 4.0 same year or newer than yours.
The head gasket is a bad sign, sitting does not make them go bad, the engine likely got pulled because of the blown gasket or worse.
The frame on the 2.5 and 4.0 are NOT the same in the front, you'll be welding motor mounts, need a 4.0 radiator.
The 4.0 does not bolt to the ax5 and even if it did it would last a week. I'm on #4 in 200K miles. With the 4cyl and
that's about 1/4 off-road miles.
Its your dime and your time but no way I'd bother...
Dave