Last active
April 10, 2024 20:08
-
-
Save eduardosilva/eeb8da3acd37499b5ce7bd164c4a8d68 to your computer and use it in GitHub Desktop.
Makefile template
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
################################################################################ | |
# Makefile Configuration for Debugging | |
################################################################################ | |
# This Makefile configuration allows for conditional debugging output during the | |
# execution of 'make' commands. Debugging output includes information such as | |
# the start of Makefile execution, the goals being executed, and the current date | |
# and time. When not in debug mode, the Makefile suppresses echoing of recipes. | |
# Set DBG_MAKEFILE to 1 to enable debugging output. | |
# Example usage: | |
# 1. Exporting the variable: | |
# export DBG_MAKEFILE=1 | |
# make [target] | |
# | |
# 2. Passing the variable directly: | |
# DBG_MAKEFILE=1 make [target] | |
# | |
# Replace [target] with the desired target to build. | |
DBG_MAKEFILE ?= | |
ifeq ($(DBG_MAKEFILE),1) | |
# If DBG_MAKEFILE is set to 1, emit debugging output. | |
$(warning ***** starting Makefile for goal(s) "$(MAKECMDGOALS)") | |
$(warning ***** $(shell date)) | |
else | |
# If DBG_MAKEFILE is not set or set to any other value, suppress echoing of recipes. | |
MAKEFLAGS += -s | |
endif | |
## CONFIGURATIONS | |
# Define ANSI color escape sequences | |
COLOR_RESET = \033[0m | |
COLOR_RED = \033[0;31m | |
COLOR_GREEN = \033[0;32m | |
COLOR_YELLOW = \033[0;33m | |
COLOR_BLUE = \033[0;34m | |
COLOR_MAGENTA = \033[0;35m | |
COLOR_CYAN = \033[0;36m | |
COLOR_WHITE = \033[0;37m | |
# Define your targets and commands | |
all: | |
@echo "$(COLOR_GREEN)Building...$(COLOR_RESET)" | |
# Your build commands here | |
@echo "$(COLOR_GREEN)Build finished!$(COLOR_RESET)" | |
clean: | |
@echo "$(COLOR_YELLOW)Cleaning...$(COLOR_RESET)" | |
# Your clean commands here | |
@echo "$(COLOR_YELLOW)Clean finished!$(COLOR_RESET)" | |
help: ## Help file | |
@echo "Available targets:" | |
@grep -E '^[^ .]+:' Makefile | \ | |
sed -e 's/\\//' | \ | |
grep -v 'https' | \ | |
sort | \ | |
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | |
.PHONY: all clean help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment