Subject: | Tcl module on FreeBSD |
The attached patch changes the Tcl.pm Makefile.PL to autodetect the latest Tcl library on FreeBSD.
Regards,
Slaven
#
#
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####
#### Patch data follows ####
diff -up '../../build/Tcl-0.75/Makefile.PL' 'Makefile.PL'
Index: ./Makefile.PL
--- ./Makefile.PL Tue Mar 23 00:44:58 2004
+++ ./Makefile.PL Wed Apr 21 00:06:52 2004
@@ -1,10 +1,17 @@
# before running this script make sure you have 'tclsh' in your path,
# and this 'tcl' distribution is required one.
-# FreeBSD users may want to modify name of tcl interpreter (this is
-# $tclsh variable below) as long as 'tclsh' does not work in their case
my $tclsh = 'tclsh';
+if ($^O eq 'freebsd' && `$tclsh /dev/null 2>&1` =~ /named with a version/) {
+ for my $ver (qw(8.4 8.3 8.2 8.1 8.0)) {
+ if (is_in_path("$tclsh$ver")) {
+ $tclsh = "$tclsh$ver";
+ last;
+ }
+ }
+}
+
open TCLSH, "$tclsh tclcfg.tcl |";
my $tclcfg = join '', <TCLSH>;
print $tclcfg;
@@ -36,5 +43,44 @@ WriteMakefile(
LIBS => ["$tclcfg{libpath} -l${libpref}tcl$tclver"],
INC => "$tclcfg{incpath}",
);
+
+# Utility functions
+
+BEGIN {
+ if (eval { require File::Spec; defined &File::Spec::file_name_is_absolute }) {
+ *file_name_is_absolute = \&File::Spec::file_name_is_absolute;
+ } else {
+ *file_name_is_absolute = sub {
+ my $file = shift;
+ my $r;
+ if ($^O eq 'MSWin32') {
+ $r = ($file =~ m;^([a-z]:(/|\\)|\\\\|//);i);
+ } else {
+ $r = ($file =~ m|^/|);
+ }
+ $r;
+ };
+ }
+}
+
+sub is_in_path {
+ my($prog) = @_;
+ return $prog if (file_name_is_absolute($prog) and -f $prog and -x $prog);
+ require Config;
+ my $sep = $Config::Config{'path_sep'} || ':';
+ foreach (split(/$sep/o, $ENV{PATH})) {
+ if ($^O eq 'MSWin32') {
+ # maybe use $ENV{PATHEXT} like maybe_command in ExtUtils/MM_Win32.pm?
+ return "$_\\$prog"
+ if (-x "$_\\$prog.bat" ||
+ -x "$_\\$prog.com" ||
+ -x "$_\\$prog.exe" ||
+ -x "$_\\$prog.cmd");
+ } else {
+ return "$_/$prog" if (-x "$_/$prog" && !-d "$_/$prog");
+ }
+ }
+ undef;
+}
#EOS
#### End of Patch data ####
#### ApplyPatch data follows ####
# Data version : 1.0
# Date generated : Wed Apr 21 00:08:24 2004
# Generated by : makepatch 2.00_05
# Recurse directories : Yes
# p 'Makefile.PL' 998 1082498812 0100751
#### End of ApplyPatch data ####
#### End of Patch kit [created: Wed Apr 21 00:08:24 2004] ####
#### Patch checksum: 81 2277 36133 ####
#### Checksum: 99 2901 22124 ####