changeset 302:b26e7c61e3b6 prerelease

Makefile can now stop processes 'make stop'
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 27 May 2016 17:28:24 +0100
parents e4392164b458
children 421a69d42943 d2b7df6b355b
files Makefile
diffstat 1 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Fri May 27 14:34:41 2016 +0100
+++ b/Makefile	Fri May 27 17:28:24 2016 +0100
@@ -12,7 +12,7 @@
 # otherwise, we could have unexpected data loss when calling clean without it
 ifndef PROJECT
   ifndef EXAMPLE
-    $(error PROJECT or EXAMPLE should be set)
+    $(warning PROJECT or EXAMPLE should be set in order to build)
   endif
 endif
 
@@ -28,6 +28,8 @@
   EXAMPLE:=that
 endif
 
+SCREEN_NAME?=BeagleRT
+
 $(shell mkdir -p $(PROJECT_DIR)/build)
 RM := rm -rf
 STATIC_LIBS := ./libprussdrv.a ./libNE10.a
@@ -44,22 +46,23 @@
 CPP_FLAGS := -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize 
 C_FLAGS := $(CPP_FLAGS)
 
+COMPILER=clang
 ifndef COMPILER
 # check whether clang is installed
 #    TEST_COMPILER := $(shell which clang)
-#  ifneq ($(strip $(TEST_COMPILER)), )
-    # if it is installed, use it
-#    COMPILER := clang
-#  else
+  ifneq ($(strip $(TEST_COMPILER)), )
+    if it is installed, use it
+    COMPILER := clang
+  else
     COMPILER := gcc
-#  endif
+  endif
 endif
 
 ifeq ($(COMPILER), clang)
-  CC=clang
-  CXX=clang++
-  CPP_FLAGS +=
-  C_FLAGS +=
+  CC=/root/clang/bin/clang
+  CXX=/root/clang/bin/clang++
+  CPP_FLAGS += -DNDEBUG 
+  C_FLAGS += -DNDEBUG
 else
   CC=gcc
   CXX=g++
@@ -105,6 +108,8 @@
 syntax: SYNTAX_FLAG := -fsyntax-only
 syntax: SYNTAX
 
+
+
 # Rule for Bela core C++ files
 build/core/%.o: ./core/%.cpp
 	@echo 'Building $(notdir $<)...'
@@ -164,11 +169,18 @@
 OUTPUT_FILE="$(PROJECT_DIR)/$(PROJECT)"
 
 $(OUTPUT_FILE): Bela
+runfg: run
 run: $(OUTPUT_FILE)
 	@echo "Running $(OUTPUT_FILE)"
 	@$(OUTPUT_FILE)
-	
-	
+
+runscreen: stop $(OUTPUT_FILE)
+runscreen:
+	@echo "Running $(OUTPUT_FILE) in a screen"
+
+BELA_AUDIO_THREAD_NAME=beaglert-audio 
+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
 #clean:
 #	-$(RM) build/source/* Bela