Skip to contentSkip to conversation

tools: Fix mingw tools build

PATCH New Vladimir Yakovlev 3 participants 3 messages Jul 7, 2012 – Jul 18, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 tools/Makefile     |    3 ++-
 tools/mkenvimage.c |   10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
tools/Makefile +2 -1
index 8993fdd..8fa6f85 100644
@@ -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) $@
 
tools/mkenvimage.c +8 -2
index bfc4eb6..c879e5d 100644
@@ -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));
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 tools: Fix mingw tools build

Dear Vladimir Yakovlev,

Quoted 9 lines · In message <[email protected]> you wrote:

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.

---
 tools/Makefile     |    3 ++-
 tools/mkenvimage.c |   10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
We, the unwilling, led by the unknowing, are doing the impossible for
the ungrateful. We have done so much, for so long, with so little, we
are now qualified to do anything with nothing.
#2 lore raw

PATCH 1/1 tools: Fix mingw tools build

In reply to Vladimir Yakovlev

tools/mkenvimage.c line 53

Quoted 12 lines · On Saturday 07 July 2012 16:05:06 Vladimir Yakovlev wrote:
tools/mkenvimage.c +6 -0
@@ -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

err, i'd rather you didn't do this. we've tried very hard to avoid sprinkling arch-specific crap (like __MINGW32__) in random files. instead, i'd like to see in (either in os_support.h or mingw_support.h):
#ifndef S_IRGRP

# define S_IRGRP 0
#endif
#indef S_IWGRP
# define S_IWGRP 0
#endif

then no one has to care about mingw, and we don't have to add complicated defines that disconnect the locations of the code (the define and the open()). -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120718/b6817417/attachment.pgp>