From 50f2ff0be52b0ced5c3d9c5c082ae8d865304544 Mon Sep 17 00:00:00 2001 From: Slaven Rezic Date: Thu, 3 Apr 2025 21:59:10 +0200 Subject: [PATCH] allow building with older gcc versions (GH#15) --- alienfile | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/alienfile b/alienfile index 00e9081..067e536 100644 --- a/alienfile +++ b/alienfile @@ -115,10 +115,24 @@ share { start_url 'https://download.osgeo.org/proj/'; #start_url "file://$base_dir"; # debug - plugin Download => ( - filter => qr/^proj-([0-9\.]+)\.tar\.gz$/, - version => qr/^proj-([0-9\.]+)\.tar\.gz$/, - ); + + my $gcc_version = detect_gcc_version(); + if ($gcc_version && $gcc_version < 7) { + plugin Download => ( + filter => qr/^proj-8\.2\.1\.tar\.gz$/, + version => qr/^proj-([0-9\.]+)\.tar\.gz$/, + ); + } elsif ($gcc_version && $gcc_version < 12) { + plugin Download => ( + filter => qr/^proj-9\.5\.1\.tar\.gz$/, + version => qr/^proj-([0-9\.]+)\.tar\.gz$/, + ); + } else { + plugin Download => ( + filter => qr/^proj-([0-9\.]+)\.tar\.gz$/, + version => qr/^proj-([0-9\.]+)\.tar\.gz$/, + ); + } my $proj_version = get_proj_version() // 'not yet defined'; say "Downloaded proj version is $proj_version"; @@ -505,3 +519,11 @@ sub get_alien_state_hash { return $h; } +sub detect_gcc_version { + my $gcc_output = `gcc --version`; + if ($gcc_output =~ /gcc\s+\(.*?\)\s+(\d+)\.(\d+)\.(\d+)/) { + my ($major, $minor, $patch) = ($1, $2, $3); + return "$major.$minor"; # Return major.minor as a floating-point number + } + return undef; # GCC not found or failed to parse version +} -- 2.11.0