Skip to content

Instantly share code, notes, and snippets.

@nazfox
Created January 29, 2022 13:24
Show Gist options
  • Save nazfox/5d38cab37bb3b9d1a2e9a3199959b152 to your computer and use it in GitHub Desktop.
Save nazfox/5d38cab37bb3b9d1a2e9a3199959b152 to your computer and use it in GitHub Desktop.
#/bin/sh
# Automatically generate .PHONY for Makefile
MAKEFILE=$1
cat $MAKEFILE | \
grep -E '^[a-zA-Z\-_0-9.]+:' | \
grep -Ev '^\.PHONY:' | \
grep -Ev '#.*NO_PHONY' | \
cut -d ':' -f 1 | tr '\n' ' ' | sed -e 's/ $/\n/g'
@nazfox
Copy link
Author

nazfox commented Jan 29, 2022

You don't want to add task to .PHONY?

Add # NO_PHONY in the same line of the task.

task: foo bar # NO_PHONY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment