Mercurial > hg > beaglert
changeset 386:e4510c9eee94 prerelease
Makefile: prompt for distclean, cleanup
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 14 Jun 2016 13:53:08 +0100 |
parents | fb5547fe6d99 |
children | fe2f8e00096b 814e85de67e1 |
files | Makefile |
diffstat | 1 files changed, 24 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Tue Jun 14 11:30:31 2016 +0100 +++ b/Makefile Tue Jun 14 13:53:08 2016 +0100 @@ -6,13 +6,15 @@ # This Makefile is intended for use on the BeagleBone Black itself # and not for cross-compiling -NO_PROJECT_TARGETS=distclean stop help +.DEFAULT_GOAL := Bela + +NO_PROJECT_TARGETS=coreclean distclean stop help NO_PROJECT_TARGETS_MESSAGE=PROJECT or EXAMPLE should be set for all targets except: $(NO_PROJECT_TARGETS) # Type `$ make help` to get a description of the functionalities of this Makefile. help: ## Show this help @echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]' - @echo $(NO_PROJECT_TARGETS_MESSAGE) - @echo 'Targets: (default: Bela)' + @printf "\n$(NO_PROJECT_TARGETS_MESSAGE)\n\n" + @echo 'Targets: (default: $(.DEFAULT_GOAL))' @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#' # PROJECT or EXAMPLE must be set for targets that are not included in NO_PROJECT_TARGETS @@ -25,7 +27,7 @@ endif # if we are building an example, just copy it to the projects/ folder -# and tehn treat it as a project +# and then treat it as a project ifdef EXAMPLE PROJECT?=exampleTempProject PROJECT_DIR?=$(abspath projects/$(PROJECT)) @@ -75,7 +77,6 @@ endif endif -$(warning $(COMPILER)) ifeq ($(COMPILER), clang) CC=clang CXX=clang++ @@ -142,7 +143,7 @@ # Rule for Bela core C++ files build/core/%.o: ./core/%.cpp @echo 'Building $(notdir $<)...' -# @echo 'Invoking: C++ Compiler' +# @echo 'Invoking: C++ Compiler $(CXX)' @$(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" @echo ' ...done' @echo ' ' @@ -158,7 +159,7 @@ # Rule for user-supplied C++ files $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.cpp @echo 'Building $(notdir $<)...' -# @echo 'Invoking: C++ Compiler' + @echo 'Invoking: C++ Compiler $(CXX)' @$(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" @echo ' ...done' @echo ' ' @@ -166,7 +167,7 @@ # Rule for user-supplied C files $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.c @echo 'Building $(notdir $<)...' -# @echo 'Invoking: C Compiler' +# @echo 'Invoking: C Compiler $(CC)' $(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 @echo ' ...done' @echo ' ' @@ -198,7 +199,20 @@ -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE) -@echo ' ' -distclean: ## Remove all the projects and the built objects, including the core Bela objects. Use with care. +clean: ## Same as projectclean +clean: projectclean + +coreclean: ## Remove the core's build objects + -$(RM) build/* + +prompt: + @printf "Warning: you are about to DELETE the projects/ folder and its content. This operation cannot be undone. Continue? (y/N) " + @read REPLY; if [ $$REPLY != y ] && [ $$REPLY != Y ]; then echo "Aborting..."; exit 1; fi + +distclean: ## Restores the Bela folder to a pristine state: remove all the projects source and the built objects, including the core Bela objects. +distclean: prompt distcleannoprompt + +distcleannoprompt: ## Same as distclean, but does not prompt for confirmation. Use with care. -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE) -@echo ' ' @@ -244,11 +258,5 @@ stop: ## Stops any Bela program that is currently running 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: projectclean -post-build: -# Nothing to do here (for now) - -.PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop -.SECONDARY: post-build +.PHONY: all clean distclean help projectclean nostartup startup startuploop debug run runfg runscreen runscreenfg runscreenfifo stop