Android.mk 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Example: Android Native Library makefile for paho.mqtt.c
  2. # contributed by Bin Li <bin.li@windriver.com>
  3. LOCAL_PATH := $(call my-dir)
  4. libpaho-mqtt3_lib_path := ../src
  5. libpaho-mqtt3_c_includes := $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path) \
  6. external/hdc/android-ifaddrs \
  7. external/openssl/include \
  8. external/zlib
  9. # build sample util
  10. define build_sample_util
  11. __sample_module:= $1
  12. __sample_lib:= $2
  13. include $(CLEAR_VARS)
  14. LOCAL_C_INCLUDES := $(libpaho-mqtt3_c_includes)
  15. LOCAL_SHARED_LIBRARIES := $$(__sample_lib)
  16. LOCAL_MODULE := $$(__sample_module)
  17. LOCAL_SRC_FILES := $(libpaho-mqtt3_lib_path)/samples/$$(__sample_module).c
  18. include $(BUILD_EXECUTABLE)
  19. endef
  20. libpaho-mqtt3_local_src_c_files_common := \
  21. $(libpaho-mqtt3_lib_path)/MQTTProtocolClient.c \
  22. $(libpaho-mqtt3_lib_path)/Tree.c \
  23. $(libpaho-mqtt3_lib_path)/Heap.c \
  24. $(libpaho-mqtt3_lib_path)/MQTTPacket.c \
  25. $(libpaho-mqtt3_lib_path)/Clients.c \
  26. $(libpaho-mqtt3_lib_path)/Thread.c \
  27. $(libpaho-mqtt3_lib_path)/utf-8.c \
  28. $(libpaho-mqtt3_lib_path)/StackTrace.c \
  29. $(libpaho-mqtt3_lib_path)/MQTTProtocolOut.c \
  30. $(libpaho-mqtt3_lib_path)/Socket.c \
  31. $(libpaho-mqtt3_lib_path)/Log.c \
  32. $(libpaho-mqtt3_lib_path)/Messages.c \
  33. $(libpaho-mqtt3_lib_path)/LinkedList.c \
  34. $(libpaho-mqtt3_lib_path)/MQTTPersistence.c \
  35. $(libpaho-mqtt3_lib_path)/MQTTPacketOut.c \
  36. $(libpaho-mqtt3_lib_path)/SocketBuffer.c \
  37. $(libpaho-mqtt3_lib_path)/MQTTPersistenceDefault.c \
  38. libpaho-mqtt3_local_src_c_files_c := \
  39. $(libpaho-mqtt3_lib_path)/MQTTClient.c \
  40. libpaho-mqtt3_local_src_c_files_cs := \
  41. $(libpaho-mqtt3_lib_path)/MQTTClient.c \
  42. $(libpaho-mqtt3_lib_path)/SSLSocket.c \
  43. libpaho-mqtt3_local_src_c_files_a := \
  44. $(libpaho-mqtt3_lib_path)/MQTTAsync.c \
  45. libpaho-mqtt3_local_src_c_files_as := \
  46. $(libpaho-mqtt3_lib_path)/MQTTAsync.c \
  47. $(libpaho-mqtt3_lib_path)/SSLSocket.c \
  48. # update the header file which normally generated by cmake
  49. $(shell (cp -f $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)/VersionInfo.h.in $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)/VersionInfo.h))
  50. $(shell (sed -i "s/@CLIENT_VERSION@/1.2.0/g" $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)/VersionInfo.h))
  51. $(shell ( sed -i "s/@BUILD_TIMESTAMP@/$(shell date)/g" $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)/VersionInfo.h))
  52. # building static libraries
  53. include $(CLEAR_VARS)
  54. LOCAL_MODULE := libpaho-mqtt3c
  55. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)
  56. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  57. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_c)
  58. include $(BUILD_STATIC_LIBRARY)
  59. include $(CLEAR_VARS)
  60. LOCAL_MODULE := libpaho-mqtt3cs
  61. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)
  62. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  63. LOCAL_CFLAGS += -DOPENSSL
  64. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_cs)
  65. include $(BUILD_STATIC_LIBRARY)
  66. include $(CLEAR_VARS)
  67. LOCAL_MODULE := libpaho-mqtt3a
  68. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/${libpaho-mqtt3_lib_path}
  69. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  70. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_a)
  71. include $(BUILD_STATIC_LIBRARY)
  72. include $(CLEAR_VARS)
  73. LOCAL_MODULE := libpaho-mqtt3as
  74. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/${libpaho-mqtt3_lib_path}
  75. LOCAL_CFLAGS += -DOPENSSL
  76. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  77. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_as)
  78. include $(BUILD_STATIC_LIBRARY)
  79. # building shared libraries
  80. include $(CLEAR_VARS)
  81. LOCAL_MODULE := libpaho-mqtt3c
  82. LOCAL_SHARED_LIBRARIES := libdl
  83. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)
  84. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  85. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_c)
  86. include $(BUILD_SHARED_LIBRARY)
  87. include $(CLEAR_VARS)
  88. LOCAL_MODULE := libpaho-mqtt3cs
  89. LOCAL_SHARED_LIBRARIES := libcrypto libssl libdl
  90. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/$(libpaho-mqtt3_lib_path)
  91. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  92. LOCAL_CFLAGS += -DOPENSSL
  93. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_cs)
  94. include $(BUILD_SHARED_LIBRARY)
  95. include $(CLEAR_VARS)
  96. LOCAL_MODULE := libpaho-mqtt3a
  97. LOCAL_SHARED_LIBRARIES := libdl
  98. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/${libpaho-mqtt3_lib_path}
  99. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  100. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_a)
  101. include $(BUILD_SHARED_LIBRARY)
  102. include $(CLEAR_VARS)
  103. LOCAL_MODULE := libpaho-mqtt3as
  104. LOCAL_SHARED_LIBRARIES := libcrypto libssl libdl
  105. LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/${libpaho-mqtt3_lib_path}
  106. LOCAL_CFLAGS += -DOPENSSL
  107. LOCAL_C_INCLUDES:= $(libpaho-mqtt3_c_includes)
  108. LOCAL_SRC_FILES := $(libpaho-mqtt3_local_src_c_files_common) $(libpaho-mqtt3_local_src_c_files_as)
  109. include $(BUILD_SHARED_LIBRARY)
  110. # building samples
  111. $(eval $(call build_sample_util, MQTTAsync_subscribe, libpaho-mqtt3a ) )
  112. $(eval $(call build_sample_util, MQTTAsync_publish, libpaho-mqtt3a ) )
  113. $(eval $(call build_sample_util, MQTTClient_publish, libpaho-mqtt3c ) )
  114. $(eval $(call build_sample_util, MQTTClient_publish_async, libpaho-mqtt3c ) )
  115. $(eval $(call build_sample_util, MQTTClient_subscribe, libpaho-mqtt3c ) )
  116. $(eval $(call build_sample_util, paho_c_pub, libpaho-mqtt3a ) )
  117. $(eval $(call build_sample_util, paho_c_sub, libpaho-mqtt3a ) )
  118. $(eval $(call build_sample_util, paho_cs_pub, libpaho-mqtt3c ) )
  119. $(eval $(call build_sample_util, paho_cs_sub, libpaho-mqtt3c ) )