Lines do not have ends: although a line is often uniquely defined by two endpoints coincident with the line; a 'line' is correctly considered to be infinite in both directions.
Line segments are lines with ends... and a 'one ended line' is usually termed either a ray, or a half-line ( depending on whether or not it's considered to be directed).
An axis is generally just a direction vector - i.e. an axis has no position, only a (usually normalized) direction.
MattEpp's suggestion is roughly correct : determine the angle that object2 is relative to the reference angle of object1 ( the reference angle is at 0 degrees ), and subtract the current angle of object1 to give the angle to rotate by (which we'll call 'delta').
However, some considerations - arctan ignores the quadrant (infact, the input to arctan makes finding the quadrant impossible): so you can't differentiate between the output of arctan for certain pairs of (non-congruent-modulo-360) angles. That's basically bad, so, use arctan2 (C function is atan2). Remember output is radians, NOT degrees.
You also need to normalize the input to atan/atan2, else the result is meaningless.
So, in C:
double obj1x, obj1y, obj2x, obj2y; /* positions of objects 1 & 2 */
double obj1rot; /* rotation of object1*/
double relx = obj2x - obj1x;
double rely = obj2y - obj1y;
/* length of relative position (i.e. distance) */
double reldis = sqrt ( ( relx * relx ) + ( rely * rely ) );
/* avoid division by zero... */
if ( reldis > EPSILON ) { /* EPSILON should be a very small number */
/* normalized relative position */
double n_relx = relx / reldis;
double n_rely = rely / reldis;
double theta = atan2 ( n_rely, n_relx );
double delta = theta - obj1rot;
obj1rot += delta;
/* a bit contrived at the end, you can do what you want with delta here. */
} else {
/* objects are in the same place, degenerate result. */
}
If your doing incremental movement (i.e. rotating a small amount every frame), then you'll actually want the smallest delta between theta and obj1rot mod 360, which is pretty easy to find given theta and obj1rot.