1 | # CXX_FLAGS are C++ compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
|
---|
2 | OS = $(shell uname)
|
---|
3 | CC = g++
|
---|
4 | #CXX_FLAGS = -std=c++17 -Wall -pedantic -g3 -rdynamic
|
---|
5 | CXX_FLAGS = -std=c++17 -Wall -pedantic -O3
|
---|
6 | # -rdynamic is to generate debug info for dynamic symbols on debian-based
|
---|
7 | # systems (tested on Linux Mint)
|
---|
8 | # for OSX, using -g generates a newgame.dSYS directory which has debug symbols.
|
---|
9 | # However, this has no effect on the stack trace, so there must be a way to specify a *.dSYS directory when running ./newgame
|
---|
10 | # or to instead put thos symbols directly into the executable, like -rdynamic does for Linux
|
---|
11 | #-Wextra -fno-inline
|
---|
12 |
|
---|
13 | ifeq ($(OS),Darwin)
|
---|
14 | DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew
|
---|
15 | endif
|
---|
16 | ifeq ($(OS),Linux)
|
---|
17 | DEP = -lglfw -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread
|
---|
18 | endif
|
---|
19 |
|
---|
20 | IMGUI_FILES = IMGUI/imgui.cpp IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui_widgets.cpp
|
---|
21 | IMGUI_IMPL_FILES =
|
---|
22 |
|
---|
23 | # If I were generating .o files as well, I should use $? instead of $^
|
---|
24 | # as this well prevent regenerating .o files for unchanged .cpp files
|
---|
25 |
|
---|
26 | openglref: new-game.cpp logger.cpp utils.cpp crash-logger.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES)
|
---|
27 | $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC
|
---|
28 |
|
---|
29 | 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)
|
---|
30 | $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC
|
---|
31 |
|
---|
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
|
---|
38 |
|
---|
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 =
|
---|
45 | endif
|
---|
46 |
|
---|
47 | LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf`
|
---|
48 | ifeq ($(OS),Darwin)
|
---|
49 | LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS)
|
---|
50 | endif
|
---|
51 | ifeq ($(OS),Linux)
|
---|
52 | #LIBS = `pkg-config --static --libs sdl2`
|
---|
53 | LIBS =
|
---|
54 | LIBS := -lvulkan $(LIBS) -lSDL2 -lSDL2_image -lSDL2_ttf # TODO: figure out how to statically link these, ideally using pkg-config
|
---|
55 | endif
|
---|
56 |
|
---|
57 | LIB_FLAGS = $(LIB_PATHS) $(LIBS)
|
---|
58 |
|
---|
59 | vulkanref: vulkan-ref.cpp game-gui-sdl.cpp
|
---|
60 | $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
|
---|
61 |
|
---|
62 | GUI_SRC_FILES = gui/imgui/button-imgui.cpp gui/imgui/ui-widget.cpp
|
---|
63 | GUI_HEADER_FILES = gui/imgui/button-imgui.hpp gui/imgui/ui-widget.hpp
|
---|
64 |
|
---|
65 | 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)
|
---|
66 | 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
|
---|
67 |
|
---|
68 | vulkangame: $(SRC_FILES) $(HEADER_FILES)
|
---|
69 | $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
|
---|
70 |
|
---|
71 | 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)
|
---|
72 | 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
|
---|
73 |
|
---|
74 | sdlgame: $(SRC_FILES) $(HEADER_FILES)
|
---|
75 | $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
|
---|
76 |
|
---|
77 | #LIBS = `pkg-config --static --libs sfml-graphics sfml-window sfml-system`
|
---|
78 | # 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
|
---|
79 | #LIBS = -lvulkan -lsfml-graphics -lsfml-window -lsfml-system
|
---|
80 |
|
---|
81 | LIB_FLAGS = $(LIBS)
|
---|
82 |
|
---|
83 | #SRC_FILES = Vulkan.cpp vulkan-utils-new.cpp
|
---|
84 | #HEADER_FILES = vulkan-utils-new.hpp
|
---|
85 |
|
---|
86 | vulkansfmlref: $(SRC_FILES) $(HEADER_FILES)
|
---|
87 | $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS)
|
---|
88 |
|
---|
89 | .PHONY: shaders
|
---|
90 | shaders:
|
---|
91 | cd shaders && ../compile.sh && cd ..
|
---|
92 |
|
---|
93 | clean:
|
---|
94 | rm -f openglref
|
---|
95 | rm -f vulkanref
|
---|
96 | rm -f vulkansfmlref
|
---|
97 | rm -f openglgame
|
---|
98 | rm -f sdlgame
|
---|
99 | rm -f vulkangame
|
---|
100 | rm -f shaders/*.spv
|
---|