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