Galaxy mergers and active nuclei. I - The luminosity function. II - Cosmological evolution