File: myConfig

package info (click to toggle)
libtk-tablematrix-perl 1.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,608 kB
  • ctags: 1,272
  • sloc: ansic: 15,026; perl: 3,305; makefile: 157; sh: 16
file content (405 lines) | stat: -rwxr-xr-x 9,388 bytes parent folder | download | duplicates (5)
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
require 5.00404;
my $path = "$Config{'archlibexp'}/CORE/perl.h";
die "Cannot find '$path' have you installed $^X?\n" unless (-r $path);
print "$^X is installed in $Config{'archlibexp'} okay\n";
use Config;
use Cwd;
use Tk::MMtry;
warn "No VERSION" unless (defined $VERSION);

my %define = ();

$inc    = "";
$xlib   = "";
$define = '';
$gccopt = "";
@macro = ( macro => {} );


if (defined $Config{'gccversion'})
 {
  $ver = $Config{'gccversion'};
  if ($ver ge "2.8")
   {
    # retain author's favourite warnings if using gcc
    $gccopt .= " -ggdb -Wall -Wno-implicit-int -Wno-comment -Wno-unused -D__USE_FIXED_PROTOTYPES__";
    eval
     {
      if ((getpwuid($<))[6] =~ /Nick\s+Ing-Simmons/)
       {
        # This is the author - catch as many bugs as possible
        $gccopt .= "  -MMD -Werror";
        @macro = ( macro => { INSTALLDIRS => 'perl' });
       }
     }
   }
   # else{ $define .= ' -g ' }

 }

if ($] >= 5.005)
 {
  # Add PPM support stuff
  push(@macro,
       ABSTRACT => 'Tk::tkTable - a Spreadsheet/Table Widget',
       AUTHOR   => 'jcerney@home.com (John Cerney)'
      );
  my $arch = ($^O eq 'MSWin32') ? $ENV{'PROCESSOR_ARCHITECTURE'} : $Config{'archname'};
  push(@ARGV,"BINARY_LOCATION=$arch/Tk$VERSION-PPM.tar.gz");
  warn "PPM for perl$]\n";
 }
else
 {
  warn "No PPM for perl$]\n";
 }

$macro[1]->{WINARCH} = $win_arch;

#
# Convert perls Config info into -DXXXX for Tk
#

$define{'USE_PROTOTYPE'} = 1     if ($Config{'prototype'});
$define{'HAVE_UNISTD_H'} = 1     if ($Config{'i_unistd'});
$define{'HAVE_SYS_SELECT_H'} = 1 if ($Config{'i_sysselct'});
$define{'NO_STDLIB_H'} = 1       unless ($Config{'i_stdlib'});
$define{'HAVE_SYS_TIME_H'} = 1   if ($Config{'i_systime'});
$define{'HAVE_LIMITS_H'} = 1     if ($Config{'i_limits'});
$define{'HAS_STDARG'} = 1        if ($Config{'i_stdarg'});
$define{'USE_BCOPY'} = 1         if (!$Config{'d_memmove'} && $Config{'d_bcopy'});

if (defined $Config{'selecttype'})
 {
   my $type = $Config{'selecttype'};
   $type =~ s/\s*\*\s*$//;
   $define{'SELECT_MASK'} = $type;
 }

if (!$Config{'i_unistd'} && defined $Config{'lseektype'})
 {
   my $type = $Config{'lseektype'};
   $type =~ s/\s*\*\s*$//;
   $define{'LSEEK_TYPE'} =$type;
 }

my $voidflags = $Config{'voidflags'};
my $voidused  = $Config{'defvoidused'}+0;

$define{'NOVOID'}  = 1 if (($voidflags & $voidused) != $voidused);
$define{'NOCONST'} = 1 unless ($Config{'d_const'});

if (try_compile("config/signedchar.c"))
 {
  $define{'ANSI_SIGNED_CHAR'} = 1;
 }
else
 {
  if (try_run("config/unsigned.c"))
   {
    $define{'CHAR_UNSIGNED'} = 1;
   }
 }

if (!try_compile("config/Ksprintf.c") &&
     try_compile("-DSPRINTF_RETURN_CHAR config/Ksprintf.c"))
 {
  $define{'SPRINTF_RETURN_CHAR'} = 1;
 }

