summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2012-08-09 23:34:41 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2012-08-09 23:34:41 +0000
commit60d9bd267e38c6241e05f0253845e1d11d04f3b3 (patch)
treeadbb52deb6d42ab9f32ed347d18ff42384190c47 /util
parentb6304c1a1a89330e84eeee34a4c6ef99b163f367 (diff)
downloadflashrom-60d9bd267e38c6241e05f0253845e1d11d04f3b3.tar.gz
flashrom-60d9bd267e38c6241e05f0253845e1d11d04f3b3.tar.bz2
flashrom-60d9bd267e38c6241e05f0253845e1d11d04f3b3.zip
Portability fixes and cleanups
Move Mac OS X IOKit/DirectHW availability checks in the Makefile from compiler check to pciutils check. Print the compiler error messages for feature detection. Add DOS libpci in the Makefile includes only if a PCI-based programmer was requested. Restrict mmap usage in ich_descriptors_tool to Unix style systems. Build ich_descriptors_tool with the correct .exe extension on DOS/Windows. Build ich_descriptors_tool by default on x86. (Patch by Stefan Tauner) Print the Windows version instead of "unknown machine" on Windows. Don't #define our own __DARWIN__, use the standard OS X detection method. Update the README. Add more generated files to svn:ignore Corresponding to flashrom svn r1567. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'util')
-rw-r--r--util/ich_descriptors_tool/Makefile13
-rw-r--r--util/ich_descriptors_tool/ich_descriptors_tool.c17
2 files changed, 21 insertions, 9 deletions
diff --git a/util/ich_descriptors_tool/Makefile b/util/ich_descriptors_tool/Makefile
index 1af90ced9..d8a79f50c 100644
--- a/util/ich_descriptors_tool/Makefile
+++ b/util/ich_descriptors_tool/Makefile
@@ -15,11 +15,16 @@ CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+ifeq ($(TARGET_OS), DOS)
+# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
+CFLAGS += -Wno-format
+endif
+
OBJ = $(OBJATH)/$(SRC:%.c=%.o)
SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o))
-all:$(PROGRAM)
+all:$(PROGRAM)$(EXEC_SUFFIX)
$(OBJ): $(OBJATH)/%.o : %.c
$(CC) $(CFLAGS) -o $@ -c $<
@@ -29,11 +34,11 @@ $(OBJ): $(OBJATH)/%.o : %.c
$(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c
$(CC) $(CFLAGS) -o $@ -c $<
-$(PROGRAM): $(OBJ) $(SHAREDOBJ)
- $(CC) -o $(PROGRAM) $(OBJ) $(SHAREDOBJ)
+$(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ)
+ $(CC) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ)
clean:
- rm -f $(PROGRAM)
+ rm -f $(PROGRAM) $(PROGRAM).exe
rm -rf $(DEPPATH) $(OBJATH)
# Include the dependency files.
diff --git a/util/ich_descriptors_tool/ich_descriptors_tool.c b/util/ich_descriptors_tool/ich_descriptors_tool.c
index a1bce1b22..1ca970a93 100644
--- a/util/ich_descriptors_tool/ich_descriptors_tool.c
+++ b/util/ich_descriptors_tool/ich_descriptors_tool.c
@@ -25,7 +25,6 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -33,6 +32,13 @@
#include <string.h>
#include <errno.h>
#include "ich_descriptors.h"
+/* Some DJGPP builds define __unix__ although they don't support mmap().
+ * Cygwin defines __unix__ and supports mmap(), but it does not work well.
+ */
+#if !defined(__MSDOS__) && !defined(_WIN32) && (defined(unix) || defined(__unix__) || defined(__unix)) || (defined(__MACH__) && defined(__APPLE__))
+#define HAVE_MMAP 1
+#include <sys/mman.h>
+#endif
static void dump_file(const char *basename, const uint32_t *dump, unsigned int len, struct ich_desc_region *reg, unsigned int i)
{
@@ -161,16 +167,17 @@ int main(int argc, char *argv[])
if (len < 0)
usage(argv, "Seeking to the end of the file failed");
+#ifdef HAVE_MMAP
buf = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
- if (buf == (void *) -1) {
+ if (buf == (void *) -1)
+#endif
+ {
/* fallback for stupid OSes like cygwin */
- int ret;
buf = malloc(len);
if (!buf)
usage(argv, "Could not allocate memory");
lseek(fd, 0, SEEK_SET);
- ret = read(fd, buf, len);
- if (ret != len)
+ if (len != read(fd, buf, len))
usage(argv, "Seeking to the end of the file failed");
}
printf("The flash image has a size of %d [0x%x] bytes.\n", len, len);