Building SeaBIOS from Windows using mingw has been broken for a long time. The problem is that in this environment, line 100 of the makefile:
$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c
creates an include statement that the mingw port of gcc rejects:
#include "/D/coreboot/build/seabios/src/misc.c"
Msys converts the Windows drive letter D:\ to a more Unix-like /D/. But the mingw port of gcc needs D:, not /d/. While this problem might not be easy to solve, I did find a work-around: use relative paths in the include statements rather than absolute paths. In other words, change makefile line 100 from this:
$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c to this: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
This solves the problem for Windows. Would it break the build in Linux environments? If so, I could just use this change locally. But even that is not easy. The way the coreboot makefile is written causes git to enforce use of unmodified SeaBIOS. To work around this, I tried to make a sed command to apply this change temporarily. But I cannot figure out the needed quoting to pass $(CURDIR) to sed without expansion.
Thanks, Scott
On Sun, Jun 01, 2014 at 10:31:39PM -0500, Scott Duplichan wrote:
Building SeaBIOS from Windows using mingw has been broken for a long time. The problem is that in this environment, line 100 of the makefile:
$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c
creates an include statement that the mingw port of gcc rejects:
#include "/D/coreboot/build/seabios/src/misc.c"
Msys converts the Windows drive letter D:\ to a more Unix-like /D/. But the mingw port of gcc needs D:, not /d/. While this problem might not be easy to solve, I did find a work-around: use relative paths in the include statements rather than absolute paths. In other words, change makefile line 100 from this:
$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c to this: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
Unfortunately, this would break builds where one specifies an OUT build directory that isn't a sub-directory of the source code. (That is, a build with "make OUT=/a/b/c".)
I've never tried building under Windows, and I'm not really sure how to help here. Does passing the CURDIR via the command-line (as in the patch below) improve things?
-Kevin
--- a/Makefile +++ b/Makefile @@ -112,8 +112,8 @@ endif # Do a whole file compile by textually including all C code. define whole-compile @echo " Compiling whole program $3" -$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c -$(Q)$(CC) $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 +$(Q)printf '$(foreach i,$2,#include "$i"\n)' > $3.tmp.c +$(Q)$(CC) -I$(CURDIR) $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 endef
%.strip.o: %.o
Kevin O'Connor [mailto:kevin@koconnor.net] wrote:
]On Sun, Jun 01, 2014 at 10:31:39PM -0500, Scott Duplichan wrote: ]> Building SeaBIOS from Windows using mingw has been broken for ]> a long time. The problem is that in this environment, line 100 ]> of the makefile: ]> ]> $(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c ]> ]> creates an include statement that the mingw port of gcc rejects: ]> ]> #include "/D/coreboot/build/seabios/src/misc.c" ]> ]> Msys converts the Windows drive letter D:\ to a more ]> Unix-like /D/. But the mingw port of gcc needs D:, not /d/. ]> While this problem might not be easy to solve, I did find ]> a work-around: use relative paths in the include statements ]> rather than absolute paths. In other words, change makefile ]> line 100 from this: ]> ]> $(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c ]> to this: ]> $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c ] ]Unfortunately, this would break builds where one specifies an OUT ]build directory that isn't a sub-directory of the source code. (That ]is, a build with "make OUT=/a/b/c".) ] ]I've never tried building under Windows, and I'm not really sure how ]to help here. Does passing the CURDIR via the command-line (as in the ]patch below) improve things? ] ]-Kevin
Well sure enough, this patch solves the problem.
]--- a/Makefile ]+++ b/Makefile ]@@ -112,8 +112,8 @@ endif ] # Do a whole file compile by textually including all C code. ] define whole-compile ] @echo " Compiling whole program $3" ]-$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c ]-$(Q)$(CC) $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 ]+$(Q)printf '$(foreach i,$2,#include "$i"\n)' > $3.tmp.c ]+$(Q)$(CC) -I$(CURDIR) $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 ] endef ] ] %.strip.o: %.o
On Mon, Jun 02, 2014 at 05:27:23PM -0500, Scott Duplichan wrote:
Kevin O'Connor [mailto:kevin@koconnor.net] wrote: ]Unfortunately, this would break builds where one specifies an OUT ]build directory that isn't a sub-directory of the source code. (That ]is, a build with "make OUT=/a/b/c".) ] ]I've never tried building under Windows, and I'm not really sure how ]to help here. Does passing the CURDIR via the command-line (as in the ]patch below) improve things? ] ]-Kevin
Well sure enough, this patch solves the problem.
Thanks. Does the patch below also work?
-Kevin
--- a/Makefile +++ b/Makefile @@ -112,8 +112,8 @@ endif # Do a whole file compile by textually including all C code. define whole-compile @echo " Compiling whole program $3" -$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c -$(Q)$(CC) $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 +$(Q)printf '$(foreach i,$2,#include "$i"\n)' > $3.tmp.c +$(Q)$(CC) -I. $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 endef
%.strip.o: %.o
Kevin O'Connor [mailto:kevin@koconnor.net] wrote:
]On Mon, Jun 02, 2014 at 05:27:23PM -0500, Scott Duplichan wrote: ]> Kevin O'Connor [mailto:kevin@koconnor.net] wrote: ]> ]Unfortunately, this would break builds where one specifies an OUT ]> ]build directory that isn't a sub-directory of the source code. (That ]> ]is, a build with "make OUT=/a/b/c".) ]> ] ]> ]I've never tried building under Windows, and I'm not really sure how ]> ]to help here. Does passing the CURDIR via the command-line (as in the ]> ]patch below) improve things? ]> ] ]> ]-Kevin ]> ]> Well sure enough, this patch solves the problem. ] ]Thanks. Does the patch below also work?
Hello Kevin, Yes, the -I. patch below also works for msys/Windows. Thanks, Scott
]-Kevin ] ] ]--- a/Makefile ]+++ b/Makefile ]@@ -112,8 +112,8 @@ endif ] # Do a whole file compile by textually including all C code. ] define whole-compile ] @echo " Compiling whole program $3" ]-$(Q)printf '$(foreach i,$2,#include "$(CURDIR)/$i"\n)' > $3.tmp.c ]-$(Q)$(CC) $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 ]+$(Q)printf '$(foreach i,$2,#include "$i"\n)' > $3.tmp.c ]+$(Q)$(CC) -I. $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 ] endef ] ] %.strip.o: %.o