summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2023-01-07 21:50:59 -0500
committerPaul Smith <psmith@gnu.org>2023-01-08 10:45:38 -0500
commit11444fb001cf57f32fb5022cd934c3cf489e66b2 (patch)
tree137a265d39ea813a74cb187f6a84771fc3ac68e5 /src
parent0de7a0d3bf29a240c5e0fef79b5b3eae8a6a01f5 (diff)
downloadmake-git-11444fb001cf57f32fb5022cd934c3cf489e66b2.tar.gz
[SV 62654] Support GNU Make on z/OS
Original patches provided by Igor Todorovski <itodorov@ca.ibm.com> Reworked by Paul Smith <psmith@gnu.org>. Thanks to IBM for providing a test system. * NEWS: Announce support. * AUTHORS: Ditto. * README.zOS: Provide details on building GNU Make on z/OS. * build.sh (get_mk_var): z/OS sh has a strange bug which causes it to generate extra lines of output: rework the function to print output as we compute it instead of collecting it into a variable, which works around this bug. * src/makeint.h: Declare MK_OS_ZOS if we're building for z/OS. * src/arscan.c: Don't include <ar.h> on z/OS. * src/job.c: We can't change environ in ASCII mode on z/OS. * src/main.c: Ditto. Also we can't use pselect() on z/OS. * src/posixos.c: pselect() seems to hang on z/OS: don't use it. * tests/run_make_tests.pl: Handle different exit codes on z/OS. * tests/test_driver.pl: Preserve some special z/OS env.vars. Add special checks to output comparisons when on z/OS. * tests/scripts/features/archives: Don't validate names. Don't try to compile empty files as IBM compilers complain. * tests/scripts/features/shell_assignment: Fix octal value of #. * tests/scripts/features/temp_stdin: Don't print "term". * tests/scripts/functions/shell: Handle shell exit codes. * tests/scripts/targets/ONESHELL: Ditto. * tests/scripts/targets/POSIX: sh -x prints differently. * tests/scripts/variables/SHELL: Ditto.
Diffstat (limited to 'src')
-rw-r--r--src/arscan.c2
-rw-r--r--src/job.c8
-rw-r--r--src/main.c12
-rw-r--r--src/makeint.h5
-rw-r--r--src/posixos.c6
5 files changed, 29 insertions, 4 deletions
diff --git a/src/arscan.c b/src/arscan.c
index 75d678bf..edd4070c 100644
--- a/src/arscan.c
+++ b/src/arscan.c
@@ -331,7 +331,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *varg)
#endif
#ifndef WINDOWS32
-# if !defined (__ANDROID__) && !defined (__BEOS__)
+# if !defined (__ANDROID__) && !defined (__BEOS__) && !defined(MK_OS_ZOS)
# include <ar.h>
# else
/* These platforms don't have <ar.h> but have archives in the same format
diff --git a/src/job.c b/src/job.c
index a42c426c..3fab8012 100644
--- a/src/job.c
+++ b/src/job.c
@@ -2586,6 +2586,11 @@ exec_command (char **argv, char **envp)
if (errno == ENOENT)
errno = ENOEXEC;
+# elif MK_OS_ZOS
+ /* In z/OS we can't set environ in ASCII mode. */
+ environ = envp;
+ execvpe(argv[0], argv, envp);
+
# else
/* Run the program. Don't use execvpe() as we want the search for argv[0]
@@ -2653,6 +2658,9 @@ exec_command (char **argv, char **envp)
pid = spawnvpe (P_NOWAIT, shell, new_argv, envp);
if (pid >= 0)
break;
+# elif MK_OS_ZOS
+ /* In z/OS we can't set environ in ASCII mode. */
+ execvpe(shell, new_argv, envp);
# else
execvp (shell, new_argv);
# endif
diff --git a/src/main.c b/src/main.c
index 4d4b88fe..433f5826 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1159,7 +1159,11 @@ temp_stdin_unlink ()
}
}
-#ifdef _AMIGA
+#ifdef MK_OS_ZOS
+extern char **environ;
+#endif
+
+#if defined(_AMIGA) || defined(MK_OS_ZOS)
int
main (int argc, char **argv)
#else
@@ -1477,6 +1481,10 @@ main (int argc, char **argv, char **envp)
done before $(MAKE) is figured out so its definitions will not be
from the environment. */
+#ifdef MK_OS_ZOS
+ char **envp = environ;
+#endif
+
#ifndef _AMIGA
{
unsigned int i;
@@ -1997,7 +2005,7 @@ main (int argc, char **argv, char **envp)
# endif
}
-#ifdef HAVE_PSELECT
+#if defined(HAVE_PSELECT) && !defined(MK_OS_ZOS)
/* If we have pselect() then we need to block SIGCHLD so it's deferred. */
{
sigset_t block;
diff --git a/src/makeint.h b/src/makeint.h
index fe49cffd..187974e4 100644
--- a/src/makeint.h
+++ b/src/makeint.h
@@ -82,6 +82,11 @@ this program. If not, see <https://www.gnu.org/licenses/>. */
extern int errno;
#endif
+/* Define macros specifying which OS we are building for. */
+#if defined(__MVS__)
+# define MK_OS_ZOS 1
+#endif
+
#ifdef __VMS
/* In strict ANSI mode, VMS compilers should not be defining the
VMS macro. Define it here instead of a bulk edit for the correct code.
diff --git a/src/posixos.c b/src/posixos.c
index 3e865cfd..164e0fba 100644
--- a/src/posixos.c
+++ b/src/posixos.c
@@ -24,6 +24,10 @@ this program. If not, see <https://www.gnu.org/licenses/>. */
#elif defined(HAVE_SYS_FILE_H)
# include <sys/file.h>
#endif
+#if MK_OS_ZOS
+/* FIXME: HAVE_PSELECT path hangs on z/OS */
+#undef HAVE_PSELECT
+#endif
#if !defined(FD_OK)
# define FD_OK(_f) 1
@@ -617,7 +621,7 @@ jobserver_acquire (int timeout)
go back and reap_children(), and try again. */
errno = saved_errno;
- if (errno != EINTR && errno != EBADF)
+ if (errno != EINTR && errno != EBADF && errno != EAGAIN)
pfatal_with_name (_("read jobs pipe"));
if (errno == EBADF)