Skip to content

Instantly share code, notes, and snippets.

@htp

htp/Makefile

Last active Aug 31, 2016
Embed
What would you like to do?
A skeleton Makefile.
.DEFAULT_GOAL = targets
# List available targets.
.PHONY: targets
targets:
@echo Available targets are:
@echo
@awk -v default_goal=$(.DEFAULT_GOAL) '/^# / { \
description = substr($$0, 3); \
line = ""; \
location = 0; \
\
while ((getline line) > 0) { \
location = match(line, /^[^.:]+/); \
\
if (location > 0) { \
break; \
} \
} \
\
target = substr(line, RSTART, RLENGTH); \
\
if (target == default_goal) { \
printf " %-7s %s \033[1mThis is the default target.\033[0m\n", target, description; \
} \
else { \
printf " %-7s %s\n", target, description; \
} \
\
}' $(MAKEFILE_LIST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment