Changeset 21685 for Makefile.PL

Show
Ignore:
Timestamp:
08/01/08 14:53:25 (4 months ago)
Author:
audreyt
Message:

* Write Pugs.Config.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Makefile.PL

    r21683 r21685  
    1010use Config; 
    1111use File::Spec; 
     12use POSIX qw/uname/; 
    1213 
    1314# Hack to prevent recursive calls 
     
    5657); 
    5758 
    58 system($cabal => 'update'); 
     59#system($cabal => 'update'); 
    5960system($cabal => 'install', '--user', @deps); 
    6061 
     
    9495 
    9596sub set_postamble { 
     97    unlink (my $build_config = 'current.build.yml'); 
     98 
     99    my $find_ver = sub { 
     100        `$_[0] $_ 2>&1` =~ /(.* (?:version|build) .*)/i && return $1 
     101            for qw{--version -v -V -? /?}; 
     102        return "unknown"; 
     103    }; 
     104    my $config = get_pugs_config( 
     105        uname               =>  join (" ", (uname)[0,2,4] ), 
     106        regex_engine        =>  ( $ENV{PUGS_REGEX_ENGINE} ?  $ENV{PUGS_REGEX_ENGINE} : 'default' ), 
     107        embed_flags         => 'noparrot nohaskell', 
     108#        embedded            =>  join (" ", ( $embed_flags =~ /HAVE_PERL5/ ?  $Config{perlpath} : 'noperl' ), 
     109#                                    ( $embed_flags =~ /HAVE_PARROT/ 
     110#                                        ?  abs_path( File::Spec->catfile( "$ENV{PARROT_PATH}", "parrot" ) ) 
     111#                                        : 'noparrot' ), 
     112#                                    ( $ENV{PUGS_EMBED} =~ /\bhaskell\b/ ?  $ghc : 'nohaskell' ) 
     113#                                ), 
     114#        ghc                 =>  join (" ", [ assert_ghc() ]->[0], $ghc_version, 
     115#                                    ( $ghc_flags =~ /HAVE_READLINE/ ?  'readline' : 'noreadline' ), 
     116#                                    ( $ghc_flags =~ /HAVE_HSPLUGINS/ ?  'hsplugins' : 'nohsplugins' ), 
     117#                                    ( $threaded ? "threads" : "nothreads" ), 
     118#                                ), 
     119        ghc => 'noreadline nohsplugins nothreads', 
     120        cc                  =>  $find_ver->( $Config{cc} ), 
     121    ); 
     122 
     123    { 
     124        # maybe move this to inc/PugsBuild/MiniYAML.pm ? 
     125        open my $fh, '>', $build_config or die "Cannot open $build_config for writing"; 
     126        print $fh "# *** NOTE ***\n"; 
     127        print $fh "# This file is generated during Makefile.PL.\n"; 
     128        print $fh "# Changes will not persist after running Makefile.PL\n"; 
     129        for ( sort keys %$config ) { 
     130            print $fh "$_: $config->{$_}\n"; 
     131        } 
     132        close $fh; 
     133    } 
     134 
    96135    # Ok, now we have Cabal-Install and all the deps.  Let's be lazy and write a simple makefile. 
    97136    postamble(<<"."); 
    98 pugs$Config{_exe} :: 
     137pugs$Config{_exe} :: src/Pugs/Config.hs 
    99138\t\$(RM_F) dist/build/Pugs/pugs$Config{_exe} 
    100139\t$cabal configure --user 
     
    112151INST6_MAN3DIR = blib6/man3 
    113152INSTPUGS_LIB = blib6/pugs 
     153 
     154src/Pugs/Config.hs : util/PugsConfig.pm current.build.yml 
     155        \$(PERL) -Iutil -MPugsConfig -e "PugsConfig->write_config_module" > src/Pugs/Config.hs 
     156 
    114157. 
    115158