if (!$IsWin32)
 {
  if (!try_compile("config/tod.c"))
   {
    my $d;
    my $def;
    foreach $d (qw(TZ NO_TZ DOTS))
     {
      if (try_compile("-DTIMEOFDAY_$d config/tod.c"))
       {
        $def = "TIMEOFDAY_$d";
        print STDERR "$d gettimeofday()\n";
        last;
       }
     }
    if (defined $def)
     {
      $define{$def} = 1;
     }
    else
     {
      print STDERR "Problem gettimeofday()\n";
     }
   }
  else
   {
    print STDERR "Generic gettimeofday()\n";
   }
 }

#
# Hunt down X Library - first a function
#
sub lX11
{
 my $user = shift;
 foreach (@_)
  {
   # allow any of libX11.a libX11.so.* etc.
   if (-d $_)
    {
     local ($lib);
     my $pattern = "$_/libX11.*";
     $pattern .= " $_/X11$Config::Config{lib_ext}"
       if $Config::Config{osname} eq 'os2';
     foreach $lib (reverse(<$ {pattern}>))
      {
       if (-r $lib)
        {
         print "Using -L$_ to find $lib\n";
         return "-L$_"
        }
      }
    }
  }
 print "No -lX11 in ",join(' ',@_),"\n" if (@_ && $user);
 return undef;
}

sub IX11
{
 foreach (@_)
  {
   if (-d $_ && -d "$_/X11" && -r "$_/X11/Xlib.h")
    {
     print "Using -I$_ to find $_/X11/Xlib.h\n";
     return "-I$_";
    }
  }
 return undef;
}

my @args = ();
my $arg;
foreach $arg (@ARGV)
 {
  if ($arg =~ /^(X11\w*)=(.*)$/)
   {
    ${"$1"} = $2;
   }
  else
   {
    $MakefileName = $1 if ($arg =~ /^MAKEFILE=(.*)$/);
    push(@args,$arg);
   }
 }
@ARGV = @args;

$win_arch or die '$win_arch not set in myConfig';

if ($win_arch eq 'x') {
  @xdirs = ();

  if (defined $X11)
    {
      my $dir = $X11;
      if (-d $dir)
	{
	  print "Looking for X in $dir\n";
	  push(@xdirs,$dir);
	}
      else
	{
	  die "X11=$dir is not a directory";
	}
    }
  else
    {
      # Find the X Library through xmkmf!
      $xmkmf = undef;
      my @exts = ("", ".cmd", ".bat");
    LOOK:
      foreach $dir (split($Config::Config{path_sep},$ENV{'PATH'})) {
	foreach $ext (@exts) {
	  if (-x "$dir/xmkmf$ext" && -r "$dir/xmkmf$ext") {
	    $xmkmf = "$dir/xmkmf$ext";
	    last LOOK;
	  }
	}
      }
      $uiline = undef;
      if (defined $xmkmf) {
	open(XMKMF,$xmkmf) || die("Can't open $xmkmf: $!\n");
	while(<XMKMF>) {
	  next unless /UseInstalled/o;
	  warn ("Odd, two lines in the $xmkmf file that have UseInstalled on them:\n$uidir$_") if defined $uiline;
	  $uidir = $_;
	}
	close(XMKMF);
	while (defined $uidir) {
	  last unless ($uidir =~ s!^.*-I(\S+)/lib/X11/config!!o);
	  $try = $1;
	  $try =~ s/'x11root'/$ENV{X11ROOT}/;
	  push(@xdirs,$try);
	}
      }
      print "$xmkmf suggests ",join(' ',@xdirs),"\n" if (@xdirs);
    }

  undef $xlib;			# Make sure

  if (defined $X11LIB)
    {
      $xlib = &lX11(1,$X11LIB)
    }
  if (!defined($xlib) && defined($X11))
    {
      $xlib = &lX11(1,"$X11/lib")
    }
  $xlib = &lX11(0,map("$_/lib",@xdirs)) unless (defined $xlib);

  # Special case for sun-machines
  unless (defined $xlib)
    {
      if ($Config{'osname'} eq 'solaris' || $Config{'osname'} eq 'sunos')
	{
	  $xlib = &lX11(0,'/usr/openwin/lib');
	}
    }

  sub chooseX11
    {
      # Aim to prefer X11R5 over X11R4 over X11
      (reverse(sort(@_)));
    }

  #
  # If no luck there try "common" places
  #
  unless (defined $xlib)
    {
      $xlib = &lX11(0,chooseX11(</usr/X11*/lib>),chooseX11(</usr/lib/X11*>),</usr/Xfree*/lib>,'/usr/X386/lib')
    }

  #
  # Try places perl looks for libraries
  # This is now "last resort" as /lib and /usr/local/lib are so often
  # full of dubious links
  #
  unless (defined $xlib)
    {
      $xlib = &lX11(0,split(/\s+/,$Config{'libpth'}))
    }

  die "Cannot find -lX11 anywhere" unless(defined $xlib);

  ($base) = $xlib =~ m#-L(.*)(?:/lib)$#x;
  if (defined $X11INC)
    {
      $xinc = &IX11("$X11INC");
    }

  $xinc = &IX11("$base/include") unless (defined $xinc);

  unless (defined $xinc)
    {
      warn "Cannot find X include files via $base/include\n";
      $xinc = &IX11(map("$_/include",@xdirs),
		    '/usr/openwin/include',
		    chooseX11(</usr/X11*/include>),
		    chooseX11(</usr/include/X11*>),
		    </usr/Xfree*/include>,
		    '/usr/X386/include',
		    $Config{'usrinc'});
    }

  die "Cannot find X include files anywhere" unless (defined $xinc);

  if (defined($Config{'gccversion'}) &&
      $Config{'gccversion'} =~ /\S/  &&
      $xinc =~ /^-I(.*openwin.*)$/)
   {
    $gccopt .= " -isystem $1";
   }

  $inc = ($xinc eq "-I/usr/include") ? "" : $xinc;
} elsif ($win_arch eq 'open32') {
  unless (defined $toolkit) {
    my @path = split /;/, $ENV{PATH};
    foreach (@path) {
      next unless m:[\\/]toolkit[\\/]bin:i;
      my $tlk = "$`/toolkit";
      next unless -d "$tlk/H" and -f "$tlk/H/os2win.h";
      $toolkit = $tlk;
      $toolkit =~ s:\\:/:g ;
      last;
    }
  }
  die "Cannot find OS/2 toolkit" unless $toolkit;
  $inc = "-I../pTk/mTk/xlib -I../../pTk/mTk/xlib -IpTk/mTk/xlib";
  $inc .= " -I$toolkit/H -I../pTk/mTk/open32/h -IpTk/mTk/open32/h -ImTk/os2_rc";
  $define .= " -D__WIN32__";
  $xlib = "-L$toolkit/LIB -lpmwinx";
} elsif ($win_arch eq 'pm') {
  $define .= " -D__PM__";
  $inc = "-I../pTk/mTk/xlib -I../../pTk/mTk/xlib -IpTk/mTk/xlib -ImTk/os2_rc";
  $xlib = "";                          # No library is needed
} elsif ($IsWin32) {
  $inc = '-I$(TKDIR)/pTk/mTk/xlib';
}


