Skip to contentSkip to conversation

Enable top level configure script for cross compile

PATCH Superseded Jerone Young 2 participants 3 messages Oct 8, 2007 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 Enable top level configure script for cross compile

This patch adds cross compile capability to the top level configure script.

configure +46 -14
diff -r f48e521e0add configure
@@ -5,13 +5,17 @@ want_module=1
 want_module=1
 qemu_cc=$(ls /usr/bin/gcc3* /usr/bin/gcc-3* 2>/dev/null | tail -n1)
 disable_gcc_check=
+cross_prefix=
+arch=`uname -m`
+target_cpu=
 
 usage() {
     cat <<-EOF
 	Usage: $0 [options]
 
 	Options include:
-
+	    --arch=ARCH            architecture to compile for ($arch)
+	    --cross-prefix=PREFIX  prefix for cross compiler
 	    --prefix=PREFIX        where to install things ($prefix)
 	    --with-patched-kernel  don't use external module
 	    --kerneldir=DIR        kernel build directory ($kerneldir)
@@ -53,6 +57,15 @@ while [[ "$1" = -* ]]; do
 	--disable-gcc-check)
 	    disable_gcc_check=1
 	    ;;
+	--arch)
+	    arch="$arg"
+	    ;;
+	--cross-prefix)
+	    cross_prefix="$arg"
+            ;;
+	--target-cpu)
+	    target_cpu="$arg"
+	    ;; 
 	--help)
 	    usage
 	    ;;
@@ -62,7 +75,7 @@ while [[ "$1" = -* ]]; do
     esac
 done
 
-if [[ -z "$qemu_cc" ]]; then
+if [[ -z "$qemu_cc" ]] && [[ -z "$cross_prefix" ]]; then
     echo "$0: cannot locate gcc 3.x. please install it or specify with --qemu-cc"
     exit 1
 fi
@@ -72,29 +85,48 @@ if (( want_module )); then
     libkvm_kerneldir=$(readlink -f kernel)
 fi
 
-target_cpu() {
-    if [[ $(uname -m) = i?86 ]]; then
-	echo x86_64
-    else
-	uname -m
+#if arch is an x86 arch set to i386
+if [[ $arch = i?86 ]]; then
+  arch="i386"
+fi
+
+#see if using a cross compiler or not
+compiler=
+qemu_opts=
+user_opts=
+if [[ -z $cross_prefix ]]; then
+    qemu_opts+=" --cc=$qemu_cc"
+    user_opts+=" --cc=$qemu_cc"
+else
+    qemu_opts+=" --cross-prefix=$cross_prefix"
+    user_opts+=" --cross-prefix=$cross_prefix"
+fi
+
+#set parameters compiling
+if [ "$arch" = "i386" -o "$arch" = "x86_64" ]; then
+    if [[ -z $target_cpu ]]; then
+        target_cpu="x86_64"
     fi
-}
+    qemu_opts+=" --enable-alsa"
+fi
 
-(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir")
-(cd qemu; ./configure --target-list=$(target_cpu)-softmmu --cc="$qemu_cc" \
+#configure user dir
+(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
+          $user_opts --arch="$arch")
+(cd qemu; ./configure --target-list=$target_cpu-softmmu \
     --disable-kqemu --extra-cflags="-I $PWD/../user" \
     --extra-ldflags="-L $PWD/../user" \
     --enable-kvm --kernel-path="$libkvm_kerneldir" \
-    --enable-alsa \
     ${disable_gcc_check:+"--disable-gcc-check"} \
-    --prefix="$prefix"
+    --prefix="$prefix" \
+    $qemu_opts --cpu="$arch"
 )
 
 
-
 cat <<EOF > config.mak
+ARCH=$arch
 PREFIX=$prefix
 KERNELDIR=$kerneldir
 WANT_MODULE=$want_module
+CC=$cross_prefix$qemu_cc
 EOF
-

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#1 lore raw

Hi,
I saw that you derive $target_cpu from arch as I know it from your older internal and external patches. Now you added the configure command line option --target-cpu to allow to overwrite that $arch derived target.
a) do you have some use cases in mind where you need an overwritten target instead the one derived from $arch ?
b) if it is needed, please add a small description to the usage() output

Kind regards,
Christian Ehrhardt

Quoted 133 lines · Jerone Young

This patch adds cross compile capability to the top level configure script.

------------------------------------------------------------------------

diff -r f48e521e0add configure

configure +46 -16
@@ -5,13 +5,17 @@ want_module=1
 want_module=1
 qemu_cc=$(ls /usr/bin/gcc3* /usr/bin/gcc-3* 2>/dev/null | tail -n1)
 disable_gcc_check=
+cross_prefix=
+arch=`uname -m`
+target_cpu=
 
 usage() {
     cat <<-EOF
 	Usage: $0 [options]
 
 	Options include:
-
+	    --arch=ARCH            architecture to compile for ($arch)
+	    --cross-prefix=PREFIX  prefix for cross compiler
 	    --prefix=PREFIX        where to install things ($prefix)
 	    --with-patched-kernel  don't use external module
 	    --kerneldir=DIR        kernel build directory ($kerneldir)
@@ -53,6 +57,15 @@ while [[ "$1" = -* ]]; do
 	--disable-gcc-check)
 	    disable_gcc_check=1
 	    ;;
+	--arch)
+	    arch="$arg"
+	    ;;
+	--cross-prefix)
+	    cross_prefix="$arg"
+            ;;
+	--target-cpu)
+	    target_cpu="$arg"
+	    ;; 
 	--help)
 	    usage
 	    ;;
@@ -62,7 +75,7 @@ while [[ "$1" = -* ]]; do
     esac
 done
 
-if [[ -z "$qemu_cc" ]]; then
+if [[ -z "$qemu_cc" ]] && [[ -z "$cross_prefix" ]]; then
     echo "$0: cannot locate gcc 3.x. please install it or specify with --qemu-cc"
     exit 1
 fi
@@ -72,29 +85,48 @@ if (( want_module )); then
     libkvm_kerneldir=$(readlink -f kernel)
 fi
 
-target_cpu() {
-    if [[ $(uname -m) = i?86 ]]; then
-	echo x86_64
-    else
-	uname -m
+#if arch is an x86 arch set to i386
+if [[ $arch = i?86 ]]; then
+  arch="i386"
+fi
+
+#see if using a cross compiler or not
+compiler=
+qemu_opts=
+user_opts=
+if [[ -z $cross_prefix ]]; then
+    qemu_opts+=" --cc=$qemu_cc"
+    user_opts+=" --cc=$qemu_cc"
+else
+    qemu_opts+=" --cross-prefix=$cross_prefix"
+    user_opts+=" --cross-prefix=$cross_prefix"
+fi
+
+#set parameters compiling
+if [ "$arch" = "i386" -o "$arch" = "x86_64" ]; then
+    if [[ -z $target_cpu ]]; then
+        target_cpu="x86_64"
     fi
-}
+    qemu_opts+=" --enable-alsa"
+fi
 
-(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir")
-(cd qemu; ./configure --target-list=$(target_cpu)-softmmu --cc="$qemu_cc" \
+#configure user dir
+(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
+          $user_opts --arch="$arch")
+(cd qemu; ./configure --target-list=$target_cpu-softmmu \
     --disable-kqemu --extra-cflags="-I $PWD/../user" \
     --extra-ldflags="-L $PWD/../user" \
     --enable-kvm --kernel-path="$libkvm_kerneldir" \
-    --enable-alsa \
     ${disable_gcc_check:+"--disable-gcc-check"} \
-    --prefix="$prefix"
+    --prefix="$prefix" \
+    $qemu_opts --cpu="$arch"
 )
 
 
-
 cat <<EOF > config.mak
+ARCH=$arch
 PREFIX=$prefix
 KERNELDIR=$kerneldir
 WANT_MODULE=$want_module
+CC=$cross_prefix$qemu_cc
 EOF
-
 
 
------------------------------------------------------------------------
 
-------------------------------------------------------------------------

This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

------------------------------------------------------------------------

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Signature · 19 lines
Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[email protected]
[email protected]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
#3 lore raw
In reply to a message not in the archive
Quoted 4 lines · Christian Ehrhardt

Hi,
I saw that you derive $target_cpu from arch as I know it from your older internal and external patches. Now you added the configure command line option --target-cpu to allow to overwrite that $arch derived target.
a) do you have some use cases in mind where you need an overwritten target instead the one derived from $arch ?

I was a bit future thinking with this option. But really it is not needed at this moment. Now the way things work today in KVM x86 & x86-64 use the same qemu target build (x86-64-softmmu).

The case I was thinking (at least at the time), was that if we wanted to use a different device model (assuming all the kvm code is in place) then this would allow that.

An example would be for powerpc. Right now our current work is for ppc embedded which is also the qemu device model we are working in (ppcemb-softmmu). But if we also ever to have a server ppc or any other higher end power product we may not want that code in our ppcemb-softmmu executable (we want it small as possible). That code would probably go in "ppc-softmmu". Now we have a problem. So you would then need to specify target_cpu= to make this distinction for building the proper qemu executable.

Quoted 1 line

b) if it is needed, please add a small description to the usage() output

