comparison Makefile @ 326:bd54819ccfa7 prerelease

Makefile: run does not re-link. Faster check for libpd
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 03 Jun 2016 17:01:36 +0100
parents f7b19ea31bbb
children ccfcf1303f12
comparison
equal deleted inserted replaced
325:a9905703219d 326:bd54819ccfa7
24 PROJECT?=exampleTempProject 24 PROJECT?=exampleTempProject
25 PROJECT_DIR?=$(abspath projects/$(PROJECT)) 25 PROJECT_DIR?=$(abspath projects/$(PROJECT))
26 $(shell rm -rf $(PROJECT_DIR)) 26 $(shell rm -rf $(PROJECT_DIR))
27 $(shell cp -r examples/$(EXAMPLE) $(PROJECT_DIR)) 27 $(shell cp -r examples/$(EXAMPLE) $(PROJECT_DIR))
28 endif 28 endif
29 OUTPUT_FILE=$(PROJECT_DIR)/$(PROJECT)
30 COMMAND_LINE_OPTIONS=$(CL)
31 RUN_COMMAND=$(OUTPUT_FILE) $(COMMAND_LINE_OPTIONS)
29 32
30 SCREEN_NAME?=BeagleRT 33 SCREEN_NAME?=BeagleRT
31 34
32 #TODO: run these lines only if the command is not syntax or 35 #TODO: run these lines only if the command is not syntax or
33 $(shell mkdir -p $(PROJECT_DIR)/build) 36 $(shell mkdir -p $(PROJECT_DIR)/build)
34 RM := rm -rf 37 RM := rm -rf
35 STATIC_LIBS := ./libprussdrv.a ./libNE10.a 38 STATIC_LIBS := ./libprussdrv.a ./libNE10.a
36 LIBS := -lrt -lnative -lxenomai -lsndfile 39 LIBS := -lrt -lnative -lxenomai -lsndfile
37 40
38 # refresh library cache and check if libpd is there 41 # refresh library cache and check if libpd is there
39 TEST_LIBPD := $(shell ldconfig; ldconfig -p | grep "libpd\.so") 42 #TEST_LIBPD := $(shell ldconfig; ldconfig -p | grep "libpd\.so") # safest but slower way of checking
40 ifeq ($(strip $(TEST_LIBPD)), ) 43 LIBPD_PATH = /usr/lib/libpd.so
41 else 44 TEST_LIBPD := $(shell which $(LIBPD_PATH))
45 ifneq ($(strip $(TEST_LIBPD)), )
42 # if libpd is there, link it in 46 # if libpd is there, link it in
43 LIBS += -lpd -lpthread_rt 47 LIBS += -lpd -lpthread_rt
44 endif 48 endif
45 49
46 CPP_FLAGS := -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize 50 CPP_FLAGS := -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize
157 # This is a nasty kludge: we want to be able to optionally link in a default 161 # This is a nasty kludge: we want to be able to optionally link in a default
158 # main file if the user hasn't supplied one. We check for the presence of the main() 162 # main file if the user hasn't supplied one. We check for the presence of the main()
159 # function, and conditionally call one of two recursive make targets depending on whether 163 # function, and conditionally call one of two recursive make targets depending on whether
160 # we want to link in the default main file or not. The kludge is the mess of a shell script 164 # we want to link in the default main file or not. The kludge is the mess of a shell script
161 # line below. Surely there's a better way to do this? 165 # line below. Surely there's a better way to do this?
162 Bela: $(CORE_ASM_OBJS) $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS) 166 $(OUTPUT_FILE): $(CORE_ASM_OBJS) $(CORE_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS) $(DEFAULT_MAIN_OBJS)
163 $(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')) 167 $(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'))
164 @echo 'Invoking: C++ linker' 168 @echo 'Invoking: C++ linker'
165 @$(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) 169 @$(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)
166 @echo 'Finished building target: $@' 170 @echo 'Finished building target: $@'
167 171
169 # This rule compiles c and c++ source files without output or linking 173 # This rule compiles c and c++ source files without output or linking
170 SYNTAX: $(C_OBJS) $(CPP_OBJS) 174 SYNTAX: $(C_OBJS) $(CPP_OBJS)
171 175
172 # Remove the project's build objects & binary 176 # Remove the project's build objects & binary
173 projectclean: 177 projectclean:
174 -$(RM) $(PROJECT_DIR)/build/* $(PROJECT_DIR)/$(PROJECT) 178 -$(RM) $(PROJECT_DIR)/build/* $(OUTPUT_FILE)
175 -@echo ' ' 179 -@echo ' '
176 180
177 # Remove all the built objects, including the core Bela objects 181 # Remove all the built objects, including the core Bela objects
178 distclean: 182 distclean:
179 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) Bela 183 -$(RM) build/source/* $(CORE_OBJS) $(CORE_CPP_DEPS) $(DEFAULT_MAIN_OBJS) $(DEFAULT_MAIN_CPP_DEPS) $(OUTPUT_FILE)
180 -@echo ' ' 184 -@echo ' '
181 OUTPUT_FILE="$(PROJECT_DIR)/$(PROJECT)" 185
182 186 Bela: $(OUTPUT_FILE)
183 $(OUTPUT_FILE): Bela 187
184 COMMAND_LINE_OPTIONS=$(CL)
185 RUN_COMMAND=$(OUTPUT_FILE) $(COMMAND_LINE_OPTIONS)
186 runfg: run 188 runfg: run
187 run: stop $(OUTPUT_FILE) 189 run: stop Bela
188 echo "Running $(RUN_COMMAND)" 190 echo "Running $(RUN_COMMAND)"
189 $(RUN_COMMAND) 191 $(RUN_COMMAND)
190 runscreen: stop $(OUTPUT_FILE) 192 runscreen: stop $(OUTPUT_FILE)
191 echo "Running $(RUN_COMMAND) in a screen" 193 echo "Running $(RUN_COMMAND) in a screen"
192 screen -S $(SCREEN_NAME) -d -m $(RUN_COMMAND) 194 screen -S $(SCREEN_NAME) -d -m $(RUN_COMMAND)
210 # -@echo ' ' 212 # -@echo ' '
211 213
212 post-build: 214 post-build:
213 # Nothing to do here (for now) 215 # Nothing to do here (for now)
214 216
215 .PHONY: all clean distclean projectclean dependents debug run 217 .PHONY: all clean distclean projectclean dependents debug run runfg runscreen stop
216 .SECONDARY: post-build 218 .SECONDARY: post-build