Prepare the Makefile for DOS cross-compilation support. Some of the changes are pretty hackish, but they shouldn't affect compilation on other systems at all. Please note that the makefile now references files that don't exist in the tree yet, but since these references are only triggered if you're compiling for DOS and DOS support is not yet merged, I think this is OK.
If you take the DOS support patch from Rudolf and replace his Makefile patch with mine, you have to call make like this: make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip WARNERROR=no OS_ARCH=DOS
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-dos/Makefile =================================================================== --- flashrom-dos/Makefile (Revision 929) +++ flashrom-dos/Makefile (Arbeitskopie) @@ -2,6 +2,7 @@ # This file is part of the flashrom project. # # Copyright (C) 2005 coresystems GmbH stepan@coresystems.de +# Copyright (C) 2009,2010 Carl-Daniel Hailfinger # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,15 +21,22 @@ PROGRAM = flashrom
CC ?= gcc -STRIP = strip +STRIP ?= strip INSTALL = install DIFF = diff PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man -CFLAGS ?= -Os -Wall -Werror -Wshadow +CFLAGS ?= -Os -Wall -Wshadow EXPORTDIR ?= .
-OS_ARCH = $(shell uname) +WARNERROR ?= yes + +ifeq ($(WARNERROR), yes) +CFLAGS += -Werror +endif + +# FIXME We have to differentiate between host and target arch. +OS_ARCH ?= $(shell uname) ifneq ($(OS_ARCH), SunOS) STRIP_ARGS = -s endif @@ -40,6 +48,13 @@ CPPFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/lib endif +ifeq ($(OS_ARCH), DOS) +CPPFLAGS += -I. +OS_OBJS = getopt.o +# Bus Pirate and Serprog are not supported under DOS. +CONFIG_BUSPIRATESPI = no +CONFIG_SERPROG = no +endif
CHIP_OBJS = jedec.o stm50flw0x0x.o w39v040c.o w39v080fa.o sharplhf00l04.o w29ee011.o \ sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \ @@ -188,14 +203,28 @@ endif
ifeq ($(NEED_PCI), yes) -LIBS += -lpci +ifneq ($(OS_ARCH), DOS) +# FIXME This workaround is needed until libpci detection can handle +# cross-compiling for DOS. +CHECK_LIBPCI = yes +endif +endif + +ifeq ($(NEED_PCI), yes) FEATURE_CFLAGS += -D'NEED_PCI=1' PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o ifeq ($(OS_ARCH), NetBSD) LIBS += -lpciutils # The libpci we want. LIBS += -l$(shell uname -p) # For (i386|x86_64)_iopl(2). +else +ifeq ($(OS_ARCH), DOS) +# FIXME There needs to be a better way to do this +LIBS += libpci.a +else +LIBS += -lpci endif endif +endif
ifeq ($(CONFIG_PRINT_WIKI), yes) FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1' @@ -205,7 +234,7 @@ # We could use PULLED_IN_LIBS, but that would be ugly. FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
-OBJS = $(CHIP_OBJS) $(CLI_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS) +OBJS = $(CHIP_OBJS) $(CLI_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS) $(OS_OBJS)
$(PROGRAM): $(OBJS) $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(FEATURE_LIBS) $(LIBS) @@ -239,7 +268,7 @@ rm -f .test.c .test; exit 1) @rm -f .test.c .test
-ifeq ($(NEED_PCI), yes) +ifeq ($(CHECK_LIBPCI), yes) pciutils: compiler @printf "Checking for libpci headers... " @$(shell ( echo "#include <pci/pci.h>"; \
On 09.03.2010 23:23, Carl-Daniel Hailfinger wrote:
Prepare the Makefile for DOS cross-compilation support. Some of the changes are pretty hackish, but they shouldn't affect compilation on other systems at all. Please note that the makefile now references files that don't exist in the tree yet, but since these references are only triggered if you're compiling for DOS and DOS support is not yet merged, I think this is OK.
As I wrote, this is a hack. As such, I do welcome comments including Nacks.
If you take the DOS support patch from Rudolf and replace his Makefile patch with mine, you have to call make like this: make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip WARNERROR=no OS_ARCH=DOS
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-dos/Makefile
--- flashrom-dos/Makefile (Revision 929) +++ flashrom-dos/Makefile (Arbeitskopie) @@ -2,6 +2,7 @@ # This file is part of the flashrom project. # # Copyright (C) 2005 coresystems GmbH stepan@coresystems.de +# Copyright (C) 2009,2010 Carl-Daniel Hailfinger # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,15 +21,22 @@ PROGRAM = flashrom
CC ?= gcc -STRIP = strip +STRIP ?= strip INSTALL = install DIFF = diff PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man -CFLAGS ?= -Os -Wall -Werror -Wshadow +CFLAGS ?= -Os -Wall -Wshadow EXPORTDIR ?= .
-OS_ARCH = $(shell uname) +WARNERROR ?= yes
+ifeq ($(WARNERROR), yes) +CFLAGS += -Werror +endif
+# FIXME We have to differentiate between host and target arch. +OS_ARCH ?= $(shell uname) ifneq ($(OS_ARCH), SunOS) STRIP_ARGS = -s endif @@ -40,6 +48,13 @@ CPPFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/lib endif +ifeq ($(OS_ARCH), DOS) +CPPFLAGS += -I. +OS_OBJS = getopt.o
The CPPFLAGS and OS_OBJS stuff needs to die. CPPFLAGS should be set by the user calling make. OS_OBJS is a hack to add getopt.c to the build. It would be a lot better to get getopt from a static library (if possible). I'm a bit surprised that the libc provided by DJGPP seems to be missing getopt (or are there other reasons to have our own getopt)?
+# Bus Pirate and Serprog are not supported under DOS. +CONFIG_BUSPIRATESPI = no +CONFIG_SERPROG = no +endif
CHIP_OBJS = jedec.o stm50flw0x0x.o w39v040c.o w39v080fa.o sharplhf00l04.o w29ee011.o \ sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \ @@ -188,14 +203,28 @@ endif
ifeq ($(NEED_PCI), yes) -LIBS += -lpci +ifneq ($(OS_ARCH), DOS) +# FIXME This workaround is needed until libpci detection can handle +# cross-compiling for DOS. +CHECK_LIBPCI = yes +endif +endif
+ifeq ($(NEED_PCI), yes) FEATURE_CFLAGS += -D'NEED_PCI=1' PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o ifeq ($(OS_ARCH), NetBSD) LIBS += -lpciutils # The libpci we want. LIBS += -l$(shell uname -p) # For (i386|x86_64)_iopl(2). +else +ifeq ($(OS_ARCH), DOS) +# FIXME There needs to be a better way to do this
Yes indeed. Can't we tell the linker that it should pick a static libpci?
+LIBS += libpci.a +else +LIBS += -lpci endif endif +endif
ifeq ($(CONFIG_PRINT_WIKI), yes) FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1' @@ -205,7 +234,7 @@ # We could use PULLED_IN_LIBS, but that would be ugly. FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
-OBJS = $(CHIP_OBJS) $(CLI_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS) +OBJS = $(CHIP_OBJS) $(CLI_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS) $(OS_OBJS)
As stated above, OS_OBJS needs to die.
$(PROGRAM): $(OBJS) $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(FEATURE_LIBS) $(LIBS) @@ -239,7 +268,7 @@ rm -f .test.c .test; exit 1) @rm -f .test.c .test
-ifeq ($(NEED_PCI), yes) +ifeq ($(CHECK_LIBPCI), yes) pciutils: compiler @printf "Checking for libpci headers... " @$(shell ( echo "#include <pci/pci.h>"; \
Yes, reviewing my own patch looks a bit strange, but I wanted to get a minimal hack out there which does not break other targets. If other parts of Rudolf's patch can be killed (getopt and libpci include files), this Makefile patch will lost a sizable amount of ugliness.
Regards, Carl-Daniel
Rudolf was so kind and improved my older Makefile patch. I believe the following should work (some additional changes were done by me).
Add DOS cross-compilation support to the Makefile. Some of the changes are pretty hackish, but they shouldn't affect compilation on other systems at all. Add a README with build instructions.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-dos/Makefile =================================================================== --- flashrom-dos/Makefile (Revision 936) +++ flashrom-dos/Makefile (Arbeitskopie) @@ -2,6 +2,7 @@ # This file is part of the flashrom project. # # Copyright (C) 2005 coresystems GmbH stepan@coresystems.de +# Copyright (C) 2009,2010 Carl-Daniel Hailfinger # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,15 +21,22 @@ PROGRAM = flashrom
CC ?= gcc -STRIP = strip +STRIP ?= strip INSTALL = install DIFF = diff PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man -CFLAGS ?= -Os -Wall -Werror -Wshadow +CFLAGS ?= -Os -Wall -Wshadow EXPORTDIR ?= .
-OS_ARCH = $(shell uname) +WARNERROR ?= yes + +ifeq ($(WARNERROR), yes) +CFLAGS += -Werror +endif + +# FIXME We have to differentiate between host and target arch. +OS_ARCH ?= $(shell uname) ifneq ($(OS_ARCH), SunOS) STRIP_ARGS = -s endif @@ -40,6 +48,12 @@ CPPFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/lib endif +ifeq ($(OS_ARCH), DOS) +CPPFLAGS += -I../libgetopt -I../libpci/include +# Bus Pirate and Serprog are not supported under DOS. +CONFIG_BUSPIRATESPI = no +CONFIG_SERPROG = no +endif
CHIP_OBJS = jedec.o stm50flw0x0x.o w39v040c.o w39v080fa.o sharplhf00l04.o w29ee011.o \ sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \ @@ -188,14 +202,28 @@ endif
ifeq ($(NEED_PCI), yes) -LIBS += -lpci +ifneq ($(OS_ARCH), DOS) +# FIXME This workaround is needed until libpci detection can handle +# cross-compiling for DOS. +CHECK_LIBPCI = yes +endif +endif + +ifeq ($(NEED_PCI), yes) FEATURE_CFLAGS += -D'NEED_PCI=1' PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o ifeq ($(OS_ARCH), NetBSD) LIBS += -lpciutils # The libpci we want. LIBS += -l$(shell uname -p) # For (i386|x86_64)_iopl(2). +else +ifeq ($(OS_ARCH), DOS) +# FIXME There needs to be a better way to do this +LIBS += ../libpci/lib/libpci.a ../libgetopt/libgetopt.a +else +LIBS += -lpci endif endif +endif
ifeq ($(CONFIG_PRINT_WIKI), yes) FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1' @@ -239,7 +267,7 @@ rm -f .test.c .test; exit 1) @rm -f .test.c .test
-ifeq ($(NEED_PCI), yes) +ifeq ($(CHECK_LIBPCI), yes) pciutils: compiler @printf "Checking for libpci headers... " @$(shell ( echo "#include <pci/pci.h>"; \ Index: flashrom-dos/README =================================================================== --- flashrom-dos/README (Revision 936) +++ flashrom-dos/README (Arbeitskopie) @@ -42,7 +42,7 @@
* pciutils / libpci * pciutils-devel / pciutils-dev / libpci-dev - * zlib-devel / zlib1g-dev (only needed if libpci is static) + * zlib-devel / zlib1g-dev (needed if libpci was compiled with libz support)
On FreeBSD, you need the following ports:
@@ -75,7 +75,24 @@ Install DirectIO from coresystems GmbH. DirectIO is available at http://www.coresystems.de/en/directio.
+To cross-compile on Linux for DOS:
+ Get RPMs of the cross compiler from the DJGPP site and install them: + djcross-binutils-2.19.1-10ap.i386.rpm + djcross-gcc-tools-4.4.1-1ap.i686.rpm + djcross-gcc-4.3.2-8ap.i686.rpm + Download pciutils 3.1.5 and apply http://assembler.cz/flashrom/pciutils.patch + Download and compile http://assembler.cz/flashrom/libgetopt/ + Compile pciutils, see README.DJGPP for instructions. + Enter the flashrom directory. + ../libpci should contain pciutils source and binaries. + ../libgetopt should contain getopt.a from libgetopt. + Run + make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip OS_ARCH=DOS + You might have to add WARNERROR=no to the make command line. + To run flashrom.exe, download http://clio.rice.edu/djgpp/csdpmi7b.zip and + make sure CWSDPMI.EXE is in the current directory. + Installation ------------
Hi Rudolf,
this patch has make djgpp-dos as you wanted. It is the last missing piece for DOS support (your code is already in). An ack would be appreciated.
Add DOS cross-compilation support to the Makefile. Add a README with build instructions.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-dos/Makefile =================================================================== --- flashrom-dos/Makefile (Revision 947) +++ flashrom-dos/Makefile (Arbeitskopie) @@ -2,6 +2,7 @@ # This file is part of the flashrom project. # # Copyright (C) 2005 coresystems GmbH stepan@coresystems.de +# Copyright (C) 2009,2010 Carl-Daniel Hailfinger # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,15 +21,22 @@ PROGRAM = flashrom
CC ?= gcc -STRIP = strip +STRIP ?= strip INSTALL = install DIFF = diff PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man -CFLAGS ?= -Os -Wall -Werror -Wshadow +CFLAGS ?= -Os -Wall -Wshadow EXPORTDIR ?= .
-OS_ARCH = $(shell uname) +WARNERROR ?= yes + +ifeq ($(WARNERROR), yes) +CFLAGS += -Werror +endif + +# FIXME We have to differentiate between host and target arch. +OS_ARCH ?= $(shell uname) ifneq ($(OS_ARCH), SunOS) STRIP_ARGS = -s endif @@ -40,6 +48,12 @@ CPPFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/lib endif +ifeq ($(OS_ARCH), DOS) +CPPFLAGS += -I../libgetopt -I../libpci/include +# Bus Pirate and Serprog are not supported under DOS. +CONFIG_BUSPIRATESPI = no +CONFIG_SERPROG = no +endif
CHIP_OBJS = jedec.o stm50flw0x0x.o w39v040c.o w39v080fa.o sharplhf00l04.o w29ee011.o \ sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \ @@ -188,14 +202,28 @@ endif
ifeq ($(NEED_PCI), yes) -LIBS += -lpci +ifneq ($(OS_ARCH), DOS) +# FIXME This workaround is needed until libpci detection can handle +# cross-compiling for DOS. +CHECK_LIBPCI = yes +endif +endif + +ifeq ($(NEED_PCI), yes) FEATURE_CFLAGS += -D'NEED_PCI=1' PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o ifeq ($(OS_ARCH), NetBSD) LIBS += -lpciutils # The libpci we want. LIBS += -l$(shell uname -p) # For (i386|x86_64)_iopl(2). +else +ifeq ($(OS_ARCH), DOS) +# FIXME There needs to be a better way to do this +LIBS += ../libpci/lib/libpci.a ../libgetopt/libgetopt.a +else +LIBS += -lpci endif endif +endif
ifeq ($(CONFIG_PRINT_WIKI), yes) FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1' @@ -239,7 +267,7 @@ rm -f .test.c .test; exit 1) @rm -f .test.c .test
-ifeq ($(NEED_PCI), yes) +ifeq ($(CHECK_LIBPCI), yes) pciutils: compiler @printf "Checking for libpci headers... " @$(shell ( echo "#include <pci/pci.h>"; \ @@ -315,6 +343,9 @@ @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
-.PHONY: all clean distclean dep compiler pciutils features export tarball +djgpp-dos: clean + make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip WARNERROR=no OS_ARCH=DOS
+.PHONY: all clean distclean dep compiler pciutils features export tarball dos + -include .dependencies Index: flashrom-dos/README =================================================================== --- flashrom-dos/README (Revision 947) +++ flashrom-dos/README (Arbeitskopie) @@ -42,7 +42,7 @@
* pciutils / libpci * pciutils-devel / pciutils-dev / libpci-dev - * zlib-devel / zlib1g-dev (only needed if libpci is static) + * zlib-devel / zlib1g-dev (needed if libpci was compiled with libz support)
On FreeBSD, you need the following ports:
@@ -75,7 +75,26 @@ Install DirectIO from coresystems GmbH. DirectIO is available at http://www.coresystems.de/en/directio.
+To cross-compile on Linux for DOS:
+ Get RPMs of the cross compiler from the DJGPP site and install them: + djcross-binutils-2.19.1-10ap.i386.rpm + djcross-gcc-tools-4.4.1-1ap.i686.rpm + djcross-gcc-4.3.2-8ap.i686.rpm + Download pciutils 3.1.5 and apply http://assembler.cz/flashrom/pciutils.patch + Download and compile http://assembler.cz/flashrom/libgetopt/ + Compile pciutils, see README.DJGPP for instructions. + Enter the flashrom directory. + ../libpci should contain pciutils source and binaries. + ../libgetopt should contain getopt.a from libgetopt. + Run either (change settings where appropriate) + make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip OS_ARCH=DOS + or (above settings hardcoded) + make djgpp-dos + You might have to add WARNERROR=no to the make command line. + To run flashrom.exe, download http://clio.rice.edu/djgpp/csdpmi7b.zip and + make sure CWSDPMI.EXE is in the current directory. + Installation ------------
On 19.03.2010 04:30, Carl-Daniel Hailfinger wrote:
Hi Rudolf,
this patch has make djgpp-dos as you wanted. It is the last missing piece for DOS support (your code is already in). An ack would be appreciated.
Add DOS cross-compilation support to the Makefile. Add a README with build instructions.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Rudolf's ack should arrive on the list soon. Committed in r963.
Regards, Carl-Daniel