--- LuaDist configuration
-- The contents of this file is automaticaly generated.
-- Feel free to edit to suit your needs.

local write = io.write
local flush = io.flush
local getenv = os.getenv

-- Look for _PROGDIR by default
local path = _PROGDIR
if path then path = path:gsub("\\", "/") .. "/.." end

module ("dist.config")

-- LuaDist Install Identification
version 	= "@DIST_VERSION@"   -- Current LuaDist version
arch			= "@DIST_ARCH@"			 -- Host architecture
type			= "@DIST_TYPE@"			 -- Host type

-- Behavior
binary  = true		-- Use binary dists.
source  = true		-- Use source dists (requires CMake and MinGW/gcc/VS to be installed).
test    = false		-- Run tests before install.
verbose = false		-- Print verbose output.
debug   = false		-- Start debug mod. Will keep temporary directories too.
proxy   = false		-- HTTP proxy to use. False for none, otherwise the proxy address.
timeout = 10		  -- HTTP fetch timeout (seconds)
cache   = 5*60		-- Cache timeout (seconds)

--- Packages provided by host
-- If you install any packages manually or using your host OS installer you can add the name-version
-- here, LuaDist will NOT install these modules and will search for the libraries in the host
provides = {
--	"unzip-6.0" 	-- Is available on OSX and most Unix/Linux based installs.
}

-- Paths
root  = path or getenv("DIST_ROOT") or "/"
temp  = root .. "/tmp"		-- Full path temp
log   = temp .. "/luadist.log" 	-- Log file
dists = "share/luadist/dists"

-- URLs of repositories to search for dists. http:// or file:// URLs are cecognized atm.
repo = {
	--- Examples
	-- "file:///home/joe/my_dists"		-- Private Local Repository Unix
	-- "file://C:/MyDists"				-- Private Local Repository Windows
	-- "http://myserver.tld/repo"		-- Private Online Repository

	--- Use local repo to speed things up when re-deploying
	-- "file://" .. root .. "/dist", 

	--- Official repo
	"https://github.com/LuaDist/Repository/raw/master/"
}

--- !!! Do not edit below unless you know what you are doing. !!!
-- Additional CMake variables to pass to build
variables	= {
    --- Install defaults
    INSTALL_BIN                       = "@INSTALL_BIN@",
    INSTALL_LIB                       = "@INSTALL_LIB@",
    INSTALL_INC                       = "@INSTALL_INC@",
    INSTALL_ETC                       = "@INSTALL_ETC@",
    INSTALL_LMOD                      = "@INSTALL_LMOD@",
    INSTALL_CMOD                      = "@INSTALL_CMOD@",
  
	--- LuaDist specific variables
	DIST_VERSION                       = version,
	DIST_ARCH                          = arch,
	DIST_TYPE                          = type,
	
	-- CMake specific setup
	CMAKE_GENERATOR                    = "@CMAKE_GENERATOR@",
	CMAKE_BUILD_TYPE                   = "@CMAKE_BUILD_TYPE@",

    -- RPath functionality
    CMAKE_SKIP_BUILD_RPATH             = "@CMAKE_SKIP_BUILD_RPATH@",
    CMAKE_BUILD_WITH_INSTALL_RPATH     = "@CMAKE_BUILD_WITH_INSTALL_RPATH@",
    CMAKE_INSTALL_RPATH                = "@CMAKE_INSTALL_RPATH@",
    CMAKE_INSTALL_RPATH_USE_LINK_PATH  = "@CMAKE_INSTALL_RPATH_USE_LINK_PATH@",
    CMAKE_INSTALL_NAME_DIR             = "@CMAKE_INSTALL_NAME_DIR@",

	-- OSX specific
	CMAKE_OSX_ARCHITECTURES            = "@CMAKE_OSX_ARCHITECTURES@",

}

-- Commands to use for building. (CMake 2.8+)
cmake           = "cmake"
cmakeDebug      = "cmake -DCMAKE_VERBOSE_MAKEFILE=true -DCMAKE_BUILD_TYPE=Debug"
ctest           = "ctest"
ctestDebug      = "ctest"
make            = "cmake --build . --target install --clean-first"
makeDebug       = "cmake --build . --target install --clean-first"

-- Add -j option to make in case of unix makefiles to speed up builds
if (variables.CMAKE_GENERATOR == "Unix Makefiles") then
        make = make .. " -- -j6"
        makeDebug = makeDebug .. " -- -j6"
end

-- Function used to display messages, warnings and errors
message = function(...)
  write(...)
  write("\n")
  flush()
end