Mercurial > hg > beaglert
view Makefile @ 289:156e6955ccf6 prerelease
Updated heavy render to latest Heavy API
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 21 May 2016 15:20:06 +0100 |
parents | 4815ed0f21de |
children | e63d35c6ae96 |
line wrap: on
line source
# BeagleRT # Low-latency, real-time audio and sensor processing on BeagleBone Black # (c) 2016 Andrew McPherson, Victor Zappi, Giulio Moro, Liam Donovan # Centre for Digital Music, Queen Mary University of London # 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=<project_name> # if the PROJECT variable is not set, throw an error and exit # otherwise, we could have unexpected data loss when calling clean without it ifndef PROJECT ifndef EXAMPLE $(error PROJECT or EXAMPLE should be set) endif endif ifndef EXAMPLE PROJECT_DIR := $(abspath projects/$(PROJECT)) endif ifdef EXAMPLE PROJECT?=exampleTempProject PROJECT_DIR?=$(abspath projects/$(PROJECT)) $(shell rm -rf $(PROJECT_DIR)) $(shell cp -r examples/$(EXAMPLE) $(PROJECT_DIR)) EXAMPLE:=that endif $(shell mkdir -p $(PROJECT_DIR)/build) RM := rm -rf STATIC_LIBS := ./libprussdrv.a ./libNE10.a LIBS := -lrt -lnative -lxenomai -lsndfile # refresh library cache and check if libpd is there TEST_LIBPD := $(shell ldconfig; ldconfig -p | grep "libpd\.so") ifeq ($(strip $(TEST_LIBPD)), ) else # if libpd is there, link it in LIBS += -lpd -lpthread_rt endif CPP_FLAGS := -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize C_FLAGS := $(CPP_FLAGS) 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 COMPILER := gcc endif endif ifeq ($(COMPILER), clang) CC=clang CXX=clang++ CPP_FLAGS += C_FLAGS += else CC=gcc CXX=g++ CPP_FLAGS += --fast-math C_FLAGS += --fast-math endif INCLUDES := -I$(PROJECT_DIR) -I./include -I/usr/include/ne10 -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10 ASM_SRCS := $(wildcard $(PROJECT_DIR)/*.S) ASM_OBJS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(ASM_SRCS:.S=.o))) ASM_DEPS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(ASM_SRCS:.S=.d))) C_SRCS := $(wildcard $(PROJECT_DIR)/*.c) C_OBJS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(C_SRCS:.c=.o))) C_DEPS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(C_SRCS:.c=.d))) CPP_SRCS := $(wildcard $(PROJECT_DIR)/*.cpp) CPP_OBJS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.o))) CPP_DEPS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.d))) # Core BeagleRT sources CORE_CPP_SRCS = $(filter-out core/default_main.cpp, $(wildcard core/*.cpp)) CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o))) CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d))) # Objects for a system-supplied default main() file, if the user # only wants to provide the render functions. DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp DEFAULT_MAIN_OBJS := ./build/core/default_main.o DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d # all = build BeagleRT all: SYNTAX_FLAG := all: BeagleRT # debug = buildBeagleRT debug debug: CPP_FLAGS=-g debug: C_FLAGS=-g debug: all # syntax = check syntax syntax: SYNTAX_FLAG := -fsyntax-only syntax: SYNTAX # Rule for BeagleRT core C++ files build/core/%.o: ./core/%.cpp @echo 'Building $(notdir $<)...' # @echo 'Invoking: C++ Compiler' @$(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 ' ' # Rule for user-supplied C++ files $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.cpp @echo 'Building $(notdir $<)...' # @echo 'Invoking: C++ Compiler' @$(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 ' ' # Rule for user-supplied C files $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.c @echo 'Building $(notdir $<)...' # @echo 'Invoking: C Compiler' $(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 ' ' # Rule for user-supplied assembly files $(PROJECT_DIR)/build/%.o: $(PROJECT_DIR)/%.S @echo 'Building $(notdir $<)...' # @echo 'Invoking: GCC Assembler' @as -o "$@" "$<" @echo ' ...done' @echo ' ' # This is a nasty kludge: we want to be able to optionally link in a default # main file if the user hasn't supplied one. We check for the presence of the main() # function, and conditionally call one of two recursive make targets depending on whether # we want to link in the default main file or not. The kludge is the mess of a shell script # line below. Surely there's a better way to do this? BeagleRT: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS) $(eval DEFAULT_MAIN_CONDITIONAL := $(shell bash -c 'if [ `nm $(PROJECT_DIR)/build/*.o | grep -w T | grep -w main | wc -l` == '0' ]; then echo "$(DEFAULT_MAIN_OBJS)"; else echo ""; fi')) @echo 'Invoking: C++ linker' @$(CXX) $(SYNTAX_FLAG) -L/usr/xenomai/lib -L/usr/arm-linux-gnueabihf/lib -L/usr/arm-linux-gnueabihf/lib/xenomai -L/usr/lib/arm-linux-gnueabihf -pthread -Wpointer-arith -o "$(PROJECT_DIR)/$(PROJECT)" $(CORE_OBJS) $(DEFAULT_MAIN_CONDITIONAL) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(LIBS) @echo 'Finished building target: $@' # Other Targets: # 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: -$(RM) $(PROJECT_DIR)/build/* $(PROJECT_DIR)/$(PROJECT) -@echo ' ' # Remove all the built objects, including the core BeagleRT objects distclean: -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) BeagleRT -@echo ' ' OUTPUT_FILE="$(PROJECT_DIR)/$(PROJECT)" $(OUTPUT_FILE): BeagleRT run: $(OUTPUT_FILE) @echo "Running $(OUTPUT_FILE)" @$(OUTPUT_FILE) # Remove only the user-generated objects #clean: # -$(RM) build/source/* BeagleRT # -@echo ' ' post-build: # Nothing to do here (for now) .PHONY: all clean distclean projectclean dependents debug run .SECONDARY: post-build