From 5d13b75b8d3d54c3babb4acc85aa3d463d639923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zag=C3=B3rowski?= Date: Mon, 8 May 2023 11:55:05 +0200 Subject: [PATCH] use pkg-config --- Makefile | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index fd6e784..a43bc3c 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,7 @@ PLUGIN_NAME=split-monitor-workspaces SOURCE_FILES=$(wildcard src/*.cpp) COMPILE_FLAGS=-g -fPIC --no-gnu-unique -std=c++23 -COMPILE_FLAGS+=-I "/usr/include/pixman-1" -COMPILE_FLAGS+=-I "/usr/include/libdrm" -COMPILE_FLAGS+=-I "${HYPRLAND_HEADERS}" -COMPILE_FLAGS+=-I "${HYPRLAND_HEADERS}/protocols" -COMPILE_FLAGS+=-I "${HYPRLAND_HEADERS}/subprojects/wlroots/include" -COMPILE_FLAGS+=-I "${HYPRLAND_HEADERS}/subprojects/wlroots/build/include" +COMPILE_FLAGS+=`pkg-config --cflags pixman-1 libdrm hyprland` COMPILE_FLAGS+=-Iinclude COMPILE_DEFINES=-DWLR_USE_UNSTABLE @@ -34,10 +29,17 @@ install: all cp $(PLUGIN_NAME).so ${HOME}/.local/share/hyprload/plugins/bin check_env: - @if [ -z "${HYPRLAND_HEADERS}" ]; then \ - echo "HYPRLAND_HEADERS not set. Please set it to the root of the hl repo directory."; \ + @if pkg-config --exists hyprland; then \ + echo 'Hyprland headers found.'; \ + else \ + echo 'Hyprland headers not available. Run `make pluginenv` in the root Hyprland directory.'; \ exit 1; \ fi + @if [ -z $(BUILT_WITH_NOXWAYLAND) ]; then \ + echo 'Building with XWayland support.'; \ + else \ + echo 'Building without XWayland support.'; \ + fi $(PLUGIN_NAME).so: $(SOURCE_FILES) $(INCLUDE_FILES) g++ -shared $(COMPILE_FLAGS) $(COMPILE_DEFINES) $(SOURCE_FILES) -o $(PLUGIN_NAME).so @@ -46,4 +48,8 @@ clean: rm -f ./$(PLUGIN_NAME).so clangd: - printf "%b" "-I/usr/include/pixman-1\n-I/usr/include/libdrm\n-I${HYPRLAND_HEADERS}\n-Iinclude\n-std=c++2b" > compile_flags.txt + echo "$(COMPILE_FLAGS) $(COMPILE_DEFINES)" | \ + sed 's/--no-gnu-unique//g' | \ + sed 's/ -/\n-/g' | \ + sed 's/std=c++23/std=c++2b/g' \ + > compile_flags.txt