1# Copyright 2018 Oticon A/S 2# SPDX-License-Identifier: Apache-2.0 3 4OBJS=$(abspath $(addprefix $(COMPONENT_OUTPUT_DIR)/,${SRCS:.c=.o})) 5MAP_FILE_NAME=${EXE_NAME}.Tsymbols 6VERSION_FILE:=${EXE_NAME}.version 7 8all: install 9 10DEPENDFILES:=$(addsuffix .d,$(basename ${OBJS})) 11 12-include ${DEPENDFILES} 13 14.PHONY: all install compile clean clean_all ${DEPENDFILES} version 15#setting the dependencies as phony targets will actually speed up things.. (otherwise make will check if there is implicit rules to remake them) 16 17compile: $(COMPONENT_OUTPUT_DIR)/${EXE_NAME} 18 19$(COMPONENT_OUTPUT_DIR): 20 @mkdir -p $(COMPONENT_OUTPUT_DIR) 21 22$(COMPONENT_OUTPUT_DIR)/%.o: %.c 23 @if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 24 @${CC} ${CPPFLAGS} ${CFLAGS} ${COVERAGE} -c $< -o $@ 25 26${A_LIBS}:; 27 $(error Required library ($@) not found. Run top level make to build all dependencies in order) 28 29$(COMPONENT_OUTPUT_DIR)/${EXE_NAME} : ${OBJS} ${A_LIBS} | $(COMPONENT_OUTPUT_DIR) 30 @${CC} -o $@ $^ ${LDFLAGS} ${SO_LIBS} ${A_LIBS} ${COVERAGE} 31 32$(COMPONENT_OUTPUT_DIR)/${MAP_FILE_NAME}: $(COMPONENT_OUTPUT_DIR)/${EXE_NAME} 33 @nm ${COMPONENT_OUTPUT_DIR}/${EXE_NAME} | grep -v " [U|w] " | sort | cut -d" " -f1,3 > $(COMPONENT_OUTPUT_DIR)/${MAP_FILE_NAME} ; sed -i "1i $$(wc -l $(COMPONENT_OUTPUT_DIR)/${MAP_FILE_NAME} | cut -d" " -f1)" $(COMPONENT_OUTPUT_DIR)/${MAP_FILE_NAME} 34 35clean: 36 @echo "Deleting intermediate compilation results" 37 @find $(COMPONENT_OUTPUT_DIR) -name "*.a" -or -name "*.o" -or -name "*.so" -or -name "*.d" -or -name "*.Tsymbols" | xargs rm 38 @rm $(COMPONENT_OUTPUT_DIR)/${EXE_NAME} 39 40clean_coverage: 41 @find $(COMPONENT_OUTPUT_DIR) -name "*.gcda" -or -name "*.gcno" | xargs rm -f ; true 42 43clean_all: clean clean_coverage 44 45${BSIM_LIBS_DIR}/${VERSION_FILE}: version 46 @if [[ -f "$<" ]]; then\ 47 cp $< $@; \ 48 else \ 49 echo "unknown" > $@; \ 50 fi 51 52${BSIM_BIN_DIR}/% : $(COMPONENT_OUTPUT_DIR)/% 53 @cp $< $@ 54 55install: ${BSIM_BIN_DIR}/${EXE_NAME} ${BSIM_BIN_DIR}/${MAP_FILE_NAME} ${BSIM_LIBS_DIR}/${VERSION_FILE} 56 57.PHONY: install clean clean_all compile all 58