--- xc/config/imake/imake.c.orig 2005-02-10 17:13:03 +0300 +++ xc/config/imake/imake.c 2005-02-10 17:52:02 +0300 @@ -145,6 +145,11 @@ * #include INCLUDE_IMAKEFILE * */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + #if defined(__FreeBSD__) || defined(__NetBSD__) /* This needs to be before _POSIX_SOURCE gets defined */ # include @@ -329,8 +334,8 @@ char *cpp = NULL; -char *tmpMakefile = "/tmp/Imf.XXXXXX"; -char *tmpImakefile = "/tmp/IIf.XXXXXX"; +char *tmpMakefile; +char *tmpImakefile; char *make_argv[ ARGUMENTS ] = { #ifdef WIN32 "nmake" @@ -391,11 +396,16 @@ #endif boolean CrossCompiling = FALSE; - - boolean verbose = FALSE; boolean show = TRUE; +static char *get_tmp_file_name (void) +{ + char *name = 0; + asprintf (&name, "%s/imake.XXXXXX", getenv("TMPDIR") ?: "/tmp"); + return name; +} + int main(int argc, char *argv[]) { @@ -427,7 +437,7 @@ #ifdef HAS_MKSTEMP int fd; #endif - tmpMakefile = Strdup(tmpMakefile); + tmpMakefile = get_tmp_file_name(); #ifndef HAS_MKSTEMP if (mktemp(tmpMakefile) == NULL || (tmpfd = fopen(tmpMakefile, "w+")) == NULL) { @@ -974,7 +984,7 @@ static void get_libc_version(FILE *inFile) { - char aout[] = "/tmp/imakeXXXXXX"; + char *aout = get_tmp_file_name(); FILE *fp; const char *format = "%s -o %s -x c -"; char *cc; @@ -1787,7 +1797,7 @@ #ifdef HAS_MKSTEMP int fd; #endif - tmpImakefile = Strdup(tmpImakefile); + tmpImakefile = get_tmp_file_name(); #ifndef HAS_MKSTEMP if (mktemp(tmpImakefile) == NULL || (outFile = fopen(tmpImakefile, "w+")) == NULL) {