comparison Makefile @ 383:e42bc9ba7550 prerelease

Fixed when rebuilding non-main() project after main() project: the 'nasty kludge' was looking in ALL the .o files in projectFolder/build/ instead of only those that have a corresponding .cpp/.c/.S file. An even better fix is make sure that object files associated with source files deleted by rsync are removed as well
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 13 Jun 2016 00:44:47 +0100
parents 9dc5a0ccad25
children fb5547fe6d99
comparison
equal deleted inserted replaced
382:bcc033b46636 383:e42bc9ba7550
94 94
95 CPP_SRCS := $(wildcard $(PROJECT_DIR)/*.cpp) 95 CPP_SRCS := $(wildcard $(PROJECT_DIR)/*.cpp)
96 CPP_OBJS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.o))) 96 CPP_OBJS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.o)))
97 CPP_DEPS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.d))) 97 CPP_DEPS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.d)))
98 98
99 PROJECT_OBJS = $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS)
100
99 # Core Bela sources 101 # Core Bela sources
100 CORE_CPP_SRCS = $(filter-out core/default_main.cpp, $(wildcard core/*.cpp)) 102 CORE_CPP_SRCS = $(filter-out core/default_main.cpp, $(wildcard core/*.cpp))
101 CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o))) 103 CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o)))
102 CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d))) 104 CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d)))
103 105
174 # This is a nasty kludge: we want to be able to optionally link in a default 176 # This is a nasty kludge: we want to be able to optionally link in a default
175 # main file if the user hasn't supplied one. We check for the presence of the main() 177 # main file if the user hasn't supplied one. We check for the presence of the main()
176 # function, and conditionally call one of two recursive make targets depending on whether 178 # function, and conditionally call one of two recursive make targets depending on whether
177 # we want to link in the default main file or not. The kludge is the mess of a shell script 179 # we want to link in the default main file or not. The kludge is the mess of a shell script
178 # line below. Surely there's a better way to do this? 180 # line below. Surely there's a better way to do this?
179 $(OUTPUT_FILE): $(CORE_ASM_OBJS) $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS) 181 $(OUTPUT_FILE): $(CORE_ASM_OBJS) $(CORE_OBJS) $(PROJECT_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS)
180 $(eval DEFAULT_MAIN_CONDITIONAL := $(shell bash -c 'if [ `nm $(PROJECT_DIR)/build/*.o | grep -w T | grep -w main | wc -l` == '0' ]; then echo "$(DEFAULT_MAIN_OBJS)"; else echo ""; fi')) 182 $(eval DEFAULT_MAIN_CONDITIONAL := $(shell bash -c 'if [ `nm $(PROJECT_OBJS) | grep -w T | grep -w main | wc -l` == '0' ]; then echo "$(DEFAULT_MAIN_OBJS)"; else echo ""; fi'))
181 @echo 'Invoking: C++ linker' 183 @echo 'Invoking: C++ linker'
182 @$(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 "$(PROJECT_DIR)/$(PROJECT)" $(CORE_ASM_OBJS) $(CORE_OBJS) $(DEFAULT_MAIN_CONDITIONAL) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(LIBS) 184 @$(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 "$(PROJECT_DIR)/$(PROJECT)" $(CORE_ASM_OBJS) $(CORE_OBJS) $(DEFAULT_MAIN_CONDITIONAL) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(LIBS)
183 @echo 'Finished building target: $@' 185 @echo 'Finished building target: $@'
184 @sync 186 @sync
185 # Other Targets: 187 # Other Targets: