rules.mk 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. iot_sdk_objects = $(patsubst %.c,%.o, $(IOTSDK_SRC_FILES))
  2. iot_platform_objects = $(patsubst %.c,%.o, $(IOTPLATFORM_SRC_FILES))
  3. .PHONY: config mbedtls clean final-out samples tests
  4. all: config mbedtls ${COMP_LIB} ${PLATFORM_LIB} final-out samples tests
  5. $(call Compile_Result)
  6. ${COMP_LIB}: ${iot_sdk_objects}
  7. $(call Brief_Log,"AR")
  8. $(TOP_Q) \
  9. $(AR) rcs $@ $(iot_sdk_objects)
  10. $(TOP_Q) \
  11. rm ${iot_sdk_objects}
  12. ${PLATFORM_LIB}: ${iot_platform_objects}
  13. $(call Brief_Log,"AR")
  14. $(TOP_Q) \
  15. $(AR) rcs $@ $(iot_platform_objects)
  16. $(TOP_Q) \
  17. rm ${iot_platform_objects}
  18. config:
  19. $(TOP_Q) \
  20. mkdir -p ${TEMP_DIR}
  21. mbedtls:
  22. ifeq (,$(filter -DAUTH_WITH_NOTLS,$(CFLAGS)))
  23. $(TOP_Q) \
  24. make -s -C $(THIRD_PARTY_PATH)/mbedtls lib -e CC=$(PLATFORM_CC) AR=$(PLATFORM_AR)
  25. $(TOP_Q) \
  26. cp -RP $(THIRD_PARTY_PATH)/mbedtls/library/libmbedtls.* \
  27. $(THIRD_PARTY_PATH)/mbedtls/library/libmbedx509.* \
  28. $(THIRD_PARTY_PATH)/mbedtls/library/libmbedcrypto.* \
  29. $(TEMP_DIR)
  30. $(TOP_Q) \
  31. cd $(TEMP_DIR) && $(AR) x libmbedtls.a \
  32. && $(AR) x libmbedx509.a \
  33. && $(AR) x libmbedcrypto.a
  34. endif
  35. ${iot_sdk_objects}:%.o:%.c
  36. $(TOP_Q) echo '' > $(TOP_DIR)/include/config.h
  37. $(call Brief_Log,"CC")
  38. $(TOP_Q) \
  39. $(PLATFORM_CC) $(CFLAGS) -c $^ -o $@
  40. ${iot_platform_objects}:%.o:%.c
  41. $(call Brief_Log,"CC")
  42. $(TOP_Q) \
  43. $(PLATFORM_CC) $(CFLAGS) -c $^ -o $@
  44. final-out :
  45. $(TOP_Q) \
  46. mkdir -p ${FINAL_DIR} ${DIST_DIR} ${FINAL_DIR}/lib \
  47. ${FINAL_DIR}/include ${FINAL_DIR}/bin
  48. $(TOP_Q) \
  49. mv ${COMP_LIB} ${FINAL_DIR}/lib/ && \
  50. mv ${PLATFORM_LIB} ${FINAL_DIR}/lib
  51. $(TOP_Q) \
  52. cp -rf $(TOP_DIR)/include $(FINAL_DIR)/
  53. $(TOP_Q) \
  54. cp -rf $(TOP_DIR)/certs $(FINAL_DIR)/bin/
  55. $(TOP_Q) \
  56. cp -rf $(TOP_DIR)/device_info.json $(FINAL_DIR)/bin/
  57. ifeq (,$(filter -DAUTH_WITH_NOTLS,$(CFLAGS)))
  58. $(TOP_Q) \
  59. mv ${TEMP_DIR}/*.a ${FINAL_DIR}/lib/
  60. endif
  61. $(TOP_Q) \
  62. rm -rf ${TEMP_DIR}
  63. #include $(SCRIPT_DIR)/rules-tests.mk
  64. samples:
  65. $(TOP_Q) \
  66. make -s -C $(SAMPLE_DIR)
  67. TLSDIR = $(THIRD_PARTY_PATH)/mbedtls
  68. clean:
  69. $(TOP_Q) \
  70. rm -rf ${TEMP_DIR}
  71. $(TOP_Q) \
  72. rm -rf ${DIST_DIR}
  73. ifeq (,$(filter -DAUTH_WITH_NOTLS,$(CFLAGS)))
  74. ifeq ($(TLSDIR), $(wildcard $(THIRD_PARTY_PATH)/mbedtls))
  75. $(TOP_Q) \
  76. make -s -C $(THIRD_PARTY_PATH)/mbedtls clean
  77. endif
  78. endif
  79. ifeq (,$(filter -DSDKTESTS_ENABLED,$(CFLAGS)))
  80. $(TOP_Q) \
  81. rm -rf $(TEST_LIB_DIR)
  82. endif