mirror of
https://github.com/mirror/make.git
synced 2025-01-01 07:50:52 +08:00
* src/misc.c (get_tmpdir): Report errors if tmpdirs are invalid
* src/main.c (main): Set up initial temporary directories.
This commit is contained in:
parent
252c26bd20
commit
deb4a42c3e
@ -1390,6 +1390,10 @@ main (int argc, char **argv, char **envp)
|
||||
|
||||
initialize_global_hash_tables ();
|
||||
|
||||
/* Ensure the temp directory is set up: we don't want the first time we use
|
||||
it to be in a forked process. */
|
||||
get_tmpdir ();
|
||||
|
||||
/* Figure out where we are. */
|
||||
|
||||
#ifdef WINDOWS32
|
||||
|
34
src/misc.c
34
src/misc.c
@ -568,7 +568,6 @@ umask (mode_t mask)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MAKE_TMPDIR "MAKE_TMPDIR"
|
||||
#ifdef VMS
|
||||
# define DEFAULT_TMPFILE "sys$scratch:gnv$make_cmdXXXXXX.com"
|
||||
#else
|
||||
@ -582,13 +581,36 @@ get_tmpdir ()
|
||||
|
||||
if (!tmpdir)
|
||||
{
|
||||
if (((tmpdir = getenv (MAKE_TMPDIR)) == NULL || *tmpdir == '\0')
|
||||
#if defined (__MSDOS__) || defined (WINDOWS32) || defined (__EMX__)
|
||||
&& ((tmpdir = getenv ("TMP")) == NULL || *tmpdir == '\0')
|
||||
&& ((tmpdir = getenv ("TEMP")) == NULL || *tmpdir == '\0')
|
||||
# define TMP_EXTRAS "TMP", "TEMP",
|
||||
#else
|
||||
# define TMP_EXTRAS
|
||||
#endif
|
||||
&& ((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0'))
|
||||
tmpdir = DEFAULT_TMPDIR;
|
||||
const char *tlist[] = { "MAKE_TMPDIR", "TMPDIR", TMP_EXTRAS NULL };
|
||||
const char **tp;
|
||||
unsigned int found = 0;
|
||||
|
||||
for (tp = tlist; *tp; ++tp)
|
||||
if ((tmpdir = getenv (*tp)) && *tmpdir != '\0')
|
||||
{
|
||||
struct stat st;
|
||||
int r;
|
||||
found = 1;
|
||||
EINTRLOOP(r, stat (tmpdir, &st));
|
||||
if (r < 0)
|
||||
OSSS (error, NILF,
|
||||
_("%s value %s: %s"), *tp, tmpdir, strerror (errno));
|
||||
else if (! S_ISDIR (st.st_mode))
|
||||
OSS (error, NILF,
|
||||
_("%s value %s: not a directory"), *tp, tmpdir);
|
||||
else
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
tmpdir = DEFAULT_TMPDIR;
|
||||
|
||||
if (found)
|
||||
OS (error, NILF, _("using default temporary directory '%s'"), tmpdir);
|
||||
}
|
||||
|
||||
return tmpdir;
|
||||
|
Loading…
Reference in New Issue
Block a user