Skip to content

Commit b57526d

Browse files
authored
update makefile and such (#5591)
1 parent 006216b commit b57526d

5 files changed

Lines changed: 110 additions & 11 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,8 @@ tools/rexm/rexm
132132
# CI
133133
emsdk-cache/
134134
raylib.com/
135+
136+
# Wayland files
137+
src/*protocol.h
138+
src/*protocol-code.h
139+
src/*protocol-code.c

examples/Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ USE_EXTERNAL_GLFW ?= FALSE
9595
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
9696
GLFW_LINUX_ENABLE_X11 ?= TRUE
9797

98+
# Enable support for X11 by default on Linux when using GLFW
99+
# NOTE: Wayland is disabled by default, only enable if you are sure
100+
RGFW_LINUX_ENABLE_WAYLAND ?= FALSE
101+
RGFW_LINUX_ENABLE_X11 ?= TRUE
102+
98103
# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
99104
# WARNING: Library is not included in raylib, it MUST be configured by users
100105
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
@@ -475,7 +480,15 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
475480
# Libraries for Debian GNU/Linux desktop compipling
476481
# NOTE: Required packages: libegl1-mesa-dev
477482
LDFLAGS += -L../src
478-
LDLIBS = -lraylib -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
483+
LDLIBS = -lraylib -lm
484+
485+
ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
486+
LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lpthread -ldl -lrt
487+
endif
488+
489+
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
490+
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
491+
endif
479492

480493
# Explicit link to libc
481494
ifeq ($(RAYLIB_LIBTYPE),SHARED)

src/Makefile

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ USE_EXTERNAL_GLFW ?= FALSE
115115
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
116116
GLFW_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
120125
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
@@ -289,6 +294,17 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
289294
CC = clang
290295
endif
291296
endif
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
292308
ifeq ($(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
474489
endif
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

476518
CFLAGS += $(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
667721
endif
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
668737
ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
669738
OBJS += rmodels.o
670739
endif
@@ -801,6 +870,17 @@ endif
801870
android_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

887967
clean_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
889969
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
890970
rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
891971
endif

src/external/RGFW/RGFW.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8667,13 +8667,13 @@ struct wl_surface* RGFW_window_getWindow_Wayland(RGFW_window* win) { return win-
86678667

86688668

86698669
/* wayland global garbage (wayland bad, X11 is fine (ish) (not really)) */
8670-
#include "xdg-shell.h"
8671-
#include "xdg-toplevel-icon-v1.h"
8672-
#include "xdg-decoration-unstable-v1.h"
8673-
#include "relative-pointer-unstable-v1.h"
8674-
#include "pointer-constraints-unstable-v1.h"
8675-
#include "xdg-output-unstable-v1.h"
8676-
#include "pointer-warp-v1.h"
8670+
#include "xdg-shell-client-protocol.h"
8671+
#include "xdg-toplevel-icon-v1-client-protocol.h"
8672+
#include "xdg-decoration-unstable-v1-client-protocol.h"
8673+
#include "relative-pointer-unstable-v1-client-protocol.h"
8674+
#include "pointer-constraints-unstable-v1-client-protocol.h"
8675+
#include "xdg-output-unstable-v1-client-protocol.h"
8676+
#include "pointer-warp-v1-client-protocol.h"
86778677

86788678
void RGFW_toggleWaylandMaximized(RGFW_window* win, RGFW_bool maximized);
86798679

src/platforms/rcore_desktop_rgfw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@ int InitPlatform(void)
16911691
// Close platform
16921692
void ClosePlatform(void)
16931693
{
1694+
mg_gamepads_free(&platform.minigamepad);
16941695
RGFW_window_close(platform.window);
16951696
}
16961697

0 commit comments

Comments
 (0)