From e2fbecbe40d6141002b7dc0dd4e860f4639ed520 Mon Sep 17 00:00:00 2001
From: Slaven Rezic <slaven@rezic.de>
Date: Mon, 20 May 2024 18:11:08 +0200
Subject: [PATCH] introduce --proj-version-lt in ALIEN_PROJ_CONFIG_ARGS

---
 alienfile | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/alienfile b/alienfile
index e508ce0..586ff75 100755
--- a/alienfile
+++ b/alienfile
@@ -107,11 +107,20 @@ share {
   #  say "libtiff libs: $ENV{TIFF_LIBS}";
   #}
 
+  my $config_args = $ENV{ALIEN_PROJ_CONFIG_ARGS} // '';
+  $config_args =~ s/[^-\s\w,=.]//g;  #  overkill?
 
   if ($on_windows) {
     #  there are issues with strawberry perl's gcc
     plugin 'Prefer::BadVersion' => '7.1.0';
   }
+  if ($config_args =~ /--proj-version-lt=(\S+)/) {
+      my $proj_version_lt = $1;
+      if ($proj_version_lt !~ /^\d+\.\d+\.\d+$/) {
+	  die "--proj-version-lt value '$proj_version_lt' does not look like a version.\n";
+      }
+      plugin 'Prefer::BadVersion' => sub { my($file) = @_; versioncmp($file->{version}, $proj_version_lt) >= 0 };
+  }
   
   start_url 'https://download.osgeo.org/proj/';
   #start_url "file://$base_dir";  #  debug
@@ -174,8 +183,6 @@ share {
     }
   }
   
-  my $config_args = $ENV{ALIEN_PROJ_CONFIG_ARGS} // '';
-  $config_args =~ s/[^-\s\w,=]//g;  #  overkill?
   my $enable_tiff = 'OFF';
   my $enable_curl = 'OFF';
   my @curl_extra_args;
-- 
2.11.0