use ExtUtils::MakeMaker; use 5.005; use Config; $|=1; $DEFINE = ""; $DEFINE .= " -DHAVE_MMAP" if $Config{d_mmap} eq "define" && $Config{d_munmap} eq "define"; if ($^O =~ /win32/i or $^O =~ /cygwin/) { $DEFINE = " -DCORO_LOOSE"; } elsif ($^O =~ /irix/) { $iface = "i"; } elsif ($^O =~ /linux/) { # default to setjmp/longjmp on non-x86... $iface = $Config{archname} =~ /^i[3456]86-/ ? "l" : "s"; } elsif ($^O =~ /solaris/) { $iface = "s"; } elsif (-e "/usr/include/ucontext.h") { $iface = "u"; } else { $iface = "s"; } print < !~ /^\s*n/i) { print "\nExperimental context sharing enabled.\n\n"; $DEFINE .= " -DCORO_LAZY_STACK"; } if ($iface) { print <etjmp/longjump, context, rix or inux [$iface]? "; my $r = <>; $iface = lc $1 if $r =~ /(\S)/; if ($iface eq "u") { $DEFINE .= " -DCORO_UCONTEXT"; print "\nUsing ucontext implementation\n\n"; conftest("TEST_makecontext"); } elsif ($iface eq "s") { $DEFINE .= " -DCORO_SJLJ"; print "\nUsing setjmp/longjmp/sigaltstack implementation\n\n"; conftest("TEST_sigaltstack"); } elsif ($iface eq "l") { $DEFINE .= " -DCORO_LINUX"; print "\nUsing linux-specific implementation\n\n"; } elsif ($iface eq "i") { $DEFINE .= " -DCORO_IRIX"; print "\nUsing irix-specific implementation\n\n"; } else { print "\nUnknown implementation \"$iface\"\n"; goto retry; } } else { print "\nUsing microsoft compatible coroutines\n\n"; } WriteMakefile( NAME => "Coro::State", VERSION_FROM => "State.pm", DEFINE => $DEFINE, DIR => [], ); sub conftest { my $type = shift; print "\nTrying to detect stack growth direction (for $type)\n"; print "You might see some warnings, this should not concern you.\n\n"; system "$Config{cc} $Config{ccflags} -D$type libcoro/conftest.c"; my $res = qx<./a.out>; $res =~ s/\s+$//; my ($sp, $ss) = split /,/, $res; print "\n\n*****************************************************************************\n"; print "If the testsuite fails PLEASE provide the following information\n"; print "to Marc Lehmann : operating system name, version,\n"; print "architecture name and this string '$sp|$ss'. Thanks a lot!\n";#d# print "*****************************************************************************\n\n"; unlink "a.out"; unlink "conftestval"; }