mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/6] Support cross-compiling on Mac OS X
@ 2012-06-04 20:40 Dirk Hörner
  2012-06-04 20:40 ` [PATCH 1/6] kbuild: Use Elfnn_Half as replacement for Elfnn_Section Dirk Hörner
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Dirk Hörner @ 2012-06-04 20:40 UTC (permalink / raw)
  To: barebox

Hi all,

this patch series adds support to cross-compile barebox on Mac OS X. Please
review as I am quite unsure as to whether I have found the best solutions
to some of the problems, especially patch two and three.

The first patch was cherry-picked from Linux.

I tested this series on Max OS X 10.6.8 using the yagarto ARM toolchain[1].

Ciao,
Dirk

[1]: http://www.yagarto.de/

Dirk Hörner (5):
  make: use wc -c instead of stat -c%s to get file sizes
  make: check for greadlink first, fall back to readlink
  hostcc tools: include "compiler.h", fix included headers
  scripts/compiler.h: fixup endianess defines on OS X
  scripts/genenv: always pass template to mktemp

Sam Ravnborg (1):
  kbuild: Use Elfnn_Half as replacement for Elfnn_Section

 Makefile              |    2 +-
 common/Makefile       |    6 ++++--
 include/envfs.h       |    2 ++
 include/image.h       |    2 +-
 scripts/Makefile.lib  |    2 +-
 scripts/bareboxenv.c  |    2 ++
 scripts/compiler.h    |    3 +++
 scripts/genenv        |    2 +-
 scripts/mod/modpost.h |    4 ++--
 9 files changed, 17 insertions(+), 8 deletions(-)

-- 
1.7.10.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/6] kbuild: Use Elfnn_Half as replacement for Elfnn_Section
  2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
@ 2012-06-04 20:40 ` Dirk Hörner
  2012-06-04 20:40 ` [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes Dirk Hörner
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Dirk Hörner @ 2012-06-04 20:40 UTC (permalink / raw)
  To: barebox

From: Sam Ravnborg <sam@ravnborg.org>

The Elfnn_Section is not available on all platforms,
noteworthy are cygwin.
Use the safe replacement _Half.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 scripts/mod/modpost.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 0c23259..497d614 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -17,7 +17,7 @@
 #define Elf_Shdr    Elf32_Shdr
 #define Elf_Sym     Elf32_Sym
 #define Elf_Addr    Elf32_Addr
-#define Elf_Section Elf32_Section
+#define Elf_Section Elf32_Half
 #define ELF_ST_BIND ELF32_ST_BIND
 #define ELF_ST_TYPE ELF32_ST_TYPE
 
@@ -31,7 +31,7 @@
 #define Elf_Shdr    Elf64_Shdr
 #define Elf_Sym     Elf64_Sym
 #define Elf_Addr    Elf64_Addr
-#define Elf_Section Elf64_Section
+#define Elf_Section Elf64_Half
 #define ELF_ST_BIND ELF64_ST_BIND
 #define ELF_ST_TYPE ELF64_ST_TYPE
 
-- 
1.7.10.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes
  2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
  2012-06-04 20:40 ` [PATCH 1/6] kbuild: Use Elfnn_Half as replacement for Elfnn_Section Dirk Hörner
@ 2012-06-04 20:40 ` Dirk Hörner
  2012-06-05  2:49   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-06-04 20:40 ` [PATCH 3/6] make: check for greadlink first, fall back to readlink Dirk Hörner
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Dirk Hörner @ 2012-06-04 20:40 UTC (permalink / raw)
  To: barebox

On OS X, stat does not know about %s. Solaris does not have stat. The
drawback to this wc -c solution is that wc reads all the bytes, but we are
only dealing with small files here, so that not be much of a problem.

Signed-off-by: Dirk Hörner <dirker@gmail.com>
---
 Makefile             |    2 +-
 common/Makefile      |    2 +-
 scripts/Makefile.lib |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index bcaae0a..3ac8788 100644
