A signal-of-opportunity-based method to automatically calibrate the orientations and shapes of a set of hydrophone arrays using the sound emitted from nearby ships is presented. The calibration problem is formulated as a simultaneous localization and mapping (SLAM) problem, where the locations, orientations, and shapes of the arrays are viewed as the unknown map states, and the position, velocity, etc. of the source as the unknown dynamic states. A sequential likelihood ratio test, together with a maximum a posteriori source location estimator, is used to automatically detect suitable sources and initialize the calibration procedure. The performance of the proposed method is evaluated using data from two 56-element hydrophone arrays. Results from two sea trials indicate that: (a) signal sources suitable for the calibration can be automatically detected; (b) the shapes and orientations of the arrays can be consistently estimated from the different data sets with shape variations of a few decimeters and orientation variations of less than two degrees; and (c) the uncertainty bounds calculated by the calibration method are in agreement with the true calibration uncertainties. Furthermore, the bearing time record from a sea trial with an autonomous mobile underwater signal source also shows the efficacy of the proposed calibration method. In the studied scenario the root mean square bearing tracking error was reduced from 4 to 1 degree when using the calibrated array shapes compared to assuming the arrays' to be straight lines. Also, the beamforming gain increased by approximately 1 decibel.