Skip to contentSkip to conversation

improve build for UNIX like non GNU platforms

PATCH Superseded Jeroen Hofstee 5 participants 17 messages Jul 19, 2011 – Jul 28, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover improve build for UNIX like non GNU platforms

The sed changes can be tested with GNU sed by sed --posix. Tested on FreeBSD / Ubuntu.

For completeness, building with the FreeBSD arm bootstrap compiler needs some non u-boot related changes:
+ gcc doesn't support the -print-file-name=include, and the correct path needs to added manually.
+ linking fails since it also needs libc.a. Just add -lc.

Jeroen Hofstee (3):
include/compiler.h: typedef ulong for FreeBSD
mkconfig: create CONFIG_ defines without relying on GNU extensions rules.mk: replace GNU specific \w with POSIX equivalant

 include/compiler.h |    2 +-
 mkconfig           |    2 +-
 rules.mk           |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/3 include/compiler.h: typedef ulong for FreeBSD

---
 include/compiler.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/compiler.h +1 -1
index 91dbe56..4e047c7 100644
@@ -44,7 +44,7 @@
 #ifdef __linux__
 # include <endian.h>
 # include <byteswap.h>
-#elif defined(__MACH__)
+#elif defined(__MACH__) || defined(__FreeBSD__)
 # include <machine/endian.h>
 typedef unsigned long ulong;
 #endif
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 1/3 include/compiler.h: typedef ulong for FreeBSD

Dear Jeroen Hofstee,

Quoted 4 lines · In message <[email protected]> you wrote:
---
 include/compiler.h |    2 +-
 1 files changed, 1 insertions(+), 1 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
So we follow our wandering paths, and the very darkness acts  as  our
guide and our doubts serve to reassure us. - Jean-Pierre de Caussade,
eighteenth-century Jesuit priest
#3 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

In reply to Jeroen Hofstee

Parsing of boards.cfg relies on sed GNU extensions and fails if sed doesn't support these. On FreeBSD this leads to the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

---
 mkconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mkconfig +1 -1
index 6ff533f..b9cfc94 100755
@@ -148,7 +148,7 @@ fi
 echo "/* Automatically generated - do not edit */" >>config.h
 
 for i in ${TARGETS} ; do
-	i="`echo ${i} | sed '/=/ {s/=/\t/;q } ; { s/$/\t1/ }'`"
+	i="`echo ${i} | sed -e '/=/!s/$/=1/' -e 's/=/	/'`"
 	echo "#define CONFIG_${i}" >>config.h ;
 done
 
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

Quoted 8 lines · Jeroen Hofstee

Parsing of boards.cfg relies on sed GNU extensions and fails if sed doesn't support these. On FreeBSD this leads to the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

- ? ? ? i="echo ${i} | sed '/=/ {s/=/\t/;q } ; { s/$/\t1/ }'"
+ ? ? ? i="echo ${i} | sed -e '/=/!s/$/=1/' -e 's/=/ ? /'"

maybe i havent read enough sed scripts, but i dont think ive seen "!" used before. how about this more straightforward replacement:
sed -e '/=/{s/=/\t/;q}' -e 's/$/\t1/'
-mike

#5 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

Hi Mike,

Quoted 1 line

maybe i havent read enough sed scripts, but i dont think ive seen "!"

I took this for irony, so I triple checked:

jeroen at green-ubuntu:~$ echo config | sed -e '/=/!s/$/=1/' config=1
jeroen at green-ubuntu:~$ echo config=2 | sed -e '/=/!s/$/=1/' config=2

Quoted 3 lines

used before. how about this more straightforward replacement:
sed -e '/=/{s/=/\t/;q}' -e 's/$/\t1/'
-mike

Won't work on FreeBSD since it can't quite early [afaik] (perhaps with a label, but gets rather ugly..)

[jeroen at blue ~]$ echo configflag | sed -e '/=/{s/=/\t/;q}' -e 's/$/\t1/'
sed: 1: "/=/{s/=/\t/;q}
": extra characters at the end of q command

Regards,
Jeroen

#6 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

Quoted 3 lines · Jeroen Hofstee
Quoted 1 line

maybe i havent read enough sed scripts, but i dont think ive seen "!"

I took this for irony, so I triple checked:

i didnt mean "it isnt in POSIX" (because it is), i meant it as "no one uses it, so it wont be obvious to people reading this code later as to what's going on"

Quoted 9 lines
Quoted 2 lines

used before. ?how about this more straightforward replacement:
sed -e '/=/{s/=/\t/;q}' -e 's/$/\t1/'

Won't work on FreeBSD since it can't quite early [afaik] (perhaps with a label, but gets rather ugly..)

[jeroen at blue ~]$ echo configflag | sed -e '/=/{s/=/\t/;q}' -e 's/$/\t1/'
sed: 1: "/=/{s/=/\t/;q}
": extra characters at the end of q command

i'm not sure you've diagnosed the problem correctly. the fact that the output says "end of q command" indicates that FreeBSD does support the "q" command (as required by POSIX).

perhaps the problem is that the ";" extension to separating commands (which is not in POSIX afaics) does not work the same in FreeBSD's sed as GNU's sed. i imagine if you stick a ";" after the "q" command it'll work ...

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
-mike

#7 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

Hi Mike,

Quoted 10 lines
Quoted 6 lines

Won't work on FreeBSD since it can't quite early [afaik] (perhaps with a label, but gets rather ugly..)

[jeroen at blue ~]$ echo configflag | sed -e '/=/{s/=/\t/;q}' -e 's/$/\t1/'
sed: 1: "/=/{s/=/\t/;q}
": extra characters at the end of q command

i'm not sure you've diagnosed the problem correctly. the fact that the output says "end of q command" indicates that FreeBSD does support the "q" command (as required by POSIX).

I didn't apparently..

Quoted 7 lines

perhaps the problem is that the ";" extension to separating commands (which is not in POSIX afaics) does not work the same in FreeBSD's sed as GNU's sed. i imagine if you stick a ";" after the "q" command it'll work ...

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
-mike

Yes, the ; does work as expected, thanks!

[jeroen at blue ~]$ echo config | sed -e '/=/{s/=/ /;q;}' -e 's/$/ 1/'
config 1
[jeroen at blue ~]$ echo config=2 | sed -e '/=/{s/=/ /;q;}' -e 's/$/ 1/'
config 2

Shall change the patch accordingly tomorrow.

Regards,
Jeroen

#8 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

In reply to Jeroen Hofstee
Quoted 5 lines · Jeroen Hofstee

Parsing of boards.cfg relies on sed GNU extensions and fails if sed doesn't support these. On FreeBSD this leads to the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

Does it still work on linux as well? Did you test? If so, I'm all for it being merged, but just from a brief look, I see it'll be missing the TAB. Am I right?

Quoted 19 lines
---
 mkconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mkconfig +1 -1
index 6ff533f..b9cfc94 100755
@@ -148,7 +148,7 @@ fi
 echo "/* Automatically generated - do not edit */" >>config.h
 
 for i in ${TARGETS} ; do
-	i="`echo ${i} | sed '/=/ {s/=/\t/;q } ; { s/$/\t1/ }'`"
+	i="`echo ${i} | sed -e '/=/!s/$/=1/' -e 's/=/	/'`"
 	echo "#define CONFIG_${i}" >>config.h ;
 done
#9 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

Quoted 9 lines · Marek Vasut
Quoted 5 lines · Jeroen Hofstee

Parsing of boards.cfg relies on sed GNU extensions and fails if sed doesn't support these. On FreeBSD this leads to the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

Does it still work on linux as well? Did you test? If so, I'm all for it being merged, but just from a brief look, I see it'll be missing the TAB. Am I right?

he inlined the tab. it isnt actually a space there.

not that it matters as this is used to create "#define CONFIG_FOO 1" and preprocessors dont care if it's a tab or space before that "1". -mike

#10 lore raw

PATCH 2/3 mkconfig: create CONFIG_ defines without relying on GNU extensions

In reply to Marek Vasut

Parsing of boards.cfg relies on sed GNU extensions and fails if sed

Quoted 7 lines
Quoted 4 lines

doesn't support these. On FreeBSD this leads to the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

Does it still work on linux as well? Did you test? If so, I'm all for it being merged, but just from a brief look, I see it'll be missing the TAB. Am I right?

yes I did build all arm boards on ubuntu (and i386?) on ubuntu. (it didn't build more
nor less boards). As pointed out by Mike there might be a a patch more closely to
the original, but I will need to test that (especially if GNU support it), and will do that
tomorrow (today actually CEST). So preferably take that one.

The BSD version doesn't understand \t, so it is a literal tab character. Can't help it.

Regards,
Jeroen

#11 lore raw

PATCH 3/3 rules.mk: replace GNU specific \w with POSIX equivalant

In reply to Jeroen Hofstee

If sed does not support the GNU \w regex extension, build attempts lead to circular dependency warnings and finally build failure (crc32.c not found). Build output before and after the patch on FreeBSD is at:
http://lists.denx.de/pipermail/u-boot/2011-June/095235.html

---
 rules.mk |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
rules.mk +2 -2
index 5fd12a0..a6bae62 100644
@@ -29,11 +29,11 @@ $(obj).depend:	$(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS)
 		@rm -f $@
 		@touch $@
 		@for f in $(SRCS); do \
-			g=`basename $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \
+			g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
 			$(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
 		done
 		@for f in $(HOSTSRCS); do \
-			g=`basename $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \
+			g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
 			$(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
 		done
 
Signature · 1 line
1.7.5.4
#12 lore raw

PATCH 3/3 rules.mk: replace GNU specific \w with POSIX equivalant

Dear Jeroen Hofstee,

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

If sed does not support the GNU \w regex extension, build attempts lead to circular dependency warnings and finally build failure (crc32.c not found). Build output before and after the patch on FreeBSD is at:
http://lists.denx.de/pipermail/u-boot/2011-June/095235.html

---
 rules.mk |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 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
Wisdom is one of the few things that looks bigger the further away it
is.                               - Terry Pratchett, _Witches Abroad_
#13 lore raw

v2 cover improve build for UNIX like non GNU platforms

In reply to Jeroen Hofstee

Changes for v2:
- updated mkconfig patch to make minimal changes and changed commit message, since it now relies on GNU and BSD extensions.

Jeroen Hofstee (3):
include/compiler.h: typedef ulong for FreeBSD rules.mk: replace GNU specific \w with POSIX equivalant
mkconfig: also create CONFIG defines with BSD sed

Signature · 1 line
1.7.5.4
#14 lore raw

PATCH v2 3/3 mkconfig: also create CONFIG defines with BSD sed

Parsing of boards.cfg fails on FreeBSD with the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

BSD sed expects commands to be on seperate 'lines', hence it expects an additional ; before the closing brackets.
BSD sed does not support \t, replaced by literal tab.

---
 mkconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mkconfig +1 -1
index 6ff533f..ecb6d4e 100755
@@ -148,7 +148,7 @@ fi
 echo "/* Automatically generated - do not edit */" >>config.h
 
 for i in ${TARGETS} ; do
-	i="`echo ${i} | sed '/=/ {s/=/\t/;q } ; { s/$/\t1/ }'`"
+	i="`echo ${i} | sed '/=/ {s/=/	/;q; } ; { s/$/	1/; }'`"
 	echo "#define CONFIG_${i}" >>config.h ;
 done
 
Signature · 1 line
1.7.5.4
#15 lore raw

PATCH v2 3/3 mkconfig: also create CONFIG defines with BSD sed

Quoted 8 lines · Jeroen Hofstee

Parsing of boards.cfg fails on FreeBSD with the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

BSD sed expects commands to be on seperate 'lines', hence it expects an additional ; before the closing brackets.
BSD sed does not support \t, replaced by literal tab.

-mike

#16 lore raw

PATCH v2 3/3 mkconfig: also create CONFIG defines with BSD sed

In reply to Jeroen Hofstee

Dear Jeroen Hofstee,

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

Parsing of boards.cfg fails on FreeBSD with the error:

sed: 1: "/=/ {s/=/\t/;q } ; { s/ ...": extra characters at the end of q command

BSD sed expects commands to be on seperate 'lines', hence it expects an additional ; before the closing brackets.
BSD sed does not support \t, replaced by literal tab.

Quoted 5 lines
---
 mkconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 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
It is more rational to sacrifice one life than six.
	-- Spock, "The Galileo Seven", stardate 2822.3