>From e6b6dbd3e37fd16aa06ea7dcf5833b0412960ed6 Mon Sep 17 00:00:00 2001
From: igor2 <igor2@997a6158-8d80-4c00-925a-7ca3944c4d11>
Date: Sat, 7 Dec 2024 12:31:02 +0000
Subject: [PATCH 1/2] -Add: optional detector for perl: perl_with_IXpv -
 accepts perl only if IXpv is available

git-svn-id: svn://repo.hu/scconfig/trunk/src@1857 997a6158-8d80-4c00-925a-7ca3944c4d11
---
 scconfig/src/scripts/find_perl.c   | 21 +++++++++++++++++++--
 scconfig/src/scripts/find_python.c |  6 +++---
 scconfig/src/scripts/scripts.c     |  1 +
 scconfig/src/scripts/scripts.h     |  1 +
 4 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/scconfig/src/scripts/find_perl.c b/scconfig/src/scripts/find_perl.c
index 87d4a32..6fcf1fb 100644
--- a/scconfig/src/scripts/find_perl.c
+++ b/scconfig/src/scripts/find_perl.c
@@ -22,11 +22,12 @@
 
 #include "scripts.h"
 
-int find_script_perl(const char *name, int logdepth, int fatal)
+static int find_script_perl_(const char *name, int logdepth, int fatal, char *extra)
 {
 	char *cflags, *ldflags, *s;
 	int res;
-	char *test_c =
+	char test_c[256];
+	char *test_c_in =
 		NL "#include <stdio.h>"
 		NL "#include <EXTERN.h>"
 		NL "#include <perl.h>"
@@ -34,11 +35,14 @@ int find_script_perl(const char *name, int logdepth, int fatal)
 		NL "	PerlInterpreter *interp;"
 		NL
 		NL "	interp = perl_alloc();"
+		NL "%s"
 		NL "	puts(\"OK\");"
 		NL "	return 0;"
 		NL "}"
 		NL;
 
+	sprintf(test_c, test_c_in, extra);
+
 	require("sys/class", logdepth, fatal);
 	require("cc/cc", logdepth, fatal);
 	require("/internal/filelist/method", logdepth, fatal);
@@ -83,3 +87,16 @@ int find_script_perl(const char *name, int logdepth, int fatal)
 
 	return try_fail(logdepth, "libs/script/perl");
 }
+
+int find_script_perl(const char *name, int logdepth, int fatal)
+{
+	return find_script_perl_(name, logdepth, fatal, "");
+}
+
+int find_script_perl_with_IXpv(const char *name, int logdepth, int fatal)
+{
+	int res = find_script_perl_(name, logdepth, fatal, "(void)interp->IXpv;");
+	put("libs/script/perl_with_IXpv", "tried");
+	return res;
+}
+
diff --git a/scconfig/src/scripts/find_python.c b/scconfig/src/scripts/find_python.c
index efde6a8..a3d8862 100644
--- a/scconfig/src/scripts/find_python.c
+++ b/scconfig/src/scripts/find_python.c
@@ -43,13 +43,13 @@ static int find_script_python_(const char *name, int logdepth, int fatal, int ve
 
 	char *inc_py =
 		NL "import distutils.sysconfig;"
-		NL "print '-I' + distutils.sysconfig.get_python_inc().replace('\\\\','/')"
+		NL "print ('-I' + distutils.sysconfig.get_python_inc().replace('\\\\','/'))"
 		NL;
 	char *lib_py =
 		NL "import distutils.sysconfig;"
-		NL "print '-L' + distutils.sysconfig.PREFIX.replace('\\\\','/') + '/libs',;"
+		NL "print ('-L' + distutils.sysconfig.PREFIX.replace('\\\\','/') + '/libs')"
 		NL "import sys;"
-		NL "print '-lpython' + str(sys.version_info[0]) + str(sys.version_info[1])"
+		NL "print ('-lpython' + str(sys.version_info[0]) + str(sys.version_info[1]))"
 		NL;
 
 
diff --git a/scconfig/src/scripts/scripts.c b/scconfig/src/scripts/scripts.c
index 8f5035e..2d7123f 100644
--- a/scconfig/src/scripts/scripts.c
+++ b/scconfig/src/scripts/scripts.c
@@ -34,6 +34,7 @@ void deps_scripts_init()
 	dep_add("libs/script/python/*",         find_script_python);
 	dep_add("libs/script/python3/*",        find_script_python3);
 	dep_add("libs/script/perl/*",           find_script_perl);
+	dep_add("libs/script/perl_with_IXpv",   find_script_perl_with_IXpv);
 	dep_add("libs/script/mawk/*",           find_script_mawk);
 	dep_add("libs/script/lua/*",            find_script_lua);
 	dep_add("libs/script/guile/*",          find_script_guile);
diff --git a/scconfig/src/scripts/scripts.h b/scconfig/src/scripts/scripts.h
index 95a3799..e18f80c 100644
--- a/scconfig/src/scripts/scripts.h
+++ b/scconfig/src/scripts/scripts.h
@@ -18,6 +18,7 @@ int find_script_mruby(const char *name, int logdepth, int fatal);
 int find_script_python(const char *name, int logdepth, int fatal);
 int find_script_python3(const char *name, int logdepth, int fatal);
 int find_script_perl(const char *name, int logdepth, int fatal);
+int find_script_perl_with_IXpv(const char *name, int logdepth, int fatal);
 int find_script_mawk(const char *name, int logdepth, int fatal);
 int find_script_lua(const char *name, int logdepth, int fatal);
 int find_script_guile(const char *name, int logdepth, int fatal);
-- 
2.49.0

