Skip to content

Commit

Permalink
🧹 mommy cleans up her makefile~
Browse files Browse the repository at this point in the history
  • Loading branch information
FWDekker committed Nov 25, 2023
1 parent 0d5b346 commit 70e2924
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ indent_size = 2

[GNUmakefile]
indent_style = tab

[debian.rules]
indent_style = tab
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs:
- name: Checkout mommy
uses: actions/checkout@v4
with:
# Checkout to subdirectory is required for 'pkg/rpm/rpkg.conf' to correctly determine '${git_props:root}'
# Checkout to subdirectory is required for 'pkg/fpm/rpkg.conf' to correctly determine '${git_props:root}'
path: mommy
- name: Test script
working-directory: ./mommy/
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
working-directory: ./mommy/
run: |
echo "::group::Build"
rpkg -p ./pkg/rpm local # build srpm
rpkg -p ./pkg/fpm local # build srpm
rpmbuild --rebuild /tmp/rpkg/mommy-*/*.rpm
echo "::endgroup::"
Expand Down Expand Up @@ -348,8 +348,8 @@ jobs:
echo "::endgroup::"
echo "::group::Install ShellSpec"
git clone --depth=1 https://github.com/shellspec/shellspec.git
gmake -C shellspec install
git clone --depth=1 https://github.com/shellspec/shellspec.git /tmp/shellspec
gmake -C /tmp/shellspec install
echo "::endgroup::"
echo "::group::Install additional shells"
Expand Down
74 changes: 35 additions & 39 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
## Configuration
# Variables are passed to sub-makes because of 'export'. Additionally, sub-makes never override their super-makes
# because of assignment using '?='.

export

# Build file locations
build_dir := build/
dist_dir := dist/
build_dir ?= build/
dist_dir ?= dist/

# Install locations
prefix := /usr/
bin_prefix := $(prefix)/bin/
man_prefix := $(prefix)/share/man/
fish_prefix := $(prefix)/share/fish/vendor_completions.d/
zsh_prefix := $(prefix)/share/zsh/site-functions/
prefix ?= /usr/
bin_prefix ?= $(prefix)/bin/
man_prefix ?= $(prefix)/share/man/
fish_prefix ?= $(prefix)/share/fish/vendor_completions.d/
zsh_prefix ?= $(prefix)/share/zsh/site-functions/

# Other locations
shellspec_bin := shellspec
shellspec_bin ?= shellspec

# Extracted values
version := $(shell head -n 1 version)
date := $(shell tail -n 1 version)
version ?= $(shell head -n 1 version)
date ?= $(shell tail -n 1 version)

comment := $(shell grep -- "--description" .fpm | tr -d "\"" | cut -d " " -f 2-)
maintainer := $(shell grep -- "--maintainer" .fpm | tr -d "\"" | cut -d " " -f 2-)
comment ?= $(shell grep -- "--description" .fpm | tr -d "\"" | cut -d " " -f 2-)
maintainer ?= $(shell grep -- "--maintainer" .fpm | tr -d "\"" | cut -d " " -f 2-)


## Meta
Expand Down Expand Up @@ -56,7 +62,8 @@ build:
@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" \
@sed -i".bak" \
"s/%%VERSION_NUMBER%%/$(version)/g;s/%%VERSION_DATE%%/$(date)/g" \
"$(build_dir)/bin/mommy" \
"$(build_dir)/man/man1/mommy.1"
@rm -f "$(build_dir)/bin/mommy.bak" "$(build_dir)/man/man1/mommy.1.bak"
Expand All @@ -83,6 +90,8 @@ install: build
install/%: install
@#


## Uninstallation
# Remove installed files
.PHONY: uninstall
uninstall:
Expand All @@ -97,11 +106,11 @@ uninstall/%: uninstall
@#


## Build packages
## Build distributable packages
.PHONY: dist/%

# Invoke fpm on built files to create `fpm_target` type output
# For valid `fpm_target`s, see https://fpm.readthedocs.io/en/latest/packaging-types.html
# Invoke fpm on built files to create 'fpm_target' type output
# For valid 'fpm_target's, see https://fpm.readthedocs.io/en/latest/packaging-types.html
.PHONY: fpm
fpm: build
ifndef fpm_target
Expand All @@ -122,39 +131,28 @@ dist/generic: prefix = $(build_dir)/generic/mommy-$(version)/usr/
dist/generic:
@rm -rf "$(build_dir)/generic/"

@$(MAKE) prefix="$(prefix)" install
@$(MAKE) install

@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/
dist/deb:
@$(MAKE) fpm_target=deb zsh_prefix="$(zsh_prefix)" fpm

# Build AlpineLinux / Debian / ArchLinux / RedHat package with fpm
dist/apk dist/pacman dist/rpm:
# Build AlpineLinux / Debian / FreeBSD / ArchLinux / RedHat package with fpm
%/deb: zsh_prefix = $(prefix)/share/zsh/vendor-completions/
%/freebsd: prefix = /usr/local/
dist/apk dist/deb dist/freebsd dist/pacman dist/rpm:
@$(MAKE) fpm_target="$(@:dist/%=%)" fpm

# Build macOS package with fpm
%/osxpkg: prefix = /usr/local/
dist/osxpkg:
@$(MAKE) fpm_target=osxpkg prefix="$(prefix)" fpm

@# `installer` program requires `pkg` extension
%/osxpkg: fpm_target = osxpkg
dist/osxpkg: fpm
@# 'installer' program requires 'pkg' extension
@mv "$(dist_dir)/"*".osxpkg" "$(dist_dir)/mommy-$(version)+osx.pkg"

# Build FreeBSD package with fpm
%/freebsd: prefix = /usr/local/
dist/freebsd:
@$(MAKE) fpm_target=freebsd prefix="$(prefix)" fpm

# Build NetBSD package manually
%/netbsd: prefix = $(build_dir)/netbsd/usr/pkg/
%/netbsd: man_prefix = $(prefix)/man/
dist/netbsd:
@$(MAKE) prefix="$(prefix)" man_prefix="$(man_prefix)" install

dist/netbsd: install
@cd "$(build_dir)/netbsd"; find . -type f | sed -e "s/^/.\//" > +CONTENTS

@echo "$(comment)" > "$(build_dir)/netbsd/+COMMENT"
Expand Down Expand Up @@ -185,9 +183,7 @@ dist/netbsd:
# Build OpenBSD package manually
%/openbsd: prefix = $(build_dir)/openbsd/usr/local/
%/openbsd: man_prefix = $(prefix)/man/
dist/openbsd:
@$(MAKE) prefix="$(prefix)" man_prefix="$(man_prefix)" install

dist/openbsd: install
@cd "$(build_dir)/openbsd"; find . -type f | sed -e "s/^/.\//" > +CONTENTS

@echo "$(comment)" > "$(build_dir)/openbsd/+COMMENT"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ unfortunately, packages for macos, netbsd, and openbsd cannot be built on system
a service builds mommy on-demand on each release, and makes the created packages available for all users.
currently, this happens only for fedora/epel at [copr](https://copr.fedorainfracloud.org/coprs/fwdekker/mommy/).
the relevant build files are hosted in
[mommy's `pkg/rpm/` directory](https://github.com/FWDekker/mommy/tree/main/pkg/rpm/)~
[mommy's `pkg/fpm/` directory](https://github.com/FWDekker/mommy/tree/main/pkg/fpm/)~
</details>
<details>
Expand All @@ -697,7 +697,7 @@ every merge into `main` automatically build and releases a new version~
* **before merging into `main`**
* update `version`~
* update `pkg/rpm/mommy.spec.rpkg` if changes were made to the packaging~
* update `pkg/fpm/mommy.spec.rpkg` if changes were made to the packaging~
* update release number~
* update change log~
* update `CHANGELOG.md`~
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions pkg/fpm/rpkg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[rpkg]
user_macros = "${git_props:root}/pkg/fpm/rpkg.macros"
File renamed without changes.
2 changes: 0 additions & 2 deletions pkg/rpm/rpkg.conf

This file was deleted.

0 comments on commit 70e2924

Please sign in to comment.