Mercurial > hg > beaglert
comparison Makefile @ 67:472e892c6e41
Merge newapi into default
| author | Andrew McPherson <a.mcpherson@qmul.ac.uk> | 
|---|---|
| date | Fri, 17 Jul 2015 15:28:18 +0100 | 
| parents | b89dd0c97a04 | 
| children | 59edd5780fef | 
   comparison
  equal
  deleted
  inserted
  replaced
| 21:0d80ff9e2227 | 67:472e892c6e41 | 
|---|---|
| 1 # BeagleRT | |
| 2 # Low-latency, real-time audio and sensor processing on BeagleBone Black | |
| 3 # (c) 2015 Andrew McPherson, Victor Zappi, Giulio Moro | |
| 4 # Centre for Digital Music, Queen Mary University of London | |
| 5 | |
| 6 # This Makefile is intended for use on the BeagleBone Black itself | |
| 7 # and not for cross-compiling | |
| 8 | |
| 9 RM := rm -rf | |
| 10 STATIC_LIBS := ./libprussdrv.a ./libNE10.a | |
| 11 LIBS := -lrt -lnative -lxenomai | |
| 12 | |
| 13 ASM_SRCS := $(wildcard source/*.S) | |
| 14 ASM_OBJS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.o))) | |
| 15 ASM_DEPS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.d))) | |
| 16 | |
| 17 C_SRCS := $(wildcard source/*.c) | |
| 18 C_OBJS := $(addprefix build/source/,$(notdir $(C_SRCS:.c=.o))) | |
| 19 C_DEPS := $(addprefix build/source/,$(notdir $(C_SRCS:.c=.d))) | |
| 20 | |
| 21 CPP_SRCS := $(wildcard source/*.cpp) | |
| 22 CPP_OBJS := $(addprefix build/source/,$(notdir $(CPP_SRCS:.cpp=.o))) | |
| 23 CPP_DEPS := $(addprefix build/source/,$(notdir $(CPP_SRCS:.cpp=.d))) | |
| 24 | |
| 25 # Core BeagleRT sources | |
| 26 CORE_CPP_SRCS := \ | |
| 27 ./core/GPIOcontrol.cpp \ | |
| 28 ./core/I2c_Codec.cpp \ | |
| 29 ./core/PRU.cpp \ | |
| 30 ./core/RTAudio.cpp \ | |
| 31 ./core/RTAudioCommandLine.cpp \ | |
| 32 ./core/Utilities.cpp \ | |
| 33 ./core/client.cpp | |
| 34 | |
| 35 CORE_OBJS := \ | |
| 36 ./build/core/GPIOcontrol.o \ | |
| 37 ./build/core/I2c_Codec.o \ | |
| 38 ./build/core/PRU.o \ | |
| 39 ./build/core/RTAudio.o \ | |
| 40 ./build/core/RTAudioCommandLine.o \ | |
| 41 ./build/core/Utilities.o \ | |
| 42 ./build/core/client.o | |
| 43 | |
| 44 CORE_CPP_DEPS := \ | |
| 45 ./build/core/GPIOcontrol.d \ | |
| 46 ./build/core/I2c_Codec.d \ | |
| 47 ./build/core/PRU.d \ | |
| 48 ./build/core/RTAudio.d \ | |
| 49 ./build/core/RTAudioCommandLine.d \ | |
| 50 ./build/core/Utilities.d \ | |
| 51 ./build/core/client.d | |
| 52 | |
| 53 # Objects for a system-supplied default main() file, if the user | |
| 54 # only wants to provide the render functions. | |
| 55 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp | |
| 56 DEFAULT_MAIN_OBJS := ./build/core/default_main.o | |
| 57 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d | |
| 58 | |
| 59 # All = build BeagleRT | |
| 60 all: BeagleRT | |
| 61 | |
| 62 # Rule for BeagleRT core C++ files | |
| 63 build/core/%.o: ./core/%.cpp | |
| 64 @echo 'Building file: $<' | |
| 65 @echo 'Invoking: GCC C++ Compiler' | |
| 66 g++ -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10 -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" | |
| 67 @echo 'Finished building: $<' | |
| 68 @echo ' ' | |
| 69 | |
| 70 # Rule for user-supplied C++ files | |
| 71 build/source/%.o: ./source/%.cpp | |
| 72 @echo 'Building file: $<' | |
| 73 @echo 'Invoking: GCC C++ Compiler' | |
| 74 g++ -I./include -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10 -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" | |
| 75 @echo 'Finished building: $<' | |
| 76 @echo ' ' | |
| 77 | |
| 78 # Rule for user-supplied C files | |
| 79 build/source/%.o: ./source/%.c | |
| 80 @echo 'Building file: $<' | |
| 81 @echo 'Invoking: GCC C Compiler' | |
| 82 gcc -I./include -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10 -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" | |
| 83 @echo 'Finished building: $<' | |
| 84 @echo ' ' | |
| 85 | |
| 86 # Rule for user-supplied assembly files | |
| 87 build/source/%.o: ./source/%.S | |
| 88 @echo 'Building file: $<' | |
| 89 @echo 'Invoking: GCC Assembler' | |
| 90 as -o "$@" "$<" | |
| 91 @echo 'Finished building: $<' | |
| 92 @echo ' ' | |
| 93 | |
| 94 # This is a nasty kludge: we want to be able to optionally link in a default | |
| 95 # main file if the user hasn't supplied one. We check for the presence of the main() | |
| 96 # function, and conditionally call one of two recursive make targets depending on whether | |
| 97 # we want to link in the default main file or not. The kludge is the mess of a shell script | |
| 98 # line below. Surely there's a better way to do this? | |
| 99 BeagleRT: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) | |
| 100 $(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')) | |
| 101 $(MAKE) $(NEXT_TARGET) | |
| 102 @echo 'Finished building target: $@' | |
| 103 @echo ' ' | |
| 104 # $(MAKE) --no-print-directory post-build | |
| 105 | |
| 106 # Rule for building BeagleRT including the default main file (no user-supplied main()) | |
| 107 BeagleRT_with_main: $(CORE_OBJS) $(DEFAULT_MAIN_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) | |
| 108 @echo 'Building target: $@' | |
| 109 @echo 'Invoking: GCC C++ Linker' | |
| 110 g++ -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) | |
| 111 | |
| 112 # Rule for building BeagleRT without the default main file (user-supplied main()) | |
| 113 BeagleRT_without_main: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) | |
| 114 @echo 'Building target: $@' | |
| 115 @echo 'Invoking: GCC C++ Linker' | |
| 116 g++ -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) | |
| 117 | |
| 118 # Other Targets: | |
| 119 | |
| 120 # Remove the temporary user-supplied source, plus the objects built from them | |
| 121 sourceclean: | |
| 122 -$(RM) source/* build/source/* BeagleRT | |
| 123 -@echo ' ' | |
| 124 | |
| 125 # Remove all the built objects, including the core BeagleRT objects | |
| 126 distclean: | |
| 127 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) BeagleRT | |
| 128 -@echo ' ' | |
| 129 | |
| 130 # Remove only the user-generated objects | |
| 131 clean: | |
| 132 -$(RM) build/source/* BeagleRT | |
| 133 -@echo ' ' | |
| 134 | |
| 135 post-build: | |
| 136 # Nothing to do here (for now) | |
| 137 | |
| 138 .PHONY: all clean distclean sourceclean dependents | |
| 139 .SECONDARY: post-build | 
