]> mj.ucw.cz Git - eval.git/commitdiff
Configure: Automatic guessing of kernel/user-space architecture
authorMartin Mares <mj@ucw.cz>
Fri, 11 Jul 2014 15:57:36 +0000 (17:57 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 11 Jul 2014 15:57:36 +0000 (17:57 +0200)
Inspired by a patch by Ronald Chan.

configure
default.cfg

index f2a192cb3ba7405c7ce62df23095b6134d7bf8f0..bcc8e5d4ac356d23f6b97381fa92e2c344b9bffb 100755 (executable)
--- a/configure
+++ b/configure
@@ -32,6 +32,44 @@ require UCW::Configure::C;
 require UCW::Configure::LibUCW;
 require UCW::Configure::Doc;
 
+Test("KERNEL_ARCH", "Checking for kernel architecture", sub {
+       my $u = `uname -m`;
+       chomp $u;
+       if ($u =~ m{^i[3-6]86$}) {
+               return 'i386';
+       } elsif ($u eq 'x86_64') {
+               return 'amd64';
+       } else {
+               return $u;
+       }
+});
+
+Log "Selecting sandbox kernel architecture ... ";
+my $karch = Get("CONFIG_BOX_KERNEL_ARCH") // "auto";
+if ($karch eq 'i386' || $karch eq 'amd64') {
+       Log "$karch (set manually)\n";
+} elsif ($karch eq 'auto') {
+       $karch = Get('KERNEL_ARCH');
+       Set('CONFIG_BOX_KERNEL_ARCH', $karch);
+       Log "$karch\n";
+} else {
+       Fail "Unrecognized architecture $karch";
+}
+Set('CONFIG_BOX_KERNEL_AMD64') if $karch eq 'amd64';
+
+Log "Selecting sandbox user-space architecture ... ";
+my $uarch = Get("CONFIG_BOX_USER_ARCH") // "auto";
+if ($uarch eq 'i386' || $uarch eq 'amd64') {
+       Log "$uarch (set manually)\n";
+} elsif ($uarch eq 'auto') {
+       $uarch = Get('ARCH');
+       Set('CONFIG_BOX_USER_ARCH', $karch);
+       Log "$uarch\n";
+} else {
+       Fail "Unrecognized architecture $uarch";
+}
+Set('CONFIG_BOX_USER_AMD64') if $uarch eq 'amd64';
+
 if (Get("CONFIG_SUBMIT") || Get("CONFIG_MOP")) {
        # Build libucw only if it is needed
        Set("CONFIG_UCW_LIBS" => 1);
index 259b391b210dbde29adfe63d6652ebc590fd6fd3..69fbd6cbf3130dceb3d7a8b42c704ddbb038c923 100644 (file)
@@ -9,9 +9,10 @@
 #Set("CONFIG_MOP" => 1);
 
 # If you are running a 64-bit Linux kernel, you need to build a 64-bit
-# sandbox and decide whether your userspace is 32- or 64-bit.
-Set("CONFIG_BOX_KERNEL_AMD64" => 1);
-#Set("CONFIG_BOX_USER_AMD64" => 1);
+# sandbox and decide whether your userspace is 32- or 64-bit. Both
+# variables can be set to "i386", "amd64", or "auto" to auto-detect.
+Set("CONFIG_BOX_KERNEL_ARCH" => "auto");
+Set("CONFIG_BOX_USER_ARCH" => "auto");
 
 ### Hard-coded configuration parameters of the process isolator ###