workspace("Pong") configurations {"Debug", "Release"} project("Pong") newaction { trigger = "install", description = "Install the game to prefix.", execute = function() os.executef("mkdir -p %s/Pong/resources", prefix) os.executef("cp -v resources/* %s/Pong/resources/", prefix) os.executef("install -Dm755 bin/*/Pong %s/Pong/pong", prefix) os.exit(0) end } newaction { trigger = "clean", description = "Clean the work environment.", execute = function() os.executef("rm -rvf %s/obj", _MAIN_SCRIPT_DIR) os.executef("rm -rvf %s/bin", _MAIN_SCRIPT_DIR) os.executef("rm -rvf %s/app", _MAIN_SCRIPT_DIR) os.executef("rm -vf %s/Makefile", _MAIN_SCRIPT_DIR) os.executef("rm -vf %s/Pong.make", _MAIN_SCRIPT_DIR) os.executef("rm -rvf %s/flatpak_repo", _MAIN_SCRIPT_DIR) os.executef("rm -rvf %s/.flatpak-builder", _MAIN_SCRIPT_DIR) os.executef("rm -rvf %s/build-dir", _MAIN_SCRIPT_DIR) os.executef("rm -vf %s/*.flatpak", _MAIN_SCRIPT_DIR) os.exit(0) end } newaction { trigger = "check_deps", description = "Check if you have all the dependencies installed.", execute = function() os.exit(0) end } kind("WindowedApp") language("C") files {"src/*.c", "src/*.h", } includedirs {"raylib/src"} -- Prefix Option newoption { trigger = "prefix", value = "path", description = "Prefix for where the game is to be installed." } prefix = _OPTIONS["prefix"] or "app" -- Flatpak newoption { trigger = "flatpak", value = "bool", description = "Build a flatpak." } flatpak = _OPTIONS["flatpak"] or "false" -- Check for pkgconf Pkgconf_Result = os.executef("pkgconf --version") if(Pkgconf_Result == nil) then print("You do not have pkgconf installed. Aborting.") os.exit(1) end if (flatpak == true) then linkoptions {"-L/app/lib"} end linkoptions {"-lraylib", "`pkgconf --libs glfw3`", "`pkgconf --libs gl`", "`pkgconf --libs sdl2`", "`pkgconf --libs SDL2_mixer`"} -- Detect OS if(os.ishost("linux") == true) then links {RaylibStaticLibrary, "m", "pthread", "dl"} elseif(os.ishost("bsd") == true) then print("It is required you build raylib to an external glfw library when on bsd.") -- Which BSD? BSD_OS = io.popen("uname") BSD_OS_NAME = BSD_OS:read("*a") BSD_OS:close() -- Check Result if(BSD_OS_NAME == "NetBSD\n") then links {RaylibStaticLibrary, "m", "pthread"} elseif(BSD_OS_NAME == "FreeBSD\n") then links {RaylibStaticLibrary, "m", "stdthreads", "pthread"} elseif(BSD_OS_NAME == "OpenBSD\n") then -- Work around the fact openbsd doesn't have c11 threads. includedirs {"src/openbsd"} files {"src/openbsd/*.c", "src/openbsd/*.h"} -- Tell compiler where libraries are. libdirs {"/usr/local/lib"} links {RaylibStaticLibrary, "m", "pthread"} else print("Couldn't figure out BSD, assuming freebsd.") links {RaylibStaticLibrary, "m", "stdthreads"} end elseif(os.ishost("windows") == true) then print("This script is expecting a MSYS2 or Cygwin environment. You've been warned.") links {RaylibStaticLibrary, "-lopengl32", "-lgdi32", "-lwinmm", "-lpthread", "-lm"} includedirs {"raylib/src", "src/windows"} else links {RaylibStaticLibrary, "m", "pthread", "dl"} end