Changeset 21782
- Timestamp:
- 08/04/08 18:03:16 (5 months ago)
- Files:
-
- 1 modified
-
Configure.PL (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Configure.PL
r21727 r21782 3 3 use 5.006; 4 4 use strict; 5 use FindBin; 6 BEGIN { chdir $FindBin::RealBin }; 7 use inc::Module::Install; 8 use lib 'inc'; 5 9 use Cwd; 6 10 use Config; 7 11 use ExtUtils::Embed; 12 use Carp; 13 14 my ($ghc, $ghc_version, $ghc_flags, $ghc_pkg) = assert_ghc(); 15 my $threaded = (try_compile_and_run("main :: IO ()\nmain = return ()", $ghc, "-threaded")) ? '-threaded' : ''; 16 if ($threaded && $ENV{PUGS_NO_THREADS}) { 17 warn << '.'; 18 *** Thread support disabled due to explicit request in PUGS_NO_THREADS. 19 20 . 21 $threaded = ''; 22 } 8 23 9 24 my $embed_flags = "-I" . cwd(); … … 78 93 my $info = << "."; 79 94 executable: pugs 80 ghc-options: $embed_flags $ccdlflags 95 ghc-options: $embed_flags $ccdlflags $threaded 81 96 include-dirs: @include_dirs 82 97 cc-options: @cc_options … … 87 102 print INFO $info; 88 103 close INFO; 104 105 our $do_run; 106 sub try_compile_and_run { 107 local $do_run = 1; 108 try_compile(@_); 109 } 110 111 sub try_compile { 112 my $code = shift; 113 my $temp = "pugs-tmp-$$"; 114 my $ghc = shift or croak "try_compile called without path to ghc"; 115 116 eval { 117 open TMP, "> $temp.hs"; 118 print TMP $code; 119 close TMP; 120 system( 121 $ghc, @_, 122 "--make", "-v0", 123 -o => "$temp.exe", 124 "$temp.hs" 125 ); 126 127 }; 128 129 my $ok = -s "$temp.exe"; 130 131 if ($do_run) { 132 $ok = 0 unless system(Cwd::abs_path("$temp.exe")) == 0; 133 } 134 135 unlink("$temp.exe"); 136 unlink("$temp.hs"); 137 unlink("$temp.hi"); 138 unlink("$temp.o"); 139 140 return $ok; 141 }