if ($Config{'osname'} eq 'solaris' && $xlib =~ /\bopenwin\b/ )
 {
  $define{'NEED_PRELOAD'} = 1;
 }

sub WriteIfChanged
{
 my ($file,$string) = @_;
 my ($dir) = $file =~ m#^(.*)/[^/]+$#;
 if (defined($dir) && !-d $dir)
  {
   mkdir($dir,0777) || die "Cannot mkdir $dir:$!";
  }
 my $ok = -f $file;
 if ($ok = open(IN,"$file"))
  {
   my $old = join('',<IN>);
   close(IN);
   $ok = $old eq $string;
   print STDERR "$file has changed\n" unless ($ok);
  }
 unless ($ok)
  {
   open(OUT,">$file") || die "Cannot open $file:$!";
   print STDERR "Writing $file\n";
   print OUT $string;
   close(OUT);
  }
}

# Config File Write ( Not Needed when building tkTable )
# if (!defined($MakefileName) || $MakefileName eq 'Makefile')
if(0) {
  my $config = "package Tk::Config;\nrequire Exporter;\nuse base qw(Exporter);\n";
  my $sym;
  my @export = ();
  foreach $sym (qw(VERSION inc define xlib xinc gccopt win_arch))
   {
    my $val = ${$sym};
    $val =~ s/([\\\'])/\\$1/g;
    $config .= "\$$sym = '$val';\n";
    push(@export,"\$$sym");
   }
  $config .= "\@EXPORT = qw(".join(' ',@export).");\n1;\n";
  WriteIfChanged("Tk/Config.pm",$config);
  $config = "#ifndef _TKCONFIG\n#define _TKCONFIG\n";
  foreach $sym (sort keys %define)
   {
    $config .= "#define $sym $define{$sym}\n";
   }
  $config .= "#endif\n";
  WriteIfChanged("pTk/tkConfig.h",$config);
 }

1;