From 6c9d7114e370e6dbb48753c39abe83bd986d9edf Mon Sep 17 00:00:00 2001 From: "Florine W. Dekker" Date: Fri, 24 Nov 2023 17:40:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=82=20mommy=20allows=20custom=20dirs?= =?UTF-8?q?=20during=20make~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++- GNUmakefile | 98 +++++++++++++++++++++++++++------------------------- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9940d..81f442b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ * 📈 mommy now explains how to integrate with nushell, thanks to [aemogie.](https://github.com/aemogie)~ ([#65](https://github.com/FWDekker/mommy/issues/65)) ### changed -* 💨 mommy is now much faster at doing her exams~ ([#69](https://github.com/FWDekker/mommy/pull/69)) +* 🍳 mommy uses newer github actions, thanks to [zopolis4](https://github.com/Zopolis4)~ ([#68](https://github.com/FWDekker/mommy/pull/68)) +* 💨 mommy became much faster at doing her exams~ ([#69](https://github.com/FWDekker/mommy/pull/69)) +* 📂 mommy supports specifying a custom directory during `make`~ ([#70](https://github.com/FWDekker/mommy/pull/70)) ## [1.2.4] -- 2023-08-28 diff --git a/GNUmakefile b/GNUmakefile index 0d2fba8..33dae3e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,8 @@ -# Target locations +# Build file locations +build_dir := build/ +dist_dir := dist/ + +# Install locations prefix := /usr/ bin_prefix := $(prefix)/bin/ man_prefix := $(prefix)/share/man/ @@ -26,7 +30,7 @@ list: # Clean up previous builds .PHONY: clean clean: - @rm -rf build/ dist/ + @rm -rf "$(build_dir)" "$(dist_dir)" ## Tests @@ -39,37 +43,37 @@ test/%: @MOMMY_SYSTEM="$(system)" MOMMY_MAKE="$(MAKE)" shellspec "src/test/sh/$(@:test/%=%)_spec.sh" -## "Compile" files into `build/` +## "Compile" source files into '$(build_dir)' along a simple prefix layout .PHONY: build build: @# Copy relevant files - @mkdir -p build/bin/; cp src/main/sh/mommy build/bin/ - @mkdir -p build/man/man1/; cp src/main/man/man1/mommy.1 build/man/man1/ - @mkdir -p build/completions/fish/; cp src/main/completions/fish/mommy.fish build/completions/fish/ - @mkdir -p build/completions/zsh/; cp src/main/completions/zsh/_mommy build/completions/zsh/ + @mkdir -p "$(build_dir)/bin/"; cp src/main/sh/mommy "$(build_dir)/bin/" + @mkdir -p "$(build_dir)/man/man1/"; cp src/main/man/man1/mommy.1 "$(build_dir)/man/man1/" + @mkdir -p "$(build_dir)/completions/fish/"; cp src/main/completions/fish/mommy.fish "$(build_dir)/completions/fish/" + @mkdir -p "$(build_dir)/completions/zsh/"; cp src/main/completions/zsh/_mommy "$(build_dir)/completions/zsh/" @# Insert version information @sed -i".bak" "s/%%VERSION_NUMBER%%/$(version)/g;s/%%VERSION_DATE%%/$(date)/g" \ - build/bin/mommy \ - build/man/man1/mommy.1 - @rm -f build/bin/mommy.bak build/man/man1/mommy.1.bak + "$(build_dir)/bin/mommy" \ + "$(build_dir)/man/man1/mommy.1" + @rm -f "$(build_dir)/bin/mommy.bak" "$(build_dir)/man/man1/mommy.1.bak" @# Compress - @gzip -f build/man/man1/mommy.1 + @gzip -f "$(build_dir)/man/man1/mommy.1" ## Installation -# Copy built files into appropriate directories +# Copy built files into prefix-appropriate directories .PHONY: install install: build @# Create directories @install -m 755 -d "$(bin_prefix)" "$(man_prefix)/man1/" "$(fish_prefix)" "$(zsh_prefix)" @# Copy files - @install -m 755 build/bin/mommy "$(bin_prefix)" - @install -m 644 build/man/man1/mommy.1.gz "$(man_prefix)/man1/" - @install -m 644 build/completions/fish/mommy.fish "$(fish_prefix)" - @install -m 644 build/completions/zsh/_mommy "$(zsh_prefix)" + @install -m 755 "$(build_dir)/bin/mommy" "$(bin_prefix)" + @install -m 644 "$(build_dir)/man/man1/mommy.1.gz" "$(man_prefix)/man1/" + @install -m 644 "$(build_dir)/completions/fish/mommy.fish" "$(fish_prefix)" + @install -m 644 "$(build_dir)/completions/zsh/_mommy" "$(zsh_prefix)" # Install with preset overrides, as specified later .PHONY: install/% @@ -100,25 +104,25 @@ fpm: build ifndef fpm_target $(error fpm_target is undefined) endif - @mkdir -p dist + @mkdir -p "$(dist_dir)" @fpm -t "$(fpm_target)" \ - -p "dist/mommy-$(version).$(fpm_target)" \ + -p "$(dist_dir)/mommy-$(version).$(fpm_target)" \ --version "$(version)" \ \ - "build/bin/mommy=$(bin_prefix)/mommy" \ - "build/man/man1/mommy.1.gz=$(man_prefix)/man1/mommy.1.gz" \ - "build/completions/fish/mommy.fish=$(fish_prefix)/mommy.fish" \ - "build/completions/zsh/_mommy=$(zsh_prefix)/_mommy" + "$(build_dir)/bin/mommy=$(bin_prefix)/mommy" \ + "$(build_dir)/man/man1/mommy.1.gz=$(man_prefix)/man1/mommy.1.gz" \ + "$(build_dir)/completions/fish/mommy.fish=$(fish_prefix)/mommy.fish" \ + "$(build_dir)/completions/zsh/_mommy=$(zsh_prefix)/_mommy" # Build generic extractable package -dist/generic: prefix = ./build/generic/mommy/usr/ +dist/generic: prefix = $(build_dir)/generic/mommy-$(version)/usr/ dist/generic: - @rm -rf build/generic/ + @rm -rf "$(build_dir)/generic/" @$(MAKE) prefix="$(prefix)" install - @mkdir -p dist/ - @tar -C build/generic/ -czf "dist/mommy-$(version)+generic.tar.gz" ./ + @mkdir -p "$(dist_dir)" + @tar -C "$(build_dir)/generic/" -czf "$(dist_dir)/mommy-$(version)+generic.tar.gz" ./ # Build Debian package with fpm dist/deb: zsh_prefix = $(prefix)/share/zsh/vendor-completions/ @@ -135,7 +139,7 @@ dist/osxpkg: @$(MAKE) fpm_target=osxpkg prefix="$(prefix)" fpm @# `installer` program requires `pkg` extension - @mv dist/*.osxpkg "dist/mommy-$(version)+osx.pkg" + @mv "$(dist_dir)/"*".osxpkg" "$(dist_dir)/mommy-$(version)+osx.pkg" # Build FreeBSD package with fpm %/freebsd: prefix = /usr/local/ @@ -143,26 +147,26 @@ dist/freebsd: @$(MAKE) fpm_target=freebsd prefix="$(prefix)" fpm # Build NetBSD package manually -%/netbsd: prefix = build/netbsd/usr/pkg/ +%/netbsd: prefix = $(build_dir)/netbsd/usr/pkg/ %/netbsd: man_prefix = $(prefix)/man/ dist/netbsd: @$(MAKE) prefix="$(prefix)" man_prefix="$(man_prefix)" install - @cd build/netbsd; find . -type f | sed -e "s/^/.\//" > +CONTENTS + @cd "$(build_dir)/netbsd"; find . -type f | sed -e "s/^/.\//" > +CONTENTS - @echo "$(comment)" > build/netbsd/+COMMENT + @echo "$(comment)" > "$(build_dir)/netbsd/+COMMENT" - @echo "$(comment)" > build/netbsd/+DESC - @echo "" >> build/netbsd/+DESC - @echo "Maintainer: $(maintainer)" >> build/netbsd/+DESC + @echo "$(comment)" > "$(build_dir)/netbsd/+DESC" + @echo "" >> "$(build_dir)/netbsd/+DESC" + @echo "Maintainer: $(maintainer)" >> "$(build_dir)/netbsd/+DESC" - @echo "MACHINE_ARCH=$$(uname -p)" > build/netbsd/+BUILD_INFO - @echo "OPSYS=$$(uname)" >> build/netbsd/+BUILD_INFO - @echo "OS_VERSION=$$(uname -r)" >> build/netbsd/+BUILD_INFO - @echo "PKGTOOLS_VERSION=$$(pkg_create -V)" >> build/netbsd/+BUILD_INFO + @echo "MACHINE_ARCH=$$(uname -p)" > "$(build_dir)/netbsd/+BUILD_INFO" + @echo "OPSYS=$$(uname)" >> "$(build_dir)/netbsd/+BUILD_INFO" + @echo "OS_VERSION=$$(uname -r)" >> "$(build_dir)/netbsd/+BUILD_INFO" + @echo "PKGTOOLS_VERSION=$$(pkg_create -V)" >> "$(build_dir)/netbsd/+BUILD_INFO" - @cd build/netbsd; \ + @cd "$(build_dir)/netbsd"; \ pkg_create \ -B +BUILD_INFO \ -c +COMMENT \ @@ -172,23 +176,23 @@ dist/netbsd: -p . \ "mommy-$(version)+netbsd.tgz" - @mkdir -p dist/ - @mv build/netbsd/mommy*.tgz dist/ + @mkdir -p "$(dist_dir)" + @mv "$(build_dir)/netbsd/mommy-$(version)+netbsd.tgz" "$(dist_dir)" # Build OpenBSD package manually -%/openbsd: prefix = build/openbsd/usr/local/ +%/openbsd: prefix = $(build_dir)/openbsd/usr/local/ %/openbsd: man_prefix = $(prefix)/man/ dist/openbsd: @$(MAKE) prefix="$(prefix)" man_prefix="$(man_prefix)" install - @cd build/openbsd; find . -type f | sed -e "s/^/.\//" > +CONTENTS + @cd "$(build_dir)/openbsd"; find . -type f | sed -e "s/^/.\//" > +CONTENTS - @echo "$(comment)" > build/openbsd/+COMMENT + @echo "$(comment)" > "$(build_dir)/openbsd/+COMMENT" - @echo "$(comment)" > build/openbsd/+DESC + @echo "$(comment)" > "$(build_dir)/openbsd/+DESC" - @cd build/openbsd; \ + @cd "$(build_dir)/openbsd"; \ pkg_create \ -d +DESC \ -D COMMENT="$(comment)" \ @@ -199,5 +203,5 @@ dist/openbsd: -p / \ "mommy-$(version)+openbsd.tgz" - @mkdir -p dist/ - @mv build/openbsd/mommy*.tgz dist/ + @mkdir -p "$(dist_dir)" + @mv "$(build_dir)/openbsd/mommy-$(version)+openbsd.tgz" "$(dist_dir)"