configuration cleanup and bugfixes
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 16 Jun 2010 00:59:26 +0000 (18:59 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 16 Jun 2010 00:59:26 +0000 (18:59 -0600)
18 files changed:
Makefile
configure
doc/rules.mk
doc/yoink.6.in
src/GameLayer.cc
src/Main.cc
src/moof/log.cc
src/moof/log.hh
src/moof/math.hh
src/moof/modal_dialog.hh
src/moof/opengl.hh
src/moof/packet.cc
src/moof/resource.cc
src/moof/resource.hh
src/moof/sound.cc
src/moof/timer.cc
src/rules.mk
src/yoink.rc

index ccf61fa0150b4ba4bbe37bd59b1a814ed6b94e4e..95ed652182519087c4f7a07274c73df624013ff5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,8 +10,8 @@
 # http://www.xs4all.nl/~evbergen/nonrecursive-make.html
 #
 
-# Set this to `yes' to echo each build command in full.
-verbose                := no
+# Set this to `true' to echo each build command in full.
+verbose                := false
 
 
 #
@@ -69,6 +69,10 @@ ifeq ($(DEP_TRACKING),true)
 COMPILE = ./tools/compile.lua
 endif
 
+# Include current directory to allow sources to #include "config.h".
+CFLAGS            += -I.
+CXXFLAGS          += -I.
+
 COMMAND_CC         = $(COMPILE) $(CC)  $(CFLAGS)    $(CF_TGT) -o $@ -c $<
 COMMAND_CXX        = $(COMPILE) $(CXX) $(CXXFLAGS)  $(CF_TGT) -o $@ -c $<
 COMMAND_LD         = $(CC)  $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
@@ -81,7 +85,7 @@ COMMAND_INSTALL    = ./tools/install.sh -m $1 $2 -d $3
 COMMAND_RM         = rm -f $1
 COMMAND_IN         = sed -f config.sed <"$1" >"$2"
 
-ifeq ($(verbose),yes)
+ifeq ($(verbose),true)
 DO_CC              = $(COMMAND_CC)
 DO_CXX             = $(COMMAND_CXX)
 DO_LD              = $(COMMAND_LD)
@@ -122,17 +126,17 @@ endif
        $(DO_CXX)
 %.o: %.rc
        $(DO_RC)
-%: %.o
+%$(EXEEXT): %.o
        $(DO_LD)
-%: %.c
+%$(EXEEXT): %.c
        $(DO_CCLD)
-%: %.cc
+%$(EXEEXT): %.cc
        $(DO_CXXLD)
-%: %.cpp
+%$(EXEEXT): %.cpp
        $(DO_CXXLD)
 %.a: %.o
        $(DO_AR)
-%: %.in
+%: %.in config.sed
        $(call DO_IN,$<,$@)
 
 
index 49127e4614b5d124be37ae374446a91d87a1c88f..d4435162569e366a992f552e31ac3cdaff3added 100755 (executable)
--- a/configure
+++ b/configure
@@ -5,12 +5,34 @@
 -- Execute this file to configure the build system.
 --
 
+-- Define project, version, tarname, website, and contact.
 project                = "Yoink"
 version                = "0.1"
-bugreport      = "onefriedrice@brokenzipper.com"
+tarname                = project:lower():gsub("%s+", "-")
+website                = "http://www.dogcows.com/yoink"
+contact                = "onefriedrice@brokenzipper.com"
 
 
-function ShowHelp()
+-- This script will create three different config files from three tables
+-- with values determined by the host and configuration options:
+--
+-- The table `config' contains key-value pairs to be written to the file
+-- `config.h' which is included by sources files.  Boolean values will
+-- either #define or #undef the key with no associated values.  String
+-- values will be defined as quoted strings while any other value,
+-- particularly numbers, will be defined unquoted.
+--
+-- The table `define' contains key-value pairs to be written to the file
+-- `config.mk' which is included by the Makefile.  Values are assigned to
+-- their keys as they are, unquoted.
+--
+-- The table `export' contains key-value pairs to be written to the file
+-- `config.sed' which is used by sed to perform search-and-replace on files
+-- containing @REPLACE_ME@-style keywords.  When used with sed, such
+-- keyworded keys will be replaced by their values as they are, unquoted.
+
+
+function show_help()
        print([[
 
 This script prepares ]]..project..[[ for building on your system.
@@ -45,23 +67,40 @@ Program options:
 end
 
 
+--
+-- Setup a temporary file to collect error messages.
+--
+
+error_log = "config.log"
+os.remove(error_log)
+
+
 --
 -- Define some useful functions.
 --
 
-function Die(...)
+-- Return true if a file exists, false otherwise.
+function file_exists(file)
+       return os.execute("test -f "..file) == 0
+end
+
+-- Print an error message and exit with an error.
+function die(...)
        for _,value in ipairs(arg) do
                print("fatal: "..tostring(value))
        end
+       if file_exists(error_log) then
+               print()
+               print("Look through the file `config.log' for more information:\n")
+               os.execute("tail "..error_log)
+       end
        os.exit(1)
 end
 
-function FileExists(file)
-       return os.execute("test -f "..file) == 0
-end
-
-function ReadCommand(command)
-       local fd = io.popen(command)
+-- Execute a command and return its output or nil if the command failed to
+-- run.
+function backtick_run(command)
+       local fd = io.popen(command.." 2>>"..error_log)
        if fd then
                local stdout = fd:read("*l")
                fd:close()
@@ -70,18 +109,82 @@ function ReadCommand(command)
        return nil
 end
 
-function TryCommand(command)
-       return os.execute(command.." 2>&1 >/dev/null") == 0
+-- Try to execute a command and return true if the command finished
+-- successfully (with an exit code of zero).
+function try_run(command)
+       return os.execute(command.." >/dev/null 2>>"..error_log) == 0
 end
 
-function Trim(str)
+-- Remove the whitespace surrounding a string.
+function trim(str)
        str  = str:gsub("^%s+", "")
        return str:gsub("%s+$", "")
 end
 
-function Reduce(str)
+-- Trim the string and convert all sequences of whitespace to a single
+-- space.
+function reduce_whitespace(str)
        str = str:gsub("%s+", " ")
-       return Trim(str)
+       return trim(str)
+end
+
+-- Get the CFLAGS from pkg-config for the passed libraries.
+function pkg_config_cflags(libs)
+       local env = "PKG_CONFIG_PATH="..libdir.."/pkgconfig:$PKG_CONFIG_PATH"
+       local cmd = env.." pkg-config"
+       return backtick_run(cmd.." --cflags "..libs)
+end
+
+-- Get the LDFLAGS from pkg-config for the passed libraries.
+function pkg_config_ldflags(libs)
+       local env = "PKG_CONFIG_PATH="..libdir.."/pkgconfig:$PKG_CONFIG_PATH"
+       local cmd = env.." pkg-config"
+       return (" "..backtick_run(cmd.." --libs "..libs)):gsub("%s%-l%S*", "")
+end
+
+-- Get the LIBS flags from pkg-config for the passed libraries.
+function pkg_config_libs(libs)
+       local env = "PKG_CONFIG_PATH="..libdir.."/pkgconfig:$PKG_CONFIG_PATH"
+       local cmd = env.." pkg-config"
+       return backtick_run(cmd.." --libs-only-l "..libs)
+end
+
+-- Add a flag to the CFLAGS and CXXFLAGS variables.
+function add_cflag(flag)
+       if CFLAGS == "" then
+               CFLAGS = flag
+       else
+               CFLAGS = string.format("%s %s", CFLAGS, flag)
+       end
+       if CXXFLAGS == "" then
+               CXXFLAGS = flag
+       else
+               CXXFLAGS = string.format("%s %s", CXXFLAGS, flag)
+       end
+end
+
+-- Replace a flag in the CFLAGS and CXXFLAGS variables.
+function set_cflag(flag)
+       local cflag_set, cxxflag_set = false, false
+       CFLAGS = CFLAGS:gsub("%"..flag:sub(1, 2).."%S+", function()
+               cflag_set = true
+               return flag
+       end)
+       CXXFLAGS = CXXFLAGS:gsub("%"..flag:sub(1, 2).."%S+", function()
+               cxxflag_set = true
+               return flag
+       end)
+       if not cflag_set or not cxxflag_set then add_cflag(flag) end
+end
+
+-- Look for a command from a list that can complete successfully (with exit
+-- code zero) given some arguments.  Returns nil if none were successful.
+function find_command(commands, args)
+       if not args then args = "" end
+       for _,command in ipairs(commands) do
+               if try_run(command.." "..args) then return command end
+       end
+       return nil
 end
 
 
@@ -89,8 +192,9 @@ end
 -- Perform a quick sanity check.
 --
 
-if not FileExists("configure") or not FileExists("Makefile") then
-       Die("You must `cd' to the project root where the Makefile is.")
+if not file_exists("configure") or not file_exists("Makefile") then
+       -- This script doesn't support out-of-tree builds.
+       die("You must `cd' to the project root where the Makefile is.")
 end
 
 
@@ -98,155 +202,156 @@ end
 -- Parse the command-line options.
 --
 
+-- This script supports many of the options provided by autoconf-generated
+-- scripts.  In particular, all the directory-related options are
+-- supported, including --prefix, --exec-prefix, and all the --dirDIR
+-- options for configuring installation paths.  If passed, the option
+-- parsing routine below will place these options in the global namespace
+-- (i.e. prefix, eprefix, bindir, datadir, etc).
+--
+-- Feature and package options are also supported.  The value of any option
+-- of the form --enable-OPT= and --with-OPT= can be obtained with the
+-- functions get_feature and get_package, respectively.  Like
+-- autoconf-generated scripts, passing --disable-OPT or --without-OPT is
+-- equivalent to passing --enable-OPT=no and --without-OPT=no,
+-- respectively.  Values that are either yes or no are interpreted as
+-- booleans.  Any other values are interpreted as strings.
+--
+-- Definitions of the form KEY=VALUE are also supported.  If passed, the
+-- option parsing routine below will place these options in the global
+-- namespace.
+--
+-- Finally, the options -h, --help, and --host are also supported, the
+-- former two calling the show_help function and the latter setting the
+-- host global variable.
+
 do
        local features = {}
        local packages = {}
-       local directories = {}
-       local definitions = {}
+       local handlers = {}
+
+
+       -- Define the option-parsing rules and handlers.
+
+       handlers["--help"]                                              = function()
+               show_help()
+               os.exit(0)
+       end
+       handlers["-h"]                                                  = handlers["--help"]
 
-       local function AddFeature(feature, value)
+       handlers["--host=(.+)"]                                 = function(triplet)
+               host = triplet
+               cross_compile = true
+       end
+
+       local add_feature                                               = function(feature, value)
                if value == "yes" or value == "" then value = true end
                if value == "no" then value = false end
                features[feature] = value
        end
+       handlers["--enable%-([%w_-]+)=?(.*)"]   = add_feature
+       handlers["--disable%-([%w_-]+)"]                = function(feature)
+               add_feature(feature, "no")
+       end
 
-       local function AddPackage(package, value)
+       local add_package                                               = function(package, value)
                if value == "yes" or value == "" then value = true end
                if value == "no" then value = false end
                packages[package] = value
        end
+       handlers["--with%-([%w_-]+)=?(.*)"]             = add_package
+       handlers["--without%-([%w_-]+)"]                = function(package)
+               add_package(package, "no")
+       end
 
-       local function AddDirectory(directory, path)
-               directories[directory] = path
+       handlers["--(%l+)dir=(.+)"]                             = function(dir, path)
+               _G[dir.."dir"] = path
+       end
+       handlers["--prefix=(.+)"]                               = function(path)
+               prefix = path
+       end
+       handlers["--exec-prefix=(.+)"]                  = function(path)
+               eprefix = path
        end
 
-       local function AddDefinition(key, value)
-               definitions[key] = value
+       handlers["([%w_]+)=(.*)"]                               = function(key, value)
+               _G[key] = value
        end
 
-       local handlers = {
-               ["--help"]                      = function() ShowHelp() os.exit(0) end,
-               ["--host=(.+)"]         = function(arg) host = arg cross_compile = true end,
-               ["--enable%-([%w_-]+)=?(.*)"]   = AddFeature,
-               ["--disable%-([%w_-]+)"]                = function(arg) AddFeature(arg, "no") end,
-               ["--with%-([%w_-]+)=?(.*)"]             = AddPackage,
-               ["--without%-([%w_-]+)"]                = function(arg) AddPackage(arg, "no") end,
-               ["--(%l+)dir=(.+)"]     = AddDirectory,
-               ["--prefix=(.+)"]               = function(arg) prefix = arg end,
-               ["--exec-prefix=(.+)"]  = function(arg) eprefix = arg end,
-               ["([%w_]+)=(.*)"]       = AddDefinition,
-       }
-       handlers["-h"] = handlers["--help"]
-
-       local function ParseArg(arg)
+
+       -- Define the feature and package accessors.
+
+       function get_feature(feature) return features[feature] end
+       function get_package(package) return packages[package] end
+
+       
+       -- Now read and parse the command-line options.
+       
+       local function parse_arg(arg)
                for key,value in pairs(handlers) do
                        local matches = {arg:match(key)}
-                       if matches[1] then
-                               value(unpack(matches))
-                               return
-                       end
+                       if matches[1] then value(unpack(matches)) return end
                end
                print("warning: unknown or incomplete argument "..arg)
        end
 
-
-       -- Define some default values.
-
-       prefix          = "/usr/local"
-
-       CC                      = ""
-       CXX                     = ""
-       AR                      = ""
-       RANLIB          = ""
-       WINDRES         = ""
-
-       CFLAGS          = "-g -O2"
-       CXXFLAGS        = CFLAGS
-       LDFLAGS         = ""
-       LIBS            = ""
-
-       features["dependency-tracking"] = true
-
-
-       -- Read the arguments from the command-line.
        for _,arg in ipairs(arg) do
-               ParseArg(arg)
+               parse_arg(arg)
        end
 
-       function GetFeature(feature) return features[feature] end
-       function GetPackage(package) return packages[package] end
+
+       -- Define default values for significant variables.
        
-       for key,value in pairs(directories) do
-               _G[key.."dir"] = value
-       end
-       for key,value in pairs(definitions) do
-               _G[key] = value
+       local function define(symbol, value)
+               if not _G[symbol] then _G[symbol] = value end
        end
 
-
-       -- Define the dependent values.
+       define("CC",                    "")
+       define("CXX",                   "")
+       define("AR",                    "")
+       define("RANLIB",                "")
+       define("WINDRES",               "")
+
+       define("CFLAGS",                "-g -O2")
+       define("CXXFLAGS",              CFLAGS)
+       define("LDFLAGS",               "")
+       define("LIBS",                  "")
+
+       define("host",                  backtick_run("tools/config.guess"))
+       define("alt_host",              backtick_run("tools/config.sub "..host))
+
+       define("prefix",                "/usr/local")
+       define("eprefix",               prefix)
+       define("bindir",                eprefix.."/bin")
+       define("sbindir",               eprefix.."/sbin")
+       define("libexecdir",    eprefix.."/libexec")
+       define("sysconfdir",    prefix.."/etc")
+       define("localstatedir", prefix.."/var")
+       define("libdir",                eprefix.."/lib")
+       define("includedir",    prefix.."/include")
+       define("datarootdir",   prefix.."/share")
+       define("datadir",               datarootdir.."/"..tarname)
+       define("infodir",               datarootdir.."/info")
+       define("localedir",             datarootdir.."/locale")
+       define("mandir",                datarootdir.."/man")
+       define("docdir",                datarootdir.."/doc/"..tarname)
+
+       if not features["dependency-tracking"] then
+               features["dependency-tracking"] = true
+       end
        
-       package = project:lower()
-       tarname = package.."-"..version
-
-       if not host then host = ReadCommand("tools/config.guess") end
-       alt_host = ReadCommand("tools/config.sub "..host)
-
-       if not eprefix                  then eprefix            = prefix end
-       if not bindir                   then bindir                     = eprefix.."/bin" end
-       if not sbindir                  then sbindir            = eprefix.."/sbin" end
-       if not libexecdir               then libexecdir         = eprefix.."/libexec" end
-       if not sysconfdir               then sysconfdir         = prefix.."/etc" end
-       if not localstatedir    then localstatedir      = prefix.."/var" end
-       if not libdir                   then libdir                     = eprefix.."/lib" end
-       if not includedir               then includedir         = prefix.."/include" end
-       if not datarootdir              then datarootdir        = prefix.."/share" end
-       if not datadir                  then datadir            = datarootdir.."/"..package end
-       if not infodir                  then infodir            = datarootdir.."/info" end
-       if not localedir                then localedir          = datarootdir.."/locale" end
-       if not mandir                   then mandir                     = datarootdir.."/man" end
-       if not docdir                   then docdir                     = datarootdir.."/doc/"..package end
-
-       cflags = ""
-       config = {}
-       define = {}
-       export = {}
-
-       define.DEP_TRACKING = GetFeature("dependency-tracking")
+       define("config",                {})
+       define("define",                {})
+       define("export",                {})
 end
 
 
 --
--- Determine the target platform.
+-- Determine special target platforms.
 --
 
-if             host:match("mingw32")   then platform = "win32"
-elseif host:match("netbsd")    then platform = "netbsd" end
-
-
---
--- Define the check function.
---
-
-do
-       local path = os.getenv("PATH")
-
-       -- 1. List of possible command names.
-       -- 2. Command arguments.
-       function FindCommand(commands, args)
-               if not args then args = "" end
-               for _,command in ipairs(commands) do
-                       if command then
-                               for dir in path:gmatch("[^:]+") do
-                                       if FileExists(dir.."/"..command) and TryCommand(command.." "..args) then
-                                               return command
-                                       end
-                               end
-                       end
-               end
-               return nil
-       end
-end
+-- Win32 has some special cases related to its resource file, src/yoinkrc.
+if host:match("mingw32") then platform = "win32" end
 
 
 --
@@ -270,18 +375,16 @@ int main()
        tmpfile:close()
 
        function extra() if not cross_compile then return "gcc", "cc" end end
-       CC = FindCommand({
+       CC = find_command({
                CC,
-               host.."-gcc",
-               host.."-cc",
-               alt_host.."-gcc",
-               alt_host.."-cc",
+               host.."-gcc", host.."-cc",
+               alt_host.."-gcc", alt_host.."-cc",
                extra()}, tmpname.." -o "..tmpname..".tmp")
        os.remove(tmpname)
        os.remove(tmpname..".tmp")
-       if not CC then Die("Can't find a working C compiler.") end
+       if not CC then die("Can't find a working C compiler.") end
 else
-       Die("failed to create temporary file: "..err)
+       die("failed to create temporary file: "..err)
 end
 
 -- Check for CXX.
@@ -299,51 +402,49 @@ int main()
        tmpfile:close()
 
        function extra() if not cross_compile then return "g++", "c++" end end
-       CXX = FindCommand({
+       CXX = find_command({
                CXX,
-               host.."-g++",
-               host.."-c++",
-               alt_host.."-g++",
-               alt_host.."-c++",
+               host.."-g++", host.."-c++",
+               alt_host.."-g++", alt_host.."-c++",
                extra()}, tmpname.." -o "..tmpname..".tmp")
        os.remove(tmpname)
        os.remove(tmpname..".tmp")
-       if not CXX then Die("Can't find a working C++ compiler.") end
+       if not CXX then die("Can't find a working C++ compiler.") end
 else
-       Die("failed to create temporary file: "..err)
+       die("failed to create temporary file: "..err)
 end
 
 -- Check for AR.
 do
        function extra() if not cross_compile then return "ar" end end
-       AR = FindCommand({
+       AR = find_command({
                AR,
                host.."-ar",
                alt_host.."-ar",
                extra()}, "--version")
-       if not AR then Die("Can't find a working archiver.") end
+       if not AR then die("Can't find a working archiver.") end
 end
 
 -- Check for RANLIB.
 do
        function extra() if not cross_compile then return "ranlib" end end
-       RANLIB = FindCommand({
+       RANLIB = find_command({
                RANLIB,
                host.."-ranlib",
                alt_host.."-ranlib",
                extra()}, "--version")
-       if not RANLIB then Die("Can't find a working library indexer.") end
+       if not RANLIB then die("Can't find a working library indexer.") end
 end
 
 -- Check for WINDRES.
 if platform == "win32" then
        function extra() if not cross_compile then return "windres" end end
-       WINDRES = FindCommand({
+       WINDRES = find_command({
                WINDRES,
                host.."-windres",
                alt_host.."-windres",
                extra()}, "--version")
-       if not WINDRES then Die("Can't find a working win32 resource compiler.") end
+       if not WINDRES then die("Can't find a working resource compiler.") end
 end
 
 
@@ -351,48 +452,33 @@ end
 -- Configure the features and packages.
 --
 
-if GetFeature("debug") then
-       cflags = cflags.." -O0 -Wall -Wno-uninitialized"
+if get_feature("debug") then
+       set_cflag("-O0")
+       add_cflag("-Wall -Wno-uninitialized")
        config.DEBUG = true
 else
        config.NDEBUG = true
 end
 
-if GetFeature("double-precision") then
-       config.USE_DOUBLE_PRECISION = true
-end
-
-if GetFeature("profile") then
-       cflags = cflags.." -pg"
-       config.PROFILING_ENABLED = true
-end
-
-if GetFeature("extra-warnings") then
-       cflags = cflags.." -Wextra -Wno-unused-parameter"
+if get_feature("extra-warnings") then
+       add_cflag("-Wextra -Wno-unused-parameter")
 end
 
-if GetFeature("link-sh") then
-       -- TODO
-end
+config.USE_CLOCK_GETTIME       = get_feature("clock_gettime")
+config.USE_DOUBLE_PRECISION    = get_feature("double-precision")
+config.USE_HOTLOADING          = get_feature("hotloading")
+config.USE_THREADS                     = get_feature("threads")
+config.PROFILING_ENABLED       = get_feature("profile") and add_cflag("-pg")
 
-if GetFeature("clock_gettime") then
+if get_feature("link-sh") then
        -- TODO
 end
 
-if GetFeature("threads") then
-       config.USE_THREADS = true
-end
-
-if GetFeature("hotloading") then
-       print("FYI: Hotloading is very experimental and only works on Linux.");
-       config.USE_HOTLOADING = true
-end
-
-if GetPackage("gtk") then
+if get_package("gtk") then
        -- TODO
 end
 
-if GetPackage("qt4") then
+if get_package("qt4") then
        -- TODO
 end
 
@@ -402,28 +488,17 @@ end
 --
 
 do
-       local command   = "PKG_CONFIG_PATH="..libdir.."/pkgconfig:$PKG_CONFIG_PATH pkg-config"
-       local deps              = "sdl gl glu libpng openal vorbisfile lua"
+       local dependencies      = "sdl gl glu libpng openal vorbisfile lua"
 
-       if GetPackage("gtk") then
-               deps = deps.." gtk+-2.0"
-       elseif GetPackage("qt4") then
-               deps = deps.." QtGui"
+       if get_package("gtk") then
+               dependencies = dependencies.." gtk+-2.0"
+       elseif get_package("qt4") then
+               dependencies = dependencies.." QtGui"
        end
 
-       local pc_cflags = ReadCommand(command.." --cflags "..deps)
-       if not pc_cflags then Die("Couldn't determine CFLAGS.") end
-       CFLAGS = CFLAGS.." "..pc_cflags
-       CXXFLAGS = CXXFLAGS.." "..pc_cflags
-
-       local pc_libs = " "..ReadCommand(command.." --libs "..deps)
-       if not pc_libs then Die("Couldn't determine LDFLAGS or LIBS.") end
-       for lib in pc_libs:gmatch("%s%-l%S+") do
-               LIBS = LIBS.." "..lib
-       end
-       for ldflag in pc_libs:gmatch("%s%-[^l]%S*") do
-               LDFLAGS = LDFLAGS.." "..ldflag
-       end
+       add_cflag(pkg_config_cflags(dependencies))
+       LDFLAGS         = LDFLAGS       .." "..pkg_config_ldflags(dependencies)
+       LIBS            = LIBS          .." "..pkg_config_libs(dependencies)
 
        if platform == "win32" then
                LIBS = LIBS.." -lws2_32"
@@ -433,44 +508,31 @@ do
        end
 end
 
-CFLAGS         = Reduce(CFLAGS.." "..cflags)
-CXXFLAGS       = Reduce(CXXFLAGS.." "..cflags)
-LDFLAGS                = Reduce(LDFLAGS)
-LIBS           = Reduce(LIBS)
-
 
 --
 -- Define the exports and definitions.
 --
 
-config.YOINK_DATADIR = datadir
-export.YOINK_DATADIR = datadir
-
-do
-       local vmajor = ReadCommand("v=$(echo "..version.." | cut -d. -f1); echo ${v:-0}")
-       local vminor = ReadCommand("v=$(echo "..version.." | cut -d. -f2); echo ${v:-0}")
-       local vrevis = ReadCommand("v=$(echo "..version.." | cut -d. -f3); echo ${v:-0}")
-
-       config.VERSION_MAJOR            = tonumber(vmajor)
-       config.VERSION_MINOR            = tonumber(vminor)
-       config.VERSION_REVISION         = tonumber(vrevis)
-end
-
-do
-       -- Determine and define the git revision.
-       local head = ReadCommand("git describe master")
-       config.YOINK_GITHEAD = head
+if platform == "win32" then
+       -- These are used in src/yoink.rc.
+       local vmajor, vminor, vrevis = version:match("^(%d*)%.?(%d*)%.?(%d*)")
+       config.VERSION_MAJOR    = tonumber(vmajor) or 0
+       config.VERSION_MINOR    = tonumber(vminor) or 0
+       config.VERSION_REVISION = tonumber(vrevis) or 0
 end
 
-config.PACKAGE                         = project
+config.PACKAGE                         = tarname
 config.PACKAGE_NAME                    = project
-config.VERSION                         = version
 config.PACKAGE_VERSION         = version
 config.PACKAGE_STRING          = project.." "..version
-config.PACKAGE_BUGREPORT       = bugreport
+config.PACKAGE_TARNAME         = tarname
+config.PACKAGE_URL                     = website
+config.PACKAGE_BUGREPORT       = contact
+config.YOINK_GITHEAD           = backtick_run("git describe master")
+config.YOINK_DATADIR           = datadir
 
 define.PACKAGE                         = project
-define.TARNAME                         = tarname
+define.TARNAME                         = tarname.."-"..version
 define.TARGET                          = host
 define.PLATFORM                                = platform
 define.CC                                      = CC
@@ -478,30 +540,32 @@ define.CXX                                        = CXX
 define.AR                                      = AR
 define.RANLIB                          = RANLIB
 define.WINDRES                         = WINDRES
-define.CFLAGS                          = CFLAGS
-define.CXXFLAGS                                = CXXFLAGS
-define.LDFLAGS                         = LDFLAGS
-define.LIBS                                    = LIBS
+define.CFLAGS                          = reduce_whitespace(CFLAGS)
+define.CXXFLAGS                                = reduce_whitespace(CXXFLAGS)
+define.LDFLAGS                         = reduce_whitespace(LDFLAGS)
+define.LIBS                                    = reduce_whitespace(LIBS)
 define.prefix                          = prefix
 define.bindir                          = bindir
 define.datadir                         = datadir
 define.mandir                          = mandir
 define.EXEEXT                          = exe_extension
+define.DEP_TRACKING                    = get_feature("dependency-tracking")
 
-export.PACKAGE_BUGREPORT       = bugreport
+export.datadir                         = datadir               -- Used in doc/yoink.6.in.
+export.PACKAGE_BUGREPORT       = contact               -- Used in doc/yoink.6.in.
 
 
 --
 -- All done; output the configuration files.
 --
 
--- Print the program options.
+-- Output the program options.
 output = io.open("config.h", "w")
 for key,value in pairs(config) do
        key = tostring(key)
        if type(value) == "boolean" then
                if value then
-                       output:write("#define "..key)
+                       output:write("#define "..key.." 1")
                else
                        output:write("#undef "..key)
                end
@@ -514,7 +578,7 @@ for key,value in pairs(config) do
 end
 output:close()
 
--- Print the make definitions.
+-- Output the make definitions.
 output = io.open("config.mk", "w")
 for key,value in pairs(define) do
        key             = tostring(key)
@@ -524,7 +588,7 @@ end
 output:close()
 
 
--- Print the exported variables.
+-- Output the exported variables.
 output = io.open("config.sed", "w")
 for key,value in pairs(export) do
        key             = key:gsub("/", "\\/")
index aff28a01c16e74c1744e433b5b5f3983566f0f29..04f135b24ed99a35f7491b4805b0606fa17f0c34 100644 (file)
@@ -14,10 +14,6 @@ MANPAGE_$(d) := $(d)/yoink.6
 MANPAGES     := $(MANPAGES) $(MANPAGE_$(d))
 CLEAN        := $(CLEAN)    $(MANPAGE_$(d))
 
-MANPAGE_$(d):
-       @export BUGREPORT=hello ;\
-       $(call DO_IN,$<,$@)
-
 
 #######################
 -include $(DEPS_$(d))
index 6582c37e6e9dc108ae19d024117ac80a69fe775b..08acade25ca49241a627721e86b846b429a1c1e5 100644 (file)
@@ -50,7 +50,7 @@ You have a certain level of control over the operation of \fByoink\fP
 through options passed as program arguments or given in config files.
 \fByoink\fP looks for config files in several locations and in this order:
 .TP
-1. \fI@YOINK_DATADIR@/yoinkrc\fP
+1. \fI@datadir@/yoinkrc\fP
 This is the base config file which should be considered read-only.  Look to
 this file as an example of the format used for config files.
 .TP
index d696f5ebdf851a0276f625f5c886eddb3dfd7594..fcb77ed65cfa086be3e30f07e85cefde40c8af81 100644 (file)
@@ -9,7 +9,7 @@
 *
 **************************************************************************/
 
-#include "../config.h"
+#include "config.h"
 
 #include <stdexcept>
 
@@ -80,7 +80,7 @@ void GameLayer::advanceScene(moof::settings& settings)
 GameLayer::GameLayer()
 {
        moof::log_info("about to load sound resource...");
-       music_ = moof::resource::load("sounds/NightFusionIntro.ogg");
+       music_ = moof::resource::load("NightFusionIntro.ogg");
        if (music_)
        {
                music_->loop(true);
index 6cdadaf23ff4e8087845e697ea2120233a906bbc..6914c97df3525ed8ce7b7d206f8ee0b5c3598720 100644 (file)
@@ -9,7 +9,7 @@
 *
 **************************************************************************/
 
-#include "../config.h"
+#include "config.h"
 
 #include <cstdlib>             // atexit
 #include <exception>
@@ -106,10 +106,8 @@ std::string Main::getSearchPath()
        // 1. YOINK_DATADIR (environment)
        // 2. YOINK_DATADIR (configure)
        
-       std::string                     path;
-       stlplus::env_vector     environment;
-
-       std::string datadir = environment["YOINK_DATADIR"];
+       std::string path;
+       std::string datadir = stlplus::env_vector()["YOINK_DATADIR"];
        if (!datadir.empty())
        {
                path += datadir;
@@ -128,17 +126,14 @@ std::string Main::getConfigPath()
        // 3. $HOME/.yoinkrc
        // 4. YOINKRC (environment)
 
-       std::string path("yoinkrc");
-       moof::resource::find(path);
-
-       stlplus::env_vector environment;
+       std::string path = moof::resource::find_file("yoinkrc");
 
 #if !defined(_WIN32)
        path += ":/etc/yoinkrc";
 #endif
        path += ":$HOME/.yoinkrc";
 
-       std::string rc_file = environment["YOINKRC"];
+       std::string rc_file = stlplus::env_vector()["YOINKRC"];
        if (!rc_file.empty())
        {
                path += ":";
@@ -221,7 +216,7 @@ void Main::printInfo(int argc, char* argv[])
 #ifdef YOINK_GITHEAD
                          << "       Commit: "YOINK_GITHEAD << std::endl
 #endif
-                         << "      Version: "VERSION << std::endl
+                         << "      Version: "PACKAGE_VERSION << std::endl
                          << "        Built: " << COMPILE_TIME << std::endl
                          << "     Compiler: "COMPILER_STRING << std::endl
                          << "       Assets: " << assets << std::endl
@@ -312,7 +307,7 @@ int main(int argc, char* argv[])
        try
        {
                std::string iconPath(PACKAGE".png");
-               moof::resource::find(iconPath);
+               iconPath = moof::resource::find_file(iconPath);
                moof::image icon(iconPath);
                icon.set_as_icon();
 
index a11b7d0233efa7538a3bacef99f758c0d3354e8b..017ce36b2209fe087a79ea43010d9fc2f47f3986 100644 (file)
 namespace moof {
 
 
-enum log::level log::gLevel = log::info;
+enum log::level log::global_level_ = log::info;
 
 
 void log::level(enum level level)
 {
-       gLevel = level;
+       global_level_ = level;
 }
 
 enum log::level log::level()
 {
-       return gLevel;
+       return global_level_;
 }
 
 
@@ -37,7 +37,7 @@ std::ostream& log(std::clog);
 static std::ofstream null_log_;
 std::ostream& null_log(null_log_);
 
-class log log_error(  log::error,  "  error: ");
+class log log_error(  log::error,   "  error: ");
 class log log_warning(log::warning, "warning: ");
 class log log_info(   log::info,    "   info: ");
 
index f65d571e854b98b74c37978c3c11ca84adbb1af4..a32daadd8b13b79cc5d8c83dce762d802c67c856 100644 (file)
@@ -127,7 +127,7 @@ private:
 
        template <class T> friend std::ostream& operator << (log&, const T&);
 
-       static enum level       gLevel;
+       static enum level       global_level_;
 
        enum level                      level_;
        const char*                     prefix_;
@@ -145,7 +145,7 @@ extern class log log_info;
 template <class T>
 inline std::ostream& operator << (class log& log, const T& item)
 {
-       if (log::gLevel < log.level_) return null_log;
+       if (log::global_level_ < log.level_) return null_log;
        return moof::log << log.prefix_ << item;
 }
 
index 62e68c8fa2ae4b0b8dcb7acbb6197e5656b60908..a960b0d1df1050370140d7869879d8ae25f7911c 100644 (file)
@@ -17,7 +17,7 @@
  * General math-related types and functions.
  */
 
-#include "../config.h"
+#include "config.h"
 
 #include <cmath>
 
index c5139f27e06bb7dd95ae9c9a2915adcd5a897180..23e929b4a3c6afc3cba59087a42af69783aa2040 100644 (file)
@@ -18,7 +18,7 @@
  * supported, but only one can be used as determined at build time.
  */
 
-#include "../config.h"
+#include "config.h"
 
 #include <string>
 
index 04cc13e9c72bfac4e7196cf6ae6b3df2299a76d7..347f3e5bd55da409c47e32a0115ec65d43ae0ae8 100644 (file)
@@ -18,7 +18,7 @@
  * and matrices.
  */
 
-#include "../config.h"
+#include "config.h"
 
 #include <SDL/SDL_opengl.h>
 
index 0440b7df5749760861dfdfc4a5c913220258a450..9cfb5bbfe38a05435bef4cc55d7822ed4293c665 100644 (file)
@@ -9,7 +9,7 @@
 *
 **************************************************************************/
 
-#include "../config.h"
+#include "config.h"
 
 #include <algorithm>
 #if HAVE_BYTESWAP_H
index d22ae217a28d81269460fa8fda3201764bccc37d..359d1b4dcdfc35fcb3b2bb8d8a3394ecbee60925 100644 (file)
@@ -9,18 +9,17 @@
 *
 **************************************************************************/
 
-#include "../config.h"
-
-#include <queue>
+#include "config.h"
 
 #ifdef USE_HOTLOADING
 #include <sys/inotify.h>
 #include <sys/ioctl.h>
 #endif
 
+#include <queue>
+
 #include <boost/algorithm/string.hpp>
 #include <boost/weak_ptr.hpp>
-
 #include <stlplus/portability/file_system.hpp>
 
 #include "hash.hh"
@@ -108,7 +107,11 @@ resource_ptr resource::load(const std::string& path)
 {
        std::string extension = stlplus::extension_part(path);
 
-       if (!find(path)) return resource_ptr();
+       if (!find(path))
+       {
+               log_error("trying to load missing resource:", path);
+               return resource_ptr();
+       }
 
        hash<std::string,resource_weakptr,hash_function>::iterator it;
        it = resource_table_.find(path);
@@ -128,8 +131,7 @@ resource_ptr resource::load(const std::string& path)
                resource_table_[path] = rsrc;
 
 #ifdef USE_HOTLOADING
-               int wd = inotify_add_watch(monitor_fd_,
-                               path.c_str(), IN_MODIFY);
+               int wd = inotify_add_watch(monitor_fd_, path.c_str(), IN_MODIFY);
                rsrc->set_watch_descriptor(wd);
                monitor_lookup_[wd] = path;
 #endif
@@ -172,8 +174,7 @@ void resource::reload()
        unloader_ = resource->unloader_;
 
 #ifdef USE_HOTLOADING
-       int wd = inotify_add_watch(monitor_fd_,
-                       path_.c_str(), IN_MODIFY);
+       int wd = inotify_add_watch(monitor_fd_, path_.c_str(), IN_MODIFY);
        set_watch_descriptor(wd);
        monitor_lookup_[wd] = path_;
 #endif
@@ -190,9 +191,17 @@ void resource::add_search_paths(const std::string& paths)
 
 bool resource::find(const std::string& path)
 {
+       std::string file = stlplus::lookup(path, search_paths_, ":");
+       log_info("found file", file, "in", search_paths_);
        return !stlplus::lookup(path, search_paths_, ":").empty();
 }
 
+std::string resource::find_file(const std::string& name)
+{
+       log_info("looking for", name, "in", search_paths_);
+       return stlplus::lookup(name, search_paths_, ":");
+}
+
 FILE* resource::open_file(const std::string& path, const std::string& mode)
 {
        std::string file = stlplus::lookup(path, search_paths_, ":");
index a269a2d04d46b6b9aea405563a2be7a2e836a005..29ae114f9d4daa4cc1b5e0cd14d900d7611963fa 100644 (file)
@@ -17,7 +17,7 @@
  * Interface for textures, sounds, and other types of resources.
  */
 
-#include "../config.h"
+#include "config.h"
 
 #include <cstdio>
 #include <map>
@@ -65,6 +65,8 @@ public:
         */
        static bool find(const std::string& file);
 
+       static std::string find_file(const std::string& name);
+
        /**
         * Get the path to a resource of a given name and open it if a resource
         * was found.
index d5b67bd2d61d85de1d64d0439bc04bd259bcb990..a1da62b8be10c9d1c2567f2931e90a1eb9841071 100644 (file)
@@ -16,7 +16,6 @@
 #include <string>
 
 #include <boost/algorithm/string.hpp>
-
 #include <AL/al.h>
 #include <AL/alc.h>
 #include <vorbis/codec.h>
@@ -39,17 +38,14 @@ public:
        
        impl()
        {
-               //log_info("registering ogg resource handler");
                resource::register_type<sound_stream>("ogg");
        }
 
        ~impl()
        {
-               //log_info("unregistering ogg resource handler");
                resource::unregister_type("ogg");
        }
 };
-
 static impl impl;
 
 
index b5c55ff528f6f3c6205afbb128a8615acc882f09..5bb2092af68591a8dc6fa3df03dd5d0ecd736b3e 100644 (file)
@@ -9,7 +9,7 @@
 *
 **************************************************************************/
 
-#include "../config.h"
+#include "config.h"
 
 #include <cerrno>
 #include <ctime>
@@ -157,7 +157,7 @@ void timer::fire_expired_timers(scalar t)
 }
 
 
-#if HAVE_CLOCK_GETTIME
+#if USE_CLOCK_GETTIME
 
 // Since the monotonic clock will provide us with the time since the
 // computer started, the number of seconds since that time could easily
@@ -209,7 +209,7 @@ void timer::sleep(scalar seconds, mode mode)
 }
 
 
-#else // ! HAVE_CLOCK_GETTIME
+#else // ! USE_CLOCK_GETTIME
 
 
 // If we don't have posix timers, we'll have to use a different timing
@@ -228,7 +228,7 @@ void timer::sleep(scalar seconds, mode mode)
        SDL_Delay(Uint32(clamp(int(seconds * 1000.0), 0, 1000)));
 }
 
-#endif // HAVE_CLOCK_GETTIME
+#endif // USE_CLOCK_GETTIME
 
 
 } // namespace moof
index ee2f52c822e19f56ffafe0944c10295299e6a02c..8bffe04960838d5974c27f62ca4fba5915d34534 100644 (file)
@@ -24,7 +24,7 @@ OBJECTS_$(d) := $(patsubst %.c,%.o,$(wildcard $(d)/*.c)) \
                 $(patsubst %.cc,%.o,$(wildcard $(d)/*.cc))
 D_FILES_$(d) := $(OBJECTS_$(d):%=%.d)
 
-ifeq ($(HOST),win32)
+ifeq ($(PLATFORM),win32)
 OBJECTS_$(d) += $(d)/yoink.o
 endif
 
index 6a417ad9823ef60a21f7e604a7b69d5ceb8bd54e..7c224036aa7d59967a5af158ba8fe49b34273f33 100644 (file)
@@ -5,7 +5,7 @@
 //
 
 #include <winver.h>
-#include "../config.h"
+#include "config.h"
 
 1 VERSIONINFO
 FILEVERSION            VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION,0
This page took 0.064114 seconds and 4 git commands to generate.