Mercurial > hg > beaglert
comparison Makefile @ 388:fe2f8e00096b prerelease
merge
author | Liam Donovan <l.b.donovan@qmul.ac.uk> |
---|---|
date | Tue, 14 Jun 2016 18:09:34 +0100 |
parents | 47612dcb44de e4510c9eee94 |
children | d107cb121bfa |
comparison
equal
deleted
inserted
replaced
387:47612dcb44de | 388:fe2f8e00096b |
---|---|
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 NO_PROJECT_TARGETS=distclean stop help | 9 .DEFAULT_GOAL := Bela |
10 | |
11 NO_PROJECT_TARGETS=coreclean distclean stop help | |
10 NO_PROJECT_TARGETS_MESSAGE=PROJECT or EXAMPLE should be set for all targets except: $(NO_PROJECT_TARGETS) | 12 NO_PROJECT_TARGETS_MESSAGE=PROJECT or EXAMPLE should be set for all targets except: $(NO_PROJECT_TARGETS) |
11 # Type `$ make help` to get a description of the functionalities of this Makefile. | 13 # Type `$ make help` to get a description of the functionalities of this Makefile. |
12 help: ## Show this help | 14 help: ## Show this help |
13 @echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]' | 15 @echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]' |
14 @echo $(NO_PROJECT_TARGETS_MESSAGE) | 16 @printf "\n$(NO_PROJECT_TARGETS_MESSAGE)\n\n" |
15 @echo 'Targets: (default: Bela)' | 17 @echo 'Targets: (default: $(.DEFAULT_GOAL))' |
16 @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#' | 18 @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#' |
17 | 19 |
18 # PROJECT or EXAMPLE must be set for targets that are not included in NO_PROJECT_TARGETS | 20 # PROJECT or EXAMPLE must be set for targets that are not included in NO_PROJECT_TARGETS |
19 ifeq (,$(filter $(NO_PROJECT_TARGETS),$(MAKECMDGOALS))) | 21 ifeq (,$(filter $(NO_PROJECT_TARGETS),$(MAKECMDGOALS))) |
20 ifndef PROJECT | 22 ifndef PROJECT |
23 endif | 25 endif |
24 endif | 26 endif |
25 endif | 27 endif |
26 | 28 |
27 # if we are building an example, just copy it to the projects/ folder | 29 # if we are building an example, just copy it to the projects/ folder |
28 # and tehn treat it as a project | 30 # and then treat it as a project |
29 ifdef EXAMPLE | 31 ifdef EXAMPLE |
30 PROJECT?=exampleTempProject | 32 PROJECT?=exampleTempProject |
31 PROJECT_DIR?=$(abspath projects/$(PROJECT)) | 33 PROJECT_DIR?=$(abspath projects/$(PROJECT)) |
32 $(shell mkdir -p $(abspath projects)) | 34 $(shell mkdir -p $(abspath projects)) |
33 $(shell rm -rf $(PROJECT_DIR)) | 35 $(shell rm -rf $(PROJECT_DIR)) |
140 syntax: SYNTAX | 142 syntax: SYNTAX |
141 | 143 |
142 # Rule for Bela core C++ files | 144 # Rule for Bela core C++ files |
143 build/core/%.o: ./core/%.cpp | 145 build/core/%.o: ./core/%.cpp |
144 @echo 'Building $(notdir $<)...' | 146 @echo 'Building $(notdir $<)...' |
145 # @echo 'Invoking: C++ Compiler' | 147 # @echo 'Invoking: C++ Compiler $(CXX)' |
146 @$(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" | 148 @$(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" |
147 @echo ' ...done' | 149 @echo ' ...done' |
148 @echo ' ' | 150 @echo ' ' |
149 | 151 |
150 # Rule for Bela core ASM files | 152 # Rule for Bela core ASM files |
156 @echo ' ' | 158 @echo ' ' |
157 | 159 |
158 # Rule for user-supplied C++ files | 160 # Rule for user-supplied C++ files |
159 $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.cpp | 161 $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.cpp |
160 @echo 'Building $(notdir $<)...' | 162 @echo 'Building $(notdir $<)...' |
161 # @echo 'Invoking: C++ Compiler' | 163 @echo 'Invoking: C++ Compiler $(CXX)' |
162 @$(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" | 164 @$(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" |
163 @echo ' ...done' | 165 @echo ' ...done' |
164 @echo ' ' | 166 @echo ' ' |
165 | 167 |
166 # Rule for user-supplied C files | 168 # Rule for user-supplied C files |
167 $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.c | 169 $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.c |
168 @echo 'Building $(notdir $<)...' | 170 @echo 'Building $(notdir $<)...' |
169 # @echo 'Invoking: C Compiler' | 171 # @echo 'Invoking: C Compiler $(CC)' |
170 $(CC) $(SYNTAX_FLAG) $(INCLUDES) $(C_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" -std=c99 | 172 $(CC) $(SYNTAX_FLAG) $(INCLUDES) $(C_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" -std=c99 |
171 @echo ' ...done' | 173 @echo ' ...done' |
172 @echo ' ' | 174 @echo ' ' |
173 | 175 |
174 # Rule for user-supplied assembly files | 176 # Rule for user-supplied assembly files |
196 | 198 |
197 projectclean:## Remove the project's build objects & binary | 199 projectclean:## Remove the project's build objects & binary |
198 -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE) | 200 -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE) |
199 -@echo ' ' | 201 -@echo ' ' |
200 | 202 |
201 distclean: ## Remove all the projects and the built objects, including the core Bela objects. Use with care. | 203 clean: ## Same as projectclean |
204 clean: projectclean | |
205 | |
206 coreclean: ## Remove the core's build objects | |
207 -$(RM) build/* | |
208 | |
209 prompt: | |
210 @printf "Warning: you are about to DELETE the projects/ folder and its content. This operation cannot be undone. Continue? (y/N) " | |
211 @read REPLY; if [ $$REPLY != y ] && [ $$REPLY != Y ]; then echo "Aborting..."; exit 1; fi | |
212 | |
213 distclean: ## Restores the Bela folder to a pristine state: remove all the projects source and the built objects, including the core Bela objects. | |
214 distclean: prompt distcleannoprompt | |
215 | |
216 distcleannoprompt: ## Same as distclean, but does not prompt for confirmation. Use with care. | |
202 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE) | 217 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE) |
203 -@echo ' ' | 218 -@echo ' ' |
204 | 219 |
205 runfg: run | 220 runfg: run |
206 run: ## Run PROJECT in the foreground | 221 run: ## Run PROJECT in the foreground |
245 @$(STARTUP_COMMAND) > $(BELA_STARTUP_SCRIPT) | 260 @$(STARTUP_COMMAND) > $(BELA_STARTUP_SCRIPT) |
246 | 261 |
247 stop: ## Stops any Bela program that is currently running | 262 stop: ## Stops any Bela program that is currently running |
248 stop: | 263 stop: |
249 @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; | 264 @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; |
250 # Remove only the user-generated objects | 265 |
251 clean: projectclean | 266 .PHONY: all clean distclean help projectclean nostartup startup startuploop debug run runfg runscreen runscreenfg runscreenfifo stop |
252 | |
253 post-build: | |
254 # Nothing to do here (for now) | |
255 | |
256 .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop | |
257 .SECONDARY: post-build |