changeset 334:ff98d79abf49 prerelease

Self-documenting help added to Makefile.
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 05 Jun 2016 02:30:32 +0100
parents 4edf9a840a2a
children f14dc4ac8955
files Makefile
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sat Jun 04 18:53:42 2016 +0100
+++ b/Makefile	Sun Jun 05 02:30:32 2016 +0100
@@ -104,21 +104,25 @@
 DEFAULT_MAIN_OBJS := ./build/core/default_main.o
 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d
 
+Bela: ## Builds the Bela program with all the opimizations
+Bela: $(OUTPUT_FILE)
+
 # all = build Bela 
+all: ## Same as Bela
 all: SYNTAX_FLAG :=
 all: Bela
 
 # debug = buildBela debug
+debug: ## Same as Bela but with debug flags and no optimizations
 debug: CPP_FLAGS=-g
 debug: C_FLAGS=-g
 debug: all
 
 # syntax = check syntax
+syntax: ## Only checks syntax
 syntax: SYNTAX_FLAG := -fsyntax-only
 syntax: SYNTAX
 
-
-
 # Rule for Bela core C++ files
 build/core/%.o: ./core/%.cpp
 	@echo 'Building $(notdir $<)...'
@@ -184,19 +188,22 @@
 	-$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE)
 	-@echo ' '
 
-Bela: $(OUTPUT_FILE)
 
 runfg: run
+run: ## Run PROJECT in the foreground
 run: stop Bela
 	@echo "Running $(RUN_COMMAND)"
 	@cd $(PROJECT_DIR) && $(RUN_COMMAND)
+runscreen: ## Run PROJECT in the background (detached screen)
 runscreen: stop $(OUTPUT_FILE)
 	@echo "Running $(RUN_COMMAND) in a screen"
 	@cd $(PROJECT_DIR) && screen -S $(SCREEN_NAME) -d -m $(RUN_COMMAND)
+runscreenfg: ## Run PROJECT in a screen in the foreground (can detach with ctrl-a ctrl-d)
 runscreenfg: stop $(OUTPUT_FILE)
 	@echo "Running $(RUN_COMMAND) in a screen"
 	@cd $(PROJECT_DIR) && screen -S $(SCREEN_NAME) -m $(RUN_COMMAND)
 FIFO_NAME=/tmp/belafifo
+runscreenfifo: ## Same as runscreen, but stdout and stderr are piped to the foreground through a fifo
 runscreenfifo: stop $(OUTPUT_FILE)
 	@echo "Running $(RUN_COMMAND), piping output to $(FIFO_NAME)"
 	@rm -rf $(FIFO_NAME)
@@ -206,18 +213,22 @@
 	@cat /tmp/belafifo
 
 STARTUP_COMMAND=printf "\#!/bin/sh\n\#\n\# This file is autogenerated by Bela. Do not edit!\n\necho Running Bela...\nscreen -S $(SCREEN_NAME) -d -m %s $(RUN_COMMAND) %s\n"
+nostartup: ## No Bela project runs at startup 
 nostartup:
 	@echo "Disabling BeagleRT at startup..."
 	@printf "#!/bin/sh\n#\n\n# This file is autogenerated by Bela. Do not edit!\n\n# Run on startup disabled -- nothing to do here" > $BELA_STARTUP_SCRIPT
 
+startuploop: ## Makes PROJECT run at startup and restarts it if it crashes
 startuploop: Bela
 	@echo "Enabling Bela at startup in a loop..."
 	@$(STARTUP_COMMAND) 'bash -c "while sleep 0.5 ; do echo Running Bela...;' '; done"' > $(BELA_STARTUP_SCRIPT)
 
+startup: ## Makes PROJECT run at startup
 startup: Bela
 	@echo "Enabling Bela at startup..."
 	@$(STARTUP_COMMAND) > $(BELA_STARTUP_SCRIPT)
 
+stop: ## Stops any Bela program that is currently running
 stop:
 	@PID=`grep $(BELA_AUDIO_THREAD_NAME) /proc/xenomai/stat | cut -d " " -f 5 | sed s/\s//g`; if [ -z $$PID ]; then echo "No process to kill"; else echo "Killing old Bela process $$PID"; kill -2 $$PID; fi; screen -X -S $(SCREEN_NAME) quit > /dev/null; exit 0;
 # Remove only the user-generated objects
@@ -227,6 +238,10 @@
 
 post-build:
 # Nothing to do here (for now)
+help: ## Show this help
+	@echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]'
+	@echo 'Targets: (default: Bela)'
+	@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e  's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#'
 
 .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop 
 .SECONDARY: post-build