annotate Makefile @ 214:1721296e3e71

Fixed printed text
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 09 Feb 2016 16:26:04 +0000
parents 5f53b838b742
children c0bf6157f67e
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
l@200 11 LIBS := -lrt -lnative -lxenomai -lsndfile
giuliomoro@64 12
giuliomoro@186 13 INCLUDES := -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 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@186 29 CORE_CPP_SRCS = $(filter-out core/default_main.cpp, $(wildcard core/*.cpp))
giuliomoro@186 30 CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o)))
giuliomoro@186 31 CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d)))
giuliomoro@64 32
giuliomoro@64 33 # Objects for a system-supplied default main() file, if the user
giuliomoro@64 34 # only wants to provide the render functions.
giuliomoro@64 35 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp
giuliomoro@64 36 DEFAULT_MAIN_OBJS := ./build/core/default_main.o
giuliomoro@64 37 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d
andrewm@68 38
giuliomoro@209 39 CPP_FLAGS=-O2
giuliomoro@209 40 C_FLAGS=-O2
giuliomoro@209 41
giuliomoro@209 42 # all = build BeagleRT
andrewm@69 43 all: SYNTAX_FLAG :=
giuliomoro@64 44 all: BeagleRT
andrewm@68 45
giuliomoro@209 46 # debug = buildBeagleRT debug
giuliomoro@209 47 debug: CPP_FLAGS=-g
giuliomoro@209 48 debug: C_FLAGS=-g
giuliomoro@209 49 debug: all
giuliomoro@209 50
andrewm@69 51 # syntax = check syntax
andrewm@69 52 syntax: SYNTAX_FLAG := -fsyntax-only
andrewm@69 53 syntax: BeagleRT
andrewm@69 54
giuliomoro@64 55 # Rule for BeagleRT core C++ files
giuliomoro@64 56 build/core/%.o: ./core/%.cpp
giuliomoro@64 57 @echo 'Building file: $<'
giuliomoro@64 58 @echo 'Invoking: GCC C++ Compiler'
giuliomoro@209 59 g++ $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
giuliomoro@64 60 @echo 'Finished building: $<'
giuliomoro@64 61 @echo ' '
andrewm@68 62
giuliomoro@64 63 # Rule for user-supplied C++ files
giuliomoro@64 64 build/source/%.o: ./source/%.cpp
giuliomoro@64 65 @echo 'Building file: $<'
giuliomoro@64 66 @echo 'Invoking: GCC C++ Compiler'
giuliomoro@209 67 g++ $(SYNTAX_FLAG) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
giuliomoro@64 68 @echo 'Finished building: $<'
giuliomoro@64 69 @echo ' '
andrewm@68 70
giuliomoro@64 71 # Rule for user-supplied C files
giuliomoro@64 72 build/source/%.o: ./source/%.c
giuliomoro@64 73 @echo 'Building file: $<'
giuliomoro@64 74 @echo 'Invoking: GCC C Compiler'
giuliomoro@209 75 gcc $(SYNTAX_FLAG) $(INCLUDES) $(C_FLAGS) -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" -std=c99 -mfpu=neon
giuliomoro@64 76 @echo 'Finished building: $<'
giuliomoro@64 77 @echo ' '
andrewm@68 78
giuliomoro@64 79 # Rule for user-supplied assembly files
giuliomoro@64 80 build/source/%.o: ./source/%.S
giuliomoro@64 81 @echo 'Building file: $<'
giuliomoro@64 82 @echo 'Invoking: GCC Assembler'
giuliomoro@64 83 as -o "$@" "$<"
giuliomoro@64 84 @echo 'Finished building: $<'
giuliomoro@64 85 @echo ' '
giuliomoro@64 86
giuliomoro@64 87 # This is a nasty kludge: we want to be able to optionally link in a default
giuliomoro@64 88 # main file if the user hasn't supplied one. We check for the presence of the main()
giuliomoro@64 89 # function, and conditionally call one of two recursive make targets depending on whether
giuliomoro@64 90 # we want to link in the default main file or not. The kludge is the mess of a shell script
giuliomoro@64 91 # line below. Surely there's a better way to do this?
giuliomoro@64 92 BeagleRT: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 93 $(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 94 $(MAKE) $(NEXT_TARGET)
giuliomoro@64 95 @echo 'Finished building target: $@'
giuliomoro@64 96 @echo ' '
giuliomoro@64 97 # $(MAKE) --no-print-directory post-build
andrewm@68 98
giuliomoro@64 99 # Rule for building BeagleRT including the default main file (no user-supplied main())
giuliomoro@64 100 BeagleRT_with_main: $(CORE_OBJS) $(DEFAULT_MAIN_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 101 @echo 'Building target: $@'
giuliomoro@64 102 @echo 'Invoking: GCC C++ Linker'
andrewm@69 103 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 104
giuliomoro@64 105 # Rule for building BeagleRT without the default main file (user-supplied main())
giuliomoro@64 106 BeagleRT_without_main: $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
giuliomoro@64 107 @echo 'Building target: $@'
giuliomoro@64 108 @echo 'Invoking: GCC C++ Linker'
andrewm@69 109 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 110
giuliomoro@64 111 # Other Targets:
giuliomoro@64 112
giuliomoro@64 113 # Remove the temporary user-supplied source, plus the objects built from them
giuliomoro@64 114 sourceclean:
giuliomoro@64 115 -$(RM) source/* build/source/* BeagleRT
giuliomoro@64 116 -@echo ' '
giuliomoro@64 117
giuliomoro@64 118 # Remove all the built objects, including the core BeagleRT objects
giuliomoro@64 119 distclean:
giuliomoro@64 120 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) BeagleRT
giuliomoro@64 121 -@echo ' '
giuliomoro@64 122
giuliomoro@64 123 # Remove only the user-generated objects
giuliomoro@64 124 clean:
giuliomoro@64 125 -$(RM) build/source/* BeagleRT
giuliomoro@64 126 -@echo ' '
giuliomoro@64 127
giuliomoro@64 128 post-build:
giuliomoro@64 129 # Nothing to do here (for now)
giuliomoro@64 130
giuliomoro@209 131 .PHONY: all clean distclean sourceclean dependents debug
giuliomoro@64 132 .SECONDARY: post-build