@@ -115,6 +115,11 @@ USE_EXTERNAL_GLFW ?= FALSE
115115GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
116116GLFW_LINUX_ENABLE_X11 ?= TRUE
117117
118+ # Enable support for X11 by default on Linux when using GLFW
119+ # NOTE: Wayland is disabled by default, only enable if you are sure
120+ RGFW_LINUX_ENABLE_WAYLAND ?= FALSE
121+ RGFW_LINUX_ENABLE_X11 ?= TRUE
122+
118123# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
119124# WARNING: Library is not included in raylib, it MUST be configured by users
120125SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH ) /external/SDL2/include
@@ -289,6 +294,17 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
289294 CC = clang
290295 endif
291296endif
297+ ifeq ($(TARGET_PLATFORM ) ,PLATFORM_DESKTOP_RGFW)
298+ ifeq ($(PLATFORM_OS),OSX)
299+ # OSX default compiler
300+ CC = clang
301+ GLFW_OSX = -x objective-c
302+ endif
303+ ifeq ($(PLATFORM_OS),BSD)
304+ # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
305+ CC = clang
306+ endif
307+ endif
292308ifeq ($(TARGET_PLATFORM ) ,PLATFORM_DRM)
293309 ifeq ($(USE_RPI_CROSSCOMPILER),TRUE)
294310 # Define RPI cross-compiler
@@ -450,7 +466,6 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
450466 endif
451467 ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
452468 CFLAGS += -D_GLFW_WAYLAND
453- LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
454469
455470 WL_PROTOCOLS_DIR := external/glfw/deps/wayland
456471
@@ -472,6 +487,33 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
472487 endif
473488 endif
474489endif
490+ # Use Wayland display on Linux desktop
491+ ifeq ($(TARGET_PLATFORM ) ,PLATFORM_DESKTOP_RGFW)
492+ ifeq ($(PLATFORM_OS), LINUX)
493+ ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
494+ CFLAGS += -DRGFW_X11 -DRGFW_UNIX
495+ endif
496+ ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
497+ CFLAGS += -DRGFW_WAYLAND -DEGLAPIENTRY=
498+
499+ WL_PROTOCOLS_DIR := external/RGFW/deps/wayland
500+
501+ wl_generate = \
502+ $(eval protocol=$(1 ) ) \
503+ $(eval basename=$(2 ) ) \
504+ $(shell wayland-scanner client-header $(protocol ) $(RAYLIB_SRC_PATH ) /$(basename ) .h) \
505+ $(shell wayland-scanner private-code $(protocol ) $(RAYLIB_SRC_PATH ) /$(basename ) -code.c)
506+
507+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol)
508+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-warp-v1.xml, pointer-warp-v1-client-protocol)
509+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol)
510+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol)
511+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-output-unstable-v1.xml, xdg-output-unstable-v1-client-protocol)
512+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol)
513+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-toplevel-icon-v1.xml, xdg-toplevel-icon-v1-client-protocol)
514+ endif
515+ endif
516+ endif
475517
476518CFLAGS += $(CUSTOM_CFLAGS )
477519
@@ -583,6 +625,10 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
583625 ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
584626 LDLIBS += -lX11
585627 endif
628+
629+ ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
630+ LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
631+ endif
586632 # TODO: On ARM 32bit arch, miniaudio requires atomics library
587633 # LDLIBS += -latomic
588634 endif
@@ -618,7 +664,15 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
618664 ifeq ($(PLATFORM_OS),LINUX)
619665 # Libraries for Debian GNU/Linux desktop compipling
620666 # NOTE: Required packages: libegl1-mesa-dev
621- LDLIBS = -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lm -lpthread -ldl -lrt
667+ LDLIBS = -lm
668+
669+ ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
670+ LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lpthread -ldl -lrt
671+ endif
672+
673+ ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
674+ LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
675+ endif
622676
623677 # Explicit link to libc
624678 ifeq ($(RAYLIB_LIBTYPE),SHARED)
@@ -665,6 +719,21 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
665719 OBJS += rglfw.o
666720 endif
667721endif
722+ ifeq ($(TARGET_PLATFORM ) ,PLATFORM_DESKTOP_RGFW)
723+ ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
724+ PROTOCOL_CODE_FILES = \
725+ pointer-constraints-unstable-v1-client-protocol-code \
726+ pointer-warp-v1-client-protocol-code \
727+ relative-pointer-unstable-v1-client-protocol-code \
728+ xdg-decoration-unstable-v1-client-protocol-code \
729+ xdg-output-unstable-v1-client-protocol-code \
730+ xdg-shell-client-protocol-code \
731+ xdg-toplevel-icon-v1-client-protocol-code
732+
733+ PROTO_OBJS = $(addsuffix .o, $(PROTOCOL_CODE_FILES))
734+ OBJS += $(PROTO_OBJS)
735+ endif
736+ endif
668737ifeq ($(RAYLIB_MODULE_MODELS ) ,TRUE)
669738 OBJS += rmodels.o
670739endif
@@ -801,6 +870,17 @@ endif
801870android_native_app_glue.o : $(NATIVE_APP_GLUE ) /android_native_app_glue.c
802871 $(CC ) -c $< $(CFLAGS ) $(INCLUDE_PATHS )
803872
873+ # Compile Wayland files
874+ ifeq ($(TARGET_PLATFORM ) ,PLATFORM_DESKTOP_RGFW)
875+ ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
876+ %-client-protocol-code.o: %-client-protocol-code.c
877+ $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
878+
879+ %-client-protocol-code.h: external/RGFW/deps/wayland/%.xml
880+ wayland-scanner private-code $< $@
881+ endif
882+ endif
883+
804884# Install generated and needed files to desired directories.
805885# On GNU/Linux and BSDs, there are some standard directories that contain extra
806886# libraries and header files. These directories (often /usr/local/lib and
@@ -885,7 +965,7 @@ clean: clean_shell_$(PLATFORM_SHELL)
885965 @echo " removed all generated files!"
886966
887967clean_shell_sh :
888- rm -fv * .o $(RAYLIB_RELEASE_PATH ) /lib$(RAYLIB_LIB_NAME ) .a $(RAYLIB_RELEASE_PATH ) /lib$(RAYLIB_LIB_NAME ) .web.a $(RAYLIB_RELEASE_PATH ) /lib$(RAYLIB_LIB_NAME ) .so* raygui.c $(RAYLIB_RELEASE_PATH ) /* -protocol.h $(RAYLIB_RELEASE_PATH ) /* -protocol-code.h
968+ rm -fv * .o $(RAYLIB_RELEASE_PATH ) /lib$(RAYLIB_LIB_NAME ) .a $(RAYLIB_RELEASE_PATH ) /lib$(RAYLIB_LIB_NAME ) .web.a $(RAYLIB_RELEASE_PATH ) /lib$(RAYLIB_LIB_NAME ) .so* raygui.c $(RAYLIB_RELEASE_PATH ) /* -protocol.h $(RAYLIB_RELEASE_PATH ) /* -protocol-code.h $( RAYLIB_RELEASE_PATH ) / * -protocol-code.c
889969ifeq ($(TARGET_PLATFORM ) ,PLATFORM_ANDROID)
890970 rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
891971endif
0 commit comments