Skip Menu |

This queue is for tickets about the Geo-GDAL CPAN distribution.

Report information
The Basics
Id: 116577
Status: new
Priority: 0/
Queue: Geo-GDAL

People
Owner: Nobody in particular
Requestors: SLAFFAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.010004
Fixed in: (no value)



Subject: Makefile.PL assumes bash available
Hello Ari, The Geo::GDAL Makefile.PL calls several bash utilities which are not available on windows by default (grep for example). If I add winbash to the path then makefile.PL tries to execute gdal-config and fails. These calls are at lines 433, 437 and 438. Changing the calls from `$config --cflags` to `sh $config --cflags` makes the error go away and the build gets to the next step (which fails, but that's for a separate report). If you're wondering why I'm trying this, it is part of an attempt to build Geo::GDAL using Strawberry Perl - I can build GDAL using MinGW with the Strawberry gcc, but have to switch back to the CMD window because dmake converts the path separator to backslashes which won't work under mingw. It's an odd approach, but has worked in the past with perl 5.16 and gdal 1.11. Thanks, Shawn.
Actually, directly parsing gdal-config avoids calling out to any shell commands (and was being used in some places already). The attached diff includes the addition of a sub to parse gdal-config, load the values into a hash, and then access these elsewhere in the Makefile. I have not tested it extensively, so perhaps treat it as a proof of concept at this stage. Regards, Shawn. On Sat Jul 30 02:42:19 2016, SLAFFAN wrote: Show quoted text
> Hello Ari, > > The Geo::GDAL Makefile.PL calls several bash utilities which are not > available on windows by default (grep for example). > > If I add winbash to the path then makefile.PL tries to execute gdal- > config and fails. These calls are at lines 433, 437 and 438. > > Changing the calls from `$config --cflags` to `sh $config --cflags` > makes the error go away and the build gets to the next step (which > fails, but that's for a separate report). > > > If you're wondering why I'm trying this, it is part of an attempt to > build Geo::GDAL using Strawberry Perl - I can build GDAL using MinGW > with the Strawberry gcc, but have to switch back to the CMD window > because dmake converts the path separator to backslashes which won't > work under mingw. It's an odd approach, but has worked in the past > with perl 5.16 and gdal 1.11. > > Thanks, > Shawn.
Subject: Makefile.PL.diff
19a20 > $_ = '' if /^--debug/; 106c107 < for ('c:/msys/1.0/local/bin/gdal-config', --- > for ('/c/msys/1.0/local/bin/gdal-config', 128a130 > my %gdal_cfg_hash = parse_gdal_config ($config); 165,170c167,170 < my $have_gnm = `grep "CONFIG_GNM_ENABLED" $config`; < my $have_ogr = `grep "CONFIG_OGR_ENABLED" $config`; < for ($have_gnm, $have_ogr) { < chomp; < $_ = /yes/ ? 1 : 0; < } --- > # reload as $config have been rebuilt? > %gdal_cfg_hash = parse_gdal_config ($config); > my $have_gnm = $gdal_cfg_hash{CONFIG_GNM_ENABLED} eq 'yes' ? 1 : 0; > my $have_ogr = $gdal_cfg_hash{CONFIG_OGR_ENABLED} eq 'yes' ? 1 : 0; 389,402c389 < my $version; < if (-x $config) { < chomp($version = `$config --version`); < } < else { < if (open(my $fh, $config) || die "Can't open '$config': $!") { < for (<$fh>) { < ($version) = /(\d+\.\d+\.\d+)/ if /^CONFIG_VERSION/; < } < close $fh; < } < die "Can't find version from '$config'." unless $version; < } < return $version; --- > return $gdal_cfg_hash{CONFIG_VERSION}; 410c397 < chomp($INC = `$config --cflags`); --- > $INC = $gdal_cfg_hash{CONFIG_CFLAGS}; 414,415c401,402 < chomp($INC = `$config --cflags`); < chomp($LIB = `$config --libs`); --- > $INC = $gdal_cfg_hash{CONFIG_CFLAGS}; > $LIB = $gdal_cfg_hash{CONFIG_LIBS}; 418,441c405,409 < if (open(my $fh, $config) || die "Can't open '$config': $!") { < for (<$fh>) { < if (/^CONFIG_LIBS/) { < s/^CONFIG_LIBS="//; < s/"\s*$//; < if ($_ =~ /\.la$/) { < $LIB .= parse_libtool_library_file_for_l($_); < } else { < $LIB .= $_; < } < $LIB .= ' '; < } < if (/^CONFIG_DEP_LIBS/) { < s/^CONFIG_DEP_LIBS="//; < s/"\s*$//; < $LIB .= $_; < } < if (/^CONFIG_CFLAGS/) { < s/^CONFIG_CFLAGS="//; < s/"\s*$//; < $INC .= $_; < } < } < close $fh; --- > if ($gdal_cfg_hash{CONFIG_LIBS} =~ /\.la$/) { > $LIB .= parse_libtool_library_file_for_l($gdal_cfg_hash{CONFIG_LIBS}); > } > else { > $LIB .= $gdal_cfg_hash{CONFIG_LIBS}; 442a411,414 > $LIB .= ' '; > $LIB .= $gdal_cfg_hash{CONFIG_DEP_LIBS}; > > $INC .= $gdal_cfg_hash{CONFIG_CFLAGS}; 464a437,460 > > > sub parse_gdal_config { > my $config = shift; > return if !$config; > > my %config_params; > > open my $fh, '<', $config or die "Unable to open $config"; > while (defined (my $line = <$fh>)) { > last if $line =~ /^usage()/; > next if $line =~ /^#/; > chomp $line; > my @components = split '=', $line; > my $key = $components[0]; > my $value = $components[1]; > $value =~ s/^"//; > $value =~ s/"\s*$//; > $config_params{$key} = $value; > } > > return %config_params; > } >