"}\n"
;
+#define libc32path "/usr/lib/libc.so"
+#define libc64path "/usr/lib64/libc.so"
+
static void
get_libc_version(FILE *inFile)
{
if (!strcmp(u.sysname, "Linux") &&
(!strcmp(u.machine, "x86_64"))) {
- if (!lstat ("/usr/lib64/libc.so", &sb) && S_ISREG(sb.st_mode)) {
- libcso = strdup("/usr/lib64/libc.so");
+ if (!lstat (libc64path, &sb) && S_ISREG(sb.st_mode)) {
+ libcso = libc64path;
}
}
if (libcso == NULL) {
- libcso = strdup("/usr/lib/libc.so");
+ libcso = libc32path;
}
if (lstat (libcso, &sb) == 0) {
* /usr/lib/libc.so is NOT a symlink -- this is libc 6.x / glibc 2.x
* now we have to figure this out the hard way.
*/
- char *aout = tmpnam (NULL);
+ char aout[PATH_MAX];
+ int fd = -1;
FILE *fp;
const char *format = "%s -o %s -x c -";
char *cc;
int len;
char *command;
+ memset(&aout, '\0', PATH_MAX);
+
+ if (!lstat(getenv("TMPDIR"), &sb) && S_ISDIR(sb.st_mode))
+ strcpy(aout, getenv("TMPDIR"));
+#ifdef P_tmpdir /* defined by XPG and XOPEN, but don't assume we have it */
+ else if (!lstat(P_tmpdir, &sb) && S_ISDIR(sb.st_mode))
+ strcpy(aout, P_tmpdir);
+#endif
+ else if (!lstat("/tmp", &sb) && S_ISDIR(sb.st_mode))
+ strcpy(aout, "/tmp");
+ else
+ abort();
+
+ strcpy(aout+strlen(aout), "/imaketmp.XXXXXX");
+
+ if ((fd = mkstemp(aout)) == -1)
+ abort ();
+
+ if (close(fd) == -1)
+ abort ();
+
cc = getenv ("CC");
if (cc == NULL)
cc = "gcc";
abort ();
}
}
-
- free(libcso);
}
static void