workspace("Pong") configurations {"Debug", "Release"} project("Pong") newaction { trigger = "install", description = "Install the game to prefix.", execute = function() os.mkdir(string.format("%s/Pong/resources", prefix)) os.executef("cp -r resources/* %s/Pong/resources/", prefix) os.executef("install -m755 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.executef("rm -rf %s/flatpak", _MAIN_SCRIPT_DIR) os.exit(0) end } newaction { trigger = "check_deps", description = "Check if you have all the dependencies installed.", execute = function() io.write("Pkgconf: ") io.flush() Pkgconf_Result = os.executef("which pkgconf") AllGood = true if(Pkgconf_Result == nil) then print("You do not have pkgconf installed. Aborting.") os.exit(1) end io.write("Raylib: ") io.flush() if(os.executef("pkgconf --modversion raylib") == nil) then print("Can't find raylib.") AllGood = false end io.write("SDL2: ") io.flush() if(os.executef("pkgconf --modversion sdl2") == nil) then print("Can't find SDL2.") AllGood = false end io.write("SDL2_mixer: ") io.flush() if (os.executef("pkgconf --modversion SDL2_mixer") == nil) then print("Can't find SDL2_mixer.") AllGood = false end io.write("GLFW3: ") io.flush() if (os.executef("pkgconf --modversion glfw3") == nil) then print("Can't find GLFW.") AllGood = false end io.write("GL: ") io.flush() if (os.executef("pkgconf --modversion gl") == nil) then print("Can't find OpenGL") AllGood = false end io.write("GLU: ") io.flush() if (os.executef("pkgconf --modversion glu") == nil) then print("Can't find GLU") AllGood = false end if(AllGood == true) then print("Found all dependencies!") os.exit(0) end print("Failed to find all needed dependencies.") os.exit(1) end } kind("WindowedApp") language("C") files {"src/*.c", "src/*.h", } --libdirs {"/usr/local/lib", "/usr/pkg/lib", "/usr/X11R7/include"} -- 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" if (flatpak == true) then else buildoptions {"`pkgconf --cflags raylib`", "`pkgconf --cflags glfw3`", "`pkgconf --cflags gl`", "`pkgconf --cflags sdl2`", "`pkgconf --cflags SDL2_mixer`", "`pkgconf --cflags glu`"} linkoptions {"`pkgconf --libs raylib`", "`pkgconf --libs glfw3`", "`pkgconf --libs gl`", "`pkgconf --libs sdl2`", "`pkgconf --libs SDL2_mixer`", "`pkgconf --libs glu`"} end