From bdb423635b713285cc973bfe4c8a3c8b405d6328 Mon Sep 17 00:00:00 2001 From: mattbauer Date: Tue, 30 Dec 2008 16:39:54 -0600 Subject: [PATCH] Include ARCHFLAGS warning for OS X --- ext/extconf.rb | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ext/extconf.rb b/ext/extconf.rb index a2886f6..591b478 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -1,7 +1,39 @@ #!/usr/bin/env ruby require 'mkmf' -dir_config('db') +inc, lib = dir_config('db') + +# OS X compatibility +if(PLATFORM =~ /darwin/) then + # test if Bdb is probably universal + + filetype = (IO.popen("file #{inc}/../db_dump").readline.chomp rescue nil) + # if it's not universal, ARCHFLAGS should be set + if((filetype !~ /universal binary/) && ENV['ARCHFLAGS'].nil?) then + arch = (IO.popen("uname -m").readline.chomp rescue nil) + $stderr.write %{ +=========== WARNING =========== + +You are building this extension on OS X without setting the +ARCHFLAGS environment variable, and BerkeleyDB does not appear +to have been built as a universal binary. If you are seeing this +message, that means that the build will probably fail. + +Try setting the environment variable ARCHFLAGS +to '-arch #{arch}' before building. + +For example: +(in bash) $ export ARCHFLAGS='-arch #{arch}' +(in tcsh) % setenv ARCHFLAGS '-arch #{arch}' + +Then try building again. + +=================================== + +} + # We don't exit here. Who knows? It might build. + end +end versions=%w(db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2) until versions.empty?