From: David McCullough Date: Wed, 28 Sep 2005 05:26:02 +0000 (+0000) Subject: Hi, X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=6f637b2faaac5516aaa63712d0d7cfd352088c03;p=elf2flt.git Hi, 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 * 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 --- diff --git a/Makefile.in b/Makefile.in index 5a692a6..24dd96d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) diff --git a/cygwin-elf.h b/cygwin-elf.h index 30faa94..bcf7ae7 100644 --- a/cygwin-elf.h +++ b/cygwin-elf.h @@ -20,8 +20,14 @@ #ifndef _ELF_H #define _ELF_H 1 +#if defined(__MINGW32__) +#include +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; +#else #include - +#endif /* Standard ELF types. */ #include diff --git a/elf2flt.c b/elf2flt.c index 3d54946..b46d224 100644 --- a/elf2flt.c +++ b/elf2flt.c @@ -52,7 +52,7 @@ #if defined(TARGET_h8300) #include /* 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 /* TARGET_* ELF support for the BFD library */ @@ -62,6 +62,10 @@ #include /* TARGET_* ELF support for the BFD library */ #endif +#if defined(__MINGW32__) +#include +#endif + /* from uClinux-x.x.x/include/linux */ #include "flat.h" /* Binary flat header description */ diff --git a/flthdr.c b/flthdr.c index 8635462..fc83780 100644 --- a/flthdr.c +++ b/flthdr.c @@ -17,11 +17,22 @@ #include /* strcat(), strcpy() */ /* macros for conversion between host and (internet) network byte order */ +#ifndef WIN32 #include /* Consts and structs defined by the internet system */ +#else +#include +#endif /* from uClinux-x.x.x/include/linux */ #include "flat.h" /* Binary flat header description */ +#if defined(__MINGW32__) +#include + +#define mkstemp(p) mktemp(p) + +#endif + /****************************************************************************/ char *program_name;