summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/main.c b/main.c
index e9cdae5..35a388b 100644
--- a/main.c
+++ b/main.c
@@ -1255,17 +1255,47 @@ int main (int argc, char ** argv)
and thus re-read the makefiles, we read standard input
into a temporary file and read from that. */
FILE *outfile;
+ char *template, *tmpdir;
if (stdin_nm)
fatal (NILF, _("Makefile from standard input specified twice."));
#ifdef VMS
-# define TMP_TEMPLATE "sys$scratch:GmXXXXXX"
+# define DEFAULT_TMPDIR "sys$scratch:"
#else
-# define TMP_TEMPLATE "/tmp/GmXXXXXX"
+# ifdef P_tmpdir
+# define DEFAULT_TMPDIR P_tmpdir
+# else
+# define DEFAULT_TMPDIR "/tmp"
+# endif
+#endif
+#define DEFAULT_TMPFILE "GmXXXXXX"
+
+ if (((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0')
+#if defined __MSDOS__ || defined(WINDOWS32)
+ /* These are also used commonly on these platforms. */
+ && ((tmpdir = getenv ("TEMP")) == NULL || *tmpdir == '\0')
+ && ((tmpdir = getenv ("TMP")) == NULL || *tmpdir == '\0')
#endif
+ )
+ tmpdir = DEFAULT_TMPDIR;
+
+ template = (char *) alloca (strlen (tmpdir)
+ + sizeof (DEFAULT_TMPFILE) + 1);
+ strcpy (template, tmpdir);
+
+#if defined __MSDOS__ || defined(WINDOWS32)
+ if (strchr ("/\\", template[strlen (template) - 1]) == NULL)
+ strcat (template, "/");
+#else
+#ifndef VMS
+ if (template[strlen (template) - 1] != '/')
+ strcat (template, "/");
+#endif /* !VMS */
+#endif /* __MSDOS__ || WINDOWS32 */
- outfile = open_tmpfile (&stdin_nm, TMP_TEMPLATE);
+ strcat (template, DEFAULT_TMPFILE);
+ outfile = open_tmpfile (&stdin_nm, template);
if (outfile == 0)
pfatal_with_name (_("fopen (temporary file)"));
while (!feof (stdin))
@@ -2658,7 +2688,7 @@ print_version ()
printf (_(", by Richard Stallman and Roland McGrath.\n\
%sBuilt for %s\n\
-%sCopyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99\n\
+%sCopyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000\n\
%s\tFree Software Foundation, Inc.\n\
%sThis is free software; see the source for copying conditions.\n\
%sThere is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\