Skip to content
Snippets Groups Projects
Select Git revision
  • 1.6
  • master default protected
  • v1.6.40
  • v1.6.39
  • v1.6.38
  • v1.6.37
  • v1.6.37.rc1
  • v1.6.36
  • 1.6.35
  • 1.6.34
  • 1.6.33
  • 1.6.32.pre2
  • 1.6.32.pre1
  • 1.6.31
  • 1.6.30
  • 1.6.29
  • 1.6.28
  • 1.6.26
  • 1.6.27
  • 1.6.26.pre1
  • 1.6.25
  • 1.6.25.pre2
22 results

pre-config.rb.erb

Blame
  • pre-config.rb.erb 4.11 KiB
    # Which directories to search?
    def search_directories
      dirs = [
              "/usr/include/fox-1.6",
              "/usr/local/include/fox-1.6",
              "/sw/include/fox-1.6",
    	  "/opt/local/include/fox-1.6"
             ]
      ARGV.each do |arg|
        if arg =~ /--with-fox-include/
          option, value = arg.split('=')
          dirs = [ value ] + dirs
          dirs.uniq! # remove duplicates
        end
      end
      dirs
    end
    
    # Return true if found in any of the search directories
    def fox_include_files_found?
      search_directories.each do |path|
        filename = File.join(path, "fxver.h")
        return true if FileTest.exist?(filename)
      end
      false
    end
    
    # Read installed FOX version info from fxver.h include file
    def read_fox_version(filename)
      foxMajor, foxMinor, foxLevel = nil, nil, nil
      File.foreach(filename) do |line|
        if    line =~ /FOX_MAJOR/
          foxMajor = line.split()[2]
        elsif line =~ /FOX_MINOR/
          foxMinor = line.split()[2]
        elsif line =~ /FOX_LEVEL/
          foxLevel = line.split()[2]
        end
      end
      [foxMajor, foxMinor, foxLevel]
    end
    
    # Returns a string (e.g. "1.0.36") indicating the installed version of FOX.
    def installed_fox_version
      search_directories.each do |path|
        filename = File.join(path, "fxver.h")
        if FileTest.exist?(filename)
          foxMajor, foxMinor, foxLevel = read_fox_version(filename)
          return [foxMajor, foxMinor, foxLevel].join('.')
        end
      end
      raise RuntimeError, "couldn't find FOX header files"
    end
    
    #
    # Confirm that FOX is installed; check for an "fxver.h"
    # include file in the directory specified via the
    # --with-fox-include command line argument (if any),
    # as well as /usr/include/fox-1.6, /usr/local/include/fox-1.6 and
    # /sw/include/fox-1.6.
    #
    unless fox_include_files_found?
      puts ""
      puts "   **********************************************************************"
      puts "   *                            Hey!                                    *"
      puts "   *                    Where is FOX installed?                         *"
      puts "   *                                                                    *"
      puts "   * I couldn't locate 'fxver.h' in any of the following directories:   *"
      puts "   *                                                                    *"
      search_directories.each { |incdir| puts "   *    #{incdir}" }