Skip to content

Commit

Permalink
Makefile: Enhance and improve help
Browse files Browse the repository at this point in the history
Enhance help for undocumented targets and
improve developer usability by leveraging
inline comments, like in the other repos.
  • Loading branch information
schuellerf committed Jan 20, 2025
1 parent c136684 commit 878cc5c
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,13 @@ PACKAGE_NAME_COMMIT = image-builder-cli-$(COMMIT)
#

.PHONY: help
help:
help: ## Print this usage information
@echo "make [TARGETS...]"
@echo
@echo "This is the maintenance makefile of image-builder. The following"
@echo "targets are available:"
@echo
@echo " help: Print this usage information."
@echo " rpm: Build the RPM"
@echo " srpm: Build the source RPM"
@echo " scratch: Quick scratch build of RPM"
@echo " clean: Remove all built binaries"
@echo " lint: Run all known linters"
@awk 'match($$0, /^([a-zA-Z_\/-]+):.*? ## (.*)$$/, m) {printf " \033[36m%-30s\033[0m %s\n", m[1], m[2]}' $(MAKEFILE_LIST) | sort

$(BUILDDIR)/:
mkdir -p "$@"
Expand All @@ -102,11 +97,11 @@ $(BUILDDIR)/%/:
#

.PHONY: build
build: $(BUILDDIR)/bin/
build: $(BUILDDIR)/bin/ ## build the binary from source
go build -o $<image-builder ./cmd/image-builder/

.PHONY: clean
clean:
clean: ## Remove all built binaries
rm -rf $(BUILDDIR)/bin/
rm -rf $(CURDIR)/rpmbuild
rm -rf $(CURDIR)/release_artifacts
Expand Down Expand Up @@ -154,23 +149,23 @@ $(RPM_TARBALL) $(RPM_TARBALL_VERSIONED): $(RPM_SPECFILE)
gzip $(call get_uncompressed_name,$@)

.PHONY: srpm
srpm: $(RPM_SPECFILE) $(RPM_TARBALL)
srpm: $(RPM_SPECFILE) $(RPM_TARBALL) ## Build the source RPM
rpmbuild -bs \
--define "_topdir $(CURDIR)/rpmbuild" \
--define "commit $(COMMIT)" \
--with tests \
$(RPM_SPECFILE)

.PHONY: rpm
rpm: $(RPM_SPECFILE) $(RPM_TARBALL)
rpm: $(RPM_SPECFILE) $(RPM_TARBALL) ## Build the RPM
rpmbuild -bb \
--define "_topdir $(CURDIR)/rpmbuild" \
--define "commit $(COMMIT)" \
--with tests \
$(RPM_SPECFILE)

.PHONY: scratch
scratch: $(RPM_SPECFILE) $(RPM_TARBALL)
scratch: $(RPM_SPECFILE) $(RPM_TARBALL) ## Quick scratch build of RPM
rpmbuild -bb \
--define "_topdir $(CURDIR)/rpmbuild" \
--define "commit $(COMMIT)" \
Expand All @@ -181,13 +176,13 @@ scratch: $(RPM_SPECFILE) $(RPM_TARBALL)
RPM_TARBALL_FILENAME=$(notdir $(RPM_TARBALL))

.PHONY: release_artifacts
release_artifacts: $(RPM_TARBALL_VERSIONED)
release_artifacts: $(RPM_TARBALL_VERSIONED) ## build a release tar but with vendor directory and matching spec file
mkdir -p release_artifacts
cp $< release_artifacts/
# Print the artifact path for Packit
echo "release_artifacts/$(shell basename $<)"

lint:
lint: ## Run all known linters
pre-commit run --all

show-version: ## Show the generated version to be reused in tools like `.packit.yaml`
Expand Down

0 comments on commit 878cc5c

Please sign in to comment.