That is actually missing from the help in this version of the patch. I missed that :-O

But for now I will probably just remove this option from the patch and resend it.

Quoted 132 lines

Kind regards,
Christian Ehrhardt

Quoted 127 lines · Jerone Young

This patch adds cross compile capability to the top level configure script.

------------------------------------------------------------------------

diff -r f48e521e0add configure

configure +46 -16
@@ -5,13 +5,17 @@ want_module=1
 want_module=1
 qemu_cc=$(ls /usr/bin/gcc3* /usr/bin/gcc-3* 2>/dev/null | tail -n1)
 disable_gcc_check=
+cross_prefix=
+arch=`uname -m`
+target_cpu=
 
 usage() {
     cat <<-EOF
 	Usage: $0 [options]
 
 	Options include:
-
+	    --arch=ARCH            architecture to compile for ($arch)
+	    --cross-prefix=PREFIX  prefix for cross compiler
 	    --prefix=PREFIX        where to install things ($prefix)
 	    --with-patched-kernel  don't use external module
 	    --kerneldir=DIR        kernel build directory ($kerneldir)
@@ -53,6 +57,15 @@ while [[ "$1" = -* ]]; do
 	--disable-gcc-check)
 	    disable_gcc_check=1
 	    ;;
+	--arch)
+	    arch="$arg"
+	    ;;
+	--cross-prefix)
+	    cross_prefix="$arg"
+            ;;
+	--target-cpu)
+	    target_cpu="$arg"
+	    ;; 
 	--help)
 	    usage
 	    ;;
@@ -62,7 +75,7 @@ while [[ "$1" = -* ]]; do
     esac
 done
 
-if [[ -z "$qemu_cc" ]]; then
+if [[ -z "$qemu_cc" ]] && [[ -z "$cross_prefix" ]]; then
     echo "$0: cannot locate gcc 3.x. please install it or specify with --qemu-cc"
     exit 1
 fi
@@ -72,29 +85,48 @@ if (( want_module )); then
     libkvm_kerneldir=$(readlink -f kernel)
 fi
 
-target_cpu() {
-    if [[ $(uname -m) = i?86 ]]; then
-	echo x86_64
-    else
-	uname -m
+#if arch is an x86 arch set to i386
+if [[ $arch = i?86 ]]; then
+  arch="i386"
+fi
+
+#see if using a cross compiler or not
+compiler=
+qemu_opts=
+user_opts=
+if [[ -z $cross_prefix ]]; then
+    qemu_opts+=" --cc=$qemu_cc"
+    user_opts+=" --cc=$qemu_cc"
+else
+    qemu_opts+=" --cross-prefix=$cross_prefix"
+    user_opts+=" --cross-prefix=$cross_prefix"
+fi
+
+#set parameters compiling
+if [ "$arch" = "i386" -o "$arch" = "x86_64" ]; then
+    if [[ -z $target_cpu ]]; then
+        target_cpu="x86_64"
     fi
-}
+    qemu_opts+=" --enable-alsa"
+fi
 
-(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir")
-(cd qemu; ./configure --target-list=$(target_cpu)-softmmu --cc="$qemu_cc" \
+#configure user dir
+(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
+          $user_opts --arch="$arch")
+(cd qemu; ./configure --target-list=$target_cpu-softmmu \
     --disable-kqemu --extra-cflags="-I $PWD/../user" \
     --extra-ldflags="-L $PWD/../user" \
     --enable-kvm --kernel-path="$libkvm_kerneldir" \
-    --enable-alsa \
     ${disable_gcc_check:+"--disable-gcc-check"} \
-    --prefix="$prefix"
+    --prefix="$prefix" \
+    $qemu_opts --cpu="$arch"
 )
 
 
-
 cat <<EOF > config.mak
+ARCH=$arch
 PREFIX=$prefix
 KERNELDIR=$kerneldir
 WANT_MODULE=$want_module
+CC=$cross_prefix$qemu_cc
 EOF
-
 
 
------------------------------------------------------------------------
 
-------------------------------------------------------------------------

This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

Quoted 8 lines
Quoted 6 lines

------------------------------------------------------------------------

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/