RKKY interaction in carbon nanotubes and graphene nanoribbons