summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--support/make/exec.mk42
2 files changed, 43 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 41cbf5ee25..f5b6ee9218 100644
--- a/Makefile
+++ b/Makefile
@@ -120,6 +120,7 @@ compiler : .latest-compiler
##############################################################################
+include $(ROOT)/support/make/exec.mk
include $(ROOT)/support/make/grep.mk
##############################################################################
diff --git a/support/make/exec.mk b/support/make/exec.mk
new file mode 100644
index 0000000000..b0f9c518a1
--- /dev/null
+++ b/support/make/exec.mk
@@ -0,0 +1,42 @@
+############################################################-*-Makefile-*-####
+# EXEC - Execute Command
+##############################################################################
+# $Id$
+
+##############################################################################
+# Usage
+#
+# make exec CMD=<command>
+#
+##############################################################################
+# Examples
+#
+# Print names of all source files:
+#
+# make exec CMD='echo $(PROJECT_SOURCES)'
+#
+#
+# Execute a java program with the project classpath:
+#
+# make exec CMD='java -cp $(PROJECT_CLASSPATH) scalac.Main'
+#
+##############################################################################
+
+##############################################################################
+# Variables
+
+EXEC_CMD ?= $(CMD)
+
+##############################################################################
+# Rules
+
+exec :
+ @if [ -z '$(EXEC_CMD)' ]; then \
+ $(ECHO) "Usage: $(MAKE) $@ CMD=<command>"; \
+ exit 1; \
+ fi
+ @$(EXEC_CMD)
+
+.PHONY : exec
+
+##############################################################################