source: opengl-game/makefile

feature/imgui-sdl
Last change on this file was 87cfede, checked in by Dmitry Portnoy <dportnoy@…>, 6 weeks ago

Update makefile to work in Linux, and update the build docs

  • Property mode set to 100644
File size: 3.6 KB
Line 
1# CXX_FLAGS are C++ compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
2OS = $(shell uname)
3CC = g++
4#CXX_FLAGS = -std=c++17 -Wall -pedantic -g3 -rdynamic
5CXX_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
13ifeq ($(OS),Darwin)
14 DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew
15endif
16ifeq ($(OS),Linux)
17 DEP = -lglfw -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread
18endif
19
20IMGUI_FILES = IMGUI/imgui.cpp IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui_widgets.cpp
21IMGUI_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
26openglref: 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
29openglgame: 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
32LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf`
33ifeq ($(OS),Darwin)
34 LIBS := -lvulkan $(LIBS)
35endif
36ifeq ($(OS),Linux)
37 LIBS = `pkg-config --static --libs vulkan sdl2`
38endif
39
40LIB_FLAGS = $(LIB_PATHS) $(LIBS)
41
42vulkanref: vulkan-ref.cpp game-gui-sdl.cpp
43 $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
44
45GUI_SRC_FILES = gui/imgui/button-imgui.cpp gui/imgui/ui-widget.cpp
46GUI_HEADER_FILES = gui/imgui/button-imgui.hpp gui/imgui/ui-widget.hpp
47
48vulkangame: 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)
49vulkangame: 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
50
51vulkangame: $(SRC_FILES) $(HEADER_FILES)
52 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
53
54sdlgame: 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)
55sdlgame: 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
56
57sdlgame: $(SRC_FILES) $(HEADER_FILES)
58 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
59
60#LIBS = `pkg-config --static --libs sfml-graphics sfml-window sfml-system`
61# 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
62#LIBS = -lvulkan -lsfml-graphics -lsfml-window -lsfml-system
63
64LIB_FLAGS = $(LIBS)
65
66#SRC_FILES = Vulkan.cpp vulkan-utils-new.cpp
67#HEADER_FILES = vulkan-utils-new.hpp
68
69vulkansfmlref: $(SRC_FILES) $(HEADER_FILES)
70 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS)
71
72.PHONY: shaders
73shaders:
74 bash compile.sh
75
76clean:
77 rm -f openglref
78 rm -f vulkanref
79 rm -f vulkansfmlref
80 rm -f openglgame
81 rm -f sdlgame
82 rm -f vulkangame
83 rm -f shaders/*.spv
Note: See TracBrowser for help on using the repository browser.