OSDN Git Service

Hi,
authordavidm <davidm>
Wed, 28 Sep 2005 05:26:02 +0000 (05:26 +0000)
committerdavidm <davidm>
Wed, 28 Sep 2005 05:26:02 +0000 (05:26 +0000)
I'm the maintainer of a windows hosted arm-elf gcc toolchain used mostly
for homebrew console development. One of my users recently asked if I
could have a look a getting elf2flt to build under mingw/msys to help
with his uclinux Nintendo DS port. I've attached a patch containing the
changes I made to the source in CVS, thought it might be useful.

2005-09-25  Dave Murphy  <davem@devkitpro.org>
   * Makefile.in: add ws2_32 library when building from msys shell.
   * cygwin-elf.h: On mingw.include stdint.h and add extra typedefs
   * elf2flt.c: Include cygwin-elf.h on mingw too.
   * flthdr.c: For mingw use winsock2.h for internet consts & structs ,
     use mktemp instead of mkstemp

Dave

Makefile.in
cygwin-elf.h
elf2flt.c
flthdr.c

index 5a692a6..24dd96d 100644 (file)
@@ -20,6 +20,12 @@ DEFS = @DEFS@ -DTARGET_$(CPU)
 EXEEXT = @EXEEXT@
 OBJEXT = @OBJEXT@
 
+UNAME := $(shell uname -s)
+
+ifneq (,$(findstring MINGW,$(UNAME)))
+   LIBS :=  $(LIBS) -lws2_32
+endif
+
 # force link order under cygwin to avoid getopts / libiberty clash
 ifneq ($(strip $(shell gcc -v 2>&1 | grep "cygwin")),)
    LIBS := -lcygwin $(LIBS)
index 30faa94..bcf7ae7 100644 (file)
 #ifndef _ELF_H
 #define        _ELF_H 1
 
+#if    defined(__MINGW32__)
+#include <stdint.h>
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+#else
 #include <features.h>
-
+#endif
 /* Standard ELF types.  */
 
 #include <sys/types.h>
index 3d54946..b46d224 100644 (file)
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -52,7 +52,7 @@
 
 #if defined(TARGET_h8300)
 #include <elf/h8.h>      /* TARGET_* ELF support for the BFD library            */
-#elif defined(__CYGWIN__)
+#elif defined(__CYGWIN__) || defined(__MINGW32__)
 #include "cygwin-elf.h"        /* Cygwin uses a local copy */
 #elif defined(TARGET_microblaze)
 #include <elf/microblaze.h>    /* TARGET_* ELF support for the BFD library */
 #include <elf.h>      /* TARGET_* ELF support for the BFD library            */
 #endif
 
+#if defined(__MINGW32__)
+#include <getopt.h>
+#endif
+
 /* from uClinux-x.x.x/include/linux */
 #include "flat.h"     /* Binary flat header description                      */
 
index 8635462..fc83780 100644 (file)
--- a/flthdr.c
+++ b/flthdr.c
 #include <string.h>   /* strcat(), strcpy() */
 
 /* macros for conversion between host and (internet) network byte order */
+#ifndef WIN32
 #include <netinet/in.h> /* Consts and structs defined by the internet system */
+#else
+#include <winsock2.h>
+#endif
 
 /* from uClinux-x.x.x/include/linux */
 #include "flat.h"     /* Binary flat header description                      */
 
+#if defined(__MINGW32__)
+#include <getopt.h>
+
+#define mkstemp(p) mktemp(p)
+
+#endif
+
 /****************************************************************************/
 
 char *program_name;