1# Copyright 2018 Oticon A/S 2# SPDX-License-Identifier: Apache-2.0 3 4OBJS=$(abspath $(addprefix $(COMPONENT_OUTPUT_DIR)/,${SRCS:.c=.o})) 5OBJS32=$(abspath $(addprefix $(COMPONENT_OUTPUT_DIR)/,${SRCS:.c=.32.o})) 6LIBFILE=${LIB_NAME}.a 7LIBFILE32=${LIB_NAME}.32.a 8VERSION_FILE:=${LIB_NAME}.version 9 10all: install 11 12DEPENDFILES:=$(addsuffix .d,$(basename ${OBJS})) 13DEPENDFILES32:=$(addsuffix .32.d,$(basename ${OBJS})) 14 15-include ${DEPENDFILES} 16-include ${DEPENDFILES32} 17 18always_run_this_target: 19#phony target to trigger the rerun of the make of each library, but ensure that make checks if the library was regenerated (so it doesnt relink the binary if it wasnt) 20# we could do like in the root Makefile, and just go first over all the libraries makefiles we may need instead, but this is slighly more efficient (although more messy) 21 22.PHONY: all install compile lib clean clean_all ${DEPENDFILES} ${DEPENDFILES32} always_run_this_target version 23#setting the dependencies as phony targets will actually speed up things.. (otherwise make will check if there is implicit rules to remake them) 24 25$(COMPONENT_OUTPUT_DIR): 26 @mkdir -p $(COMPONENT_OUTPUT_DIR) 27 28${OBJS32}:$(COMPONENT_OUTPUT_DIR)/%.32.o: %.c 29 @if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 30 @${CC} ${CPPFLAGS} ${CFLAGS} ${COVERAGE} -m32 -c $< -o $@ 31 32${OBJS}:$(COMPONENT_OUTPUT_DIR)/%.o: %.c 33 @if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 34 @${CC} ${CPPFLAGS} ${CFLAGS} ${COVERAGE} -c $< -o $@ 35 36%.c: ; 37%.h: ; 38 39$(COMPONENT_OUTPUT_DIR)/${LIBFILE} : ${OBJS} ${A_LIBS} 40 @rm $(COMPONENT_OUTPUT_DIR)/${LIBFILE} &> /dev/null ; true 41 @${AR} -cr $(COMPONENT_OUTPUT_DIR)/${LIBFILE} ${OBJS} ${A_LIBS} 42 43$(COMPONENT_OUTPUT_DIR)/${LIBFILE32} : ${OBJS32} ${A_LIBS32} 44 @rm $(COMPONENT_OUTPUT_DIR)/${LIBFILE32} &> /dev/null ; true 45 @${AR} -cr $(COMPONENT_OUTPUT_DIR)/${LIBFILE32} ${OBJS32} ${A_LIBS32} 46 47compile: $(COMPONENT_OUTPUT_DIR)/${LIBFILE} $(COMPONENT_OUTPUT_DIR)/${LIBFILE32} 48 49lib : compile 50 51${A_LIBS32}:; 52 $(error Required library ($@) not found. Run top level make to build all dependencies in order) 53 54${A_LIBS}:; 55 $(error Required library ($@) not found. Run top level make to build all dependencies in order) 56 57clean: 58 @echo "Deleting intermediate compilation results" 59 @find $(COMPONENT_OUTPUT_DIR) -name "*.a" -or -name "*.o" -or -name "*.so" -or -name "*.d" | xargs rm 60 @rm $(COMPONENT_OUTPUT_DIR)/${LIBFILE} $(COMPONENT_OUTPUT_DIR)/${LIBFILE32} &> /dev/null ; true 61 62clean_coverage: 63 @find $(COMPONENT_OUTPUT_DIR) -name "*.gcda" -or -name "*.gcno" | xargs rm -f ; true 64 65clean_all: clean clean_coverage 66 67${BSIM_LIBS_DIR}/${VERSION_FILE}: version 68 @if [[ -f "$<" ]]; then\ 69 cp $< $@; \ 70 else \ 71 echo "unknown" > $@; \ 72 fi 73 74${BSIM_LIBS_DIR}/% : $(COMPONENT_OUTPUT_DIR)/% 75 @cp $< $@ 76 77install: ${BSIM_LIBS_DIR}/${LIBFILE} ${BSIM_LIBS_DIR}/${LIBFILE32} ${BSIM_LIBS_DIR}/${VERSION_FILE} 78 79Makefile: ;