[71876b9] | 1 | # CFLAGS are compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
|
---|
[5a643d3] | 2 | OS = $(shell uname)
|
---|
[15c7ed9] | 3 | CC = g++
|
---|
[ab65f84] | 4 | CFLAGS = -std=c++17 -Wall -pedantic -rdynamic
|
---|
[17f28a1] | 5 | # -rdynamic is to generate debug info for dynamic symbols on debian-based
|
---|
| 6 | # systems (tested on Linux Mint)
|
---|
| 7 | # for OSX, using -g generates a newgame.dSYS directory which has debug symbols.
|
---|
| 8 | # However, this has no effect on the stack trace, so there must be a way to specify a *.dSYS directory when running ./newgame
|
---|
| 9 | # or to instead put thos symbols directly into the executable, like -rdynamic does for Linux
|
---|
[4762301] | 10 | #-Wextra -fno-inline
|
---|
[5a643d3] | 11 |
|
---|
| 12 | ifeq ($(OS),Darwin)
|
---|
[e6bc0f4] | 13 | DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew
|
---|
[5a643d3] | 14 | endif
|
---|
[15c7ed9] | 15 | ifeq ($(OS),Linux)
|
---|
[c6fec84] | 16 | DEP = -lglfw3 -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread
|
---|
[5a643d3] | 17 | endif
|
---|
| 18 |
|
---|
[1a616e6] | 19 | IMGUI_FILES = IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui.cpp
|
---|
| 20 |
|
---|
[fc424f6] | 21 | # If I were generating .o files as well, I should use $? instead of $^
|
---|
[8e232ce] | 22 | # as this well prevent regenerating .o files for unchanged .cpp files
|
---|
| 23 |
|
---|
[d2f607c] | 24 | openglref: new-game.cpp logger.cpp utils.cpp crash-logger.cpp imgui_impl_glfw_gl3.cpp $(IMGUI_FILES)
|
---|
[8e232ce] | 25 | $(CC) $^ $(DEP) $(CFLAGS) -o $@
|
---|
[5272b6b] | 26 |
|
---|
[5b02676] | 27 | openglgame: main-opengl.cpp opengl-game.cpp crash-logger.cpp logger.cpp game-gui-glfw.cpp imgui_impl_glfw_gl3.cpp graphics-pipeline_opengl.cpp $(IMGUI_FILES)
|
---|
[c6fec84] | 28 | $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC
|
---|
[d02c25f] | 29 |
|
---|
[a8f0577] | 30 | CXX_FLAGS = -std=c++17 -Wall -pedantic# -O3 -rdynamic
|
---|
[826df16] | 31 |
|
---|
[ab65f84] | 32 | ifeq ($(OS),Darwin)
|
---|
| 33 | VULKAN_SDK_PATH = /Users/dportnoy15/Development/vulkan-sdk-macos-1.1.108.0/macOS
|
---|
| 34 | endif
|
---|
| 35 | ifeq ($(OS),Linux)
|
---|
| 36 | VULKAN_SDK_PATH = /home/dportnoy/Desktop/VulkanSDK/1.1.106.0/x86_64
|
---|
| 37 | endif
|
---|
[826df16] | 38 |
|
---|
[ab65f84] | 39 | LIB_PATHS = -I$(VULKAN_SDK_PATH)/include
|
---|
| 40 | ifeq ($(OS),Darwin)
|
---|
| 41 | LIB_PATHS := -Wl,-rpath,$(VULKAN_SDK_PATH)/lib $(LIB_PATHS)
|
---|
| 42 | endif
|
---|
| 43 | ifeq ($(OS),Linux)
|
---|
| 44 | LIB_PATHS := -L$(VULKAN_SDK_PATH)/lib $(LIB_PATHS)
|
---|
| 45 | endif
|
---|
[03f4c64] | 46 |
|
---|
[eba8c0c] | 47 | LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf`
|
---|
[ab65f84] | 48 | ifeq ($(OS),Darwin)
|
---|
| 49 | LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS)
|
---|
| 50 | endif
|
---|
| 51 | ifeq ($(OS),Linux)
|
---|
[eba8c0c] | 52 | LIBS = `pkg-config --static --libs sdl2`
|
---|
[17714b8] | 53 | LIBS := -lvulkan $(LIBS) -lSDL2_image -lSDL2_ttf # TODO: figure out how to statically link these, ideally using pkg-config
|
---|
[ab65f84] | 54 | endif
|
---|
[826df16] | 55 |
|
---|
| 56 | LIB_FLAGS = $(LIB_PATHS) $(LIBS)
|
---|
| 57 |
|
---|
[4eb4d0a] | 58 | vulkanref: vulkan-ref.cpp game-gui-sdl.cpp
|
---|
| 59 | $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
|
---|
[17714b8] | 60 |
|
---|
[5b02676] | 61 | vulkangame: main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp graphics-pipeline_vulkan.cpp
|
---|
[5289665] | 62 | $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
|
---|
[03f4c64] | 63 |
|
---|
[88ebdc8] | 64 | .PHONY: shaders
|
---|
[c8c6da8] | 65 | shaders:
|
---|
[88ebdc8] | 66 | cd shaders && ../compile.sh && cd ..
|
---|
| 67 |
|
---|
[cfda3b2] | 68 | clean:
|
---|
[d2f607c] | 69 | rm -f openglref
|
---|
[4eb4d0a] | 70 | rm -f vulkanref
|
---|
[d02c25f] | 71 | rm -f openglgame
|
---|
[99d44b2] | 72 | rm -f vulkangame
|
---|
[88ebdc8] | 73 | rm -f shaders/*.spv
|
---|