Updated Makefile

Added new PHONY all. Target will be ran by default and will check if
submodules have been initialised (error is provided if no).

Git submodule commands for each target and corresponding recipe has been
removed in favour of simpler setup.

Fixed bug with most app targets. The target is now the specific binary
in each build. This means that if a build fails it can run again.

Targets also have required prerequisites.
This commit is contained in:
Ethan Smith-Coss 2024-06-19 23:12:53 +01:00
parent c7b7893837
commit 8a4b7fa3b2
Signed by: TheOnePath
GPG Key ID: 1D351CCC6D01F32B

View File

@ -5,7 +5,7 @@ MESON=/usr/bin/meson
INCLUDE_SYS_PATH=/usr/include INCLUDE_SYS_PATH=/usr/include
# Set the default target to build # Set the default target to build
.DEFAULT_GOAL := build .DEFAULT_GOAL := all
### Makefile targets for hyprwm libraries ### ### Makefile targets for hyprwm libraries ###
@ -37,13 +37,8 @@ $(__Hyprcursor): $(__Tomlplusplus) $(__Hyprlang)
# Build hyprutils if the .hpp file is not installed # Build hyprutils if the .hpp file is not installed
# Library for hyprwm # Library for hyprwm
.PHONY : hyprutils
hyprutils:
git submodule init
git submodule update --remote hyprutils
__Hyprutils = $(INCLUDE_SYS_PATH)/hyprutils __Hyprutils = $(INCLUDE_SYS_PATH)/hyprutils
$(__Hyprutils): $(__Hyprutils):
@[[ -z "$(ls -A hyprutils)" ]] && $(MAKE) hyprutils
$(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \ $(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/usr -S hyprutils -B ./hyprutils/build -DCMAKE_INSTALL_PREFIX:PATH=/usr -S hyprutils -B ./hyprutils/build
$(CMAKE) --build ./hyprutils/build --config Release --target all -j`nproc \ $(CMAKE) --build ./hyprutils/build --config Release --target all -j`nproc \
@ -52,13 +47,8 @@ $(__Hyprutils):
# Build hyprlang if the .hpp file is not installed # Build hyprlang if the .hpp file is not installed
# Library for hyprwm # Library for hyprwm
.PHONY : hyprlang
hyprlang:
git submodule init
git submodule update --remote hyprlang
__Hyprlang = $(INCLUDE_SYS_PATH)/hyprlang.hpp __Hyprlang = $(INCLUDE_SYS_PATH)/hyprlang.hpp
$(__Hyprlang): $(__Hyprutils) $(__Hyprlang): $(__Hyprutils)
@[[ -z "$(ls -A hyprlang)" ]] && $(MAKE) hyprlang
# built using cmake # built using cmake
$(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \ $(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/usr -S ./hyprlang -B ./hyprlang/build -DCMAKE_INSTALL_PREFIX:PATH=/usr -S ./hyprlang -B ./hyprlang/build
@ -68,13 +58,8 @@ $(__Hyprlang): $(__Hyprutils)
@echo "Installing library hyprlang..." @echo "Installing library hyprlang..."
sudo $(CMAKE) --install ./hyprlang/build sudo $(CMAKE) --install ./hyprlang/build
.PHONY : hyprwayland-scanner
hyprwayland-scanner:
git submodule init
git submodule update --remote hyprwayland-scanner
__Hyprwayland-scanner = /usr/lib64/cmake/hyprwayland-scanner __Hyprwayland-scanner = /usr/lib64/cmake/hyprwayland-scanner
$(__Hyprwayland-scanner): $(__Hyprwayland-scanner):
@[[ -z "$(ls -A hyprwayland-scanner)" ]] && $(MAKE) hyprwayland-scanner
$(CMAKE) -DCMAKE_INSTALL_PREFIX=/usr -S ./hyprwayland-scanner \ $(CMAKE) -DCMAKE_INSTALL_PREFIX=/usr -S ./hyprwayland-scanner \
-B hyprwayland-scanner/build -B hyprwayland-scanner/build
$(CMAKE) --build ./hyprwayland-scanner/build -j \ $(CMAKE) --build ./hyprwayland-scanner/build -j \
@ -82,14 +67,11 @@ $(__Hyprwayland-scanner):
@echo "Installing library hyprwayland-scanner..." @echo "Installing library hyprwayland-scanner..."
sudo $(CMAKE) --install ./hyprwayland-scanner/build sudo $(CMAKE) --install ./hyprwayland-scanner/build
## :@TODO: install libxcb-errors
.PHONY : libxcb-errors
libxcb-errors: libxcb-errors:
git clone https://gitlab.freedesktop.org/xorg/lib/libxcb-errors.git git clone https://gitlab.freedesktop.org/xorg/lib/libxcb-errors.git
__Libxcb-errors = /usr/lib/pkgconfig/xcb-errors.pc __Libxcb-errors = /usr/lib/pkgconfig/xcb-errors.pc
$(__Libxcb-errors): $(__Libxcb-errors): libxcb-errors
@echo "Building and install library libxcb-errors..." @echo "Building and install library libxcb-errors..."
@[[ -z "$(ls -A libxcb-errors)" ]] && $(MAKE) libxcb-errors
cd libxcb-errors && { \ cd libxcb-errors && { \
git submodule update --init ; \ git submodule update --init ; \
/bin/sh autogen.sh ; \ /bin/sh autogen.sh ; \
@ -99,54 +81,44 @@ $(__Libxcb-errors):
### Makefile targets for hyprwm apps ### ### Makefile targets for hyprwm apps ###
# Build Hyprland if it's not installed on the system # Build Hyprland if it's not installed on the system
.PHONY : Hyprland __Hyprland = Hyprland/build/Hyprland
Hyprland:
git submodule init
git submodule update --recursive --remote Hyprland
__Hyprland = Hyprland/build
$(__Hyprland): $(__Hyprlang) $(__Hyprcursor) $(__Hyprwayland-scanner) \ $(__Hyprland): $(__Hyprlang) $(__Hyprcursor) $(__Hyprwayland-scanner) \
$(__Libxcb-errors) $(__Libxcb-errors)
@[[ -z "$(ls -A Hyprland)" ]] && $(MAKE) Hyprland @echo "Building Hyprland..."
sudo $(MAKE) -C Hyprland all sudo $(MAKE) -C Hyprland all
# Build hyprlock if it's not installed on the system # Build hyprlock if it's not installed on the system
.PHONY : hyprlock __Hyprlock = hyprlock/build/hyprlock
hyprlock:
git submodule init
git submodule update --remote hyprlock
__Hyprlock = hyprlock/build
$(__Hyprlock): $(__Hyprlang) $(__Hyprlock): $(__Hyprlang)
@[[ -z "$(ls -A hyprlock)" ]] && $(MAKE) hyprlock @echo "Building hyprlock..."
$(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \ $(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \
-S ./hyprlock -B ./hyprlock/build -S ./hyprlock -B ./hyprlock/build
$(CMAKE) --build ./hyprlock/build --config Release --target hyprlock \ $(CMAKE) --build ./hyprlock/build --config Release --target hyprlock \
-j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF` -j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF`
# Build hyprpaper if it's not installed on the system # Build hyprpaper if it's not installed on the system
.PHONY : hyprpaper __Hyprpaper = hyprpaper/build/hyprpaper
hyprpaper:
git submodule init
git submodule update --init --recursive --remote hyprpaper
__Hyprpaper = hyprpaper/build
$(__Hyprpaper): $(__Hyprlang) $(__Hyprpaper): $(__Hyprlang)
@[[ -z "$(ls -A hyprpaper)" ]] && $(MAKE) hyprpaper @echo "Building hyprpaper..."
$(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \ $(CMAKE) --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/usr -S ./hyprpaper -B ./hyprpaper/build -DCMAKE_INSTALL_PREFIX:PATH=/usr -S ./hyprpaper -B ./hyprpaper/build
$(CMAKE) --build ./hyprpaper/build --config Release --target hyprpaper \ $(CMAKE) --build ./hyprpaper/build --config Release --target hyprpaper \
-j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF` -j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF`
# Build wl-clipboard if it's not installed on the system # Build wl-clipboard if it's not installed on the system
.PHONY : wl-clipboard __Wl_clipboard = wl-clipboard/build/src/$(wildcard wl-*)
wl-clipboard:
git submodule init
git submodule update --remote wl-clipboard
__Wl_clipboard = wl-clipboard/build
$(__Wl_clipboard): $(__Wl_clipboard):
@[[ -z "$(ls -A wl-clipboard)" ]] && $(MAKE) wl-clipboard
cd wl-clipboard && $(MESON) setup --prefix=/usr build cd wl-clipboard && $(MESON) setup --prefix=/usr build
ninja -C wl-clipboard/build ninja -C wl-clipboard/build
### PHONY targets that a user would run ### ### PHONY targets that a user would run ###
.PHONY : all
all:
@[[ -z "$(git submodule status | grep --quiet '^-')" ]] && \
$(error "Git submodules have not been initialised. Please run: git "+\
"submodule update --init.")
$(MAKE) build
.PHONY : build .PHONY : build
build: $(__Hyprlock) $(__Hyprpaper) $(__Wl-clipboard) $(__Hyprland) build: $(__Hyprlock) $(__Hyprpaper) $(__Wl-clipboard) $(__Hyprland)
@ -159,7 +131,7 @@ install: build
@echo "Installing wl-clipboard" @echo "Installing wl-clipboard"
sudo $(MESON) install -C wl-clipboard/build sudo $(MESON) install -C wl-clipboard/build
@echo "Installing Hyprland" @echo "Installing Hyprland"
sudo $(MAKE) -C install sudo $(MAKE) -C Hyprland install
.PHONY: test .PHONY: test