source: opengl-game/makefile@ 9d21aac

feature/imgui-sdl
Last change on this file since 9d21aac was 756162f, checked in by Dmitry Portnoy <dportnoy@…>, 4 years ago

Merge branch 'feature/imgui-sdl' of medievaltech.com:opengl-game into feature/imgui-sdl

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[187b0f5]1# CXX_FLAGS are C++ compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
[5a643d3]2OS = $(shell uname)
[15c7ed9]3CC = g++
[187b0f5]4#CXX_FLAGS = -std=c++17 -Wall -pedantic -g3 -rdynamic
5CXX_FLAGS = -std=c++17 -Wall -pedantic -O3
[17f28a1]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
[4762301]11#-Wextra -fno-inline
[5a643d3]12
13ifeq ($(OS),Darwin)
[e6bc0f4]14 DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew
[5a643d3]15endif
[15c7ed9]16ifeq ($(OS),Linux)
[78c3045]17 DEP = -lglfw -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread
[5a643d3]18endif
19
[95c657f]20IMGUI_FILES = IMGUI/imgui.cpp IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui_widgets.cpp
[db1b548]21IMGUI_IMPL_FILES =
[1a616e6]22
[fc424f6]23# If I were generating .o files as well, I should use $? instead of $^
[8e232ce]24# as this well prevent regenerating .o files for unchanged .cpp files
25
[95c657f]26openglref: new-game.cpp logger.cpp utils.cpp crash-logger.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES)
[187b0f5]27 $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC
[5272b6b]28
[95c657f]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)
[187b0f5]30 $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC
[826df16]31
[187b0f5]32LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf`
[ab65f84]33ifeq ($(OS),Darwin)
[cb6fabb]34 LIBS := -lvulkan $(LIBS)
[ab65f84]35endif
36ifeq ($(OS),Linux)
[187b0f5]37 #LIBS = `pkg-config --static --libs sdl2`
38 LIBS =
39 LIBS := -lvulkan $(LIBS) -lSDL2 -lSDL2_image -lSDL2_ttf # TODO: figure out how to statically link these, ideally using pkg-config
[ab65f84]40endif
[826df16]41
42LIB_FLAGS = $(LIB_PATHS) $(LIBS)
43
[4eb4d0a]44vulkanref: vulkan-ref.cpp game-gui-sdl.cpp
45 $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
[17714b8]46
[d255d52]47GUI_SRC_FILES = gui/imgui/button-imgui.cpp gui/imgui/ui-widget.cpp
48GUI_HEADER_FILES = gui/imgui/button-imgui.hpp gui/imgui/ui-widget.hpp
[e1f88a9]49
[d255d52]50vulkangame: 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)
51vulkangame: 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
[683dd55]52
53vulkangame: $(SRC_FILES) $(HEADER_FILES)
54 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
[03f4c64]55
[d255d52]56sdlgame: 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)
57sdlgame: 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
[db1b548]58
59sdlgame: $(SRC_FILES) $(HEADER_FILES)
60 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
61
62#LIBS = `pkg-config --static --libs sfml-graphics sfml-window sfml-system`
63# 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
64#LIBS = -lvulkan -lsfml-graphics -lsfml-window -lsfml-system
65
66LIB_FLAGS = $(LIBS)
67
68#SRC_FILES = Vulkan.cpp vulkan-utils-new.cpp
69#HEADER_FILES = vulkan-utils-new.hpp
70
71vulkansfmlref: $(SRC_FILES) $(HEADER_FILES)
72 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS)
73
[88ebdc8]74.PHONY: shaders
[c8c6da8]75shaders:
[756162f]76 ./compile.sh
[88ebdc8]77
[cfda3b2]78clean:
[d2f607c]79 rm -f openglref
[4eb4d0a]80 rm -f vulkanref
[db1b548]81 rm -f vulkansfmlref
[d02c25f]82 rm -f openglgame
[db1b548]83 rm -f sdlgame
[99d44b2]84 rm -f vulkangame
[88ebdc8]85 rm -f shaders/*.spv
Note: See TracBrowser for help on using the repository browser.