source: opengl-game/makefile@ db1b548

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

Add a makefile recipe for SDLGame

  • Property mode set to 100644
File size: 4.1 KB
RevLine 
[71876b9]1# CFLAGS are compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
[5a643d3]2OS = $(shell uname)
[15c7ed9]3CC = g++
[ab65f84]4CFLAGS = -std=c++17 -Wall -pedantic -rdynamic
[17f28a1]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
[4762301]10#-Wextra -fno-inline
[5a643d3]11
12ifeq ($(OS),Darwin)
[e6bc0f4]13 DEP = -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lglfw -lglew
[5a643d3]14endif
[15c7ed9]15ifeq ($(OS),Linux)
[78c3045]16 DEP = -lglfw -lGLEW -lGL -ldl -lX11 -lXrandr -lXxf86vm -lXinerama -lXcursor -pthread
[5a643d3]17endif
18
[95c657f]19IMGUI_FILES = IMGUI/imgui.cpp IMGUI/imgui_demo.cpp IMGUI/imgui_draw.cpp IMGUI/imgui_widgets.cpp
[db1b548]20IMGUI_IMPL_FILES =
[1a616e6]21
[fc424f6]22# If I were generating .o files as well, I should use $? instead of $^
[8e232ce]23# as this well prevent regenerating .o files for unchanged .cpp files
24
[95c657f]25openglref: new-game.cpp logger.cpp utils.cpp crash-logger.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES)
[670c09a]26 $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC
[5272b6b]27
[95c657f]28openglgame: 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)
[670c09a]29 $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC
[d02c25f]30
[a8f0577]31CXX_FLAGS = -std=c++17 -Wall -pedantic# -O3 -rdynamic
[826df16]32
[ab65f84]33ifeq ($(OS),Darwin)
34 VULKAN_SDK_PATH = /Users/dportnoy15/Development/vulkan-sdk-macos-1.1.108.0/macOS
35endif
36ifeq ($(OS),Linux)
37 VULKAN_SDK_PATH = /home/dportnoy/Desktop/VulkanSDK/1.1.106.0/x86_64
38endif
[826df16]39
[ab65f84]40LIB_PATHS = -I$(VULKAN_SDK_PATH)/include
41ifeq ($(OS),Darwin)
42 LIB_PATHS := -Wl,-rpath,$(VULKAN_SDK_PATH)/lib $(LIB_PATHS)
43endif
44ifeq ($(OS),Linux)
[db1b548]45 LIB_PATHS =
[ab65f84]46endif
[03f4c64]47
[e1f88a9]48LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf sdl2_gfx`
[ab65f84]49ifeq ($(OS),Darwin)
50 LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS)
51endif
52ifeq ($(OS),Linux)
[eba8c0c]53 LIBS = `pkg-config --static --libs sdl2`
[e1f88a9]54 LIBS := -lvulkan $(LIBS) -lSDL2_image -lSDL2_ttf -lSDL2_gfx # TODO: figure out how to statically link these, ideally using pkg-config
[ab65f84]55endif
[826df16]56
57LIB_FLAGS = $(LIB_PATHS) $(LIBS)
58
[4eb4d0a]59vulkanref: vulkan-ref.cpp game-gui-sdl.cpp
60 $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
[17714b8]61
[699e83a]62GUI_SRC_FILES = gui/screen.cpp gui/main-screen.cpp gui/game-screen.cpp gui/ui-element.cpp gui/button.cpp gui/panel.cpp
[f809ae6]63GUI_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
[e1f88a9]64
65SRC_FILES = main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp utils.cpp game-gui-sdl.cpp $(GUI_SRC_FILES)
66HEADER_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)
[683dd55]67
68vulkangame: $(SRC_FILES) $(HEADER_FILES)
69 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
[03f4c64]70
[db1b548]71SRC_FILES = main-vulkan.cpp sdl-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp IMGUI/imgui_impl_sdl.cpp IMGUI/imgui_impl_vulkan.cpp $(IMGUI_FILES)
72HEADER_FILES = sdl-game.hpp crash-logger.hpp logger.hpp vulkan-utils.hpp game-gui.hpp game-gui-sdl.hpp IMGUI/imgui_impl_sdl.h IMGUI/imgui_impl_vulkan.h
73
74sdlgame: $(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
81LIB_FLAGS = $(LIBS)
82
83#SRC_FILES = Vulkan.cpp vulkan-utils-new.cpp
84#HEADER_FILES = vulkan-utils-new.hpp
85
86vulkansfmlref: $(SRC_FILES) $(HEADER_FILES)
87 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS)
88
[88ebdc8]89.PHONY: shaders
[c8c6da8]90shaders:
[88ebdc8]91 cd shaders && ../compile.sh && cd ..
92
[cfda3b2]93clean:
[d2f607c]94 rm -f openglref
[4eb4d0a]95 rm -f vulkanref
[db1b548]96 rm -f vulkansfmlref
[d02c25f]97 rm -f openglgame
[db1b548]98 rm -f sdlgame
[99d44b2]99 rm -f vulkangame
[88ebdc8]100 rm -f shaders/*.spv
Note: See TracBrowser for help on using the repository browser.