[flashrom] [PATCH] Fix and improve Windows/MinGW/MSYS build

Uwe Hermann uwe at hermann-uwe.de
Sun Jul 3 16:42:39 CEST 2011


On Sun, Jul 03, 2011 at 01:11:51AM +0200, Carl-Daniel Hailfinger wrote:
> >  - Explicitly set CC=gcc in the Makefile, otherwise you get an error like
> >    "cc: command not found" on MinGW.
> >   
> 
> Mh. Would CC?=gcc work as well?

Doesn't work unfortunately.

 
> >  - serial.c: Add missing casts to avoid compile errors due to -Werror.
> >   
> 
> Those casts seem to use a Windows-specific cast.

Yes (they're in the _WIN32 ifdef though).

 
> >  ifeq ($(CONFIG_FT2232_SPI), yes)
> > +ifeq ($(OS_ARCH), MINGW32_NT-5.1)
> > +# No pkg-config files for libftdi on Windows/MinGW, just assume it's installed.
> > +FTDILIBS := -lftdi -lusb
> >   
> 
> Umm... if pkg-config fails, the fallback below will do exactly what you
> did manually above. Does the fallback fail for you?

Oops, true, I removed that hunk.

 
> > -		WriteFile(sp_fd, buf, writecnt, &tmp, NULL);
> > +		WriteFile(sp_fd, buf, writecnt, (PDWORD)&tmp, NULL);
> >   
> 
> Use (uint32_t *) instead of (PDWORD). That said, this might mess up
> aliasing handling in the compiler, and we should fix the type of tmp
> instead.

WriteFile(), a Windows API call, expects an 'LPDWORD', i.e. a pointer to
a DWORD, I think it makes sense to use that (in the _WIN32 ifdef part).

http://msdn.microsoft.com/en-us/library/aa365747%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/cc230318%28PROT.10%29.aspx

We do similar things with 'fdtype' on MinGW:

  programmer.h:typedef HANDLE fdtype;
  programmer.h:typedef int fdtype;


> >  #else
> >  		tmp = write(sp_fd, buf, writecnt);

This write() here, however, returns an ssize_t, so I changed "long tmp"
to "ssize_t tmp" here, too.


Updated patch attached.


Uwe.
-- 
http://hermann-uwe.de     | http://sigrok.org
http://randomprojects.org | http://unmaintained-free-software.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flashrom_mingw2.patch
Type: text/x-diff
Size: 3893 bytes
Desc: not available
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20110703/d4c869ce/attachment.bin>


More information about the flashrom mailing list