about summary refs log blame commit diff stats
path: root/premake5.lua
blob: 7b8f6424c5c9c27666038462f6b5341707078acc (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                 
                              

               



                                                    

                                                                       

                                                                    


           


















                                                                                                    
               


                                                                          
                                    
                      
                                                            


                                     
                                                                        



                                
                                                                    





                                           
                                                                  





                                         
                                                                         





                                               
                                                                    



                                         

                            
                                                                 





                                              
                                                                  



                                           

                               
                                                

                          
                                                            
                      


           
                       
                     

                                  
                                                                      
 















                                                                     

                        
        

                                                                                                                                                                                                                              
       
    
workspace("Pong")
    configurations {"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("pkg-config: ")
            io.flush()
            Pkgconf_Result = os.executef("which pkg-config")
            AllGood = true
            if(Pkgconf_Result == nil)
            then
                print("You do not have pkg-config installed. Aborting.")
                os.exit(1)
            end
            io.write("Raylib: ")
            io.flush()
            if(os.executef("pkg-config --modversion raylib") == nil)
            then
                print("Can't find raylib.")
                AllGood = false
            end
            io.write("SDL2: ")
            io.flush()
            if(os.executef("pkg-config --modversion sdl2") == nil)
            then
                print("Can't find SDL2.")
                AllGood = false
            end
            io.write("SDL2_mixer: ")
            io.flush()
            if (os.executef("pkg-config --modversion SDL2_mixer") == nil)
            then
                print("Can't find SDL2_mixer.")
                AllGood = false
            end
            io.write("GLFW3: ")
            io.flush()
            if (os.executef("pkg-config --modversion glfw3") == nil)
            then
                print("Can't find GLFW.")
                AllGood = false
            end
	    io.write("GL: ")
	    io.flush()
	    if (os.executef("pkg-config --modversion gl") == nil)
	    then
		    print("Can't find OpenGL")
		    AllGood = false
	    end
	    io.write("GLU: ")
	    io.flush()
	    if (os.executef("pkg-config --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")
    optimize("Debug")
    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 {"-g", "-ggdb", "`pkg-config --cflags raylib`", "`pkg-config --cflags glfw3`", "`pkg-config --cflags gl`", "`pkg-config --cflags sdl2`", "`pkg-config --cflags SDL2_mixer`", "`pkg-config --cflags glu`"}
        linkoptions {"-g", "-ggdb", "`pkg-config --libs raylib`", "`pkg-config --libs glfw3`", "`pkg-config --libs gl`", "`pkg-config --libs sdl2`", "`pkg-config --libs SDL2_mixer`", "`pkg-config --libs glu`"}
    end