Last active
August 31, 2016 00:30
-
-
Save htp/c9080edfded00c1dc3471a2f207615c6 to your computer and use it in GitHub Desktop.
A skeleton Makefile.
This file contains hidden or 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
.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