Created
July 9, 2012 07:06
-
-
Save nagos/3074734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ce21fbf37a816189d44d8f91844426a9faa7b129 Mon Sep 17 00:00:00 2001 | |
From: Vladimir Yakovlev <nagos@inbox.ru> | |
Date: Sat, 7 Jul 2012 23:52:41 +0400 | |
Subject: [PATCH] tools: Fix mingw tools build | |
mkenvimage does not build due to missed os_support.o and unsupported | |
file modes S_IRGRP S_IWGRP. | |
Tested with mingw 4.2.1 on ubuntu 12.04. | |
Signed-off-by: Vladimir Yakovlev <nagos@inbox.ru> | |
--- | |
tools/Makefile | 3 ++- | |
tools/mkenvimage.c | 10 ++++++++-- | |
2 files changed, 10 insertions(+), 3 deletions(-) | |
diff --git a/tools/Makefile b/tools/Makefile | |
index 8993fdd..8fa6f85 100644 | |
--- a/tools/Makefile | |
+++ b/tools/Makefile | |
@@ -194,7 +194,8 @@ $(obj)xway-swap-bytes$(SFX): $(obj)xway-swap-bytes.o | |
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ | |
$(HOSTSTRIP) $@ | |
-$(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o | |
+$(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o \ | |
+ $(obj)os_support.o | |
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ | |
$(HOSTSTRIP) $@ | |
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c | |
index bfc4eb6..c879e5d 100644 | |
--- a/tools/mkenvimage.c | |
+++ b/tools/mkenvimage.c | |
@@ -45,6 +45,13 @@ | |
#define CRC_SIZE sizeof(uint32_t) | |
+#ifdef __MINGW32__ | |
+#define FILE_PERM (S_IRUSR | S_IWUSR) | |
+#else | |
+#define FILE_PERM (S_IRUSR | S_IWUSR | S_IRGRP |\ | |
+ S_IWGRP) | |
+#endif | |
+ | |
static void usage(const char *exec_name) | |
{ | |
fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] -s <environment partition size> -o <output> <input file>\n" | |
@@ -292,8 +299,7 @@ int main(int argc, char **argv) | |
if (!bin_filename || strcmp(bin_filename, "-") == 0) { | |
bin_fd = STDOUT_FILENO; | |
} else { | |
- bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP | | |
- S_IWGRP); | |
+ bin_fd = creat(bin_filename, FILE_PERM); | |
if (bin_fd == -1) { | |
fprintf(stderr, "Can't open output file \"%s\": %s\n", | |
bin_filename, strerror(errno)); | |
-- | |
1.7.9.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment