[Buildroot] pciutils-2.2.6 fails to build for powerpc 405

Darcy Watkins DWatkins at tranzeo.com
Wed Feb 13 18:05:48 UTC 2008


Included / attached is patch to allow pciutils to cross compile under
buildroot for non i386 architectures.  I believe that the pciutils
package will natively compile for non i386 architectures.  It failed to
cross compile due to the use of 'uname' on the build machine by the
configure script to attempt to determine system information that applies
to the target machine.

I am including the original email thread at the end of the email since
it dates back to sep'07.

The updated configure script will now check the $CC variable.  If it is
a simple compiler name such as "gcc" or "cc", it will assume native
compile.  If is sees the compiler name of the form of
"powerpc-linux-uclibc-gcc" it will assume cross compiled.

For cross compile, I pipe the basename into 'cut' and get cpu from the
first part of the name and the sys from the second.  For native compile,
I just allow the existing usage of 'uname' to prevail.

For buildroot project, the attached can simply replace:

For pciutils (upstream project) the patch will update:

The patch would need to be in the buildroot project until such a time
that the updated script comes into buildroot from the upstream project.

The patch is below for perusal, and attached as a file to ensure that
Windows / Outlook doesn't mangle it up.

--- pciutils-2.2.6/lib/configure.theorig	2008-02-12
10:56:24.000000000 -0800
+++ pciutils-2.2.6/lib/configure	2008-02-12 10:59:05.000000000
@@ -12,6 +12,21 @@ echo_n() {
 echo_n "Configuring libpci for your system..."
+if [ $CC ] ; then
+	# Cross compiling is assumed if $CC is of the form
+	# i.e. not simply "gcc", "cc", etc.
+	sys=`basename $CC | cut -d '-' -f 2`
+	if [ "$sys" == "`basename $CC`" ] ; then
+		# Native compiled
+		unset sys
+	else
+		cpu=`basename $CC | cut -d '-' -f 1`
+		rel=$4
+		echo "cross-compiled for ${cpu}-${sys} $rel using: $CC"
+	fi
+if [ ! $sys ] ; then
 sys=`uname -s`
 rel=`uname -r`
 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
@@ -33,6 +48,7 @@ cpu=`echo $host | sed 's/^\([^-]*\)-\([^
 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo " $host $rel"

I have tested this for buildroot cross compile on an i386 linux (fc6)
build machine for powerpc target to run on embedded linux.  I have not
tested for any other architecture (or build machine config).



-----Original Message-----
From: buildroot-bounces at uclibc.org [mailto:buildroot-bounces at uclibc.org]
On Behalf Of Darcy Watkins
Sent: Friday, September 14, 2007 8:02 AM
To: buildroot at uclibc.org
Subject: Re: [Buildroot] pciutils-2.2.6 fails to build for powerpc 405

Hello Bernhard et al,

I checked into this.  Extracted from email response from Martin who owns
/ maintains PCI utils...

>> I believe that in order to properly support cross compiling, the 
>> configure scripts need to check the variables normally associated
>> cross compiling and target architecture rather than using the "uname"
>> utility of the machine running the build (otherwise it will configure

>> for the build machine and then attempt to cross compile it for the 
>> target).
>Which variables do you have in mind?

I looked at the "configure" script and put in a few "echo"'s to spit out
typical cross compile variables that are set.  I notice that $ARCH and
$CROSS_COMPILE are not set when using buildroot.  It appears that the
only one reliable (I know of) is $CC.  When using buildroot to compile
for powerpc, I see something like:

  <path to my toolchain>/powerpc-linux-uclibc-gcc

So I could suggest to Martin a check of $CC for a prefix in front of the
gcc (after any path).  If so then extract contents as follows:

  Cpu <== from the prefix up to the first "-"
  Sys <== from the prefix after the first "-" to the "-" before the gcc
  Host <== I believe that this should still be derived from "uname"
since it
           describes the build machine not the target machine

*** DLW feb13,2008 - Host will be derived from cpu and sys as before for
native compile and not be used at all for cross compile.

If there is no prefix in front of the "gcc" then assume not cross
compiling (native compile) and use "uname" as is done at present.

I think that "linux-uclibc" will work out OK.

Ultimately, at this point, it appears that we only need sufficient logic
to ensure that $cpu takes on a value other than "i386" when cross
compiling for other architectures, because that is all the configure
script checks for now.

I don't know how this will behave for native compiling on all the other
operating systems (BSD, cygwin, etc).  Is there a better variable to use
than $CC?



-----Original Message-----
From: Bernhard Fischer [mailto:rep.dot.nop at gmail.com] 
Sent: Thursday, September 13, 2007 2:26 AM
To: Darcy Watkins
Cc: buildroot at uclibc.org
Subject: Re: [Buildroot] pciutils-2.2.6 fails to build for powerpc 405


>I think that the short solution is to patch line #23 so that it derives
>cpu from architecture variables instead of the output of uname.

Sounds ok. Is this already fixed updstream? If not it would be nice if
you could make sure that we can inherit a working version from
buildroot mailing list
buildroot at uclibc.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diff.txt
Url: http://lists.busybox.net/pipermail/buildroot/attachments/20080213/202a2a8e/attachment-0002.txt 

More information about the buildroot mailing list