Skip to content

Instantly share code, notes, and snippets.

@rsperl
Last active November 6, 2025 19:55
Show Gist options
  • Save rsperl/d2dfe88a520968fbc1f49db0a29345b9 to your computer and use it in GitHub Desktop.
Save rsperl/d2dfe88a520968fbc1f49db0a29345b9 to your computer and use it in GitHub Desktop.

Revisions

  1. rsperl renamed this gist Jul 25, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. rsperl revised this gist Jan 7, 2021. 1 changed file with 21 additions and 10 deletions.
    31 changes: 21 additions & 10 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -5,16 +5,27 @@ SHELL=/bin/bash
    # the first 15 entries are the 8-bit colors

    # define standard colors
    BLACK := $(shell tput -Txterm setaf 0)
    RED := $(shell tput -Txterm setaf 1)
    GREEN := $(shell tput -Txterm setaf 2)
    YELLOW := $(shell tput -Txterm setaf 3)
    LIGHTPURPLE := $(shell tput -Txterm setaf 4)
    PURPLE := $(shell tput -Txterm setaf 5)
    BLUE := $(shell tput -Txterm setaf 6)
    WHITE := $(shell tput -Txterm setaf 7)

    RESET := $(shell tput -Txterm sgr0)
    ifneq (,$(findstring xterm,${TERM}))
    BLACK := $(shell tput -Txterm setaf 0)
    RED := $(shell tput -Txterm setaf 1)
    GREEN := $(shell tput -Txterm setaf 2)
    YELLOW := $(shell tput -Txterm setaf 3)
    LIGHTPURPLE := $(shell tput -Txterm setaf 4)
    PURPLE := $(shell tput -Txterm setaf 5)
    BLUE := $(shell tput -Txterm setaf 6)
    WHITE := $(shell tput -Txterm setaf 7)
    RESET := $(shell tput -Txterm sgr0)
    else
    BLACK := ""
    RED := ""
    GREEN := ""
    YELLOW := ""
    LIGHTPURPLE := ""
    PURPLE := ""
    BLUE := ""
    WHITE := ""
    RESET := ""
    endif

    # set target color
    TARGET_COLOR := $(BLUE)
  3. rsperl revised this gist Oct 18, 2018. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ SHELL=/bin/bash
    # bash -c 'for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; echo =$c; done'
    # the first 15 entries are the 8-bit colors

    # standard colors
    # define standard colors
    BLACK := $(shell tput -Txterm setaf 0)
    RED := $(shell tput -Txterm setaf 1)
    GREEN := $(shell tput -Txterm setaf 2)
    @@ -19,6 +19,8 @@ RESET := $(shell tput -Txterm sgr0)
    # set target color
    TARGET_COLOR := $(BLUE)

    POUND = \#

    .PHONY: no_targets__ info help build deploy doc
    no_targets__:

    @@ -46,7 +48,15 @@ job%: ## help for job with wildcard
    @echo "job $@"

    help:
    @echo "${BLACK}:: ${RED}Self-documenting Makefile${RESET} ${BLACK}::${RESET}"
    @echo ""
    @echo " ${BLACK}:: ${RED}Self-documenting Makefile${RESET} ${BLACK}::${RESET}"
    @echo ""
    @echo "Document targets by adding '$(POUND)$(POUND) comment' after the target"
    @echo ""
    @echo "Example:"
    @echo " | job1: $(POUND)$(POUND) help for job 1"
    @echo " | @echo \"run stuff for target1\""
    @echo ""
    @echo "${BLACK}-----------------------------------------------------------------${RESET}"
    @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "${TARGET_COLOR}%-30s${RESET} %s\n", $$1, $$2}'

  4. rsperl created this gist Oct 18, 2018.
    54 changes: 54 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    SHELL=/bin/bash

    # to see all colors, run
    # bash -c 'for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; echo =$c; done'
    # the first 15 entries are the 8-bit colors

    # standard colors
    BLACK := $(shell tput -Txterm setaf 0)
    RED := $(shell tput -Txterm setaf 1)
    GREEN := $(shell tput -Txterm setaf 2)
    YELLOW := $(shell tput -Txterm setaf 3)
    LIGHTPURPLE := $(shell tput -Txterm setaf 4)
    PURPLE := $(shell tput -Txterm setaf 5)
    BLUE := $(shell tput -Txterm setaf 6)
    WHITE := $(shell tput -Txterm setaf 7)

    RESET := $(shell tput -Txterm sgr0)

    # set target color
    TARGET_COLOR := $(BLUE)

    .PHONY: no_targets__ info help build deploy doc
    no_targets__:

    .DEFAULT_GOAL := help

    colors: ## show all the colors
    @echo "${BLACK}BLACK${RESET}"
    @echo "${RED}RED${RESET}"
    @echo "${GREEN}GREEN${RESET}"
    @echo "${YELLOW}YELLOW${RESET}"
    @echo "${LIGHTPURPLE}LIGHTPURPLE${RESET}"
    @echo "${PURPLE}PURPLE${RESET}"
    @echo "${BLUE}BLUE${RESET}"
    @echo "${WHITE}WHITE${RESET}"

    job1: ## help for job 1
    @echo "job 1 started"
    @$(MAKE) job2
    @echo "job 1 finished"

    job2: ## help for job 2
    @echo "job 2"

    job%: ## help for job with wildcard
    @echo "job $@"

    help:
    @echo "${BLACK}:: ${RED}Self-documenting Makefile${RESET} ${BLACK}::${RESET}"
    @echo "${BLACK}-----------------------------------------------------------------${RESET}"
    @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "${TARGET_COLOR}%-30s${RESET} %s\n", $$1, $$2}'


    # vim:noexpandtab:ts=8:sw=8:ai