| 1 | # CFLAGS are compiler flags and LIBFLAGS could be renamed LINKER_FLAGS
|
|---|
| 2 | OS = $(shell uname)
|
|---|
| 3 | CC = g++
|
|---|
| 4 | CFLAGS = -std=c++11 -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 stb_image.cpp imgui_impl_glfw_gl3.cpp $(IMGUI_FILES)
|
|---|
| 25 | $(CC) $^ $(DEP) $(CFLAGS) -o $@
|
|---|
| 26 |
|
|---|
| 27 | pong: pong.cpp logger.cpp
|
|---|
| 28 | $(CC) $^ $(DEP) $(CFLAGS) -o $@
|
|---|
| 29 |
|
|---|
| 30 | mygame: mygame.cpp common/shader.cpp common/texture.cpp common/controls-new.cpp
|
|---|
| 31 | $(CC) $^ $(DEP) $(CFLAGS) -o $@
|
|---|
| 32 |
|
|---|
| 33 | demo: game06.cpp common/shader.cpp common/texture.cpp common/controls.cpp
|
|---|
| 34 | $(CC) $^ $(DEP) $(CFLAGS) -o $@
|
|---|
| 35 |
|
|---|
| 36 | VULKAN_SDK_PATH = /home/dportnoy/Desktop/VulkanSDK/1.1.106.0/x86_64
|
|---|
| 37 | CFLAGS_VULKAN = -std=c++17 -I$(VULKAN_SDK_PATH)/include -Wall -pedantic
|
|---|
| 38 | #LIBFLAGS = -L$(VULKAN_SDK_PATH)/lib `pkg-config --static --libs glfw3` -lvulkan
|
|---|
| 39 | LIBFLAGS = -L$(VULKAN_SDK_PATH)/lib -lvulkan -lSDL2
|
|---|
| 40 |
|
|---|
| 41 | vulkangame: new-vulkan-game.cpp
|
|---|
| 42 | $(CC) $(CFLAGS_VULKAN) -o $@ $^ $(LIBFLAGS)
|
|---|
| 43 |
|
|---|
| 44 | clean:
|
|---|
| 45 | rm -f newgame
|
|---|
| 46 | rm -f pong
|
|---|
| 47 | rm -f mygame
|
|---|
| 48 | rm -f demo
|
|---|
| 49 | rm -f vulkangame
|
|---|