Date: Sun, 27 Sep 1998 12:59:42 +1000 From: David Dawes <dawes@rf900.physics.usyd.edu.au> To: current@FreeBSD.ORG Subject: imake autodetecting the binary format Message-ID: <19980927125942.Y22169@rf900.physics.usyd.edu.au>
next in thread | raw e-mail | index | archive | help
I'm planning to add the patch included below to imake so that it can auto-detect the binary format at runtime. Together with this, the following would be added to FreeBSD.cf: #ifndef UseElfFormat #define UseElfFormat DefaultToElfFormat #endif If anyone sees any problems with this, let me know. I don't need to hear comments about how gross this might appear to be. Also, I don't think calling getobjformat() is an option. David -- *** imake.c 1998/03/01 00:34:54 3.13.2.16 --- xc/config/imake/imake.c 1998/09/27 02:50:27 *************** *** 968,973 **** --- 968,1000 ---- } #endif + #ifdef __FreeBSD__ + static void + get_binary_format(FILE *inFile) + { + int mib[2]; + size_t len; + int osrel = 0; + FILE *objprog = NULL; + int iself = 0; + char buf[10]; + + mib[0] = CTL_KERN; + mib[1] = KERN_OSRELDATE; + len = sizeof(osrel); + sysctl(mib, 2, &osrel, &len, NULL, 0); + if (osrel >= 300004 && + (objprog = popen("objformat", "r")) != NULL && + fgets(buf, sizeof(buf), objprog) != NULL && + strncmp(buf, "elf", 3) == 0) + iself = 1; + if (objprog) + pclose(objprog); + + fprintf(inFile, "#define DefaultToElfFormat %s\n", iself ? "YES" : "NO"); + } + #endif + #ifndef PATH_MAX #define PATH_MAX 1024 #endif *************** *** 1074,1079 **** --- 1101,1109 ---- get_ld_version(inFile); #endif get_gcc_incdir(inFile); + #ifdef __FreeBSD__ + get_binary_format(inFile); + #endif #endif /* WIN32 */ return FALSE; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980927125942.Y22169>