diff options
Diffstat (limited to 'support/make/grep.mk')
-rw-r--r-- | support/make/grep.mk | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/support/make/grep.mk b/support/make/grep.mk new file mode 100644 index 0000000000..e6a78a61f5 --- /dev/null +++ b/support/make/grep.mk @@ -0,0 +1,46 @@ +############################################################-*-Makefile-*-#### +# GREP - search regular expressions +############################################################################## +# $Id$ + +############################################################################## +# Usage +# +# make grep [FLAGS=<flags>] REGEXP=<regexp> [FILES=<files>]" +# +############################################################################## +# Examples +# +# Search for "runtime" in all source files: +# +# make grep REGEXP=runtime +# +# +# Search for "runtime" in the compiler source files: +# +# make grep REGEXP=runtime FILES=\$\(COMPILER_SOURCES\) +# +############################################################################## + +############################################################################## +# Variables + +GREP_BINARY ?= $(GREP) +GREP_FLAGS ?= $(FLAGS) +GREP_REGEXP ?= $(REGEXP) +GREP_FILES ?= $(if $(FILES),$(FILES),$(PROJECT_SOURCES)) + +############################################################################## +# Rules + +grep : + @if [ -z '$(GREP_REGEXP)' ]; then \ + $(ECHO) "Usage:" \ + "$(MAKE) grep [FLAGS=<flags>] REGEXP=<regexp> [FILES=<files>]";\ + exit 1; \ + fi + @$(GREP_BINARY) $(GREP_FLAGS) '$(GREP_REGEXP)' $(GREP_FILES) + +.PHONY : grep + +############################################################################## |