Mercurial > hg > beaglert
comparison Makefile @ 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 | 1c35a5d0ce32 |
comparison
equal
deleted
inserted
replaced
333:4edf9a840a2a | 334:ff98d79abf49 |
---|---|
102 # only wants to provide the render functions. | 102 # only wants to provide the render functions. |
103 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp | 103 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp |
104 DEFAULT_MAIN_OBJS := ./build/core/default_main.o | 104 DEFAULT_MAIN_OBJS := ./build/core/default_main.o |
105 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d | 105 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d |
106 | 106 |
107 Bela: ## Builds the Bela program with all the opimizations | |
108 Bela: $(OUTPUT_FILE) | |
109 | |
107 # all = build Bela | 110 # all = build Bela |
111 all: ## Same as Bela | |
108 all: SYNTAX_FLAG := | 112 all: SYNTAX_FLAG := |
109 all: Bela | 113 all: Bela |
110 | 114 |
111 # debug = buildBela debug | 115 # debug = buildBela debug |
116 debug: ## Same as Bela but with debug flags and no optimizations | |
112 debug: CPP_FLAGS=-g | 117 debug: CPP_FLAGS=-g |
113 debug: C_FLAGS=-g | 118 debug: C_FLAGS=-g |
114 debug: all | 119 debug: all |
115 | 120 |
116 # syntax = check syntax | 121 # syntax = check syntax |
122 syntax: ## Only checks syntax | |
117 syntax: SYNTAX_FLAG := -fsyntax-only | 123 syntax: SYNTAX_FLAG := -fsyntax-only |
118 syntax: SYNTAX | 124 syntax: SYNTAX |
119 | |
120 | |
121 | 125 |
122 # Rule for Bela core C++ files | 126 # Rule for Bela core C++ files |
123 build/core/%.o: ./core/%.cpp | 127 build/core/%.o: ./core/%.cpp |
124 @echo 'Building $(notdir $<)...' | 128 @echo 'Building $(notdir $<)...' |
125 # @echo 'Invoking: C++ Compiler' | 129 # @echo 'Invoking: C++ Compiler' |
182 # Remove all the built objects, including the core Bela objects | 186 # Remove all the built objects, including the core Bela objects |
183 distclean: | 187 distclean: |
184 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE) | 188 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE) |
185 -@echo ' ' | 189 -@echo ' ' |
186 | 190 |
187 Bela: $(OUTPUT_FILE) | |
188 | 191 |
189 runfg: run | 192 runfg: run |
193 run: ## Run PROJECT in the foreground | |
190 run: stop Bela | 194 run: stop Bela |
191 @echo "Running $(RUN_COMMAND)" | 195 @echo "Running $(RUN_COMMAND)" |
192 @cd $(PROJECT_DIR) && $(RUN_COMMAND) | 196 @cd $(PROJECT_DIR) && $(RUN_COMMAND) |
197 runscreen: ## Run PROJECT in the background (detached screen) | |
193 runscreen: stop $(OUTPUT_FILE) | 198 runscreen: stop $(OUTPUT_FILE) |
194 @echo "Running $(RUN_COMMAND) in a screen" | 199 @echo "Running $(RUN_COMMAND) in a screen" |
195 @cd $(PROJECT_DIR) && screen -S $(SCREEN_NAME) -d -m $(RUN_COMMAND) | 200 @cd $(PROJECT_DIR) && screen -S $(SCREEN_NAME) -d -m $(RUN_COMMAND) |
201 runscreenfg: ## Run PROJECT in a screen in the foreground (can detach with ctrl-a ctrl-d) | |
196 runscreenfg: stop $(OUTPUT_FILE) | 202 runscreenfg: stop $(OUTPUT_FILE) |
197 @echo "Running $(RUN_COMMAND) in a screen" | 203 @echo "Running $(RUN_COMMAND) in a screen" |
198 @cd $(PROJECT_DIR) && screen -S $(SCREEN_NAME) -m $(RUN_COMMAND) | 204 @cd $(PROJECT_DIR) && screen -S $(SCREEN_NAME) -m $(RUN_COMMAND) |
199 FIFO_NAME=/tmp/belafifo | 205 FIFO_NAME=/tmp/belafifo |
206 runscreenfifo: ## Same as runscreen, but stdout and stderr are piped to the foreground through a fifo | |
200 runscreenfifo: stop $(OUTPUT_FILE) | 207 runscreenfifo: stop $(OUTPUT_FILE) |
201 @echo "Running $(RUN_COMMAND), piping output to $(FIFO_NAME)" | 208 @echo "Running $(RUN_COMMAND), piping output to $(FIFO_NAME)" |
202 @rm -rf $(FIFO_NAME) | 209 @rm -rf $(FIFO_NAME) |
203 @mkfifo $(FIFO_NAME) | 210 @mkfifo $(FIFO_NAME) |
204 @cd $(PROJECT_DIR) | 211 @cd $(PROJECT_DIR) |
205 @screen -S $(SCREEN_NAME) -d -m stdbuf -e 0 -i 0 -o 0 bash -c "$(RUN_COMMAND) &> $(FIFO_NAME)" | 212 @screen -S $(SCREEN_NAME) -d -m stdbuf -e 0 -i 0 -o 0 bash -c "$(RUN_COMMAND) &> $(FIFO_NAME)" |
206 @cat /tmp/belafifo | 213 @cat /tmp/belafifo |
207 | 214 |
208 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" | 215 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" |
216 nostartup: ## No Bela project runs at startup | |
209 nostartup: | 217 nostartup: |
210 @echo "Disabling BeagleRT at startup..." | 218 @echo "Disabling BeagleRT at startup..." |
211 @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 | 219 @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 |
212 | 220 |
221 startuploop: ## Makes PROJECT run at startup and restarts it if it crashes | |
213 startuploop: Bela | 222 startuploop: Bela |
214 @echo "Enabling Bela at startup in a loop..." | 223 @echo "Enabling Bela at startup in a loop..." |
215 @$(STARTUP_COMMAND) 'bash -c "while sleep 0.5 ; do echo Running Bela...;' '; done"' > $(BELA_STARTUP_SCRIPT) | 224 @$(STARTUP_COMMAND) 'bash -c "while sleep 0.5 ; do echo Running Bela...;' '; done"' > $(BELA_STARTUP_SCRIPT) |
216 | 225 |
226 startup: ## Makes PROJECT run at startup | |
217 startup: Bela | 227 startup: Bela |
218 @echo "Enabling Bela at startup..." | 228 @echo "Enabling Bela at startup..." |
219 @$(STARTUP_COMMAND) > $(BELA_STARTUP_SCRIPT) | 229 @$(STARTUP_COMMAND) > $(BELA_STARTUP_SCRIPT) |
220 | 230 |
231 stop: ## Stops any Bela program that is currently running | |
221 stop: | 232 stop: |
222 @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; | 233 @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; |
223 # Remove only the user-generated objects | 234 # Remove only the user-generated objects |
224 #clean: | 235 #clean: |
225 # -$(RM) build/source/* Bela | 236 # -$(RM) build/source/* Bela |
226 # -@echo ' ' | 237 # -@echo ' ' |
227 | 238 |
228 post-build: | 239 post-build: |
229 # Nothing to do here (for now) | 240 # Nothing to do here (for now) |
241 help: ## Show this help | |
242 @echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]' | |
243 @echo 'Targets: (default: Bela)' | |
244 @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#' | |
230 | 245 |
231 .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop | 246 .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop |
232 .SECONDARY: post-build | 247 .SECONDARY: post-build |