comparison Makefile @ 385:fb5547fe6d99 prerelease

Updated Makefile docs and defaulting to clang if available
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 14 Jun 2016 11:30:31 +0100
parents e42bc9ba7550
children e4510c9eee94 47612dcb44de
comparison
equal deleted inserted replaced
384:59fbea44696a 385:fb5547fe6d99
4 # Centre for Digital Music, Queen Mary University of London 4 # Centre for Digital Music, Queen Mary University of London
5 5
6 # This Makefile is intended for use on the BeagleBone Black itself 6 # This Makefile is intended for use on the BeagleBone Black itself
7 # and not for cross-compiling 7 # and not for cross-compiling
8 8
9 # set the project to be compiled by calling: make all PROJECT=<project_name> 9 NO_PROJECT_TARGETS=distclean stop help
10 10 NO_PROJECT_TARGETS_MESSAGE=PROJECT or EXAMPLE should be set for all targets except: $(NO_PROJECT_TARGETS)
11 # if the PROJECT variable is not set, throw an error and exit 11 # Type `$ make help` to get a description of the functionalities of this Makefile.
12 # otherwise, we could have unexpected data loss when calling clean without it 12 help: ## Show this help
13 NO_PROJECT_TARGETS=distclean stop 13 @echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]'
14 @echo $(NO_PROJECT_TARGETS_MESSAGE)
15 @echo 'Targets: (default: Bela)'
16 @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#'
17
18 # PROJECT or EXAMPLE must be set for targets that are not included in NO_PROJECT_TARGETS
14 ifeq (,$(filter $(NO_PROJECT_TARGETS),$(MAKECMDGOALS))) 19 ifeq (,$(filter $(NO_PROJECT_TARGETS),$(MAKECMDGOALS)))
15 ifndef PROJECT 20 ifndef PROJECT
16 ifndef EXAMPLE 21 ifndef EXAMPLE
17 $(error PROJECT or EXAMPLE should be set when the target is not one of: `$(NO_PROJECT_TARGETS)`) 22 $(error $(NO_PROJECT_TARGETS_MESSAGE))
18 endif 23 endif
19 endif 24 endif
20 endif 25 endif
21 26
22 # if we are building an example, just copy it to the projects/ folder 27 # if we are building an example, just copy it to the projects/ folder
59 CPP_FLAGS := -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize 64 CPP_FLAGS := -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize
60 C_FLAGS := $(CPP_FLAGS) 65 C_FLAGS := $(CPP_FLAGS)
61 66
62 ifndef COMPILER 67 ifndef COMPILER
63 # check whether clang is installed 68 # check whether clang is installed
64 # TEST_COMPILER := $(shell which clang) 69 TEST_COMPILER := $(shell which clang)
65 ifneq ($(strip $(TEST_COMPILER)), ) 70 ifneq ($(strip $(TEST_COMPILER)), )
66 if it is installed, use it 71 #if it is installed, use it
67 COMPILER := clang 72 COMPILER := clang
68 else 73 else
69 COMPILER := gcc 74 COMPILER := gcc
70 endif 75 endif
71 endif 76 endif
72 77
78 $(warning $(COMPILER))
73 ifeq ($(COMPILER), clang) 79 ifeq ($(COMPILER), clang)
74 CC=clang 80 CC=clang
75 CXX=clang++ 81 CXX=clang++
76 CPP_FLAGS += -DNDEBUG 82 CPP_FLAGS += -DNDEBUG
77 C_FLAGS += -DNDEBUG 83 C_FLAGS += -DNDEBUG
186 @sync 192 @sync
187 # Other Targets: 193 # Other Targets:
188 # This rule compiles c and c++ source files without output or linking 194 # This rule compiles c and c++ source files without output or linking
189 SYNTAX: $(C_OBJS) $(CPP_OBJS) 195 SYNTAX: $(C_OBJS) $(CPP_OBJS)
190 196
191 # Remove the project's build objects & binary 197 projectclean:## Remove the project's build objects & binary
192 projectclean:
193 -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE) 198 -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE)
194 -@echo ' ' 199 -@echo ' '
195 200
196 # Remove all the built objects, including the core Bela objects 201 distclean: ## Remove all the projects and the built objects, including the core Bela objects. Use with care.
197 distclean:
198 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE) 202 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE)
199 -@echo ' ' 203 -@echo ' '
200
201 204
202 runfg: run 205 runfg: run
203 run: ## Run PROJECT in the foreground 206 run: ## Run PROJECT in the foreground
204 run: stop Bela 207 run: stop Bela
205 @echo "Running $(RUN_COMMAND)" 208 @echo "Running $(RUN_COMMAND)"
240 243
241 stop: ## Stops any Bela program that is currently running 244 stop: ## Stops any Bela program that is currently running
242 stop: 245 stop:
243 @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; 246 @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;
244 # Remove only the user-generated objects 247 # Remove only the user-generated objects
245 #clean: 248 clean: projectclean
246 # -$(RM) build/source/* Bela
247 # -@echo ' '
248 249
249 post-build: 250 post-build:
250 # Nothing to do here (for now) 251 # Nothing to do here (for now)
251 help: ## Show this help
252 @echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]'
253 @echo 'Targets: (default: Bela)'
254 @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#'
255 252
256 .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop 253 .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop
257 .SECONDARY: post-build 254 .SECONDARY: post-build