// SPDX-License-Identifier: GPL-3.0-or-later // Select the matching relocatable Perl installation. Architecture-specific // Config.pm and XS modules remain paired with the interpreter that built them. #include #include #include #include #include #include int main(int argc, char **argv) { (void)argc; char path[PATH_MAX], resolved[PATH_MAX]; uint32_t size = sizeof path; if (_NSGetExecutablePath(path, &size) || !realpath(path, resolved)) { perror("Cannot locate bundled Perl"); return 1; } char *last = strrchr(resolved, '/'); if (!last) return 1; *last = 0; last = strrchr(resolved, '/'); if (!last) return 1; *last = 0; #if defined(__aarch64__) const char *relative = "/libexec/perl/arm64/bin/perl"; #elif defined(__x86_64__) const char *relative = "/libexec/perl/x86_64/bin/perl"; #else #error Unsupported Perl host architecture #endif if (strlen(resolved) + strlen(relative) >= sizeof path) return 1; snprintf(path, sizeof path, "%s%s", resolved, relative); argv[0] = path; execv(path, argv); perror("Cannot execute bundled Perl"); return 1; }