--- xc/config/imake/imake.c.orig 2005-03-02 17:30:31 +0300 +++ xc/config/imake/imake.c 2005-08-04 16:16:46 +0400 @@ -145,6 +145,11 @@ * #include INCLUDE_IMAKEFILE * */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) /* 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" @@ -396,6 +401,13 @@ 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 +439,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 +986,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; @@ -1790,7 +1802,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) {