From owner-freebsd-current Sat Sep 26 20:00:08 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA28646 for freebsd-current-outgoing; Sat, 26 Sep 1998 20:00:08 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from rf900.physics.usyd.edu.au (rf900.physics.usyd.edu.au [129.78.129.109]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA28566 for ; Sat, 26 Sep 1998 19:59:55 -0700 (PDT) (envelope-from dawes@rf900.physics.usyd.edu.au) Received: (from dawes@localhost) by rf900.physics.usyd.edu.au (8.8.5/8.8.2) id MAA29159; Sun, 27 Sep 1998 12:59:42 +1000 (EST) Message-ID: <19980927125942.Y22169@rf900.physics.usyd.edu.au> Date: Sun, 27 Sep 1998 12:59:42 +1000 From: David Dawes To: current@FreeBSD.ORG Subject: imake autodetecting the binary format Mail-Followup-To: current@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.91.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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