I'm working on a module (X) that needs another module (Y) as a dependency, and I'm encountering problems when the module X is installed using CPAN. The problem is that X's Makefile.PL uses some settings from Y when it generates its Makefile. CPAN actually detects the dependencies all right, and asks to download and install Y, but it does not rerun X's Makefile.PL after Y is installed, which results in X's Makefile being wrongly generated.
I was looking into both CPAN documentation and sources and couldn't find anything useful. Has anyone encountered this problem, and possibly a fix for it?
Update: there seems to be a misunderstanding of the question: I'm interested not how to do that myself, but how to teach module X to interact with CPAN in automated (3rd user)/controlled (CPAN testers) environment.