# CXX_FLAGS are C++ compiler flags and LIBFLAGS could be renamed LINKER_FLAGS OS = $(shell uname) CC = g++ #CXX_FLAGS = -std=c++17 -Wall -pedantic -g3 -rdynamic CXX_FLAGS = -std=c++17 -Wall -pedantic -O3 # -rdynamic is to generate debug info for dynamic symbols on debian-based # systems (tested on Linux Mint) # for OSX, using -g generates a newgame.dSYS directory which has debug symbols. # However, this has no effect on the stack trace, so there must be a way to specify a *.dSYS directory when running ./newgame # or to instead put thos symbols directly into the executable, like -rdynamic does for Linux #-Wextra -fno-inline ifeq ($(OS),Darwin) DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew endif ifeq ($(OS),Linux) DEP = -lglfw -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread endif IMGUI_FILES = IMGUI/imgui.cpp IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui_widgets.cpp IMGUI_IMPL_FILES = # If I were generating .o files as well, I should use $? instead of $^ # as this well prevent regenerating .o files for unchanged .cpp files openglref: new-game.cpp logger.cpp utils.cpp crash-logger.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES) $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC openglgame: main-opengl.cpp opengl-game.cpp crash-logger.cpp logger.cpp game-gui-glfw.cpp graphics-pipeline_opengl.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES) $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC ifeq ($(OS),Darwin) VULKAN_SDK_PATH = /Users/dportnoy15/Development/vulkan-sdk-macos-1.1.108.0/macOS endif ifeq ($(OS),Linux) VULKAN_SDK_PATH = /home/dportnoy/Desktop/VulkanSDK/1.1.106.0/x86_64 endif LIB_PATHS = -I$(VULKAN_SDK_PATH)/include ifeq ($(OS),Darwin) LIB_PATHS := -Wl,-rpath,$(VULKAN_SDK_PATH)/lib $(LIB_PATHS) endif ifeq ($(OS),Linux) LIB_PATHS = endif LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf` ifeq ($(OS),Darwin) LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS) endif ifeq ($(OS),Linux) #LIBS = `pkg-config --static --libs sdl2` LIBS = LIBS := -lvulkan $(LIBS) -lSDL2 -lSDL2_image -lSDL2_ttf # TODO: figure out how to statically link these, ideally using pkg-config endif LIB_FLAGS = $(LIB_PATHS) $(LIBS) vulkanref: vulkan-ref.cpp game-gui-sdl.cpp $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN GUI_SRC_FILES = gui/imgui/button-imgui.cpp gui/imgui/ui-widget.cpp GUI_HEADER_FILES = gui/imgui/button-imgui.hpp gui/imgui/ui-widget.hpp vulkangame: SRC_FILES = main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp utils.cpp game-gui-sdl.cpp $(GUI_SRC_FILES) IMGUI/imgui_impl_sdl.cpp IMGUI/imgui_impl_vulkan.cpp $(IMGUI_FILES) vulkangame: HEADER_FILES = vulkan-game.hpp crash-logger.hpp logger.hpp vulkan-utils.hpp utils.hpp game-gui-sdl.hpp game-gui.hpp graphics-pipeline_vulkan.hpp $(GUI_HEADER_FILES) IMGUI/imgui_impl_sdl.h IMGUI/imgui_impl_vulkan.h vulkangame: $(SRC_FILES) $(HEADER_FILES) $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN sdlgame: SRC_FILES = main-vulkan.cpp sdl-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp $(GUI_SRC_FILES) IMGUI/imgui_impl_sdl.cpp IMGUI/imgui_impl_vulkan.cpp $(IMGUI_FILES) sdlgame: HEADER_FILES = sdl-game.hpp crash-logger.hpp logger.hpp vulkan-utils.hpp game-gui.hpp game-gui-sdl.hpp $(GUI_HEADER_FILES) IMGUI/imgui_impl_sdl.h IMGUI/imgui_impl_vulkan.h sdlgame: $(SRC_FILES) $(HEADER_FILES) $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN #LIBS = `pkg-config --static --libs sfml-graphics sfml-window sfml-system` # using pkg-config directly didn't add -s to the end of the sfml libs and since I only installed the static ones, g++ couldn't find them #LIBS = -lvulkan -lsfml-graphics -lsfml-window -lsfml-system LIB_FLAGS = $(LIBS) #SRC_FILES = Vulkan.cpp vulkan-utils-new.cpp #HEADER_FILES = vulkan-utils-new.hpp vulkansfmlref: $(SRC_FILES) $(HEADER_FILES) $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) .PHONY: shaders shaders: cd shaders && ../compile.sh && cd .. clean: rm -f openglref rm -f vulkanref rm -f vulkansfmlref rm -f openglgame rm -f sdlgame rm -f vulkangame rm -f shaders/*.spv