1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
|
use Config;
use ExtUtils::MakeMaker;
use Tk::MMtry qw(try_compile);
use Tk::MMutil;
if( $tkversion <= 800.022 ){
# Tkversion 800.022 needs the old style LandWidgetArg
# instead of the new LangWidgetObj call
$define .= ' -DUSE_LANGWIDGETARG';
}
# mTk directory to use for munging into the pTk dir.
# If Tk804 or greater, use the normal Tktable dir.
# If otherwise using the old Tktable800 dir
my $mTkDir = 'Tktable';
if( $tkversion < 804.000 ){
print STDERR "### Your Tk version is less than 804. ###\n";
print STDERR "### Ok, Using Tk800.0XX dir 'mTk/Tktable800' ###\n";
$mTkDir = 'Tktable800';
}
# Find path to existing pTk include files
my $ptkPath = Tk::MMutil::findINC('Tk/pTk/Lang.h');
$ptkPath =~ s/\/Lang.h$//g;
Tk::MMutil::TkExtMakefile(
'NAME' => 'Tk::pTk',
'VERSION' => '1.22',
'XS_VERSION'=> '0.9',
'LINKTYPE' => 'static',
'OBJECT' => '$(O_FILES)',
macro => { WINARCH => $win_arch },
'DEFINE' => $define,
'INC' => "$inc -I$ptkPath -I. -Ibitmaps",
'SKIP' => [qw( distclean dist makeaperl xs_o)],
'clean' => {'FILES' => 'libpTk$(LIB_EXT)'}
);
sub MY::top_targets {
my ($self) = @_;
local $_ = $self->MM::top_targets;
s/^(\$\(O_FILES\)\s*:.*)$/# Explicit dependancies provided\n# $1/m;
return $_;
}
sub MY::xs_c {
'
';
}
sub MY::post_initialize
{
my ($self) = @_;
my %mTk;
my $dir;
my @list;
if ($Tk::MMutil::IsWin32)
{ # only Tktable needed for everything
@list = ($mTkDir);
}
elsif ($win_arch eq 'open32')
{
@list = ($mTkDir);
}
elsif ($win_arch eq 'pm')
{
@list = ($mTkDir);
}
else
{
@list = ($mTkDir);
}
print STDERR "Generating Dependencies for $^O, win_arch=$win_arch\n";
foreach $dir (@list)
{
my %exc;
my $src = $self->catdir("mTk",$dir);
next unless -d $src;
if (open(EXC,$self->catfile($src,"pTk.inc")))
{
while (<EXC>)
{
chomp;
s/#.*$//;
next unless /\S/;
$mTk{$_} = $self->catfile($src,$_) unless (exists $mTk{$_});
}
close(EXC);
}
else
{
opendir(DIR,$src) || die "Cannot open $src:$!";
if (open(EXC,$self->catfile($src,"pTk.exc")))
{
while (<EXC>)
{
chomp;
s/#.*$//;
next unless /\S/;
$exc{$_} = 1;
if (-f $_)
{
chmod(0777,$_);
unlink($_);
warn "Loose $_\n";
}
}
close(EXC);
}
else
{
warn "Cannot open $src/pTk.exc:$!";
}
my $file;
while (defined($file = readdir(DIR)))
{
next if $exc{$file};
if ($file =~ /\.[ch]$/)
{
$mTk{$file} = $self->catfile($src,$file) unless (exists $mTk{$file});
}
}
closedir(DIR);
}
}
my @loose = ();
if (defined($Config{'i_stdlib'}) && try_compile("config/Hstrtoul.c"))
{
push(@loose,'strtoul.c');
}
if (defined($Config{'i_string'}) && try_compile("config/Hstrdup.c"))
{
push(@loose,'strdup.c');
}
if (try_compile("config/Hstrcasecmp.c"))
{
push(@loose,'strcasecmp.c');
}
$self->Tk::MMutil::mTk_CHO(\%mTk,@loose);
my %files = ();
$files{'windows.h'} = 1 if $win_arch eq 'open32';
my $name;
$self->{'dir_targets'} = [];
$dir = $self->catdir('$(INST_ARCHLIBDIR)','pTk');
push(@{$self->{'dir_targets'}},$dir);
foreach $name ($self->lsdir("."))
{
next if ($name =~ /^\./);
next unless (-f $name);
$files{$name} = 1 if ($name =~ /\.[tm]$/);
}
foreach $name (sort(@{$self->{H}},keys %files))
{
$self->{PM}->{$name} = $self->catfile($dir,$name);
}
if ($Tk::MMutil::IsWin32 or $win_arch eq 'open32' or $win_arch eq 'pm')
{my $ddir = $self->catdir('$(INST_ARCHLIBDIR)','X11');
my $sdir = $self->catdir('mTk','xlib','X11');
push(@{$self->{'dir_targets'}},$ddir);
foreach $name ($self->lsdir($sdir))
{
next if $name =~ /^\.+$/;
my $src = $self->catfile($sdir,$name);
next unless -f $src;
$self->{PM}->{$src} = $self->catfile($ddir,$name);
}
}
$dir = $self->catdir($dir,"compat");
push(@{$self->{'dir_targets'}},$dir);
foreach $name ($self->lsdir("compat"))
{
next if $name =~ /^\.+$/;
my $src = $self->catfile('compat',$name);
next unless -f $src;
$self->{PM}->{$src} = $self->catfile($dir,$name);
}
'';
}
sub MY::test
{
q[
test ::
@echo 'No tests defined for $(NAME)'
];
}
sub MY::post_constants
{
'
INST_STATIC=libpTk$(LIB_EXT)
';
};
sub MY::install {
'
install :: all
';
}
sub MY::dynamic_lib { my $self = shift; "dynamic_lib :: static_lib\n\t".$self->{'NOECHO'}."\$(NOOP)\n" }
sub MY::dynamic { my $self = shift; "dynamic :: static\n\t".$self->{'NOECHO'}."\$(NOOP)\n" }
sub MY::static
{
my $self = shift;
my $str = $self->MM::static(@_);
if ($win_arch eq 'open32' or $win_arch eq 'pm')
{
$str .= '
static :: dllInit$(LIB_EXT)
dllInit$(LIB_EXT): dllMain$(OBJ_EXT)
$(AR) $(AR_STATIC_ARGS) $@ dllMain$(OBJ_EXT) && $(RANLIB) $@
';
}
return $str;
}
sub MY::realclean {
my $self = shift;
my $str = $self->MM::realclean(@_);
$str =~ s/(::\s*clean)/$1 mungeclean/;
$str .= "\nmungeclean ::\n";
$str .= "\t\$(RM_F) ".join(" \\\n\t",keys %{$self->{'MTK'}})."\n";
return $str;
}
sub MY::postamble {
my $self = shift;
my $dep = $self->Tk::MMutil::mTk_postamble;
$dep .= $self->dir_target(@{$self->{'dir_targets'}});
$dep .= "config :: " . join(" \\\n\t",map($self->catfile($_,".exists"),@{$self->{'dir_targets'}})) .
"\n\t".$self->{NOECHO}."\$(NOOP)\n";
$dep . '
'.$self->{NOECHO}.'$(NOOP)
';
}
|