summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2000-04-22 02:11:17 +0000
committerPaul Smith <psmith@gnu.org>2000-04-22 02:11:17 +0000
commit5ed9fb46b28be4a703c1d88915fa150f0b74d5f4 (patch)
tree61047b6120465235eb65f70345fb3afd4b8a063b /main.c
parentf9c91ec34d9427c35bceec9b025a0bb20c9ec17f (diff)
downloadgunmake-5ed9fb46b28be4a703c1d88915fa150f0b74d5f4.tar.gz
* Various bug fixes.
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\