def self.apache2_module_c_or_cxxflags(language, with_apr_flags = true)
flags = [""]
if (language == :c && cc_is_sun_studio?) || (language == :cxx && cxx_is_sun_studio?)
flags << "-KPIC"
else
flags << "-fPIC"
end
if with_apr_flags
if language == :c
flags << apr_cflags
flags << apu_cflags
else
flags << apr_cxxflags
flags << apu_cxxflags
end
end
if !apxs2.nil?
apxs2_flags = `#{apxs2} -q CFLAGS`.strip << " -I" << `#{apxs2} -q INCLUDEDIR`.strip
apxs2_flags.gsub!(/-O\d? /, '')
if os_name_simple == "solaris"
if (language == :c && !cc_is_sun_studio?) || (language == :cxx && !cxx_is_sun_studio?)
options = apxs2_flags.split
options.reject! { |f| f =~ /^\-x/ }
options.reject! { |f| f =~ /^\-Xa/ }
options.reject! { |f| f =~ /^\-fast/ }
options.reject! { |f| f =~ /^\-mt/ }
options.reject! { |f| f =~ /^\-W2/ }
apxs2_flags = options.join(' ')
apxs2_flags.gsub!(/ ?-Qoption cg ?/, " ")
end
end
if os_name_simple == "linux" &&
linux_distro_tags.include?(:redhat) &&
apxs2 == "/usr/sbin/apxs" &&
httpd_architecture_bits == 64
apxs2_flags.gsub!('-m32 -march=i386 -mtune=generic', '')
end
apxs2_flags.gsub!('-pie', '')
apxs2_flags.strip!
flags << apxs2_flags
end
if !httpd.nil? && os_name_simple == "macosx"
output = `file "#{httpd}"`.strip
if output =~ /Mach-O fat file/ && output !~ /for architecture/
architectures = ["i386", "ppc", "x86_64", "ppc64"]
else
architectures = []
output.split("\n").grep(/for architecture/).each do |line|
line =~ /for architecture (.*?)\)/
architectures << $1
end
end
architectures.reject! do |arch|
!compiler_supports_architecture?(arch)
end
architectures.map! do |arch|
"-arch #{arch}"
end
flags << architectures.compact.join(' ')
end
return flags.compact.join(' ').strip
end