lib/passenger/platform_info.rb in passenger-1.0.1 vs lib/passenger/platform_info.rb in passenger-1.0.2

- old
+ new

@@ -118,33 +118,46 @@ flags.gsub!(/-O\d? /, '') return flags end end - def self.determine_apr1_info - flags = nil - libs = nil - if find_command('pkg-config') - flags = `pkg-config --cflags apr-1 apr-util-1 2>/dev/null`.strip - libs = `pkg-config --libs apr-1 apr-util-1 2>/dev/null`.strip - end - if (flags.nil? || flags.empty?) && (libs.nil? || libs.empty?) + def self.find_apr_config + if env_defined?('APR_CONFIG') + apr_config = ENV['APR_CONFIG'] + elsif RUBY_PLATFORM =~ /darwin/ && HTTPD == "/usr/sbin/httpd" + # If we're on MacOS X, and we're compiling against the + # default provided Apache, then we'll want to query the + # correct 'apr-1-config' command. However, that command + # is not in $PATH by default. Instead, it lives in + # /Developer/SDKs/MacOSX*sdk/usr/bin. + sdk_dir = Dir["/Developer/SDKs/MacOSX*sdk"].sort.last + if sdk_dir + apr_config = "#{sdk_dir}/usr/bin/apr-1-config" + if !File.executable?(apr_config) + apr_config = nil + end + end + else apr_config = find_command('apr-1-config') if apr_config.nil? apr_config = find_command('apr-config') end - if apr_config.nil? - return nil - else - flags = `#{apr_config} --cppflags --includes`.strip - libs = `#{apr_config} --link-ld`.strip - end end - flags.gsub!(/-O\d? /, '') - return [flags, libs] + return apr_config end + def self.determine_apr_info + if APR_CONFIG.nil? + return nil + else + flags = `#{APR_CONFIG} --cppflags --includes`.strip + libs = `#{APR_CONFIG} --link-ld`.strip + flags.gsub!(/-O\d? /, '') + return [flags, libs] + end + end + def self.determine_multi_arch_flags if RUBY_PLATFORM =~ /darwin/ && !HTTPD.nil? architectures = [] `file "#{HTTPD}"`.split("\n").grep(/for architecture/).each do |line| line =~ /for architecture (.*?)\)/ @@ -229,14 +242,16 @@ APACHE2_SBINDIR = determine_apache2_sbindir # The absolute path to the 'apachectl' or 'apache2ctl' binary. APACHE2CTL = find_apache2ctl # The absolute path to the Apache binary (that is, 'httpd', 'httpd2', 'apache' or 'apache2'). HTTPD = find_httpd + # The absolute path to the 'apr-config' or 'apr-1-config' executable. + APR_CONFIG = find_apr_config # The C compiler flags that are necessary to compile an Apache module. APXS2_FLAGS = determine_apxs2_flags # The C compiler flags that are necessary for programs that use APR. - APR1_FLAGS, APR1_LIBS = determine_apr1_info + APR_FLAGS, APR_LIBS = determine_apr_info # The C compiler flags that are necessary for building binaries in the same architecture(s) as Apache. MULTI_ARCH_FLAGS = determine_multi_arch_flags # The current platform's shared library extension ('so' on most Unices). LIBEXT = determine_library_extension