Browse Source

build: Check for the required minimal perl version

We document the minimal perl version required at build and run-time, but
we should instead do an actual check so that this is catched earlier and
gives less surprises during the build process.
Guillem Jover 7 years ago
parent
commit
5a0276aaac
2 changed files with 15 additions and 3 deletions
  1. 1 0
      debian/changelog
  2. 14 3
      m4/dpkg-progs.m4

+ 1 - 0
debian/changelog

@@ -22,6 +22,7 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
     - Require libselinux 2.0.99 for baseline API, remove static linking
       support, use pkg-config unconditionally, and perform refinement checks
       only if available.
+    - Check for the required minimal perl version.
 
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).

+ 14 - 3
m4/dpkg-progs.m4

@@ -7,10 +7,21 @@
 # Locate perl interpreter in the path
 AC_DEFUN([DPKG_PROG_PERL], [
   AC_ARG_VAR([PERL], [Perl interpreter])dnl
-  AC_PATH_PROG([PERL], [perl], [no])
-  AS_IF([test "$PERL" = "no" || test ! -x "$PERL"], [
-    AC_MSG_ERROR([cannot find the Perl interpreter])
+  m4_define([PERL_MIN_VERSION], [5.14.2])
+  AC_CACHE_CHECK([for perl >= PERL_MIN_VERSION], [ac_cv_path_PERL], [
+    AC_PATH_PROGS_FEATURE_CHECK([PERL], [perl], [
+      perlcheck=$(test -x $ac_path_PERL && \
+                  $ac_path_PERL -MConfig -Mversion -e \
+                  'my $r = qv("v$Config{version}") >= qv("PERL_MIN_VERSION");
+                   print "yes" if $r')
+      AS_IF([test "x$perlcheck" = "xyes"], [
+        ac_cv_path_PERL=$ac_path_PERL ac_path_PERL_found=:
+      ])
+    ], [
+      AC_MSG_ERROR([cannot find perl >= PERL_MIN_VERSION])
+    ])
   ])
+  AC_SUBST([PERL], [$ac_cv_path_PERL])
   AC_ARG_VAR([PERL_LIBDIR], [Perl library directory])dnl
   # Let the user override the variable.
   AS_IF([test -z "$PERL_LIBDIR"], [