# HG changeset patch # User Giulio Moro # Date 1465900231 -3600 # Node ID fb5547fe6d99a38ca4489fe7b688dfadcc3ed05a # Parent 59fbea44696ac208c9c27f06e369ca167ffac570 Updated Makefile docs and defaulting to clang if available diff -r 59fbea44696a -r fb5547fe6d99 Makefile --- a/Makefile Tue Jun 14 11:29:51 2016 +0100 +++ b/Makefile Tue Jun 14 11:30:31 2016 +0100 @@ -6,15 +6,20 @@ # This Makefile is intended for use on the BeagleBone Black itself # and not for cross-compiling -# set the project to be compiled by calling: make all PROJECT= +NO_PROJECT_TARGETS=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)' + @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#' -# if the PROJECT variable is not set, throw an error and exit -# otherwise, we could have unexpected data loss when calling clean without it -NO_PROJECT_TARGETS=distclean stop +# PROJECT or EXAMPLE must be set for targets that are not included in NO_PROJECT_TARGETS ifeq (,$(filter $(NO_PROJECT_TARGETS),$(MAKECMDGOALS))) ifndef PROJECT ifndef EXAMPLE - $(error PROJECT or EXAMPLE should be set when the target is not one of: `$(NO_PROJECT_TARGETS)`) + $(error $(NO_PROJECT_TARGETS_MESSAGE)) endif endif endif @@ -61,15 +66,16 @@ ifndef COMPILER # check whether clang is installed -# TEST_COMPILER := $(shell which clang) + TEST_COMPILER := $(shell which clang) ifneq ($(strip $(TEST_COMPILER)), ) - if it is installed, use it + #if it is installed, use it COMPILER := clang else COMPILER := gcc endif endif +$(warning $(COMPILER)) ifeq ($(COMPILER), clang) CC=clang CXX=clang++ @@ -188,17 +194,14 @@ # This rule compiles c and c++ source files without output or linking SYNTAX: $(C_OBJS) $(CPP_OBJS) -# Remove the project's build objects & binary -projectclean: +projectclean:## Remove the project's build objects & binary -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE) -@echo ' ' -# Remove all the built objects, including the core Bela objects -distclean: +distclean: ## Remove all the projects and the built objects, including the core Bela objects. Use with care. -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE) -@echo ' ' - runfg: run run: ## Run PROJECT in the foreground run: stop Bela @@ -242,16 +245,10 @@ 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 -# -@echo ' ' +clean: projectclean post-build: # Nothing to do here (for now) -help: ## Show this help - @echo 'Usage: make [target] CL=[command line options] [PROJECT=[projectName] | EXAMPLE=[exampleName]]' - @echo 'Targets: (default: Bela)' - @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#' .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop .SECONDARY: post-build