# HG changeset patch # User Giulio Moro # Date 1466431812 -3600 # Node ID c47709e8b5c90783740b3b28e22d1d1765c270e6 # Parent d9a4fc5357e79a89b163d9866d491bdf81d845f1 Makefile automatically links in default_libpd_render.cpp if there is a _main.pd file and there is no render symbol diff -r d9a4fc5357e7 -r c47709e8b5c9 Makefile --- a/Makefile Mon Jun 20 14:09:43 2016 +0100 +++ b/Makefile Mon Jun 20 15:10:12 2016 +0100 @@ -122,7 +122,7 @@ PROJECT_OBJS = $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) # Core Bela sources -CORE_CPP_SRCS = $(filter-out core/default_main.cpp, $(wildcard core/*.cpp)) +CORE_CPP_SRCS = $(filter-out core/default_main.cpp core/default_libpd_render.cpp, $(wildcard core/*.cpp)) CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o))) CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d))) @@ -137,7 +137,13 @@ DEFAULT_MAIN_OBJS := ./build/core/default_main.o DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d -Bela: ## Builds the Bela program with all the opimizations +# Objects for a system-supplied default render() file for libpd projects, +# if the user only wants to provide the Pd files. +DEFAULT_PD_CPP_SRCS := ./core/default_libpd_render.cpp +DEFAULT_PD_OBJS := ./build/core/default_libpd_render.o +DEFAULT_PD_CPP_DEPS := ./build/core/default_libpd_render.d + +Bela: ## Builds the Bela program with all the optimizations Bela: $(OUTPUT_FILE) # all = build Bela @@ -202,9 +208,14 @@ # we want to link in the default main file or not. The kludge is the mess of a shell script # line below. Surely there's a better way to do this? $(OUTPUT_FILE): $(CORE_ASM_OBJS) $(CORE_OBJS) $(PROJECT_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS) - $(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')) + $(eval DEFAULT_MAIN_CONDITIONAL :=\ + $(shell bash -c '[ `nm $(PROJECT_OBJS) 2>/dev/null | grep -w T | grep -w main | wc -l` == '0' ] && echo "$(DEFAULT_MAIN_OBJS)" || : ')) + @#If there is a _main.pd file AND there is no "render" symbol then link in the $(DEFAULT_PD_OBJS) + $(eval DEFAULT_PD_CONDITIONAL :=\ + $(shell bash -c '{ [ -f "$(PROJECT_DIR)/_main.pd" ] && [ `nm $(PROJECT_OBJS) 2>/dev/null | grep -w T | grep -w render | wc -l` = '0' ]; } && echo '$(DEFAULT_PD_OBJS)' || : ' )) + @echo $(DEFAULT_MAIN_CONDITIONAL) $(DEFAULT_PD_CONDITIONAL) @echo 'Linking...' - @$(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) + $(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) $(DEFAULT_PD_CONDITIONAL) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(LIBS) @echo ' ...done' # Other Targets: