Last active
October 16, 2024 18:29
-
-
Save iNamik/73fd1081fe299e3bc897d613179e4aee to your computer and use it in GitHub Desktop.
Base Makefile With Ability To List Targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Base Makefile with ability to list targets | |
# | |
.PHONY: help about list targets | |
ME := $(realpath $(firstword $(MAKEFILE_LIST))) | |
# Contains trailing '/' | |
# | |
PWD := $(dir $(ME)) | |
.DEFAULT_GOAL := help | |
## | |
# help | |
# Displays a (hopefully) useful help screen to the user | |
# | |
# NOTE: Keep 'help' as first target in case .DEFAULT_GOAL is not honored | |
# | |
help: about list ## This help screen | |
about: | |
@echo | |
@echo "Base Makefile with ability to list targets" | |
## | |
# list | |
# Displays a list of targets, using '##' comment as target description | |
# | |
# NOTE: ONLY targets with ## comments are shown | |
# | |
list: targets ## see 'targets' | |
targets: ## Lists targets | |
@echo | |
@echo "Make targets:" | |
@echo | |
@cat $(ME) | \ | |
sed -n -E 's/^([^.][^: ]+)\s*:(([^=#]*##\s*(.*[^[:space:]])\s*)|[^=].*)$$/ \1 \4/p' | \ | |
sort -u | \ | |
expand -t15 | |
@echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome!