A curiously uncommon build framework... π§
uncommon-build is a set of handcrafted GNU Makefile includes for building
software projects. It may be installed as a git submodule to enable your
project Makefiles to be more trim, elegant, and classy. π€΅ββοΈ
- An initialized
gitrepo - Ability to create a file in this repo:
.uncommon-build-init.mk - GNU
makecommand - Bash shell
bashcommand must be available- Not necessarily as your default shell
- POSIX shell utilities:
sed,grep,echo,cd,rm,mkdir,awk,sort,find,xargs,basename
The simple way to accomplish this, naturally, is to add the following file to
your repo: .uncommon-build-init.mk $^{...You\ \textbf{\textit{doOo}
\ have\ a\ git\ repo\ already,\ yes?}$
curl -Ls -o .uncommon-build-init.mk https://bit.ly/3K5HcJOThen, one must simply π€ add the following line to your Makefile:
include .uncommon-build-init.mkThis single include line should generally be placed at the top of your
Makefile. However, if one wishes to configure any variables or
override defaults, then one must do so before including main.mk.
Finally, one must run:
make stylishThis short GNU Makefile code snippet creates a target + recipe, stylish
to install via make stylish. It's recommended to use the dot . prefix for
.uncommon-build-init.mk, so the installation is as unobtrusive and tucked
away as possible. This also allows for an elegant one-liner in your main
Makefile: include .uncommon-build-init.mk
The recipe checks for existence of .uncommon-build, and installs it if
not found.
If .uncommon-build is found, the .gitmodules definition is updated.
If the .uncommon-build directory is missing the submodule will be added for
you, and will be automatically committed.
Default Targets: This Makefile framework creates some basic targets for
use when building Docker images:
help: Output all make targets with help text. Hint: Add your own help text by appending## Help text here, Or prevent a target from showing up inhelpby appending:## no-helpto the recipe definition line (e.g.:foo: foo.c ## no-help)build: Builds the Docker imagesave-image: Saves the Docker image viadocker save. Output defaults to:$(top_builddir)/.uncommon-build-stamps/$(REPO_NAME).tarpush: Pushes the Docker image to a Registry. Default:docker.io/$(REPO_NAME):$(IMAGE_TAG)whereIMAGE_TAGis a 12-character short commit SHAcompile: Compile the project's source files.
Language Specific Includes: When using specific programming languages,
set $(PROJECT_LANG) before including main.mk. The list of supported
languages will grow over time. Currently supported languages are:
go: GoLang
To automatically update uncommon-build to latest, run:
make update-uncommon-buildThis target executes the following steps:
- Change directory into the
.uncommon-buildsubmodule folder:cd .uncommon-build - Fetch & Update the
gitsubmodule to latest - Commit the
.uncommon-buildand.gitmodulesfile changes.
NOTE: If you need to update uncommon-build to some version
different than origin/main branch, set the UNCOMMON_BUILD_REF variable.
This accepts any git ref.
For example: a branch name, tag, or commit SHA.