# CFLAGS are compiler flags and LIBFLAGS could be renamed LINKER_FLAGS OS = $(shell uname) CC = g++ CFLAGS = -std=c++17 -Wall -pedantic -rdynamic # -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 # 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) $(CFLAGS) -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) $(CFLAGS) -o $@ -DGLEW_STATIC CXX_FLAGS = -std=c++17 -Wall -pedantic# -O3 -rdynamic 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 := -L$(VULKAN_SDK_PATH)/lib $(LIB_PATHS) endif LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf sdl2_gfx` ifeq ($(OS),Darwin) LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS) endif ifeq ($(OS),Linux) LIBS = `pkg-config --static --libs sdl2` LIBS := -lvulkan $(LIBS) -lSDL2_image -lSDL2_ttf -lSDL2_gfx # 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/screen.cpp gui/main-screen.cpp gui/game-screen.cpp gui/ui-element.cpp gui/button.cpp gui/panel.cpp GUI_HEADER_FILES = gui/screen.hpp gui/main-screen.hpp gui/game-screen.hpp gui/ui-element.hpp gui/button.hpp gui/panel.hpp gui/ui-value.hpp 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) 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) vulkangame: $(SRC_FILES) $(HEADER_FILES) $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN .PHONY: shaders shaders: cd shaders && ../compile.sh && cd .. clean: rm -f openglref rm -f vulkanref rm -f openglgame rm -f vulkangame rm -f shaders/*.spv