diff --git a/config.mk b/config.mk index 6689e7b..f56d914 100644 --- a/config.mk +++ b/config.mk @@ -1,14 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause CC := cc -CFLAGS := -Wall -Wextra -std=c99 -pedantic -ggdb -fsanitize=address -DDEBUG +CFLAGS := -Wall -Wextra -std=c99 -pedantic LIBS := -lm -# can be gl or vk +# Can be gl or vk BACKEND := vk PLATFORM := $(shell uname) -ifeq (${BACKEND},gl) +ifeq (${GRAPHICS_BACKEND},gl) CFLAGS += -DBACKEND_GL ifeq (${PLATFORM},Darwin) LIBS += -framework OpenGL @@ -24,5 +24,13 @@ ifeq (${PLATFORM},Darwin) CFLAGS += -DPLATFORM_MACOS LIBS += -framework Cocoa -framework CoreVideo -framework Metal -framework IOKit else ifeq (${PLATFORM},Linux) - CFLAGS += -DPLATFORM_LINUX +# Check for windowing platforms if it's linux + LINUX_WINDOW_PLATFORM := $(shell echo $$DISPLAY) +endif + +# If LINUX_WINDOW_PLATFORM is "", it is Wayland, otherwise it's Xorg +ifeq ($(LINUX_WINDOW_PLATFORM),) + LIBS += -lwayland-client +else + LIBS += -lX11 -lXrandr endif diff --git a/makefile b/makefile index 02900d7..faede51 100644 --- a/makefile +++ b/makefile @@ -1,18 +1,22 @@ # SPDX-License-Identifier: BSD-3-Clause include config.mk +ifeq (${DEBUG_BUILD},1) + CFLAGS += -ggdb -fsanitize=address,undefined -DDEBUG +endif SRC:=\ topaz.c\ linear.c\ core/arena.c\ - core/vector.c + core/vector.c\ -ifeq (${BACKEND},gl) +ifeq (${GRAPHICS_BACKEND},gl) SRC += gl/gl.c\ - gl/platform.c + gl/platform.c\ + gl/renderer.c endif -ifeq (${BACKEND},vk) +ifeq (${GRAPHICS_BACKEND},vk) SRC += vk/platform.c\ vk/renderer.c\ vk/instance.c\