annotate Makefile @ 269:ac8eb07afcf5

Oxygen text added to each render.cpp file for the default projects. Text includes project explanation from Wiki, edited in places. Empty project added as a default project. Doxyfile updated. Each of the project locations added to INPUT configuration option. Consider just watching the whole project file so all new projects are automatically pulled through.
author Robert Jack <robert.h.jack@gmail.com>
date Tue, 17 May 2016 15:40:16 +0100
parents feadb63cff32
children afdddd5f189f 48d36405e987
rev   line source
giuliomoro@64 1 # BeagleRT
giuliomoro@64 2 # Low-latency, real-time audio and sensor processing on BeagleBone Black
giuliomoro@64 3 # (c) 2015 Andrew McPherson, Victor Zappi, Giulio Moro
giuliomoro@64 4 # Centre for Digital Music, Queen Mary University of London
giuliomoro@64 5
giuliomoro@64 6 # This Makefile is intended for use on the BeagleBone Black itself
giuliomoro@64 7 # and not for cross-compiling
giuliomoro@64 8
giuliomoro@64 9 RM := rm -rf
giuliomoro@64 10 STATIC_LIBS := ./libprussdrv.a ./libNE10.a
giuliomoro@244 11 LIBS := -lrt -lnative -lxenomai -lsndfile
giuliomoro@244 12 # refresh library cache and check if libpd is there
giuliomoro@244 13 TEST_LIBPD := $(shell ldconfig; ldconfig -p | grep "libpd\.so")
giuliomoro@244 14 ifeq ($(strip $(TEST_LIBPD)), )
giuliomoro@244 15 else
giuliomoro@244 16 # if libpd is there, link it in
giuliomoro@244 17 LIBS += -lpd -lpthread_rt
giuliomoro@244 18 endif
giuliomoro@64 19
giuliomoro@241 20 CPP_FLAGS := -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize
giuliomoro@241 21 C_FLAGS := $(CPP_FLAGS)
giuliomoro@241 22
giuliomoro@241 23 ifndef COMPILER
giuliomoro@241 24 # check whether clang is installed
giuliomoro@241 25 TEST_COMPILER := $(shell which clang)
giuliomoro@241 26 ifneq ($(strip $(TEST_COMPILER)), )
giuliomoro@241 27 # if it is installed, use it
giuliomoro@241 28 COMPILER := clang
giuliomoro@241 29 else
giuliomoro@241 30 COMPILER := gcc
giuliomoro@241 31 endif
giuliomoro@241 32 endif
giuliomoro@241 33
giuliomoro@241 34 ifeq ($(COMPILER), clang)
giuliomoro@241 35 CC=clang
giuliomoro@241 36 CXX=clang++
giuliomoro@241 37 CPP_FLAGS +=
giuliomoro@244 38 C_FLAGS +=
giuliomoro@241 39 else
giuliomoro@241 40 CC=gcc
giuliomoro@241 41 CXX=g++
giuliomoro@241 42 CPP_FLAGS += --fast-math
giuliomoro@241 43 C_FLAGS += --fast-math
giuliomoro@241 44 endif
giuliomoro@241 45
giuliomoro@247 46 INCLUDES := -I./source -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
andrewm@68 47
giuliomoro@64 48 ASM_SRCS := $(wildcard source/*.S)
giuliomoro@64 49 ASM_OBJS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.o)))
giuliomoro@64 50 ASM_DEPS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.d)))
giuliomoro@64 51
giuliomoro@64 52 C_SRCS := $(wildcard source/*.c)
giuliomoro@64 53 C_OBJS := $(addprefix build/source/,$(notdir $(C_SRCS:.c=.o)))
giuliomoro@64 54 C_DEPS := $(addprefix build/source/,$(notdir $(C_SRCS:.c=.d)))
giuliomoro@64 55
giuliomoro@64 56 CPP_SRCS := $(wildcard source/*.cpp)
giuliomoro@64 57 CPP_OBJS := $(addprefix build/source/,$(notdir $(CPP_SRCS:.cpp=.o)))
giuliomoro@64 58 CPP_DEPS := $(addprefix build/source/,$(notdir $(CPP_SRCS:.cpp=.d)))
giuliomoro@64 59
giuliomoro@64 60 # Core BeagleRT sources
giuliomoro@186 61 CORE_CPP_SRCS = $(filter-out core/default_main.cpp, $(wildcard core/*.cpp))
giuliomoro@186 62 CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o)))
giuliomoro@186 63 CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d)))
giuliomoro@64 64
giuliomoro@64 65 # Objects for a system-supplied default main() file, if the user
giuliomoro@64 66 # only wants to provide the render functions.
giuliomoro@64 67 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp
giuliomoro@64 68 DEFAULT_MAIN_OBJS := ./build/core/default_main.o
giuliomoro@64 69 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d
andrewm@68 70
giuliomoro@209 71 # all = build BeagleRT
andrewm@69 72 all: SYNTAX_FLAG :=
giuliomoro@64 73 all: BeagleRT
andrewm@68 74
giuliomoro@209 75 # debug = buildBeagleRT debug
giuliomoro@209 76 debug: CPP_FLAGS=-g
giuliomoro@209 77 debug: C_FLAGS=-g
giuliomoro@209 78 debug: all
giuliomoro@209 79
andrewm@69 80 # syntax = check syntax
andrewm@69 81 syntax: SYNTAX_FLAG := -fsyntax-only
andrewm@69 82 syntax: BeagleRT
andrewm@69 83
giuliomoro@64 84 # Rule for BeagleRT core C++ files
giuliomoro@64 85 build/core/%.o: ./core/%.cpp
giuliomoro@64 86 @echo 'Building file: $<'
giuliomoro@241 87 @echo 'Invoking: C++ Compiler'
giuliomoro@241 88 $(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
giuliomoro@64 89 @echo 'Finished building: $<'
giuliomoro@64 90 @echo ' '
andrewm@68 91
giuliomoro@64 92 # Rule for user-supplied C++ files
giuliomoro@64 93 build/source/%.o: ./source/%.cpp
giuliomoro@64 94 @echo 'Building file: $<'
giuliomoro@241 95 @echo 'Invoking: C++ Compiler'
giuliomoro@241 96 $(CXX) $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
giuliomoro@64 97 @echo 'Finished building: $<'
giuliomoro@64 98 @echo ' '
andrewm@68 99
giuliomoro@64 100 # Rule for user-supplied C files
giuliomoro@64 101 build/source/%.o: ./source/%.c
giuliomoro@64 102 @echo 'Building file: $<'
giuliomoro@241 103 @echo 'Invoking: C Compiler'
giuliomoro@241 104 $(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
giuliomoro@64 105 @echo 'Finished building: $<'
giuliomoro@64 106 @echo ' '
andrewm@68 107
giuliomoro@64 108 # Rule for user-supplied assembly files
giuliomoro@64 109 build/source/%.o: ./source/%.S
giuliomoro@64 110 @echo 'Building file: $<'
giuliomoro@64 111 @echo 'Invoking: GCC Assembler'
giuliomoro@64 112 as -o "$@" "$<"
giuliomoro@64 113 @echo 'Finished building: $<'
giuliomoro@64 114 @echo ' '
giuliomoro@64 115
giuliomoro@64 116 # This is a nasty kludge: we want to be able to optionally link in a default
giuliomoro@64 117 # main file if the user hasn't supplied one. We check for the presence of the main()
giuliomoro@64 118 # function, and conditionally call one of two recursive make targets depending on whether
giuliomoro@64 119 # we want to link in the default main file or not. The kludge is the mess of a shell script
giuliomoro@64 120 # line below. Surely there's a better way to do this?
giuliomoro@64 121 BeagleRT: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 122 $(eval NEXT_TARGET := $(shell bash -c 'if [ `nm build/source/*.o | grep -w T | grep -w main | wc -l` == '0' ]; then echo "BeagleRT_with_main"; else echo "BeagleRT_without_main"; fi'))
giuliomoro@64 123 $(MAKE) $(NEXT_TARGET)
giuliomoro@64 124 @echo 'Finished building target: $@'
giuliomoro@64 125 @echo ' '
giuliomoro@64 126 # $(MAKE) --no-print-directory post-build
andrewm@68 127
giuliomoro@64 128 # Rule for building BeagleRT including the default main file (no user-supplied main())
giuliomoro@64 129 BeagleRT_with_main: $(CORE_OBJS) $(DEFAULT_MAIN_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 130 @echo 'Building target: $@'
giuliomoro@241 131 @echo 'Invoking: C++ Linker'
giuliomoro@241 132 $(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 "BeagleRT" $(CORE_OBJS) $(DEFAULT_MAIN_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(LIBS)
giuliomoro@64 133
giuliomoro@64 134 # Rule for building BeagleRT without the default main file (user-supplied main())
giuliomoro@64 135 BeagleRT_without_main: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 136 @echo 'Building target: $@'
giuliomoro@241 137 @echo 'Invoking: C++ Linker'
giuliomoro@241 138 $(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 "BeagleRT" $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(LIBS)
giuliomoro@64 139
giuliomoro@64 140 # Other Targets:
giuliomoro@64 141
giuliomoro@64 142 # Remove the temporary user-supplied source, plus the objects built from them
giuliomoro@64 143 sourceclean:
giuliomoro@64 144 -$(RM) source/* build/source/* BeagleRT
giuliomoro@64 145 -@echo ' '
giuliomoro@64 146
giuliomoro@64 147 # Remove all the built objects, including the core BeagleRT objects
giuliomoro@64 148 distclean:
giuliomoro@64 149 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) BeagleRT
giuliomoro@64 150 -@echo ' '
giuliomoro@64 151
giuliomoro@64 152 # Remove only the user-generated objects
giuliomoro@64 153 clean:
giuliomoro@64 154 -$(RM) build/source/* BeagleRT
giuliomoro@64 155 -@echo ' '
giuliomoro@64 156
giuliomoro@64 157 post-build:
giuliomoro@64 158 # Nothing to do here (for now)
giuliomoro@64 159
giuliomoro@209 160 .PHONY: all clean distclean sourceclean dependents debug
giuliomoro@64 161 .SECONDARY: post-build