--- a/Makefile
+++ b/Makefile
@@ -536,7 +536,7 @@ quiet_cmd_barebox_version = GEN     .version
 # Check size of a file
 quiet_cmd_check_file_size = CHKSIZE $@
       cmd_check_file_size = set -e;					\
-	size=`stat -c%s $@`;						\
+	size=`wc -c < $@`;						\
 	max_size=`printf "%d" $2`;					\
 	if [ $$size -gt $$max_size ] ;					\
 	then								\
diff --git a/common/Makefile b/common/Makefile
index a58aef9..9c14d7b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -77,7 +77,7 @@ barebox_default_env.lzo: barebox_default_env
 
 include/generated/barebox_default_env.h: barebox_default_env$(barebox_default_env_comp)
 	$(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
-	$(Q)echo "const int default_environment_uncompress_size=`stat -c%s barebox_default_env`;" >> $@
+	$(Q)echo "const int default_environment_uncompress_size=`wc -c < barebox_default_env`;" >> $@
 
 CLEAN_FILES += include/generated/barebox_default_env.h barebox_default_env
 CLEAN_FILES += barebox_default_env.gz barebox_default_env.bz2
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b842c48..9b02b1b 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -171,7 +171,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
 size_append = printf $(shell						\
 dec_size=0;								\
 for F in $1; do								\
-	fsize=$$(stat -c "%s" $$F);					\
+	fsize=$$(wc -c < $$F);					        \
 	dec_size=$$(expr $$dec_size + $$fsize);				\
 done;									\
 printf "%08x\n" $$dec_size |						\
-- 
1.7.10.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/6] make: check for greadlink first, fall back to readlink
  2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
  2012-06-04 20:40 ` [PATCH 1/6] kbuild: Use Elfnn_Half as replacement for Elfnn_Section Dirk Hörner
  2012-06-04 20:40 ` [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes Dirk Hörner
@ 2012-06-04 20:40 ` Dirk Hörner
  2012-06-05  8:56   ` Michael Olbrich
  2012-06-04 20:40 ` [PATCH 4/6] hostcc tools: include "compiler.h", fix included headers Dirk Hörner
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Dirk Hörner @ 2012-06-04 20:40 UTC (permalink / raw)
  To: barebox

OS X' readlink does not have an -f option.

Signed-off-by: Dirk Hörner <dirker@gmail.com>
---
 common/Makefile |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/Makefile b/common/Makefile
index 9c14d7b..48cf715 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -48,7 +48,9 @@ ifneq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
 DEFAULT_ENVIRONMENT_PATH += $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
 endif
 
-ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec readlink -f '{}' \;; done)
+READLINK := $(shell command -v greadlink || echo readlink)
+
+ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec $(READLINK) -f '{}' \;; done)
 
 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
 
-- 
1.7.10.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/6] hostcc tools: include "compiler.h", fix included headers
  2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
                   ` (2 preceding siblings ...)
  2012-06-04 20:40 ` [PATCH 3/6] make: check for greadlink first, fall back to readlink Dirk Hörner
@ 2012-06-04 20:40 ` Dirk Hörner
  2012-06-04 20:40 ` [PATCH 5/6] scripts/compiler.h: fixup endianess defines on OS X Dirk Hörner
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Dirk Hörner @ 2012-06-04 20:40 UTC (permalink / raw)
  To: barebox

When barebox headers get included from HOSTCC tools they should not
include other architecture specific headers as barebox might get
cross-compiled. Instead, the tool itself should include "compiler.h".

Signed-off-by: Dirk Hörner <dirker@gmail.com>
---
 include/envfs.h      |    2 ++
 include/image.h      |    2 +-
 scripts/bareboxenv.c |    2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/envfs.h b/include/envfs.h
index b5849d9..67b8902 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -1,7 +1,9 @@
 #ifndef _ENVFS_H
 #define _ENVFS_H
 
+#ifdef __BAREBOX__
 #include <asm/byteorder.h>
+#endif
 
 #define ENVFS_MAGIC		    0x798fba79	/* some random number */
 #define ENVFS_INODE_MAGIC	0x67a8c78d
diff --git a/include/image.h b/include/image.h
index 35ff01b..027b5f2 100644
--- a/include/image.h
+++ b/include/image.h
@@ -31,8 +31,8 @@
 #ifndef __IMAGE_H__
 #define __IMAGE_H__
 
-#include <linux/types.h>
 #ifdef __BAREBOX__
+#include <linux/types.h>
 #include <asm/byteorder.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index b0d5818..866e345 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -34,6 +34,8 @@
 #include <getopt.h>
 #include <libgen.h>
 
+#include "compiler.h"
+
 #define debug(...)
 
 void *xmalloc(size_t size)
-- 
1.7.10.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 5/6] scripts/compiler.h: fixup endianess defines on OS X
  2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
                   ` (3 preceding siblings ...)
  2012-06-04 20:40 ` [PATCH 4/6] hostcc tools: include "compiler.h", fix included headers Dirk Hörner
@ 2012-06-04 20:40 ` Dirk Hörner
  2012-06-04 20:40 ` [PATCH 6/6] scripts/genenv: always pass template to mktemp Dirk Hörner
  2012-06-05 19:42 ` [PATCH 0/6] Support cross-compiling on Mac OS X Sascha Hauer
  6 siblings, 0 replies; 12+ messages in thread
From: Dirk Hörner @ 2012-06-04 20:40 UTC (permalink / raw)
  To: barebox

Signed-off-by: Dirk Hörner <dirker@gmail.com>
---
 scripts/compiler.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/compiler.h b/scripts/compiler.h
index f4b1432..53f84b6 100644
--- a/scripts/compiler.h
+++ b/scripts/compiler.h
@@ -45,6 +45,9 @@
 # include <byteswap.h>
 #elif defined(__MACH__)
 # include <machine/endian.h>
+# define __BYTE_ORDER    BYTE_ORDER
+# define __LITTLE_ENDIAN LITTLE_ENDIAN
+# define __BIG_ENDIAN    BIG_ENDIAN
 typedef unsigned long ulong;
 typedef unsigned int  uint;
 #endif
-- 
1.7.10.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 6/6] scripts/genenv: always pass template to mktemp
  2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
                   ` (4 preceding siblings ...)
  2012-06-04 20:40 ` [PATCH 5/6] scripts/compiler.h: fixup endianess defines on OS X Dirk Hörner
@ 2012-06-04 20:40 ` Dirk Hörner
  2012-06-05 19:42 ` [PATCH 0/6] Support cross-compiling on Mac OS X Sascha Hauer
  6 siblings, 0 replies; 12+ messages in thread
From: Dirk Hörner @ 2012-06-04 20:40 UTC (permalink / raw)
  To: barebox

Passing a template to mktemp is mandatory on OS X.

Signed-off-by: Dirk Hörner <dirker@gmail.com>
---
 scripts/genenv |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/genenv b/scripts/genenv
index 7b279c8..c84af0c 100755
--- a/scripts/genenv
+++ b/scripts/genenv
@@ -8,7 +8,7 @@ objtree=$2
 cd $1 || exit 1
 shift 2
 
-tempdir=$(mktemp -d)
+tempdir=$(mktemp -d tmp.XXXXXX)
 
 for i in $*; do
 	cp -r $i/* $tempdir
-- 
1.7.10.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes
  2012-06-04 20:40 ` [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes Dirk Hörner
@ 2012-06-05  2:49   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-06-05 19:43     ` Sascha Hauer
  2012-06-05 21:15     ` Dirk Hörner
  0 siblings, 2 replies; 12+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-06-05  2:49 UTC (permalink / raw)
  To: Dirk Hörner; +Cc: barebox

HI,

	I don't like this to continue to duplicate code

Best Regards,
J.
On 22:40 Mon 04 Jun     , Dirk Hörner wrote:
> On OS X, stat does not know about %s. Solaris does not have stat. The
> drawback to this wc -c solution is that wc reads all the bytes, but we are
> only dealing with small files here, so that not be much of a problem.
> 
> Signed-off-by: Dirk Hörner <dirker@gmail.com>
> ---
>  Makefile             |    2 +-
>  common/Makefile      |    2 +-
>  scripts/Makefile.lib |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index bcaae0a..3ac8788 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -536,7 +536,7 @@ quiet_cmd_barebox_version = GEN     .version
>  # Check size of a file
>  quiet_cmd_check_file_size = CHKSIZE $@
>        cmd_check_file_size = set -e;					\
> -	size=`stat -c%s $@`;						\
> +	size=`wc -c < $@`;						\
>  	max_size=`printf "%d" $2`;					\
>  	if [ $$size -gt $$max_size ] ;					\
>  	then								\
> diff --git a/common/Makefile b/common/Makefile
> index a58aef9..9c14d7b 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -77,7 +77,7 @@ barebox_default_env.lzo: barebox_default_env
>  
>  include/generated/barebox_default_env.h: barebox_default_env$(barebox_default_env_comp)
>  	$(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
> -	$(Q)echo "const int default_environment_uncompress_size=`stat -c%s barebox_default_env`;" >> $@
> +	$(Q)echo "const int default_environment_uncompress_size=`wc -c < barebox_default_env`;" >> $@
>  
>  CLEAN_FILES += include/generated/barebox_default_env.h barebox_default_env
>  CLEAN_FILES += barebox_default_env.gz barebox_default_env.bz2
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index b842c48..9b02b1b 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -171,7 +171,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
>  size_append = printf $(shell						\
>  dec_size=0;								\
>  for F in $1; do								\
> -	fsize=$$(stat -c "%s" $$F);					\
> +	fsize=$$(wc -c < $$F);					        \
>  	dec_size=$$(expr $$dec_size + $$fsize);				\
>  done;									\
>  printf "%08x\n" $$dec_size |						\
> -- 
> 1.7.10.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/6] make: check for greadlink first, fall back to readlink
  2012-06-04 20:40 ` [PATCH 3/6] make: check for greadlink first, fall back to readlink Dirk Hörner
@ 2012-06-05  8:56   ` Michael Olbrich
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Olbrich @ 2012-06-05  8:56 UTC (permalink / raw)
  To: barebox

On Mon, Jun 04, 2012 at 10:40:16PM +0200, Dirk Hörner wrote:
> OS X' readlink does not have an -f option.
> 
> Signed-off-by: Dirk Hörner <dirker@gmail.com>
> ---
>  common/Makefile |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/common/Makefile b/common/Makefile
> index 9c14d7b..48cf715 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -48,7 +48,9 @@ ifneq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
>  DEFAULT_ENVIRONMENT_PATH += $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
>  endif
>  
> -ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec readlink -f '{}' \;; done)
> +READLINK := $(shell command -v greadlink || echo readlink)
> +
> +ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec $(READLINK) -f '{}' \;; done)

This is already broken. '-type f' only matches regular files. And ENV_FILES
is only used for make dependencies. And make follows links. I think what we
really need here is 'find $${i} ! -type d -print'

Michael

>  
>  endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
>  
> -- 
> 1.7.10.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/6] Support cross-compiling on Mac OS X
  2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
                   ` (5 preceding siblings ...)
  2012-06-04 20:40 ` [PATCH 6/6] scripts/genenv: always pass template to mktemp Dirk Hörner
@ 2012-06-05 19:42 ` Sascha Hauer
  6 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2012-06-05 19:42 UTC (permalink / raw)
  To: Dirk Hörner; +Cc: barebox

Hi Dirk,

On Mon, Jun 04, 2012 at 10:40:13PM +0200, Dirk Hörner wrote:
> Hi all,
> 
> this patch series adds support to cross-compile barebox on Mac OS X. Please
> review as I am quite unsure as to whether I have found the best solutions
> to some of the problems, especially patch two and three.
> 
> The first patch was cherry-picked from Linux.
> 
> I tested this series on Max OS X 10.6.8 using the yagarto ARM toolchain[1].
> 

Applied the patches nobody has commented on.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes
  2012-06-05  2:49   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-06-05 19:43     ` Sascha Hauer
  2012-06-05 21:15     ` Dirk Hörner
  1 sibling, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2012-06-05 19:43 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Tue, Jun 05, 2012 at 04:49:21AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	I don't like this to continue to duplicate code
> 

What do you mean here?

Sascha

> Best Regards,
> J.
> On 22:40 Mon 04 Jun     , Dirk Hörner wrote:
> > On OS X, stat does not know about %s. Solaris does not have stat. The
> > drawback to this wc -c solution is that wc reads all the bytes, but we are
> > only dealing with small files here, so that not be much of a problem.
> > 
> > Signed-off-by: Dirk Hörner <dirker@gmail.com>
> > ---
> >  Makefile             |    2 +-
> >  common/Makefile      |    2 +-
> >  scripts/Makefile.lib |    2 +-
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index bcaae0a..3ac8788 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -536,7 +536,7 @@ quiet_cmd_barebox_version = GEN     .version
> >  # Check size of a file
> >  quiet_cmd_check_file_size = CHKSIZE $@
> >        cmd_check_file_size = set -e;					\
> > -	size=`stat -c%s $@`;						\
> > +	size=`wc -c < $@`;						\
> >  	max_size=`printf "%d" $2`;					\
> >  	if [ $$size -gt $$max_size ] ;					\
> >  	then								\
> > diff --git a/common/Makefile b/common/Makefile
> > index a58aef9..9c14d7b 100644
> > --- a/common/Makefile
> > +++ b/common/Makefile
> > @@ -77,7 +77,7 @@ barebox_default_env.lzo: barebox_default_env
> >  
> >  include/generated/barebox_default_env.h: barebox_default_env$(barebox_default_env_comp)
> >  	$(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
> > -	$(Q)echo "const int default_environment_uncompress_size=`stat -c%s barebox_default_env`;" >> $@
> > +	$(Q)echo "const int default_environment_uncompress_size=`wc -c < barebox_default_env`;" >> $@
> >  
> >  CLEAN_FILES += include/generated/barebox_default_env.h barebox_default_env
> >  CLEAN_FILES += barebox_default_env.gz barebox_default_env.bz2
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index b842c48..9b02b1b 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -171,7 +171,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
> >  size_append = printf $(shell						\
> >  dec_size=0;								\
> >  for F in $1; do								\
> > -	fsize=$$(stat -c "%s" $$F);					\
> > +	fsize=$$(wc -c < $$F);					        \
> >  	dec_size=$$(expr $$dec_size + $$fsize);				\
> >  done;									\
> >  printf "%08x\n" $$dec_size |						\
> > -- 
> > 1.7.10.3
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes
  2012-06-05  2:49   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-06-05 19:43     ` Sascha Hauer
@ 2012-06-05 21:15     ` Dirk Hörner
  1 sibling, 0 replies; 12+ messages in thread
From: Dirk Hörner @ 2012-06-05 21:15 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Hi Jean-Christophe,

On Tue, Jun 5, 2012 at 4:49 AM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
>
> HI,
>
>        I don't like this to continue to duplicate code

I agree. Would you rather like a function in common/Kbuild.include and
then $(call) it in appropriate places?

In any case, I guess the code unification should be done in a separate
commit, either before or after my patch.

Ciao,
Dirk

>
> Best Regards,
> J.
> On 22:40 Mon 04 Jun     , Dirk Hörner wrote:
> > On OS X, stat does not know about %s. Solaris does not have stat. The
> > drawback to this wc -c solution is that wc reads all the bytes, but we
> > are
> > only dealing with small files here, so that not be much of a problem.
> >
> > Signed-off-by: Dirk Hörner <dirker@gmail.com>
> > ---
> >  Makefile             |    2 +-
> >  common/Makefile      |    2 +-
> >  scripts/Makefile.lib |    2 +-
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index bcaae0a..3ac8788 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -536,7 +536,7 @@ quiet_cmd_barebox_version = GEN     .version
> >  # Check size of a file
> >  quiet_cmd_check_file_size = CHKSIZE $@
> >        cmd_check_file_size = set -e;                                  \
> > -     size=`stat -c%s $@`;                                            \
> > +     size=`wc -c < $@`;                                              \
> >       max_size=`printf "%d" $2`;                                      \
> >       if [ $$size -gt $$max_size ] ;                                  \
> >       then                                                            \
> > diff --git a/common/Makefile b/common/Makefile
> > index a58aef9..9c14d7b 100644
> > --- a/common/Makefile
> > +++ b/common/Makefile
> > @@ -77,7 +77,7 @@ barebox_default_env.lzo: barebox_default_env
> >
> >  include/generated/barebox_default_env.h:
> > barebox_default_env$(barebox_default_env_comp)
> >       $(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
> > -     $(Q)echo "const int default_environment_uncompress_size=`stat -c%s
> > barebox_default_env`;" >> $@
> > +     $(Q)echo "const int default_environment_uncompress_size=`wc -c <
> > barebox_default_env`;" >> $@
> >
> >  CLEAN_FILES += include/generated/barebox_default_env.h
> > barebox_default_env
> >  CLEAN_FILES += barebox_default_env.gz barebox_default_env.bz2
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index b842c48..9b02b1b 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -171,7 +171,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f
> > -9 > $@) || \
> >  size_append = printf $(shell                                         \
> >  dec_size=0;                                                          \
> >  for F in $1; do
> >      \
> > -     fsize=$$(stat -c "%s" $$F);                                     \
> > +     fsize=$$(wc -c < $$F);                                          \
> >       dec_size=$$(expr $$dec_size + $$fsize);                         \
> >  done;
> >      \
> >  printf "%08x\n" $$dec_size |                                         \
> > --
> > 1.7.10.3
> >
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-06-05 21:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-04 20:40 [PATCH 0/6] Support cross-compiling on Mac OS X Dirk Hörner
2012-06-04 20:40 ` [PATCH 1/6] kbuild: Use Elfnn_Half as replacement for Elfnn_Section Dirk Hörner
2012-06-04 20:40 ` [PATCH 2/6] make: use wc -c instead of stat -c%s to get file sizes Dirk Hörner
2012-06-05  2:49   ` Jean-Christophe PLAGNIOL-VILLARD
2012-06-05 19:43     ` Sascha Hauer
2012-06-05 21:15     ` Dirk Hörner
2012-06-04 20:40 ` [PATCH 3/6] make: check for greadlink first, fall back to readlink Dirk Hörner
2012-06-05  8:56   ` Michael Olbrich
2012-06-04 20:40 ` [PATCH 4/6] hostcc tools: include "compiler.h", fix included headers Dirk Hörner
2012-06-04 20:40 ` [PATCH 5/6] scripts/compiler.h: fixup endianess defines on OS X Dirk Hörner
2012-06-04 20:40 ` [PATCH 6/6] scripts/genenv: always pass template to mktemp Dirk Hörner
2012-06-05 19:42 ` [PATCH 0/6] Support cross-compiling on Mac OS X Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox