* default.c, main.c, makeint.h, vmsfunctions.c: prefix argv[0] with
"mcr " for MAKE/MAKE_COMMAND and set the program name
to the image filename (without the .exe;version)
* vmsfunctions.c: remove obsolete code
---
default.c | 3 +-
main.c | 14 +++--
makeint.h | 8 ++-
vmsfunctions.c | 167
+++++++++++++++-----------------------------------------
4 files changed, 61 insertions(+), 131 deletions(-)
>From dee23c89b7ea34216a67266d959d9d2b09d585d8 Mon Sep 17 00:00:00 2001
From: Hartmut Becker <[email protected]>
Date: Thu, 21 Aug 2014 23:10:39 +0200
Subject: [PATCH] Enhance/fix VMS setting of program name, MAKE/MAKE_COMMAND
variables
* default.c, main.c, makeint.h, vmsfunctions.c: prefix argv[0] with
"mcr " for MAKE/MAKE_COMMAND and set the program name
to the image filename (without the .exe;version)
* vmsfunctions.c: remove obsolete code
---
default.c | 3 +-
main.c | 14 +++--
makeint.h | 8 ++-
vmsfunctions.c | 167 +++++++++++++++-----------------------------------------
4 files changed, 61 insertions(+), 131 deletions(-)
diff --git a/default.c b/default.c
index 48b899d..4eedff7 100644
--- a/default.c
+++ b/default.c
@@ -1,5 +1,5 @@
/* Data base of default implicit rules for GNU Make.
-Copyright (C) 1988-2013 Free Software Foundation, Inc.
+Copyright (C) 1988-2014 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@@ -332,7 +332,6 @@ static const char *default_variables[] =
"CC", "cc",
#endif
"CD", "builtin_cd",
- "MAKE", "make",
"ECHO", "write sys$$output \"",
#ifdef GCC_IS_NATIVE
"C++", "gcc/plus",
diff --git a/main.c b/main.c
index 0508ae1..754f794 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
/* Argument parsing and main program of GNU Make.
-Copyright (C) 1988-2013 Free Software Foundation, Inc.
+Copyright (C) 1988-2014 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@@ -1161,11 +1161,7 @@ main (int argc, char **argv, char **envp)
program = "make";
else
{
-#ifdef VMS
- program = strrchr (argv[0], ']');
-#else
program = strrchr (argv[0], '/');
-#endif
#if defined(__MSDOS__) || defined(__EMX__)
if (program == 0)
program = strrchr (argv[0], '\\');
@@ -1195,7 +1191,11 @@ main (int argc, char **argv, char **envp)
}
#endif
if (program == 0)
+#ifdef VMS
+ program = vms_progname(argv[0]);
+#else
program = argv[0];
+#endif
else
++program;
}
@@ -1581,7 +1581,11 @@ main (int argc, char **argv, char **envp)
/* The extra indirection through $(MAKE_COMMAND) is done
for hysterical raisins. */
+#ifdef VMS
+ define_variable_cname("MAKE_COMMAND", vms_command(argv[0]), o_default, 0);
+#else
define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0);
+#endif
define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1);
if (command_variables != 0)
diff --git a/makeint.h b/makeint.h
index 5133cf1..3916e0a 100644
--- a/makeint.h
+++ b/makeint.h
@@ -1,5 +1,5 @@
/* Miscellaneous global declarations and portability cruft for GNU Make.
-Copyright (C) 1988-2013 Free Software Foundation, Inc.
+Copyright (C) 1988-2014 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@@ -614,6 +614,12 @@ extern char *program;
#else
extern const char *program;
#endif
+
+#ifdef VMS
+char *vms_command(const char *argv0);
+char *vms_progname(const char *argv0);
+#endif
+
extern char *starting_directory;
extern unsigned int makelevel;
extern char *version_string, *remote_description, *make_host;
diff --git a/vmsfunctions.c b/vmsfunctions.c
index 1907e3a..03e5bc4 100644
--- a/vmsfunctions.c
+++ b/vmsfunctions.c
@@ -1,5 +1,5 @@
/* VMS functions
-Copyright (C) 1996-2013 Free Software Foundation, Inc.
+Copyright (C) 1996-2014 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@@ -127,135 +127,56 @@ closedir (DIR *dir)
}
#endif /* compiled for OpenVMS prior to V7.x */
+/*
+ * Argv0 will be a full vms file specification, like
+ * node$dka100:[utils.gnumake]make.exe;47
+ * prefix it with "mcr " to make it a vms command, executable for DCL.
+ */
char *
-getwd (char *cwd)
+vms_command(const char* argv0)
{
- static char buf[512];
-
- if (cwd)
- return (getcwd (cwd, 512));
- else
- return (getcwd (buf, 512));
+ size_t l = strlen(argv0) + 1;
+ char* s = malloc(l + 4);
+ memcpy(s, "mcr ", 4);
+ memcpy(s+4, argv0, l);
+ return s;
}
-#if 0
/*
- * Is this used? I don't see any reference, so I suggest to remove it.
+ * Argv0 will be a full vms file specification, like
+ * node$dka100:[utils.gnumake]make.exe;47
+ * the vms progname should be ^^^^, the filename without
+ * file type .exe and ;version (and there are some checks,
+ * just in case something unexpected is passed and then the
+ * progname is set to "make").
*/
-int
-vms_stat (char *name, struct stat *buf)
+char *
+vms_progname(const char* argv0)
{
- int status;
- int i;
-
- static struct FAB Fab;
- static struct NAM Nam;
- static struct fibdef Fib; /* short fib */
- static struct dsc$descriptor FibDesc =
- { sizeof (Fib), DSC$K_DTYPE_Z, DSC$K_CLASS_S, (char *) &Fib };
- static struct dsc$descriptor_s DevDesc =
- { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &Nam.nam$t_dvi[1] };
- static char EName[NAM$C_MAXRSS];
- static char RName[NAM$C_MAXRSS];
- static struct dsc$descriptor_s FileName =
- { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0 };
- static struct dsc$descriptor_s string =
- { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0 };
- static unsigned long Rdate[2];
- static unsigned long Cdate[2];
- static struct atrdef Atr[] =
- {
-#if defined(VAX)
- /* Revision date */
- { sizeof (Rdate), ATR$C_REVDATE, (unsigned int) &Rdate[0] },
- /* Creation date */
- { sizeof (Cdate), ATR$C_CREDATE, (unsigned int) &Cdate[0] },
-#else
- /* Revision date */
- { sizeof (Rdate), ATR$C_REVDATE, &Rdate[0] },
- /* Creation date */
- { sizeof (Cdate), ATR$C_CREDATE, &Cdate[0]},
-#endif
- { 0, 0, 0 }
- };
- static short int DevChan;
- static short int iosb[4];
-
- name = vmsify (name, 0);
-
- /* initialize RMS structures, we need a NAM to retrieve the FID */
- Fab = cc$rms_fab;
- Fab.fab$l_fna = name; /* name of file */
- Fab.fab$b_fns = strlen (name);
- Fab.fab$l_nam = &Nam; /* FAB has an associated NAM */
-
- Nam = cc$rms_nam;
- Nam.nam$l_esa = EName; /* expanded filename */
- Nam.nam$b_ess = sizeof (EName);
- Nam.nam$l_rsa = RName; /* resultant filename */
- Nam.nam$b_rss = sizeof (RName);
-
- /* do $PARSE and $SEARCH here */
- status = sys$parse (&Fab);
- if (!(status & 1))
- return -1;
-
- DevDesc.dsc$w_length = Nam.nam$t_dvi[0];
- status = sys$assign (&DevDesc, &DevChan, 0, 0);
- if (!(status & 1))
- return -1;
-
- FileName.dsc$a_pointer = Nam.nam$l_name;
- FileName.dsc$w_length = Nam.nam$b_name + Nam.nam$b_type + Nam.nam$b_ver;
-
- /* Initialize the FIB */
- for (i = 0; i < 3; i++)
+ int len;
+ char *progname;
+ char *p;
+ p = strrchr(argv0, ']');
+ if (p)
{
-#ifndef __VAXC
- Fib.fib$w_fid[i] = Nam.nam$w_fid[i];
- Fib.fib$w_did[i] = Nam.nam$w_did[i];
-#else
- Fib.fib$r_fid_overlay.fib$w_fid[i] = Nam.nam$w_fid[i];
- Fib.fib$r_did_overlay.fib$w_did[i] = Nam.nam$w_did[i];
-#endif
+ p++;
+ if (*p)
+ {
+ progname = malloc(strlen(p) + 1);
+ strcpy(progname, p);
+ p = strrchr(progname, ';');
+ if (p)
+ *p = '\0';
+ len = strlen(progname);
+ if (0 == strcasecmp(&progname[len - 4], ".exe"))
+ progname[len - 4] = '\0';
+ if (!*progname)
+ progname = "make";
+ }
+ else
+ progname = "make";
}
-
- status = sys$qiow (0, DevChan, IO$_ACCESS, &iosb, 0, 0,
- &FibDesc, &FileName, 0, 0, &Atr, 0);
- sys$dassgn (DevChan);
- if (!(status & 1))
- return -1;
- status = iosb[0];
- if (!(status & 1))
- return -1;
-
- status = stat (name, buf);
- if (status)
- return -1;
-
- buf->st_mtime = ((Rdate[0] >> 24) & 0xff) + ((Rdate[1] << 8) & 0xffffff00);
- buf->st_ctime = ((Cdate[0] >> 24) & 0xff) + ((Cdate[1] << 8) & 0xffffff00);
-
- return 0;
-}
-#endif
-
-char *
-cvt_time (unsigned long tval)
-{
- static long int date[2];
- static char str[27];
- static struct dsc$descriptor date_str =
- { 26, DSC$K_DTYPE_T, DSC$K_CLASS_S, str };
-
- date[0] = (tval & 0xff) << 24;
- date[1] = ((tval >> 8) & 0xffffff);
-
- if ((date[0] == 0) && (date[1] == 0))
- return ("never");
-
- sys$asctim (0, &date_str, date, 0);
- str[26] = '\0';
-
- return (str);
+ else
+ progname = "make";
+ return progname;
}
--
1.7.10.4
_______________________________________________
Bug-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-make