FAQ
Hi all,

what is the best way to make perl Makefile.PL set the value of the CC variable in the "Makefile" file
to a different value? I sometimes want to make it point to /usr/bin/clang because clang compiles much faster
than gcc, and produces compatible binaries, so the "make" stage is less time-consuming.

So far the only way I found is to do something like:

sub MY::postamble {

my $CC_LINE =
(
exists($ENV{CC})
? "CC = $ENV{CC}"
: ''
);

return "$CC_LINE\n\n" . <<'MAKE_FRAG';

This adds a second "CC = " line which overrides the first and built-in one.

Is there a better way?

Regards,

Shlomi Fish

--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/

I learned a lot from my teachers, and from my friends more than my teachers,
and from my pupils the most. — Rabbi Hanina

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Search Discussions

  • Sisyphus at Aug 9, 2012 at 9:20 am
    ----- Original Message -----
    From: "Shlomi Fish"
    what is the best way to make perl Makefile.PL set the value of the CC
    variable in the "Makefile" file
    to a different value?
    I've a notion that you can override the default CC with (untested):

    perl Makefile.PL CC=whatever

    but if that turns out to be not the case, or doesn't really suit, then
    there's always the option of using tied():

    ##############################
    C:\>type Makefile.PL

    use ExtUtils::MakeMaker;

    $obj = tied(%Config::Config);
    $obj->{cc} = 'whatever';

    print $Config::Config{cc}, "\n";

    C:\>perl Makefile.PL
    whatever

    C:\>
    ##############################

    Sorry if neither of those options are of any use :-)

    Cheers,
    Rob
  • Shlomi Fish at Aug 9, 2012 at 10:48 am
    Hi Sisyphus,

    On Thu, 9 Aug 2012 19:19:30 +1000
    "Sisyphus" wrote:
    ----- Original Message -----
    From: "Shlomi Fish"
    what is the best way to make perl Makefile.PL set the value of the
    CC variable in the "Makefile" file
    to a different value?
    I've a notion that you can override the default CC with (untested):

    perl Makefile.PL CC=whatever
    Many thanks, that worked like a charm. I believed I tried it, but maybe
    I only tried setting the "CC" environment variable.

    Regards,

    Shlomi Fish

    --
    -----------------------------------------------------------------
    Shlomi Fish http://www.shlomifish.org/
    "Humanity" - Parody of Modern Life - http://shlom.in/humanity

    I learned a lot from my teachers, and from my friends more than my teachers,
    and from my pupils the most. — Rabbi Hanina

    Please reply to list if it's a mailing list post - http://shlom.in/reply .
  • Bill Moseley at Aug 9, 2012 at 1:38 pm

    On Thu, Aug 9, 2012 at 3:48 AM, Shlomi Fish wrote:

    perl Makefile.PL CC=whatever
    Many thanks, that worked like a charm. I believed I tried it, but maybe
    I only tried setting the "CC" environment variable.

    Why can't those variables be added via the environment?

    Or more related to a recent issue I had:

    If I'm installing a CPAN module via "cpan" or "cpanm" (or even as a
    dependency to some other module installed that way), how can I pass needed
    parameters to Makefile.PL?

    My specific situation is I'm setting up an environment for developers, and
    the goal is for them to check out some project and run Makefile.PL (or use
    cpanm --installdeps) to bring in all CPAN dependencies, but some of those
    dependencies need parameters passed to Makefile.PL.

    I can't seem to find it right now but isn't there a way to have site config
    files perl distribution to configure the build process -- such as to answer
    questions given during Makefile.PL?


    --
    Bill Moseley
    moseley@hank.org
  • Martin Becker at Aug 9, 2012 at 5:12 pm

    On Thu, Aug 09, 2012 at 06:38:09AM -0700, Bill Moseley wrote:
    On Thu, Aug 9, 2012 at 3:48 AM, Shlomi Fish wrote:

    perl Makefile.PL CC=whatever
    Many thanks, that worked like a charm. I believed I tried it, but maybe
    I only tried setting the "CC" environment variable.

    Why can't those variables be added via the environment?

    Or more related to a recent issue I had:

    If I'm installing a CPAN module via "cpan" or "cpanm" (or even as a
    dependency to some other module installed that way), how can I pass needed
    parameters to Makefile.PL?

    My specific situation is I'm setting up an environment for developers, and
    the goal is for them to check out some project and run Makefile.PL (or use
    cpanm --installdeps) to bring in all CPAN dependencies, but some of those
    dependencies need parameters passed to Makefile.PL.

    I can't seem to find it right now but isn't there a way to have site config
    files perl distribution to configure the build process -- such as to answer
    questions given during Makefile.PL?
    This is a CPAN question.

    But yes, the Distroprefs mechanism is perfectly suited to supply
    additional parameters to one of the installation commands on
    a distro by distro basis.

    You would have to place a YAML file (or Data::Dumper output
    file) in your preferences directory ("o conf prefs_dir" in a
    cpan shell queries/sets the location), where you set a value for
    "commandline" in the "pl" stage. Examples can be found in the
    distroprefs subdirectory of the CPAN distro.

    Have fun!
    -Martin

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmakemaker @
categoriesperl
postedAug 8, '12 at 9:32a
activeAug 9, '12 at 5:12p
posts5
users4
websitemetacpan.org...

People

Translate

site design / logo © 2022 Grokbase