diff --git a/moz.configure b/moz.configure index 618208ab4857..cb962ea9a6c0 100755 --- a/moz.configure +++ b/moz.configure @@ -498,49 +498,6 @@ def awk_for_old_configure(value): add_old_configure_assignment("AWK", awk_for_old_configure) -# Perl detection -# ============================================================== -perl = check_prog("PERL", ("perl5", "perl")) - - -@template -def perl_version_check(min_version): - @depends(perl) - @checking("for minimum required perl version >= %s" % min_version) - def get_perl_version(perl): - return Version( - check_cmd_output( - perl, - "-e", - "print $]", - onerror=lambda: die("Failed to get perl version."), - ) - ) - - @depends(get_perl_version) - def check_perl_version(version): - if version < min_version: - die("Perl %s or higher is required.", min_version) - - @depends(perl) - @checking("for full perl installation") - @imports("subprocess") - def has_full_perl_installation(perl): - ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"]) - return ret == 0 - - @depends(has_full_perl_installation) - def require_full_perl_installation(has_full_perl_installation): - if not has_full_perl_installation: - die( - "Cannot find Config.pm or $Config{archlib}. " - "A full perl installation is required." - ) - - -perl_version_check("5.006") - - # GNU make detection # ============================================================== option(env="MAKE", nargs=1, help="Path to GNU make") diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 6f4297d6bf81..b75071325648 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -3313,3 +3313,53 @@ set_config( "STL_FLAGS", depends(build_environment.dist)(lambda dist: [f"-I{dist}/stl_wrappers"]), ) + + +# Perl detection +# ============================================================== +@depends(target) +def need_perl(target): + # Ideally, we'd also depend on gnu_as here, but that adds complications. + return target.cpu == "arm" + + +perl = check_prog("PERL", ("perl5", "perl"), when=need_perl) + + +@template +def perl_version_check(min_version): + @depends(perl) + @checking("for minimum required perl version >= %s" % min_version) + def get_perl_version(perl): + return Version( + check_cmd_output( + perl, + "-e", + "print $]", + onerror=lambda: die("Failed to get perl version."), + ) + ) + + @depends(get_perl_version) + def check_perl_version(version): + if version < min_version: + die("Perl %s or higher is required.", min_version) + + @depends(perl) + @checking("for full perl installation") + @imports("subprocess") + def has_full_perl_installation(perl): + ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"]) + return ret == 0 + + @depends(has_full_perl_installation) + def require_full_perl_installation(has_full_perl_installation): + if not has_full_perl_installation: + die( + "Cannot find Config.pm or $Config{archlib}. " + "A full perl installation is required." + ) + + +with only_when(need_perl): + perl_version_check("5.006")