Select Git revision
pre-config.rb.erb
-
Lyle Johnson authoredLyle Johnson authored
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}" }