The makefile-utils is helpful for developing with make
command.
It provides a series of Makefile Targets for enhancing your Makefile.
Read tags for versions. The versions follow the rules of Semantic Versioning 2.0.0.
You can install it by curl
or git
.
VERSION=v0.4.1
curl -LO "https://github.com/adoyle-h/makefile-utils/releases/download/$VERSION/makefile-utils.tgz{,.md5}"
# Check files integrity
md5sum -c ./*.md5
tar -xzf ./makefile-utils.tgz
VERSION=v0.4.1
git clone --depth 1 --branch "$VERSION" https://github.com/adoyle-h/makefile-utils.git
cd makefile-utils
make init OUTPUT=your_project
or
cd makefile-utils
sudo ln -s $PWD/bin/makefile-utils /usr/local/bin/
makefile-utils init your_project
It will do:
- Create 'makefile-utils' directory in your project.
- Add
include ./makefile-utils/*.mk
to your Makefile. You can delete these files that you won't use. - Add
.DEFAULT_GOAL := help
to your Makefile if.DEFAULT_GOAL
not defined in Makefile.
- Then run
make
equals tomake help
. - You can skip it via
make init OUTPUT=your_project DEFAULT_TARGET=
ormakefile-utils init your_project ''
.
- Add
/makefile-utils/*
and!/makefile-utils/*.mk
to your .gitignore if this file existed. - Add
[{Makefile,*.mk}] indent_style = tab
to your .editorconfig if this file existed.
Now cd
to your project and run make help
to show usage.
By default, it only shows target name. Add @desc {description}
at the previous line of target for printing description.
It does not print target defined with makefile functions like $(target):
. But you can add @target {name} {description}
in Makefile.
make semver-major
only print next major version. And also the make semver-minor
and make semver-patch
.
You can call the target in other targets.
For example, to replace VERSION=v...
in README file.
# @target bump-major bump major version (x)
# @target bump-minor bump minor version (y)
# @target bump-patch bump patch version (z)
BUMP_TARGETS := $(addprefix bump-,major minor patch)
.PHONY: $(BUMP_TARGETS)
$(BUMP_TARGETS):
@$(MAKE) $(subst bump-,semver-,$@) > VERSION
@sed -i.bak -E "s/^VERSION=.+/VERSION=v$$(cat VERSION)/" README.md
@rm README.md.bak VERSION
To generate a CHANGELOG file and update it.
Do not run make CHANGELOG
directly. Add below codes in your Makefile.
.PHONY: changelog
changelog:
$(MAKE) CHANGELOG NEXT_VERSION=$(shell cat VERSION)
To update the CHANGELOG, just echo "0.1.0" > VERSION
and run make changelog
.
You can preview the example of generated CHANGELOG. Read the Makefile of makefile-utils for reference.
You can change the output of CHANGELOG file.
.PHONY: changelog
changelog:
$(MAKE) CHANGELOG NEXT_VERSION=0.1.0 OUTPUT=change_log.md
To generate .md5 file for each files in the specified directory.
Defaults to the files in ./dist
. But you can change it by make md5 DIST=./dist
.
Checks the md5 of the file in the specified directory.
Defaults to the files in ./dist
. But you can change it by make md5 DIST=./dist
.
Check dead links in markdown files with lychee.
Copy the lychee.toml
to your project.
You can exclude urls by .lycheeignore
. example.
To avoid getting rate-limited while checking GitHub links. You can set GITHUB_TOKEN=xxx make md-check-links
.
The github token can be generated in your GitHub account settings page.
A personal token with no extra permissions is enough to be able to check public repos links.
More handy makefile targets will be added later.
Welcome to talk requirements with me in Discussion.
Before opening new Issue/Discussion/PR and posting any comments, please read Contributing Guidelines.
Copyright 2023 ADoyle ([email protected]). Some Rights Reserved. The project is licensed under the Apache License Version 2.0.
See the LICENSE file for the specific language governing permissions and limitations under the License.
See the NOTICE file distributed with this work for additional information regarding copyright ownership.
- Other shell projects created by me.