From 0d78c470af588f533ceb47e9702bf51798bd7b3a Mon Sep 17 00:00:00 2001 From: inglorion Date: Sun, 11 Apr 2010 13:29:23 +0200 Subject: [PATCH] Target host architecture by default, unless a different default is specified when running configure. --- configure | 13 +------------ lib/voodoo/config.rb.in | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 2ef763e..823158b 100755 --- a/configure +++ b/configure @@ -58,18 +58,7 @@ done [ -n "$MANDIR" ] || MANDIR="\$(PREFIX)/share/man" [ -n "$RUBYLIBDIR" ] || RUBYLIBDIR="\$(PREFIX)/lib/site_ruby" -if [ -z "$DEFAULT_ARCHITECTURE" ] -then - # Try to automagically configure the native architecture - arch=`uname -m` - case "$arch" in - amd64|x86_64) - DEFAULT_ARCHITECTURE=amd64 - ;; - *) - DEFAULT_ARCHITECTURE=i386 - esac -fi +[ -n "$DEFAULT_ARCHITECTURE" ] || DEFAULT_ARCHITECTURE=auto [ -n "$DEFAULT_FORMAT" ] || DEFAULT_FORMAT=elf printf 'Testing for ruby...' diff --git a/lib/voodoo/config.rb.in b/lib/voodoo/config.rb.in index d2ea15a..da1f238 100644 --- a/lib/voodoo/config.rb.in +++ b/lib/voodoo/config.rb.in @@ -20,10 +20,41 @@ module Voodoo @nasm_command = #{nasm_command.inspect} end - attr_accessor :default_architecture, - :default_format, + attr_accessor :default_format, :gas_command, :nasm_command + + attr_writer :default_architecture + + # Returns the default architecture for this compiler + def default_architecture + if @default_architecture == :auto + # If @default_architecture has been set to :auto, + # return the host architecture, falling back to :i386 + # if the host architecture cannot be determined + host_architecture || :i386 + else + @default_architecture + end + end + + # Returns the architecture of the machine running the program, + # or nil if that architecture cannot be determined + def host_architecture + arch, = RUBY_PLATFORM.split '-' + case arch + when 'x86_64', 'amd64' + :amd64 + when 'i386', 'i686' + :i386 + when 'mips' + :mips + when 'mipsel' + :mipsel + else + nil + end + end end DEFAULT_CONFIGURATION = Configuration.new -- 2.11.4.GIT