1 | # CFLAGS are compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
|
---|
2 | OS = $(shell uname)
|
---|
3 | CC = g++
|
---|
4 | CFLAGS = -std=c++17 -Wall -pedantic -rdynamic
|
---|
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
|
---|
10 | #-Wextra -fno-inline
|
---|
11 |
|
---|
12 | ifeq ($(OS),Darwin)
|
---|
13 | DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew
|
---|
14 | endif
|
---|
15 | ifeq ($(OS),Linux)
|
---|
16 | DEP = -lglfw3 -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread
|
---|
17 | endif
|
---|
18 |
|
---|
19 | IMGUI_FILES = IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui.cpp
|
---|
20 |
|
---|
21 | # If I were generating .o files as well, I should use $? instead of $^
|
---|
22 | # as this well prevent regenerating .o files for unchanged .cpp files
|
---|
23 |
|
---|
24 | newgame: new-game.cpp logger.cpp utils.cpp CrashLogger.cpp imgui_impl_glfw_gl3.cpp $(IMGUI_FILES)
|
---|
25 | $(CC) $^ $(DEP) $(CFLAGS) -o $@
|
---|
26 |
|
---|
27 | CXX_FLAGS = -std=c++17 -Wall -pedantic# -O3 -rdynamic
|
---|
28 |
|
---|
29 | ifeq ($(OS),Darwin)
|
---|
30 | VULKAN_SDK_PATH = /Users/dportnoy15/Development/vulkan-sdk-macos-1.1.108.0/macOS
|
---|
31 | endif
|
---|
32 | ifeq ($(OS),Linux)
|
---|
33 | VULKAN_SDK_PATH = /home/dportnoy/Desktop/VulkanSDK/1.1.106.0/x86_64
|
---|
34 | endif
|
---|
35 |
|
---|
36 | LIB_PATHS = -I$(VULKAN_SDK_PATH)/include
|
---|
37 | ifeq ($(OS),Darwin)
|
---|
38 | LIB_PATHS := -Wl,-rpath,$(VULKAN_SDK_PATH)/lib $(LIB_PATHS)
|
---|
39 | endif
|
---|
40 | ifeq ($(OS),Linux)
|
---|
41 | LIB_PATHS := -L$(VULKAN_SDK_PATH)/lib $(LIB_PATHS)
|
---|
42 | endif
|
---|
43 |
|
---|
44 | LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf`
|
---|
45 | ifeq ($(OS),Darwin)
|
---|
46 | LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS)
|
---|
47 | endif
|
---|
48 | ifeq ($(OS),Linux)
|
---|
49 | LIBS = `pkg-config --static --libs sdl2`
|
---|
50 | LIBS := -lvulkan $(LIBS) -lSDL2_image -lSDL2_ttf # TODO: figure out how to statically link these, ideally using pkg-config
|
---|
51 | endif
|
---|
52 |
|
---|
53 | LIB_FLAGS = $(LIB_PATHS) $(LIBS)
|
---|
54 |
|
---|
55 | vulkanref: vulkan-ref.cpp game-gui-sdl.cpp
|
---|
56 | $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
|
---|
57 |
|
---|
58 | vulkangame: main-vulkan.cpp vulkan-game.cpp game-gui-sdl.cpp
|
---|
59 | $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS)
|
---|
60 |
|
---|
61 | .PHONY: shaders
|
---|
62 | shaders:
|
---|
63 | cd shaders && ../compile.sh && cd ..
|
---|
64 |
|
---|
65 | clean:
|
---|
66 | rm -f newgame
|
---|
67 | rm -f vulkanref
|
---|
68 | rm -f vulkangame
|
---|
69 | rm -f shaders/*.spv
|
---|