# File src/ruby_supportlib/phusion_passenger/platform_info/apache.rb, line 565
    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?)
            # Remove flags not supported by GCC
            # The big problem is Coolstack apxs includes a bunch of solaris -x directives.
            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
          # The Apache package in CentOS 5 x86_64 is broken.
          # 'apxs -q CFLAGS' contains directives for compiling
          # the module as 32-bit, even though httpd itself
          # is 64-bit. Fix this.
          apxs2_flags.gsub!('-m32 -march=i386 -mtune=generic', '')
        end

        # Some Apache installations include '-pie' in CFLAGS, which
        # won't work on shared libraries.
        # https://github.com/phusion/passenger/issues/1756
        apxs2_flags.gsub!('-pie', '')

        apxs2_flags.strip!
        flags << apxs2_flags
      end
      if !httpd.nil? && os_name_simple == "macosx"
        # The default Apache install on OS X is a universal binary.
        # Figure out which architectures it's compiled for and do the same
        # thing for mod_passenger. We use the 'file' utility to do this.
        #
        # Running 'file' on the Apache executable usually outputs something
        # like this:
        #
        #   /usr/sbin/httpd: Mach-O universal binary with 4 architectures
        #   /usr/sbin/httpd (for architecture ppc7400):     Mach-O executable ppc
        #   /usr/sbin/httpd (for architecture ppc64):       Mach-O 64-bit executable ppc64
        #   /usr/sbin/httpd (for architecture i386):        Mach-O executable i386
        #   /usr/sbin/httpd (for architecture x86_64):      Mach-O 64-bit executable x86_64
        #
        # But on some machines, it may output just:
        #
        #   /usr/sbin/httpd: Mach-O fat file with 4 architectures
        #
        # (http://code.google.com/p/phusion-passenger/issues/detail?id=236)
        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
        # The compiler may not support all architectures in the binary.
        # XCode 4 seems to have removed support for the PPC architecture
        # even though there are still plenty of Apache binaries around
        # containing PPC components.
        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