source: opengl-game/makefile@ c324d6a

feature/imgui-sdl
Last change on this file since c324d6a was 670c09a, checked in by Dmitry Portnoy <dportnoy@…>, 4 years ago

Fix makefile formatting

  • Property mode set to 100644
File size: 3.2 KB
Line 
1# CFLAGS are compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
2OS = $(shell uname)
3CC = g++
4CFLAGS = -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
12ifeq ($(OS),Darwin)
13 DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew
14endif
15ifeq ($(OS),Linux)
16 DEP = -lglfw -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread
17endif
18
19IMGUI_FILES = IMGUI/imgui.cpp IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui_widgets.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
24openglref: new-game.cpp logger.cpp utils.cpp crash-logger.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES)
25 $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC
26
27openglgame: 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)
28 $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC
29
30CXX_FLAGS = -std=c++17 -Wall -pedantic# -O3 -rdynamic
31
32ifeq ($(OS),Darwin)
33 VULKAN_SDK_PATH = /Users/dportnoy15/Development/vulkan-sdk-macos-1.1.108.0/macOS
34endif
35ifeq ($(OS),Linux)
36 VULKAN_SDK_PATH = /home/dportnoy/Desktop/VulkanSDK/1.1.106.0/x86_64
37endif
38
39LIB_PATHS = -I$(VULKAN_SDK_PATH)/include
40ifeq ($(OS),Darwin)
41 LIB_PATHS := -Wl,-rpath,$(VULKAN_SDK_PATH)/lib $(LIB_PATHS)
42endif
43ifeq ($(OS),Linux)
44 LIB_PATHS := -L$(VULKAN_SDK_PATH)/lib $(LIB_PATHS)
45endif
46
47LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf sdl2_gfx`
48ifeq ($(OS),Darwin)
49 LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS)
50endif
51ifeq ($(OS),Linux)
52 LIBS = `pkg-config --static --libs sdl2`
53 LIBS := -lvulkan $(LIBS) -lSDL2_image -lSDL2_ttf -lSDL2_gfx # TODO: figure out how to statically link these, ideally using pkg-config
54endif
55
56LIB_FLAGS = $(LIB_PATHS) $(LIBS)
57
58vulkanref: vulkan-ref.cpp game-gui-sdl.cpp
59 $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
60
61GUI_SRC_FILES = gui/screen.cpp gui/main-screen.cpp gui/game-screen.cpp gui/ui-element.cpp gui/button.cpp gui/panel.cpp
62GUI_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
63
64SRC_FILES = main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp utils.cpp game-gui-sdl.cpp $(GUI_SRC_FILES)
65HEADER_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)
66
67vulkangame: $(SRC_FILES) $(HEADER_FILES)
68 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
69
70.PHONY: shaders
71shaders:
72 cd shaders && ../compile.sh && cd ..
73
74clean:
75 rm -f openglref
76 rm -f vulkanref
77 rm -f openglgame
78 rm -f vulkangame
79 rm -f shaders/*.spv
Note: See TracBrowser for help on using the repository browser.