| 1 |
# Copyright (c) 1995-2003 Nick Ing-Simmons. All rights reserved. |
| 2 |
# This program is free software; you can redistribute it and/or |
| 3 |
# modify it under the same terms as Perl itself. |
| 4 |
package Tk::MMutil; |
| 5 |
use ExtUtils::MakeMaker; |
| 6 |
use Cwd; |
| 7 |
use Config; |
| 8 |
use Carp; |
| 9 |
use File::Basename; |
| 10 |
use File::Spec::Functions qw(abs2rel); |
| 11 |
|
| 12 |
use vars qw($VERSION); |
| 13 |
$VERSION = '4.026'; |
| 14 |
|
| 15 |
# warn __FILE__." $VERSION\n"; |
| 16 |
|
| 17 |
use Tk::MakeDepend; |
| 18 |
|
| 19 |
use Tk::Config qw(!$VERSION); |
| 20 |
use vars qw($IsWin32); |
| 21 |
|
| 22 |
*IsWin32 = \$main::IsWin32; |
| 23 |
$IsWin32 = ($^O eq 'MSWin32' || $Config{'ccflags'} =~ /-D_?WIN32_?/) |
| 24 |
unless defined $IsWin32; |
| 25 |
|
| 26 |
@MYEXPORT = qw(pasthru perldepend cflags const_config constants installbin c_o xs_o makefile manifypods); |
| 27 |
|
| 28 |
sub arch_prune |
| 29 |
{ |
| 30 |
my $hash = shift; |
| 31 |
foreach (keys %$hash) |
| 32 |
{ |
| 33 |
if ($win_arch eq 'x') |
| 34 |
{ |
| 35 |
delete $hash->{$_} if /Win[A-Z0-9]/ or /OS2/ or /ImgUtil/ or /^x/; |
| 36 |
} |
| 37 |
elsif ($win_arch eq 'open32') |
| 38 |
{ |
| 39 |
delete $hash->{$_} if /Unix|Mwm/ and not /tclUnix/; |
| 40 |
delete $hash->{$_} if /winMain|dllMain/; |
| 41 |
} |
| 42 |
elsif ($win_arch eq 'pm') |
| 43 |
{ |
| 44 |
delete $hash->{$_} |
| 45 |
if /Unix|Mwm/ and not |
| 46 |
/tclUnix|Unix(3d|Button|Dialog|Color|Embed|Focus|Font|Menu|Scrlbr|Send|Int\.|Scale)/; |
| 47 |
delete $hash->{$_} if /os2Main|dllMain|tkOS2Dll|^x(colors\.c|gc\.)/; |
| 48 |
delete $hash->{$_} if /ImgUtil|tkWin[A-Z0-9]/ and not /OS2/; |
| 49 |
} |
| 50 |
elsif ($win_arch eq 'MSWin32') |
| 51 |
{ |
| 52 |
delete $hash->{$_} if /Mwm/ and not /tclUnix/; |
| 53 |
delete $hash->{$_} if /winMain|dllMain/; |
| 54 |
# delete $hash->{$_} if /^Xrm/; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
sub mTk_postamble |
| 60 |
{ |
| 61 |
my ($self) = @_; |
| 62 |
my $dep = "config :: \$(C_FILES) \$(H_FILES)\n\t$self->{NOECHO}\$(NOOP)\n"; |
| 63 |
my $mTk = $self->{'MTK'}; |
| 64 |
$dep .= "# Begin Munging dependencies\n"; |
| 65 |
foreach my $file (sort keys %$mTk) |
| 66 |
{ |
| 67 |
$dep .= "$file : ".$mTk->{$file}." \$(TKDIR)/pTk/Tcl-pTk\n"; |
| 68 |
$dep .= "\t\$(PERL) \$(TKDIR)/pTk/Tcl-pTk ".$mTk->{$file}." $file\n"; |
| 69 |
} |
| 70 |
$dep .= "# End Munging dependencies\n\n"; |
| 71 |
return $dep; |
| 72 |
} |
| 73 |
|
| 74 |
sub mTk_CHO |
| 75 |
{ |
| 76 |
my $self = shift; |
| 77 |
my $mTk = shift; |
| 78 |
my $exc = shift; |
| 79 |
my %c; |
| 80 |
my %h; |
| 81 |
foreach (@{$self->{H}}) { $h{$_} = 1 } |
| 82 |
foreach (@{$self->{C}}) { $c{$_} = 1 } |
| 83 |
foreach (keys %$mTk) |
| 84 |
{ |
| 85 |
if (/\.c$/) |
| 86 |
{ |
| 87 |
$c{$_} = 1; |
| 88 |
} |
| 89 |
elsif (/\.h$/) |
| 90 |
{ |
| 91 |
$h{$_} = 1; |
| 92 |
} |
| 93 |
} |
| 94 |
foreach (keys %$exc) |
| 95 |
{ |
| 96 |
if (/\.c$/) |
| 97 |
{ |
| 98 |
delete $c{$_}; |
| 99 |
} |
| 100 |
elsif (/\.h$/) |
| 101 |
{ |
| 102 |
delete $h{$_}; |
| 103 |
} |
| 104 |
} |
| 105 |
while (@_) |
| 106 |
{ |
| 107 |
my $name = shift; |
| 108 |
cluck("No $name") unless (exists $c{$name}); |
| 109 |
delete $c{$name} |
| 110 |
} |
| 111 |
arch_prune(\%h); |
| 112 |
arch_prune(\%c); |
| 113 |
$self->{'H'} = [sort keys %h]; |
| 114 |
$self->{'C'} = [sort keys %c]; |
| 115 |
my(@o_files) = @{$self->{C}}; |
| 116 |
$self->{O_FILES} = [grep s/\.c(pp|xx|c)?$/$self->{OBJ_EXT}/i, @o_files] ; |
| 117 |
$self->{'MTK'} = $mTk; |
| 118 |
my $tk = installed_tk(); |
| 119 |
my $perl = $^X; |
| 120 |
foreach my $file (sort keys %$mTk) |
| 121 |
{ |
| 122 |
unless (-f $file && -M $file < -M $mTk->{$file}) |
| 123 |
{ |
| 124 |
warn "Extracting $file\n"; |
| 125 |
my @cmd = ($perl,"$tk/pTk/Tcl-pTk",$mTk->{$file},$file); |
| 126 |
system @cmd; |
| 127 |
die "The command '@cmd' failed with $?" if $? != 0; |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
my %visited; |
| 133 |
|
| 134 |
sub abspath |
| 135 |
{ |
| 136 |
my $dir = shift; |
| 137 |
my $here = getcwd() || die "Cannot get current directory:$!"; |
| 138 |
if (chdir($dir)) |
| 139 |
{ |
| 140 |
$dir = getcwd(); |
| 141 |
chdir($here) || die "Cannot cd back to $here:$!"; |
| 142 |
} |
| 143 |
return $dir; |
| 144 |
} |
| 145 |
|
| 146 |
sub relpath |
| 147 |
{ |
| 148 |
my ($path,$dir) = @_; |
| 149 |
unless (defined $dir) |
| 150 |
{ |
| 151 |
$dir = (-d $path) ? $path : dirname($path); |
| 152 |
} |
| 153 |
if (defined $dir and -d $dir) |
| 154 |
{ |
| 155 |
if ($path =~ m#^\Q$dir\E([/\\]?.*)$#) |
| 156 |
{ |
| 157 |
my $base = $1; |
| 158 |
my $here = getcwd; |
| 159 |
if ($here =~ m#^\Q$dir\E([/\\]?.*)#) |
| 160 |
{ |
| 161 |
my $depth = reverse($1); |
| 162 |
if ($depth) |
| 163 |
{ |
| 164 |
$depth =~ s,[^/\\]+,..,g; |
| 165 |
} |
| 166 |
else |
| 167 |
{ |
| 168 |
$depth = '.' ; |
| 169 |
} |
| 170 |
$depth =~ s,[/\\]+$,,; |
| 171 |
$base =~ s,^[/\\]+,,; |
| 172 |
$depth .= "/$base" if ($base); |
| 173 |
if (-e $depth) |
| 174 |
{ |
| 175 |
# print "$path is $depth from $here\n"; |
| 176 |
return $depth; |
| 177 |
} |
| 178 |
else |
| 179 |
{ |
| 180 |
warn "Cannot find $depth\n"; |
| 181 |
} |
| 182 |
} |
| 183 |
else |
| 184 |
{ |
| 185 |
unless(exists $visited{$here}) |
| 186 |
{ |
| 187 |
$visited{$here} = 1; |
| 188 |
warn "$here does not start with $dir\n"; |
| 189 |
warn "i.e. building outside Tk itself\n"; |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
else |
| 194 |
{ |
| 195 |
die "'$path' not under '$dir'\n"; |
| 196 |
} |
| 197 |
} |
| 198 |
else |
| 199 |
{ |
| 200 |
die "Cannot get directory for $path\n"; |
| 201 |
} |
| 202 |
return $path; |
| 203 |
} |
| 204 |
|
| 205 |
use strict; |
| 206 |
|
| 207 |
sub upgrade_pic |
| 208 |
{ |
| 209 |
my $flags = ''; |
| 210 |
die 'upgrade_pic is obsolete'; |
| 211 |
return $flags; |
| 212 |
} |
| 213 |
|
| 214 |
sub pasthru |
| 215 |
{ |
| 216 |
my $self = shift; |
| 217 |
my $str = $self->MM::pasthru; |
| 218 |
if ($str =~ s/^\s+INC=.*\n//m) |
| 219 |
{ |
| 220 |
$str = "# - Do NOT pasthru INC for Tk - it is computed by subdir\n$str" |
| 221 |
} |
| 222 |
if ($str =~ s/\bLIB="\$\(LIB\)"//) |
| 223 |
{ |
| 224 |
$str = qq[# - Drop LIB="\$(LIB)" - not used\n$str]; |
| 225 |
} |
| 226 |
$str = "#Tk::MMutil pasthru\n$str"; |
| 227 |
return $str; |
| 228 |
} |
| 229 |
|
| 230 |
sub perldepend |
| 231 |
{ |
| 232 |
my $self = shift; |
| 233 |
my $str = $self->MM::perldepend; |
| 234 |
my $name; |
| 235 |
my %c; |
| 236 |
foreach my $file (@{$self->{'C'}}) |
| 237 |
{ |
| 238 |
$c{$file} = 1; |
| 239 |
} |
| 240 |
foreach my $file (keys %{$self->{'XS'}}) |
| 241 |
{ |
| 242 |
$c{$file} = 1; |
| 243 |
delete $c{$self->{'XS'}{$file}}; |
| 244 |
} |
| 245 |
my @files = grep(-f $_,sort(keys %c)); |
| 246 |
if (@files) |
| 247 |
{ |
| 248 |
my $tk = installed_tk(); |
| 249 |
my @inc = split(/\s+/,$self->{'INC'}); |
| 250 |
my @def = split(/\s+/,$self->{'DEFINE'}); |
| 251 |
push(@def,qw(-DWIN32 -D__WIN32__)) if ($IsWin32); |
| 252 |
if ($^O eq 'cygwin') |
| 253 |
{ |
| 254 |
push(@def,qw(-D__CYGWIN__)); |
| 255 |
if ($win_arch eq 'MSWin32') |
| 256 |
{ |
| 257 |
push(@def,qw(-D__WIN32__)) unless $self->{'DEFINE'} =~ /-D__WIN32__/; |
| 258 |
push(@def,qw(-DWIN32)) if $self->{'NAME'} eq 'Tk::pTk'; |
| 259 |
push(@def,qw(-dWINARCH_MSWIN32)); |
| 260 |
} |
| 261 |
elsif ($win_arch eq 'x') |
| 262 |
{ |
| 263 |
push(@def,qw(-U_WIN32)); |
| 264 |
push(@def,qw(-DWINARCH_X)); |
| 265 |
} |
| 266 |
} |
| 267 |
foreach (@inc) |
| 268 |
{ |
| 269 |
s/\$\(TKDIR\)/$tk/g; |
| 270 |
warn "Odd:$_" if /\$\(/; |
| 271 |
} |
| 272 |
$str .= Tk::MakeDepend::command_line(@inc,@def,@files) unless ($ENV{'TKNOMAKEDEPEND'}); |
| 273 |
} |
| 274 |
return $str; |
| 275 |
} |
| 276 |
|
| 277 |
sub const_config |
| 278 |
{ |
| 279 |
my $self = shift; |
| 280 |
my $name; |
| 281 |
foreach $name (grep /(%|\.(old|bak|q4|orig|rej))$/,keys %{$self->{PM}}) |
| 282 |
{ |
| 283 |
delete $self->{PM}->{$name}; |
| 284 |
} |
| 285 |
my $flags = $self->{'CCCDLFLAGS'}; |
| 286 |
$flags =~ s/(-[fK]?\s*)pic\b/${1}PIC/; |
| 287 |
$self->{'CCCDLFLAGS'} = $flags; |
| 288 |
if ($^O eq 'MSWin32' && $Config{'ccflags'} =~ /-DPERL_OBJECT/) |
| 289 |
{ |
| 290 |
$self->{'LDFLAGS'} =~ s/-(debug|pdb:\w+)\s+//g; |
| 291 |
$self->{'LDDLFLAGS'} =~ s/-(debug|pdb:\w+)\s+//g; |
| 292 |
} |
| 293 |
elsif ($^O eq 'darwin' ) |
| 294 |
{ |
| 295 |
$self->{'LDDLFLAGS'} =~ s/-flat_namespace//; |
| 296 |
$self->{'LDDLFLAGS'} =~ s/-undefined\s+suppress//; |
| 297 |
## These lines seem to be not necessary for Panther, both |
| 298 |
## builds with and without shared libperl, and seem to |
| 299 |
## be dangerous for other MacOSX versions using perl builds |
| 300 |
## without shared libperl, so disabled completely. |
| 301 |
## See http://rt.cpan.org/Public/Bug/Display.html?id=39593 |
| 302 |
# if ( -e "$Config{'archlib'}/CORE/$Config{'libperl'}" ) { |
| 303 |
# $self->{'LDDLFLAGS'} .= " -L\${PERL_ARCHLIB}/CORE -lperl "; |
| 304 |
# } |
| 305 |
# elsif ( -e "/System/Library/Perl/darwin/CORE/libperl.dylib" ) { |
| 306 |
# $self->{'LDDLFLAGS'} .= " -L/System/Library/Perl/darwin/CORE -lperl "; |
| 307 |
# } |
| 308 |
# else { |
| 309 |
# warn "Can't find libperl.dylib"; |
| 310 |
# } |
| 311 |
$self->{'LDFLAGS'} =~ s/-flat_namespace//; |
| 312 |
$self->{'LDFLAGS'} =~ s/-undefined\s+suppress//; |
| 313 |
} elsif ($^O =~ /(openbsd)/i) |
| 314 |
{ |
| 315 |
# -Bforcearchive is bad news for Tk - we don't want all of libpTk.a in all .so-s. |
| 316 |
$self->{'LDDLFLAGS'} =~ s/-Bforcearchive\s*//g; |
| 317 |
} |
| 318 |
return $self->MM::const_config; |
| 319 |
} |
| 320 |
|
| 321 |
sub constants |
| 322 |
{ |
| 323 |
my $self = shift; |
| 324 |
local $_ = $self->MM::constants; |
| 325 |
s/(\.SUFFIXES)/$1:\n$1/; |
| 326 |
$_ .= "\nGCCOPT = $Tk::Config::gccopt\n"; |
| 327 |
if ($IsWin32) |
| 328 |
{ |
| 329 |
} |
| 330 |
$_; |
| 331 |
} |
| 332 |
|
| 333 |
sub cflags |
| 334 |
{ |
| 335 |
my $self = shift; |
| 336 |
local $_ = $self->MM::cflags; |
| 337 |
if (0 && $IsWin32) |
| 338 |
{ |
| 339 |
if ($Config::Config{cc} =~ /^bcc/i) { |
| 340 |
# s/(CCFLAGS\s*=)/$1/; |
| 341 |
} |
| 342 |
else { |
| 343 |
s/(CCFLAGS\s*=)/$1 \$(cflags) \$(cvarsdll)/; |
| 344 |
s/(OPTIMIZE\s*=).*/$1 \$(cdebug)/; |
| 345 |
} |
| 346 |
} |
| 347 |
$_; |
| 348 |
} |
| 349 |
|
| 350 |
sub c_o |
| 351 |
{ |
| 352 |
my $self = shift; |
| 353 |
local $_ = $self->MM::c_o; |
| 354 |
s/\$\(DEFINE\)/\$(DEFINE) \$(GCCOPT)/g; |
| 355 |
$_; |
| 356 |
} |
| 357 |
|
| 358 |
sub xs_o |
| 359 |
{ |
| 360 |
my $self = shift; |
| 361 |
local $_ = $self->MM::xs_o; |
| 362 |
s/\$\(DEFINE\)/\$(DEFINE) \$(GCCOPT)/g; |
| 363 |
$_; |
| 364 |
} |
| 365 |
|
| 366 |
sub manifypods |
| 367 |
{ |
| 368 |
my $self = shift; |
| 369 |
# Maybe always call UNIX version - we HTMLize them later |
| 370 |
local $_ = $self->MM::manifypods; |
| 371 |
if ($] >= 5.00565) |
| 372 |
{ |
| 373 |
s/(POD2MAN_EXE.*pod2man.*)/$1 --center "perl\/Tk Documentation" --release "Tk\$(VERSION)"/; |
| 374 |
} |
| 375 |
elsif ($] >= 5.003) |
| 376 |
{ |
| 377 |
s/(POD2MAN_EXE.*pod2man.*)/$1 -center "perl\/Tk Documentation" -release "Tk\$(VERSION)"/; |
| 378 |
} |
| 379 |
else |
| 380 |
{ |
| 381 |
s/(POD2MAN_EXE.*pod2man.*)/$1 -center \\"perl\/Tk Documentation\\" -release \\"Tk\$(VERSION)\\"/; |
| 382 |
} |
| 383 |
s/\bpod::/Tk::/mg; |
| 384 |
s/\bpTk:://mg; |
| 385 |
$_; |
| 386 |
} |
| 387 |
|
| 388 |
sub findINC |
| 389 |
{ |
| 390 |
my $file = shift; |
| 391 |
my $dir; |
| 392 |
foreach $dir (@INC) |
| 393 |
{ |
| 394 |
my $try = "$dir/$file"; |
| 395 |
return $try if (-f $try); |
| 396 |
} |
| 397 |
die "Cannot find $file in \@INC\n"; |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
sub makefile |
| 402 |
{ |
| 403 |
my $self = shift; |
| 404 |
my $str = $self->MM::makefile; |
| 405 |
my $mm = abs2rel findINC('Tk/MMutil.pm'); |
| 406 |
my $cf = abs2rel findINC('Tk/Config.pm'); |
| 407 |
$str =~ s/(\$\(CONFIGDEP\))/$1 $cf $mm/; |
| 408 |
$str =~ s/\$\(OBJECT\)\s*:.*\n//; |
| 409 |
return $str; |
| 410 |
} |
| 411 |
|
| 412 |
sub installed_tk |
| 413 |
{ |
| 414 |
my $tk; |
| 415 |
my $dir; |
| 416 |
foreach $dir (@INC) |
| 417 |
{ |
| 418 |
if (-f "$dir/tkGlue.h") |
| 419 |
{ |
| 420 |
$tk = relpath($dir); |
| 421 |
last; |
| 422 |
} |
| 423 |
my $try = "$dir/Tk"; |
| 424 |
if (-f "$try/tkGlue.h") |
| 425 |
{ |
| 426 |
$tk = relpath($try,$dir); |
| 427 |
last; |
| 428 |
} |
| 429 |
} |
| 430 |
die "Cannot find perl/Tk include files\n" unless (defined $tk); |
| 431 |
$tk =~ s,^(\./)+,,; |
| 432 |
return $tk; |
| 433 |
} |
| 434 |
|
| 435 |
sub installbin |
| 436 |
{ |
| 437 |
my ($self) = @_; |
| 438 |
my $str = $self->MM::installbin; |
| 439 |
my $prog = 'perl'; # $self->{'MAP_TARGET'} || 'perl'; |
| 440 |
my $inc = findINC('Tk/MMutil.pm'); |
| 441 |
$inc =~ s,/Tk/MMutil.pm$,,; |
| 442 |
$inc = relpath($inc); |
| 443 |
$str =~ s/^\tcp\s/\t\$(PERL) -I$inc -MTk::install -e installbin $prog /mg; |
| 444 |
return $str; |
| 445 |
} |
| 446 |
|
| 447 |
sub findpTk |
| 448 |
{ |
| 449 |
my $ptk; |
| 450 |
my $dir; |
| 451 |
foreach $dir (map(abspath($_),@_),@INC) |
| 452 |
{ |
| 453 |
my $try = "$dir/pTk"; |
| 454 |
if (-d $try && (-f "$try/Lang.h" || -f "$try/libpTk\$(LIB_EXT)")) |
| 455 |
{ |
| 456 |
$ptk = relpath($try,$dir); |
| 457 |
last; |
| 458 |
} |
| 459 |
} |
| 460 |
confess "Cannot locate pTk\n" unless (defined $ptk); |
| 461 |
return $ptk; |
| 462 |
} |
| 463 |
|
| 464 |
sub find_subdir |
| 465 |
{ |
| 466 |
my %dir; |
| 467 |
opendir(DIR,'.') || die "Cannot opendir:$!"; |
| 468 |
foreach my $dir (readdir(DIR)) |
| 469 |
{ |
| 470 |
next if $dir =~ /^\.\.?$/; |
| 471 |
next if -l $dir; |
| 472 |
next unless -d $dir; |
| 473 |
if (-f "$dir/Makefile.PL") |
| 474 |
{ |
| 475 |
my $exc = ($win_arch eq 'x') ? 'Unix' : 'Win'; |
| 476 |
if (-f "$dir/Not${exc}.exc") |
| 477 |
{ |
| 478 |
warn "Skip $dir on $win_arch\n" |
| 479 |
} |
| 480 |
else |
| 481 |
{ |
| 482 |
$dir{$dir} = 1 |
| 483 |
} |
| 484 |
} |
| 485 |
} |
| 486 |
closedir(DIR); |
| 487 |
return \%dir; |
| 488 |
} |
| 489 |
|
| 490 |
sub TkExtMakefile |
| 491 |
{ |
| 492 |
my (%att) = @_; |
| 493 |
if ($Config{'ccflags'} =~ /-DPERL_OBJECT/) |
| 494 |
{ |
| 495 |
$att{'CAPI'} = 'TRUE' unless exists $att{'CAPI'}; |
| 496 |
} |
| 497 |
unless (exists $att{'DIR'}) |
| 498 |
{ |
| 499 |
my $dir = find_subdir(); |
| 500 |
$att{'DIR'} = [sort(keys %$dir)]; |
| 501 |
} |
| 502 |
unless (exists $att{'NAME'}) |
| 503 |
{ |
| 504 |
my $dir = getcwd; |
| 505 |
my ($pack) = $dir =~ m#/([^/]+)$#; |
| 506 |
if (defined $pack) |
| 507 |
{ |
| 508 |
$att{NAME} = 'Tk::'.$pack; |
| 509 |
} |
| 510 |
else |
| 511 |
{ |
| 512 |
warn "No Name and cannot deduce from '$dir'"; |
| 513 |
} |
| 514 |
} |
| 515 |
my $tk = installed_tk(); |
| 516 |
$att{'macro'} = {} unless (exists $att{'macro'}); |
| 517 |
$att{'macro'}{'TKDIR'} = $tk; |
| 518 |
my @opt = ('VERSION' => $Tk::Config::VERSION, |
| 519 |
'XS_VERSION' => $Tk::Config::VERSION); |
| 520 |
push(@opt,'clean' => {} ) unless (exists $att{'clean'}); |
| 521 |
$att{'clean'}->{FILES} = '' unless (exists $att{'clean'}->{FILES}); |
| 522 |
$att{'clean'}->{FILES} .= ' *.bak'; |
| 523 |
unless (exists($att{'linkext'}) && $att{linkext}{LINKTYPE} eq '') |
| 524 |
{ |
| 525 |
my $ptk = findpTk($tk); |
| 526 |
my @tm = (findINC('Tk/typemap')); |
| 527 |
unshift(@tm,@{$att{'TYPEMAPS'}}) if (exists $att{'TYPEMAPS'}); |
| 528 |
$att{'TYPEMAPS'} = \@tm; |
| 529 |
my $i = delete ($att{'INC'}); |
| 530 |
$i = (defined $i) ? "$i $inc" : $inc; |
| 531 |
if (delete $att{'dynamic_ptk'}) |
| 532 |
{ |
| 533 |
push(@opt, |
| 534 |
'MYEXTLIB' => "$ptk/libpTk\$(LIB_EXT)", |
| 535 |
# 'dynamic_lib' => { INST_DYNAMIC_DEP => "$ptk/libpTk\$(LIB_EXT)" } |
| 536 |
); |
| 537 |
} |
| 538 |
# Several loadable widgets use things from -lm |
| 539 |
# if platform does not have a shared -lm need to link against it |
| 540 |
if ($Config{libs} =~/-lm\b/) |
| 541 |
{ |
| 542 |
my $libs = $att{'LIBS'}->[0]; |
| 543 |
$att{'LIBS'}->[0] = "$libs -lm" unless $libs =~ /-lm\b/; |
| 544 |
} |
| 545 |
if ($IsWin32 && $Config{'cc'} =~ /^bcc/) |
| 546 |
{ |
| 547 |
# Borland compiler is very dumb at finding files |
| 548 |
$i = "-I$tk $i"; |
| 549 |
$i = "-I$ptk $i"; |
| 550 |
} |
| 551 |
if ($IsWin32 && $Config{'cc'} =~ /gcc/i) |
| 552 |
{ |
| 553 |
my $base = $Config{'libpth'}; |
| 554 |
#$base =~ s#lib$#i386-mingw32/lib#; |
| 555 |
my $extra = "-L$base -limm32 -lcomctl32 -lcomdlg32 -lgdi32"; |
| 556 |
my $libs = $att{'LIBS'}->[0]; |
| 557 |
$att{'LIBS'}->[0] = "$extra $libs"; |
| 558 |
} |
| 559 |
if ($^O eq 'cygwin') |
| 560 |
{ |
| 561 |
# NOTE: use gcc -shared instead of dllwrap (ld2), |
| 562 |
# dllwrap tries to resolve all symbols, even those |
| 563 |
# that are brought in from libraries like libpTk.a |
| 564 |
push(@opt,'LD' => 'gcc -shared'); |
| 565 |
if ($win_arch eq 'MSWin32') |
| 566 |
{ |
| 567 |
my $extra = "-L/lib/w32api -limm32 -lcomctl32 -lcomdlg32 -lgdi32"; |
| 568 |
my $libs = $att{'LIBS'}->[0]; |
| 569 |
$att{'LIBS'}->[0] = "$extra $libs"; |
| 570 |
$att{'DEFINE'} .= ' -D__WIN32__ -D_WIN32 -DWINARCH_MSWIN32'; |
| 571 |
$att{'DEFINE'} .= ' -DWIN32' if($att{'NAME'} eq 'Tk::pTk'); |
| 572 |
} |
| 573 |
elsif ($win_arch eq 'x') |
| 574 |
{ |
| 575 |
$att{'DEFINE'} .= ' -U_WIN32 -DWINARCH_X'; |
| 576 |
} |
| 577 |
} |
| 578 |
if (delete $att{'ptk_include'}) |
| 579 |
{ |
| 580 |
$i = "-I$ptk $i" unless ($ptk eq '.'); |
| 581 |
} |
| 582 |
else |
| 583 |
{ |
| 584 |
$i = "-I$tk $i" unless ($tk eq '.'); |
| 585 |
} |
| 586 |
push(@opt,'DEFINE' => $define, 'INC' => $i); |
| 587 |
} |
| 588 |
WriteMakefile(@opt, %att); |
| 589 |
} |
| 590 |
|
| 591 |
sub import |
| 592 |
{ |
| 593 |
no strict 'refs'; |
| 594 |
my $class = shift; |
| 595 |
my @list = (@_) ? @_ : @{"${class}::MYEXPORT"}; |
| 596 |
my $name; |
| 597 |
foreach $name (@list) |
| 598 |
{ |
| 599 |
*{"MY::$name"} = \&{"$name"}; |
| 600 |
} |
| 601 |
} |
| 602 |
|
| 603 |
|
| 604 |
1; |