Camera's aren't worth worrying about any performance issues so this is just informational. Skipping euler angles, you have:

The lookat direction from the camera to target (the dx,dy,dz above). Normalize that. Cross it with your up vector (say y, so little computation) and that give the direction to the 'side'. Normalize that. Cross side and lookat gives camera's up (no need to normalize...side and lookat are orthogonal). Shove these three vectors into the matrix (row or columns depending on your convention) and you're done.

forward = (fx,fy,fz) = (dx,dy,dz)/sqrt(dx*dx+dy*dy+dz*dz)

side = (sx,sy,sz) = (-fz, 0, fx)/sqrt(fz*fz+fx*fx)

up = (ux,uy,uz) = (-fy*sz, fx*sz-fz*sx, fy*sx)

Assuming I didn't screw anything up.