comparison Makefile @ 331:cfdf0003e6e8 prerelease

Makefile can now do startup and startuploop
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 04 Jun 2016 16:17:06 +0100
parents ccfcf1303f12
children 4edf9a840a2a
comparison
equal deleted inserted replaced
330:276a8517da13 331:cfdf0003e6e8
24 PROJECT?=exampleTempProject 24 PROJECT?=exampleTempProject
25 PROJECT_DIR?=$(abspath projects/$(PROJECT)) 25 PROJECT_DIR?=$(abspath projects/$(PROJECT))
26 $(shell rm -rf $(PROJECT_DIR)) 26 $(shell rm -rf $(PROJECT_DIR))
27 $(shell cp -r examples/$(EXAMPLE) $(PROJECT_DIR)) 27 $(shell cp -r examples/$(EXAMPLE) $(PROJECT_DIR))
28 endif 28 endif
29 OUTPUT_FILE=$(PROJECT_DIR)/$(PROJECT) 29 OUTPUT_FILE?=$(PROJECT_DIR)/$(PROJECT)
30 COMMAND_LINE_OPTIONS=$(CL) 30 COMMAND_LINE_OPTIONS?=$(CL)
31 RUN_COMMAND=$(OUTPUT_FILE) $(COMMAND_LINE_OPTIONS) 31 RUN_COMMAND?=$(OUTPUT_FILE) $(COMMAND_LINE_OPTIONS)
32 32 BELA_STARTUP_SCRIPT?=/root/BeagleRT_startup.sh
33 BELA_AUDIO_THREAD_NAME?=beaglert-audio
33 SCREEN_NAME?=BeagleRT 34 SCREEN_NAME?=BeagleRT
34 35
35 #TODO: run these lines only if the command is not syntax or 36 #TODO: run these lines only if the command is not syntax or
36 $(shell mkdir -p $(PROJECT_DIR)/build) 37 $(shell mkdir -p $(PROJECT_DIR)/build)
37 RM := rm -rf 38 RM := rm -rf
202 @mkfifo $(FIFO_NAME) 203 @mkfifo $(FIFO_NAME)
203 @cd $(PROJECT_DIR) 204 @cd $(PROJECT_DIR)
204 @screen -S $(SCREEN_NAME) -d -m stdbuf -e 0 -i 0 -o 0 bash -c "$(RUN_COMMAND) &> $(FIFO_NAME)" 205 @screen -S $(SCREEN_NAME) -d -m stdbuf -e 0 -i 0 -o 0 bash -c "$(RUN_COMMAND) &> $(FIFO_NAME)"
205 @cat /tmp/belafifo 206 @cat /tmp/belafifo
206 207
207 BELA_AUDIO_THREAD_NAME=beaglert-audio 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"
209 nostartup:
210 @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
212
213 startuploop: Bela
214 @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)
216
217 startup: Bela
218 @echo "Enabling Bela at startup..."
219 @$(STARTUP_COMMAND) > $(BELA_STARTUP_SCRIPT)
220
208 stop: 221 stop:
209 @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; 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;
210 # Remove only the user-generated objects 223 # Remove only the user-generated objects
211 #clean: 224 #clean:
212 # -$(RM) build/source/* Bela 225 # -$(RM) build/source/* Bela