[U-Boot] [PATCH 12/15] Add support for building native win32 tools

Mike Frysinger vapier at gentoo.org
Thu Mar 5 01:21:20 CET 2009


On Wednesday 04 March 2009 18:33:02 Peter Tyser wrote:
> --- a/README
> +++ b/README
> +Note: If you wish to generate WIN32 versions of the utilities in

WIN32 -> Windows

> +      the tools directory you can use the MinGW toolchain
> +      (http://www.mingw.org).  Set your HOST tools to the MinGW
> +      binaries and execute 'make tools'.  For example:

binaries -> cross-compiler

> +      Binaries such as tools/mkimage.exe will be created which can
> +      be executed on computers using Windows.

using -> running

> --- a/include/linux/types.h
> +++ b/include/linux/types.h
> @@ -10,10 +10,13 @@
>
>  #ifndef __KERNEL_STRICT_NAMES
>
> +#ifndef __MINGW32__
> +/* prevent mingw overlaps for certain typedefs */
>  typedef __kernel_fd_set		fd_set;
>  typedef __kernel_dev_t		dev_t;
>  typedef __kernel_ino_t		ino_t;
>  typedef __kernel_mode_t		mode_t;
> +#endif
>  typedef __kernel_nlink_t	nlink_t;
>  typedef __kernel_off_t		off_t;
>  typedef __kernel_pid_t		pid_t;
> @@ -54,7 +57,7 @@ typedef __kernel_loff_t		loff_t;
>  typedef __kernel_size_t		size_t;
>  #endif
>
> -#ifndef _SSIZE_T
> +#if !defined(_SSIZE_T) && !defined(__MINGW32__)
>  #define _SSIZE_T
>  typedef __kernel_ssize_t	ssize_t;
>  #endif

perhaps we should be defining __KERNEL_STRICT_NAMES for host builds instead

> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -79,6 +79,14 @@ SFX =
>  endif
>
>  #
> +# mingw toolchain requires mingw_support.c and generates .exe files
> +#
> +ifneq (,$(findstring mingw,$(shell $(HOSTCC) -v 2>&1 | grep mingw)))
> +MINGW_OBJ_FILES-y += mingw_support.o
> +SFX = .exe
> +endif

perhaps we should create a sfx.sh script which handles the logic of detecting 
the default suffix.  would be a lot cleaner than relying on strings in 
toolchain names.

as for the mingw_support.c, how about we create a new "os_support.c" file 
which is always compiled and in there we can do things like:
#ifdef MINGW
# include "mingw_support.c"
#elif .....
... other system warts ...
#endif

that would allow us to keep system-specific OBJ vars from popping up all over 
and having to constantly update the Makefile for them

> -$(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
> +$(LOGO_H):	$(obj)bmp_logo$(SFX) $(LOGO_BMP)

this is unrelated ... please move to a more appropriate patch and/or make it 
into its own

> +void *mmap(void *addr, size_t len, int prot, int flags, int fd, int
> offset) +{

this is a pretty naïve implementation ... but it seems like for u-boot's 
usage, it should be complete ?

> --- /dev/null
> +++ b/tools/mingw_support.h
> +/* Windows 64-bit access macros */
> +#define LODWORD(l) ((DWORD)((DWORDLONG)(l)))
> +#define HIDWORD(l) ((DWORD)(((DWORDLONG)(l)>>32)&0xFFFFFFFF))

ugh, this makes my eyes burn.  please change I to something that doesnt look 
like a bar (perhaps the common "x"), and add whitespace where appropriate.

> --- a/tools/mkimage.c
> +++ b/tools/mkimage.c
> @@ -25,6 +25,10 @@
> +#ifdef __MINGW32__
> +#include "mingw_support.h"
> +#endif
> --- a/tools/mkimage.h
> +++ b/tools/mkimage.h
> @@ -28,7 +28,11 @@
>  #ifndef __WIN32__
>  #include <netinet/in.h>		/* for host / network byte order conversions	*/
>  #endif
> +#ifdef __MINGW32__
> +#include <stdint.h>
> +#else
>  #include <sys/mman.h>
> +#endif

why not move the mingw_support.h to mkimage.h ... then you wont have to touch 
mkimage.c.  or create a new "os_support.h" header and move these differences 
there.  then you wont have to copy & paste the same code to every tool that 
uses mmap().
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090304/ec2416e5/attachment-0001.pgp 


More information about the U-Boot mailing list