annotate Makefile @ 72:d837fb676977

Documentation updates and include Arduino-type constants in Utilities.h
author andrewm
date Fri, 17 Jul 2015 20:09:50 +0100
parents f3251851c718
children 39962292dfb4
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@64 11 LIBS := -lrt -lnative -lxenomai
giuliomoro@64 12
andrewm@68 13 INCLUDES := -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 14
andrewm@68 15
giuliomoro@64 16 ASM_SRCS := $(wildcard source/*.S)
giuliomoro@64 17 ASM_OBJS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.o)))
giuliomoro@64 18 ASM_DEPS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.d)))
giuliomoro@64 19
giuliomoro@64 20 C_SRCS := $(wildcard source/*.c)
giuliomoro@64 21 C_OBJS := $(addprefix build/source/,$(notdir $(C_SRCS:.c=.o)))
giuliomoro@64 22 C_DEPS := $(addprefix build/source/,$(notdir $(C_SRCS:.c=.d)))
giuliomoro@64 23
giuliomoro@64 24 CPP_SRCS := $(wildcard source/*.cpp)
giuliomoro@64 25 CPP_OBJS := $(addprefix build/source/,$(notdir $(CPP_SRCS:.cpp=.o)))
giuliomoro@64 26 CPP_DEPS := $(addprefix build/source/,$(notdir $(CPP_SRCS:.cpp=.d)))
giuliomoro@64 27
giuliomoro@64 28 # Core BeagleRT sources
giuliomoro@64 29 CORE_CPP_SRCS := \
giuliomoro@64 30 ./core/GPIOcontrol.cpp \
giuliomoro@64 31 ./core/I2c_Codec.cpp \
giuliomoro@64 32 ./core/PRU.cpp \
giuliomoro@64 33 ./core/RTAudio.cpp \
giuliomoro@64 34 ./core/RTAudioCommandLine.cpp \
giuliomoro@64 35 ./core/Utilities.cpp \
andrewm@70 36 ./core/UdpClient.cpp \
giuliomoro@64 37 ./core/client.cpp
giuliomoro@64 38
giuliomoro@64 39 CORE_OBJS := \
giuliomoro@64 40 ./build/core/GPIOcontrol.o \
giuliomoro@64 41 ./build/core/I2c_Codec.o \
giuliomoro@64 42 ./build/core/PRU.o \
giuliomoro@64 43 ./build/core/RTAudio.o \
giuliomoro@64 44 ./build/core/RTAudioCommandLine.o \
giuliomoro@64 45 ./build/core/Utilities.o \
andrewm@70 46 ./build/core/UdpClient.o \
giuliomoro@64 47 ./build/core/client.o
giuliomoro@64 48
giuliomoro@64 49 CORE_CPP_DEPS := \
giuliomoro@64 50 ./build/core/GPIOcontrol.d \
giuliomoro@64 51 ./build/core/I2c_Codec.d \
giuliomoro@64 52 ./build/core/PRU.d \
giuliomoro@64 53 ./build/core/RTAudio.d \
giuliomoro@64 54 ./build/core/RTAudioCommandLine.d \
giuliomoro@64 55 ./build/core/Utilities.d \
andrewm@70 56 ./build/core/UdpClient.d \
giuliomoro@64 57 ./build/core/client.d
giuliomoro@64 58
giuliomoro@64 59 # Objects for a system-supplied default main() file, if the user
giuliomoro@64 60 # only wants to provide the render functions.
giuliomoro@64 61 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp
giuliomoro@64 62 DEFAULT_MAIN_OBJS := ./build/core/default_main.o
giuliomoro@64 63 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d
andrewm@68 64
giuliomoro@64 65 # All = build BeagleRT
andrewm@69 66 all: SYNTAX_FLAG :=
giuliomoro@64 67 all: BeagleRT
andrewm@68 68
andrewm@69 69 # syntax = check syntax
andrewm@69 70 syntax: SYNTAX_FLAG := -fsyntax-only
andrewm@69 71 syntax: BeagleRT
andrewm@69 72
giuliomoro@64 73 # Rule for BeagleRT core C++ files
giuliomoro@64 74 build/core/%.o: ./core/%.cpp
giuliomoro@64 75 @echo 'Building file: $<'
giuliomoro@64 76 @echo 'Invoking: GCC C++ Compiler'
andrewm@69 77 g++ $(SYNTAX_FLAG) $(INCLUDES) -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
giuliomoro@64 78 @echo 'Finished building: $<'
giuliomoro@64 79 @echo ' '
andrewm@68 80
giuliomoro@64 81 # Rule for user-supplied C++ files
giuliomoro@64 82 build/source/%.o: ./source/%.cpp
giuliomoro@64 83 @echo 'Building file: $<'
giuliomoro@64 84 @echo 'Invoking: GCC C++ Compiler'
andrewm@69 85 g++ $(SYNTAX_FLAG) -I./include $(INCLUDES) -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
giuliomoro@64 86 @echo 'Finished building: $<'
giuliomoro@64 87 @echo ' '
andrewm@68 88
giuliomoro@64 89 # Rule for user-supplied C files
giuliomoro@64 90 build/source/%.o: ./source/%.c
giuliomoro@64 91 @echo 'Building file: $<'
giuliomoro@64 92 @echo 'Invoking: GCC C Compiler'
andrewm@69 93 gcc $(SYNTAX_FLAG) -I./include $(INCLUDES) -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
giuliomoro@64 94 @echo 'Finished building: $<'
giuliomoro@64 95 @echo ' '
andrewm@68 96
giuliomoro@64 97 # Rule for user-supplied assembly files
giuliomoro@64 98 build/source/%.o: ./source/%.S
giuliomoro@64 99 @echo 'Building file: $<'
giuliomoro@64 100 @echo 'Invoking: GCC Assembler'
giuliomoro@64 101 as -o "$@" "$<"
giuliomoro@64 102 @echo 'Finished building: $<'
giuliomoro@64 103 @echo ' '
giuliomoro@64 104
giuliomoro@64 105 # This is a nasty kludge: we want to be able to optionally link in a default
giuliomoro@64 106 # main file if the user hasn't supplied one. We check for the presence of the main()
giuliomoro@64 107 # function, and conditionally call one of two recursive make targets depending on whether
giuliomoro@64 108 # we want to link in the default main file or not. The kludge is the mess of a shell script
giuliomoro@64 109 # line below. Surely there's a better way to do this?
giuliomoro@64 110 BeagleRT: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 111 $(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 112 $(MAKE) $(NEXT_TARGET)
giuliomoro@64 113 @echo 'Finished building target: $@'
giuliomoro@64 114 @echo ' '
giuliomoro@64 115 # $(MAKE) --no-print-directory post-build
andrewm@68 116
giuliomoro@64 117 # Rule for building BeagleRT including the default main file (no user-supplied main())
giuliomoro@64 118 BeagleRT_with_main: $(CORE_OBJS) $(DEFAULT_MAIN_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 119 @echo 'Building target: $@'
giuliomoro@64 120 @echo 'Invoking: GCC C++ Linker'
andrewm@69 121 g++ $(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 122
giuliomoro@64 123 # Rule for building BeagleRT without the default main file (user-supplied main())
giuliomoro@64 124 BeagleRT_without_main: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 125 @echo 'Building target: $@'
giuliomoro@64 126 @echo 'Invoking: GCC C++ Linker'
andrewm@69 127 g++ $(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 128
giuliomoro@64 129 # Other Targets:
giuliomoro@64 130
giuliomoro@64 131 # Remove the temporary user-supplied source, plus the objects built from them
giuliomoro@64 132 sourceclean:
giuliomoro@64 133 -$(RM) source/* build/source/* BeagleRT
giuliomoro@64 134 -@echo ' '
giuliomoro@64 135
giuliomoro@64 136 # Remove all the built objects, including the core BeagleRT objects
giuliomoro@64 137 distclean:
giuliomoro@64 138 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) BeagleRT
giuliomoro@64 139 -@echo ' '
giuliomoro@64 140
giuliomoro@64 141 # Remove only the user-generated objects
giuliomoro@64 142 clean:
giuliomoro@64 143 -$(RM) build/source/* BeagleRT
giuliomoro@64 144 -@echo ' '
giuliomoro@64 145
giuliomoro@64 146 post-build:
giuliomoro@64 147 # Nothing to do here (for now)
giuliomoro@64 148
giuliomoro@64 149 .PHONY: all clean distclean sourceclean dependents
giuliomoro@64 150 .SECONDARY: post-build