Mercurial > hg > beaglert
comparison Makefile @ 463:c47709e8b5c9 prerelease
Makefile automatically links in default_libpd_render.cpp if there is a _main.pd file and there is no render symbol
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 20 Jun 2016 15:10:12 +0100 |
parents | f96238bdbb18 |
children | 1d585c5fa663 |
comparison
equal
deleted
inserted
replaced
462:d9a4fc5357e7 | 463:c47709e8b5c9 |
---|---|
120 CPP_DEPS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.d))) | 120 CPP_DEPS := $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.d))) |
121 | 121 |
122 PROJECT_OBJS = $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) | 122 PROJECT_OBJS = $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) |
123 | 123 |
124 # Core Bela sources | 124 # Core Bela sources |
125 CORE_CPP_SRCS = $(filter-out core/default_main.cpp, $(wildcard core/*.cpp)) | 125 CORE_CPP_SRCS = $(filter-out core/default_main.cpp core/default_libpd_render.cpp, $(wildcard core/*.cpp)) |
126 CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o))) | 126 CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o))) |
127 CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d))) | 127 CORE_CPP_DEPS := $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d))) |
128 | 128 |
129 CORE_ASM_SRCS := $(wildcard core/*.S) | 129 CORE_ASM_SRCS := $(wildcard core/*.S) |
130 CORE_ASM_OBJS := $(addprefix build/core/,$(notdir $(CORE_ASM_SRCS:.S=.o))) | 130 CORE_ASM_OBJS := $(addprefix build/core/,$(notdir $(CORE_ASM_SRCS:.S=.o))) |
135 # only wants to provide the render functions. | 135 # only wants to provide the render functions. |
136 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp | 136 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp |
137 DEFAULT_MAIN_OBJS := ./build/core/default_main.o | 137 DEFAULT_MAIN_OBJS := ./build/core/default_main.o |
138 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d | 138 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d |
139 | 139 |
140 Bela: ## Builds the Bela program with all the opimizations | 140 # Objects for a system-supplied default render() file for libpd projects, |
141 # if the user only wants to provide the Pd files. | |
142 DEFAULT_PD_CPP_SRCS := ./core/default_libpd_render.cpp | |
143 DEFAULT_PD_OBJS := ./build/core/default_libpd_render.o | |
144 DEFAULT_PD_CPP_DEPS := ./build/core/default_libpd_render.d | |
145 | |
146 Bela: ## Builds the Bela program with all the optimizations | |
141 Bela: $(OUTPUT_FILE) | 147 Bela: $(OUTPUT_FILE) |
142 | 148 |
143 # all = build Bela | 149 # all = build Bela |
144 all: ## Same as Bela | 150 all: ## Same as Bela |
145 all: SYNTAX_FLAG := | 151 all: SYNTAX_FLAG := |
200 # main file if the user hasn't supplied one. We check for the presence of the main() | 206 # main file if the user hasn't supplied one. We check for the presence of the main() |
201 # function, and conditionally call one of two recursive make targets depending on whether | 207 # function, and conditionally call one of two recursive make targets depending on whether |
202 # we want to link in the default main file or not. The kludge is the mess of a shell script | 208 # we want to link in the default main file or not. The kludge is the mess of a shell script |
203 # line below. Surely there's a better way to do this? | 209 # line below. Surely there's a better way to do this? |
204 $(OUTPUT_FILE): $(CORE_ASM_OBJS) $(CORE_OBJS) $(PROJECT_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS) | 210 $(OUTPUT_FILE): $(CORE_ASM_OBJS) $(CORE_OBJS) $(PROJECT_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS) |
205 $(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')) | 211 $(eval DEFAULT_MAIN_CONDITIONAL :=\ |
212 $(shell bash -c '[ `nm $(PROJECT_OBJS) 2>/dev/null | grep -w T | grep -w main | wc -l` == '0' ] && echo "$(DEFAULT_MAIN_OBJS)" || : ')) | |
213 @#If there is a _main.pd file AND there is no "render" symbol then link in the $(DEFAULT_PD_OBJS) | |
214 $(eval DEFAULT_PD_CONDITIONAL :=\ | |
215 $(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)' || : ' )) | |
216 @echo $(DEFAULT_MAIN_CONDITIONAL) $(DEFAULT_PD_CONDITIONAL) | |
206 @echo 'Linking...' | 217 @echo 'Linking...' |
207 @$(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) | 218 $(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) |
208 @echo ' ...done' | 219 @echo ' ...done' |
209 | 220 |
210 # Other Targets: | 221 # Other Targets: |
211 projectclean:## Remove the PROJECT's build objects & binary | 222 projectclean:## Remove the PROJECT's build objects & binary |
212 -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE) | 223 -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE) |