# 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 = -lglfw3 -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread endif IMGUI_FILES = IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui.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_impl_glfw_gl3.cpp $(IMGUI_FILES) $(CC) $^ $(DEP) $(CFLAGS) -o $@ openglgame: main-opengl.cpp opengl-game.cpp crash-logger.cpp logger.cpp game-gui-glfw.cpp imgui_impl_glfw_gl3.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` 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 # 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 vulkangame: main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp $(CC) $(CXX_FLAGS) -o $@ $^ $(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