diff --git a/.pubnub.yml b/.pubnub.yml index 343bfd48..9d0c2f6f 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,19 @@ name: c-core schema: 1 -version: "4.15.0" +version: "4.16.0" scm: github.com/pubnub/c-core changelog: + - date: 2024-12-25 + version: v4.16.0 + changes: + - type: feature + text: "Additional flags for C/CPP can be set with: `USER_C_FLAGS` / `USER_CXX_FLAGS`." + - type: bug + text: "Fix because of which one of the source files has been missed for Windows." + - type: bug + text: "Fix issue with unsupported concatenation of sources files / definitions (`+=`)." + - type: improvement + text: "Refactor our `Makefiles` from different folders and platforms to use `include` directives to include shared definitions, flags, source files." - date: 2024-11-25 version: v4.15.0 changes: @@ -884,7 +895,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.16.0 requires: - name: "miniz" @@ -950,7 +961,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.16.0 requires: - name: "miniz" @@ -1016,7 +1027,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.16.0 requires: - name: "miniz" @@ -1078,7 +1089,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.16.0 requires: - name: "miniz" @@ -1139,7 +1150,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.16.0 requires: - name: "miniz" @@ -1195,7 +1206,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.16.0 requires: - name: "miniz" @@ -1248,7 +1259,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.16.0 requires: - name: "miniz" diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d05815a..d2e1aa43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## v4.16.0 +December 25 2024 + +#### Added +- Additional flags for C/CPP can be set with: `USER_C_FLAGS` / `USER_CXX_FLAGS`. + +#### Fixed +- Fix because of which one of the source files has been missed for Windows. +- Fix issue with unsupported concatenation of sources files / definitions (`+=`). + +#### Modified +- Refactor our `Makefiles` from different folders and platforms to use `include` directives to include shared definitions, flags, source files. + ## v4.15.0 November 25 2024 diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c26259..0ed79ce1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,17 +62,17 @@ num_option(USE_GZIP_COMPRESSION "Use gzip compression" ON) num_option(RECEIVE_GZIP_RESPONSE "Use gzip decompression" ON) num_option(USE_RETRY_CONFIGURATION "Use requests retry" OFF) num_option(USE_SUBSCRIBE_V2 "Use subscribe v2" ON) -num_option(USE_SUBSCRIBE_EVENT_ENGINE "Use Subscribe Event Engine" OFF) +num_option(USE_SUBSCRIBE_EVENT_ENGINE "Use Subscribe Event Engine [USE_SUBSCRIBE_V2=ON needed]" OFF) num_option(USE_ADVANCED_HISTORY "Use advanced history" ON) num_option(USE_OBJECTS_API "Use objects API" ON) num_option(USE_AUTO_HEARTBEAT "Use auto heartbeat" ON) num_option(USE_ACTIONS_API "Use actions API" ON) -num_option(USE_REVOKE_TOKEN_API "Use revoke token API" OFF) -num_option(USE_GRANT_TOKEN_API "Use grant token API" OFF) +num_option(USE_REVOKE_TOKEN_API "Use revoke token API [OPENSSL ONLY]" OFF) +num_option(USE_GRANT_TOKEN_API "Use grant token API [OPENSSL ONLY]" OFF) num_option(USE_FETCH_HISTORY "Use fetch history" ON) num_option(USE_CRYPTO_API "Use crypto API [OPENSSL ONLY]" OFF) num_option(USE_CALLBACK_API "Use callback API [CALLBACK=ON SYNC=OFF]" ${DEFAULT_USE_CALLBACK_API}) -num_option(USE_IPV6 "Use IPv6 [CALLBACK=ON]" ${DEFAULT_USE_CALLBACK_API}) +num_option(USE_IPV6 "Use IPv6" ON) num_option(USE_SET_DNS_SERVERS "Use set DNS servers [CALLBACK=ON]" ${DEFAULT_USE_CALLBACK_API}) num_option(USE_EXTERN_API "Use extern C API [WITH_CPP=ON]" ON) num_option(USE_LEGACY_CRYPTO_RANDOM_IV "Use random IV for legacy crypto module [OpenSSL only]" ON) @@ -112,6 +112,14 @@ set(FLAGS "\ -D PUBNUB_RAND_INIT_VECTOR=${USE_LEGACY_CRYPTO_RANDOM_IV} \ -D PUBNUB_MBEDTLS=${MBEDTLS}") +#Required on windows with Event Engine, so only winsock2 is used (otherwise it tries to use winsock and winsock2 and there are redefinition errors) +if(WIN32 OR WIN64 OR MSVC) +set(FLAGS "\ + ${FLAGS} \ + -D _WINSOCKAPI_") +endif() + + set(LDLIBS) set(OS_SOURCEFILES) @@ -277,19 +285,11 @@ if(${USE_CALLBACK_API}) ${CMAKE_CURRENT_LIST_DIR}/posix/pubnub_ntf_callback_posix.c ${CMAKE_CURRENT_LIST_DIR}/posix/pubnub_get_native_socket.c) elseif(WIN32 OR WIN64 OR MSVC) - if (${OPENSSL}) - set(INTF_SOURCEFILES - ${INTF_SOURCEFILES} - ${CMAKE_CURRENT_LIST_DIR}/openssl/pubnub_ntf_callback_windows.c - ${CMAKE_CURRENT_LIST_DIR}/openssl/pubnub_dns_system_servers.c - ${CMAKE_CURRENT_LIST_DIR}/openssl/pubnub_get_native_socket.c) - else() - set(INTF_SOURCEFILES - ${INTF_SOURCEFILES} - ${CMAKE_CURRENT_LIST_DIR}/windows/pubnub_ntf_callback_windows.c - ${CMAKE_CURRENT_LIST_DIR}/windows/pubnub_dns_system_servers.c - ${CMAKE_CURRENT_LIST_DIR}/windows/pubnub_get_native_socket.c) - endif() + set(INTF_SOURCEFILES + ${INTF_SOURCEFILES} + ${CMAKE_CURRENT_LIST_DIR}/windows/pubnub_ntf_callback_windows.c + ${CMAKE_CURRENT_LIST_DIR}/windows/pubnub_dns_system_servers.c + ${CMAKE_CURRENT_LIST_DIR}/windows/pubnub_get_native_socket.c) endif() else() message(STATUS "Using sync API") diff --git a/core/pbcc_fetch_history.c b/core/pbcc_fetch_history.c index 20d417d6..fb5254a3 100644 --- a/core/pbcc_fetch_history.c +++ b/core/pbcc_fetch_history.c @@ -18,58 +18,87 @@ enum pubnub_res pbcc_fetch_history_prep(struct pbcc_context* pb, - const char* channel, - unsigned int max_per_channel, - enum pubnub_tribool include_meta, - enum pubnub_tribool include_custom_message_type, - enum pubnub_tribool include_message_type, - enum pubnub_tribool include_user_id, - enum pubnub_tribool include_message_actions, - enum pubnub_tribool reverse, - char const* start, - char const* end) + const char* channel, + unsigned int max_per_channel, + enum pubnub_tribool include_meta, + enum pubnub_tribool + include_custom_message_type, + enum pubnub_tribool + include_message_type, + enum pubnub_tribool include_user_id, + enum pubnub_tribool + include_message_actions, + enum pubnub_tribool reverse, + char const* start, + char const* end) { char const* const uname = pubnub_uname(); - enum pubnub_res rslt = PNR_OK; + enum pubnub_res rslt = PNR_OK; pb->http_content_len = 0; - pb->msg_ofs = pb->msg_end = 0; + pb->msg_ofs = pb->msg_end = 0; pb->http_buf_len = snprintf(pb->http_buf, sizeof pb->http_buf, "/v3/%s/sub-key/%s/channel/", - (include_message_actions == pbccTrue) ? "history-with-actions" : "history", + (include_message_actions == pbccTrue) + ? "history-with-actions" + : "history", pb->subscribe_key); APPEND_URL_ENCODED_M(pb, channel); URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS); if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); } - int ch_count = 0; - char* ch_lst = (char*)strtok((char*)channel, ","); + int ch_count = 0; + char* ch_lst = (char*)strtok((char*)channel, ","); while (ch_lst != NULL) { ch_count++; ch_lst = (char*)strtok(NULL, ","); } if (max_per_channel <= 0) { - if (include_message_actions == pbccTrue || ch_count > 1) { max_per_channel = 25; } - else {max_per_channel = 100; } + if (include_message_actions == pbccTrue || ch_count > 1) { + max_per_channel = 25; + } + else { max_per_channel = 100; } } char max_per_ch_cnt_buf[sizeof(int) * 4 + 1]; - sprintf(max_per_ch_cnt_buf, "%d", max_per_channel); + snprintf(max_per_ch_cnt_buf, + sizeof(max_per_ch_cnt_buf), + "%d", + max_per_channel); if (max_per_channel) { ADD_URL_PARAM(qparam, max, max_per_ch_cnt_buf); } - if (include_meta != pbccNotSet) { ADD_URL_PARAM(qparam, include_meta, include_meta == pbccTrue ? "true" : "false"); } - if (include_custom_message_type != pbccNotSet) { ADD_URL_PARAM(qparam, include_custom_message_type, include_custom_message_type == pbccTrue ? "true" : "false"); } - if (include_message_type != pbccNotSet) { ADD_URL_PARAM(qparam, include_message_type, include_message_type == pbccTrue ? "true" : "false"); } - if (include_user_id != pbccNotSet) { ADD_URL_PARAM(qparam, include_uuid, include_user_id == pbccTrue ? "true" : "false"); } + if (include_meta != pbccNotSet) { + ADD_URL_PARAM(qparam, + include_meta, + include_meta == pbccTrue ? "true" : "false"); + } + if (include_custom_message_type != pbccNotSet) { + ADD_URL_PARAM(qparam, + include_custom_message_type, + include_custom_message_type == pbccTrue ? "true" : + "false"); + } + if (include_message_type != pbccNotSet) { + ADD_URL_PARAM(qparam, + include_message_type, + include_message_type == pbccTrue ? "true" : "false"); + } + if (include_user_id != pbccNotSet) { + ADD_URL_PARAM(qparam, + include_uuid, + include_user_id == pbccTrue ? "true" : "false"); + } #if PUBNUB_CRYPTO_API if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); } ADD_TS_TO_URL_PARAM(); #else ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif - if (reverse != pbccNotSet) { ADD_URL_PARAM(qparam, reverse, reverse == pbccTrue ? "true" : "false"); } + if (reverse != pbccNotSet) { + ADD_URL_PARAM(qparam, reverse, reverse == pbccTrue ? "true" : "false"); + } if (start) { ADD_URL_PARAM(qparam, start, start); } if (end) { ADD_URL_PARAM(qparam, end, end); } @@ -89,37 +118,39 @@ enum pubnub_res pbcc_fetch_history_prep(struct pbcc_context* pb, enum pubnub_res pbcc_parse_fetch_history_response(struct pbcc_context* pb) { - char* reply = pb->http_reply; - int replylen = pb->http_buf_len; + char* reply = pb->http_reply; + int replylen = pb->http_buf_len; struct pbjson_elem elem; if ((replylen < 2) || (reply[0] != '{')) { return PNR_FORMAT_ERROR; } - + pb->msg_end = replylen + 1; elem.end = pbjson_find_end_element(reply, reply + replylen); /* elem.end has to be just behind end curly brace */ if ((*reply != '{') || (*(elem.end++) != '}')) { - PUBNUB_LOG_ERROR("pbcc_parse_fetch_history_response(pbcc=%p) - Invalid: " - "response from server is not JSON - response='%s'\n", - pb, - reply); + PUBNUB_LOG_ERROR( + "pbcc_parse_fetch_history_response(pbcc=%p) - Invalid: " + "response from server is not JSON - response='%s'\n", + pb, + reply); return PNR_FORMAT_ERROR; } elem.start = reply; - if (pbjson_value_for_field_found(&elem, "status", "403")){ - PUBNUB_LOG_ERROR("pbcc_parse_fetch_history_response(pbcc=%p) - AccessDenied: " - "response from server - response='%s'\n", - pb, - reply); + if (pbjson_value_for_field_found(&elem, "status", "403")) { + PUBNUB_LOG_ERROR( + "pbcc_parse_fetch_history_response(pbcc=%p) - AccessDenied: " + "response from server - response='%s'\n", + pb, + reply); return PNR_ACCESS_DENIED; } - if (pbjson_value_for_field_found(&elem, "error", "true")){ + if (pbjson_value_for_field_found(&elem, "error", "true")) { PUBNUB_LOG_ERROR("pbcc_parse_fetch_history_response(pbcc=%p) - Error: " "response from server - response='%s'\n", pb, @@ -132,9 +163,9 @@ enum pubnub_res pbcc_parse_fetch_history_response(struct pbcc_context* pb) pubnub_chamebl_t pbcc_get_fetch_history(struct pbcc_context* pb) { - pubnub_chamebl_t result; - char const* reply = pb->http_reply; - int replylen = pb->http_buf_len; + pubnub_chamebl_t result; + char const* reply = pb->http_reply; + int replylen = pb->http_buf_len; struct pbjson_elem elem; if (pb->last_result != PNR_OK) { PUBNUB_LOG_ERROR("pbcc_get_fetch_history(pb=%p) can be called only if " @@ -144,16 +175,16 @@ pubnub_chamebl_t pbcc_get_fetch_history(struct pbcc_context* pb) PBTT_FETCH_HISTORY, pb->last_result, pubnub_res_2_string(pb->last_result)); - result.ptr = NULL; + result.ptr = NULL; result.size = 0; return result; } - + elem.start = reply; - elem.end = pbjson_find_end_element(reply, reply + replylen) + 1; + elem.end = pbjson_find_end_element(reply, reply + replylen) + 1; - result.size = elem.end - elem.start; - result.ptr = (char*)elem.start; + result.size = elem.end - elem.start; + result.ptr = (char*)elem.start; result.ptr[result.size] = '\0'; return result; diff --git a/core/pbcc_subscribe_event_engine.c b/core/pbcc_subscribe_event_engine.c index bab5eca0..75479dd6 100644 --- a/core/pbcc_subscribe_event_engine.c +++ b/core/pbcc_subscribe_event_engine.c @@ -1,10 +1,8 @@ /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ #include "pbcc_subscribe_event_engine.h" -#include #include #include -#include #include "core/pubnub_helper.h" #include "core/pubnub_subscribe_event_engine_internal.h" @@ -215,7 +213,7 @@ pbcc_subscribe_ee_t* pbcc_subscribe_ee_alloc(pubnub_t* pb) PBARRAY_CHAR_CONTENT_TYPE, (pbarray_element_free)free); ee->current_transaction = PBTT_NONE; - ee->cancel_invocation = NULL; + ee->cancel_invocation = NULL; pubnub_mutex_init(ee->mutw); if (NULL == ee->subscriptions) { @@ -557,7 +555,7 @@ enum pubnub_res pbcc_subscribe_ee_unsubscribe_all(pbcc_subscribe_ee_t* ee) PUBNUB_ASSERT_OPT(NULL != ee); pubnub_mutex_lock(ee->mutw); - char* ch,* cg; + char * ch, *cg; enum pubnub_res rslt = pbcc_subscribe_ee_subscribables_(ee->subscribables, &ch, &cg, @@ -736,7 +734,7 @@ enum pubnub_res pbcc_subscribe_ee_subscribe_( const bool sent_by_ee) { pbcc_ee_event_t* event = NULL; - char* ch = NULL,* cg = NULL; + char * ch = NULL, *cg = NULL; enum pubnub_res rslt = PNR_OK; if (update) { rslt = pbcc_subscribe_ee_update_subscribables_(ee); } @@ -798,7 +796,7 @@ enum pubnub_res pbcc_subscribe_ee_unsubscribe_( pbcc_subscribe_ee_t* ee, pbhash_set_t* subscribables) { - char* ch = NULL,* cg = NULL; + char *ch = NULL, *cg = NULL; bool send_leave = false; size_t count = 0; @@ -1070,14 +1068,14 @@ enum pubnub_res pbcc_subscribe_ee_subscribables_( ch_offset += snprintf(*channels + ch_offset, ch_len - ch_offset, "%s%s", - ch_offset > 0 ? ",": "", + ch_offset > 0 ? "," : "", sub->id->ptr); } else { cg_offset += snprintf(*channel_groups + cg_offset, cg_len - cg_offset, "%s%s", - cg_offset > 0 ? ",": "", + cg_offset > 0 ? "," : "", sub->id->ptr); } } diff --git a/core/pubnub_ccore.c b/core/pubnub_ccore.c index 04b69357..ab02303a 100644 --- a/core/pubnub_ccore.c +++ b/core/pubnub_ccore.c @@ -14,22 +14,22 @@ static enum pubnub_res simple_parse_response(struct pbcc_context* p) { struct pbjson_elem el; - char* reply = p->http_reply; - int replylen = p->http_buf_len; + char* reply = p->http_reply; + int replylen = p->http_buf_len; if (replylen < 2) { return PNR_FORMAT_ERROR; } el.start = reply; el.end = reply + replylen; - if (pbjson_value_for_field_found(&el, "status", "403")){ + if (pbjson_value_for_field_found(&el, "status", "403")) { PUBNUB_LOG_ERROR("simple_parse_response(pbcc=%p) - AccessDenied: " - "response from server - response='%s'\n", - p, - reply); + "response from server - response='%s'\n", + p, + reply); return PNR_ACCESS_DENIED; } - + if ((reply[0] != '[') || (reply[replylen - 1] != ']')) { return PNR_FORMAT_ERROR; } @@ -59,16 +59,17 @@ enum pubnub_res pbcc_parse_history_response(struct pbcc_context* p) enum pubnub_res pbcc_parse_presence_response(struct pbcc_context* p) { struct pbjson_elem el; - char* reply = p->http_reply; - int replylen = p->http_buf_len; + char* reply = p->http_reply; + int replylen = p->http_buf_len; if (replylen < 2) { return PNR_FORMAT_ERROR; } el.start = reply; el.end = reply + replylen; - if (pbjson_value_for_field_found(&el, "status", "403")){ - PUBNUB_LOG_ERROR("pbcc_parse_presence_response(pbcc=%p) - AccessDenied: " + if (pbjson_value_for_field_found(&el, "status", "403")) { + PUBNUB_LOG_ERROR( + "pbcc_parse_presence_response(pbcc=%p) - AccessDenied: " "response from server - response='%s'\n", p, reply); @@ -94,10 +95,11 @@ enum pubnub_res pbcc_parse_channel_registry_response(struct pbcc_context* p) struct pbjson_elem el; struct pbjson_elem found; - el.start = p->http_reply; - el.end = p->http_reply + p->http_buf_len; + el.start = p->http_reply; + el.end = p->http_reply + p->http_buf_len; if (pbjson_value_for_field_found(&el, "status", "403")) { - PUBNUB_LOG_ERROR("pbcc_parse_channel_registry_response(pbcc=%p) - AccessDenied: " + PUBNUB_LOG_ERROR( + "pbcc_parse_channel_registry_response(pbcc=%p) - AccessDenied: " "response from server - response='%s'\n", p, p->http_reply); @@ -169,7 +171,7 @@ enum pubnub_res pbcc_leave_prep(struct pbcc_context* pb, ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif if (channel_group) { ADD_URL_PARAM(qparam, channel-group, channel_group); } - + #if PUBNUB_CRYPTO_API SORT_URL_PARAMETERS(qparam); #endif @@ -187,8 +189,8 @@ enum pubnub_res pbcc_leave_prep(struct pbcc_context* pb, enum pubnub_res pbcc_time_prep(struct pbcc_context* pb) { - char const* user_id = pbcc_user_id_get(pb); - char const* const uname = pubnub_uname(); + char const* user_id = pbcc_user_id_get(pb); + char const* const uname = pubnub_uname(); PUBNUB_ASSERT_OPT(user_id != NULL); @@ -197,7 +199,7 @@ enum pubnub_res pbcc_time_prep(struct pbcc_context* pb) } pb->http_content_len = 0; - pb->msg_ofs = pb->msg_end = 0; + pb->msg_ofs = pb->msg_end = 0; pb->http_buf_len = snprintf(pb->http_buf, sizeof pb->http_buf, "/time/0"); @@ -222,14 +224,14 @@ enum pubnub_res pbcc_history_prep(struct pbcc_context* pb, char const* start, char const* end) { - char const* const uname = pubnub_uname(); - char const* user_id = pbcc_user_id_get(pb); - enum pubnub_res rslt = PNR_OK; + char const* const uname = pubnub_uname(); + char const* user_id = pbcc_user_id_get(pb); + enum pubnub_res rslt = PNR_OK; PUBNUB_ASSERT_OPT(user_id != NULL); pb->http_content_len = 0; - pb->msg_ofs = pb->msg_end = 0; + pb->msg_ofs = pb->msg_end = 0; #if PUBNUB_CRYPTO_API for (size_t i = 0; i < pb->decrypted_message_count; i++) { @@ -248,18 +250,28 @@ enum pubnub_res pbcc_history_prep(struct pbcc_context* pb, if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); } if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); } char cnt_buf[sizeof(int) * 4 + 1]; - sprintf(cnt_buf, "%d", count); + snprintf(cnt_buf, sizeof(cnt_buf), "%d", count); if (count) { ADD_URL_PARAM(qparam, count, cnt_buf); } ADD_URL_PARAM(qparam, include_token, include_token ? "true" : "false"); - if (string_token != pbccNotSet) { ADD_URL_PARAM(qparam, stringtoken, string_token == pbccTrue ? "1" : "0"); } + if (string_token != pbccNotSet) { + ADD_URL_PARAM(qparam, + stringtoken, + string_token == pbccTrue ? "1" : "0"); + } #if PUBNUB_CRYPTO_API if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); } ADD_TS_TO_URL_PARAM(); #else ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif - if (reverse != pbccNotSet) { ADD_URL_PARAM(qparam, reverse, reverse == pbccTrue ? "1" : "0"); } - if (include_meta != pbccNotSet) { ADD_URL_PARAM(qparam, include_meta, include_meta == pbccTrue ? "1" : "0"); } + if (reverse != pbccNotSet) { + ADD_URL_PARAM(qparam, reverse, reverse == pbccTrue ? "1" : "0"); + } + if (include_meta != pbccNotSet) { + ADD_URL_PARAM(qparam, + include_meta, + include_meta == pbccTrue ? "1" : "0"); + } if (start) { ADD_URL_PARAM(qparam, start, start); } if (end) { ADD_URL_PARAM(qparam, end, end); } @@ -282,9 +294,9 @@ enum pubnub_res pbcc_heartbeat_prep(struct pbcc_context* pb, const char* channel, const char* channel_group) { - char const* user_id = pbcc_user_id_get(pb); - char const* const uname = pubnub_uname(); - enum pubnub_res rslt = PNR_OK; + char const* user_id = pbcc_user_id_get(pb); + char const* const uname = pubnub_uname(); + enum pubnub_res rslt = PNR_OK; PUBNUB_ASSERT_OPT(user_id != NULL); @@ -299,16 +311,16 @@ enum pubnub_res pbcc_heartbeat_prep(struct pbcc_context* pb, } pb->http_content_len = 0; - pb->msg_ofs = pb->msg_end = 0; + pb->msg_ofs = pb->msg_end = 0; pb->http_buf_len = snprintf(pb->http_buf, sizeof pb->http_buf, "/v2/presence/sub-key/%s/channel/", pb->subscribe_key); APPEND_URL_ENCODED_M(pb, channel); - pb->http_buf_len += snprintf(pb->http_buf + pb->http_buf_len, - sizeof pb->http_buf - pb->http_buf_len, - "/heartbeat"); + pb->http_buf_len += snprintf(pb->http_buf + pb->http_buf_len, + sizeof pb->http_buf - pb->http_buf_len, + "/heartbeat"); URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS); if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); } if (channel_group) { ADD_URL_PARAM(qparam, channel-group, channel_group); } @@ -342,9 +354,9 @@ enum pubnub_res pbcc_here_now_prep(struct pbcc_context* pb, enum pubnub_tribool disable_uuids, enum pubnub_tribool state) { - char const* const uname = pubnub_uname(); - char const* user_id = pbcc_user_id_get(pb); - enum pubnub_res rslt = PNR_OK; + char const* const uname = pubnub_uname(); + char const* user_id = pbcc_user_id_get(pb); + enum pubnub_res rslt = PNR_OK; PUBNUB_ASSERT_OPT(user_id != NULL); @@ -355,7 +367,7 @@ enum pubnub_res pbcc_here_now_prep(struct pbcc_context* pb, } pb->http_content_len = 0; - pb->msg_ofs = pb->msg_end = 0; + pb->msg_ofs = pb->msg_end = 0; pb->http_buf_len = snprintf(pb->http_buf, sizeof pb->http_buf, @@ -374,8 +386,14 @@ enum pubnub_res pbcc_here_now_prep(struct pbcc_context* pb, #else ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif - if (disable_uuids != pbccNotSet) { ADD_URL_PARAM(qparam, disable_uuids, disable_uuids == pbccTrue ? "1" : "0"); } - if (state != pbccNotSet) { ADD_URL_PARAM(qparam, state, state == pbccTrue ? "1" : "0"); } + if (disable_uuids != pbccNotSet) { + ADD_URL_PARAM(qparam, + disable_uuids, + disable_uuids == pbccTrue ? "1" : "0"); + } + if (state != pbccNotSet) { + ADD_URL_PARAM(qparam, state, state == pbccTrue ? "1" : "0"); + } #if PUBNUB_CRYPTO_API SORT_URL_PARAMETERS(qparam); @@ -392,17 +410,18 @@ enum pubnub_res pbcc_here_now_prep(struct pbcc_context* pb, } -enum pubnub_res pbcc_where_now_prep(struct pbcc_context* pb, const char* user_id) +enum pubnub_res pbcc_where_now_prep(struct pbcc_context* pb, + const char* user_id) { PUBNUB_ASSERT_OPT(user_id != NULL); - enum pubnub_res rslt = PNR_OK; - char const* const uname = pubnub_uname(); - char const* pb_user_id = pbcc_user_id_get(pb); + enum pubnub_res rslt = PNR_OK; + char const* const uname = pubnub_uname(); + char const* pb_user_id = pbcc_user_id_get(pb); PUBNUB_ASSERT_OPT(pb_user_id != NULL); pb->http_content_len = 0; - pb->msg_ofs = pb->msg_end = 0; + pb->msg_ofs = pb->msg_end = 0; pb->http_buf_len = snprintf(pb->http_buf, sizeof pb->http_buf, @@ -418,7 +437,7 @@ enum pubnub_res pbcc_where_now_prep(struct pbcc_context* pb, const char* user_id #else ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif - + #if PUBNUB_CRYPTO_API SORT_URL_PARAMETERS(qparam); #endif @@ -442,9 +461,9 @@ enum pubnub_res pbcc_set_state_prep(struct pbcc_context* pb, { PUBNUB_ASSERT_OPT(user_id != NULL); PUBNUB_ASSERT_OPT(state != NULL); - enum pubnub_res rslt = PNR_OK; - char const* pb_user_id = pbcc_user_id_get(pb); - char const* const uname = pubnub_uname(); + enum pubnub_res rslt = PNR_OK; + char const* pb_user_id = pbcc_user_id_get(pb); + char const* const uname = pubnub_uname(); PUBNUB_ASSERT_OPT(pb_user_id != NULL); @@ -478,7 +497,7 @@ enum pubnub_res pbcc_set_state_prep(struct pbcc_context* pb, #else ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif - if (state){ ADD_URL_PARAM(qparam, state, state); } + if (state) { ADD_URL_PARAM(qparam, state, state); } #if PUBNUB_CRYPTO_API SORT_URL_PARAMETERS(qparam); @@ -501,10 +520,10 @@ enum pubnub_res pbcc_state_get_prep(struct pbcc_context* pb, const char* user_id) { PUBNUB_ASSERT_OPT(user_id != NULL); - enum pubnub_res rslt = PNR_OK; - char const* pb_user_id = pbcc_user_id_get(pb); - char const* const uname = pubnub_uname(); - + enum pubnub_res rslt = PNR_OK; + char const* pb_user_id = pbcc_user_id_get(pb); + char const* const uname = pubnub_uname(); + PUBNUB_ASSERT_OPT(pb_user_id != NULL); if (NULL == channel) { @@ -556,9 +575,9 @@ enum pubnub_res pbcc_remove_channel_group_prep(struct pbcc_context* pb, char const* channel_group) { PUBNUB_ASSERT_OPT(channel_group != NULL); - enum pubnub_res rslt = PNR_OK; - char const* user_id = pbcc_user_id_get(pb); - char const* const uname = pubnub_uname(); + enum pubnub_res rslt = PNR_OK; + char const* user_id = pbcc_user_id_get(pb); + char const* const uname = pubnub_uname(); PUBNUB_ASSERT_OPT(user_id != NULL); @@ -578,7 +597,7 @@ enum pubnub_res pbcc_remove_channel_group_prep(struct pbcc_context* pb, #else ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif - + #if PUBNUB_CRYPTO_API SORT_URL_PARAMETERS(qparam); #endif @@ -588,7 +607,8 @@ enum pubnub_res pbcc_remove_channel_group_prep(struct pbcc_context* pb, rslt = pbcc_sign_url(pb, "", pubnubSendViaGET, true); } #endif - PUBNUB_LOG_DEBUG("pbcc_remove_channel_group_prep. REQUEST =%s\n", pb->http_buf); + PUBNUB_LOG_DEBUG("pbcc_remove_channel_group_prep. REQUEST =%s\n", + pb->http_buf); return (rslt != PNR_OK) ? rslt : PNR_STARTED; } @@ -599,9 +619,9 @@ enum pubnub_res pbcc_channel_registry_prep(struct pbcc_context* pb, char const* channel) { PUBNUB_ASSERT_OPT(channel_group != NULL); - enum pubnub_res rslt = PNR_OK; - char const* user_id = pbcc_user_id_get(pb); - char const* const uname = pubnub_uname(); + enum pubnub_res rslt = PNR_OK; + char const* user_id = pbcc_user_id_get(pb); + char const* const uname = pubnub_uname(); PUBNUB_ASSERT_OPT(user_id != NULL); @@ -626,7 +646,7 @@ enum pubnub_res pbcc_channel_registry_prep(struct pbcc_context* pb, #else ADD_URL_AUTH_PARAM(pb, qparam, auth); #endif - + #if PUBNUB_CRYPTO_API SORT_URL_PARAMETERS(qparam); #endif diff --git a/core/pubnub_ccore_pubsub.h b/core/pubnub_ccore_pubsub.h index 737cbfed..2d5dabd2 100644 --- a/core/pubnub_ccore_pubsub.h +++ b/core/pubnub_ccore_pubsub.h @@ -37,13 +37,14 @@ /** The Pubnub "(C) core" context, contains context data that is shared among all Pubnub C clients. */ -struct pbcc_context { +struct pbcc_context +{ /** The publish key (to use when publishing) */ char const* publish_key; /** The subscribe key (to use when subscribing) */ char const* subscribe_key; /** The user_id to be sent to server. If empty string, don't send any */ - char *user_id; + char* user_id; /** The user_id length */ int user_id_len; /** The `auth` parameter to be sent to server. If NULL, don't send @@ -68,7 +69,7 @@ struct pbcc_context { #if PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE // Event Engine which supports new subscription loop. - pbcc_subscribe_ee_t *subscribe_ee; + pbcc_subscribe_ee_t* subscribe_ee; #endif /** The result of the last Pubnub transaction */ @@ -90,7 +91,7 @@ struct pbcc_context { #if PUBNUB_USE_GZIP_COMPRESSION /** Buffer for compressed message */ char gzip_msg_buf[PUBNUB_COMPRESSED_MAXLEN]; - + /** The length of compressed data in 'comp_http_buf' ready to be sent */ size_t gzip_msg_len; #endif @@ -325,11 +326,11 @@ struct pbcc_context { name[(int)(name##_index)].param_key = #key; \ name[(int)(name##_index)].key_size = sizeof(#key)-1; \ name[(int)(name##_index)].param_val = value; \ - (int)(name##_index)++; + (name##_index)++; #define ADD_URL_AUTH_PARAM(pb, name, key) \ if (pb->auth_token != NULL) { ADD_URL_PARAM(name, key, pb->auth_token); } \ - else if (pb->auth != NULL) { ADD_URL_PARAM(name, key, pb->auth); } + else if (pb->auth != NULL) { ADD_URL_PARAM(name, key, pb->auth); } #define ADD_URL_PARAM_SIZET(name, key, value) \ int val_len = snprintf(NULL, 0, "%lu", (long unsigned int)value); \ @@ -341,20 +342,20 @@ struct pbcc_context { name[(int)(name##_index)].param_key = #key; \ name[(int)(name##_index)].key_size = sizeof(#key)-1; \ name[(int)(name##_index)].param_val = name##_val_str; \ - (int)(name##_index)++; + (name##_index)++; #define ADD_URL_PARAM_TRUE_KEY(name, key, value) \ name[(int)(name##_index)].param_key = key; \ name[(int)(name##_index)].key_size = strlen(key); \ name[(int)(name##_index)].param_val = value; \ - (int)(name##_index)++; - -#define ADD_TS_TO_URL_PARAM() \ - time_t epoch_time = time(NULL); \ - char timestamp[16]; \ - if (epoch_time > 0) { \ - sprintf(timestamp, "%lld", (long long)epoch_time); \ - ADD_URL_PARAM(qparam, timestamp, timestamp); \ + (name##_index)++; + +#define ADD_TS_TO_URL_PARAM() \ + time_t epoch_time = time(NULL); \ + char timestamp[16]; \ + if (epoch_time > 0) { \ + snprintf(timestamp, sizeof(timestamp), "%lld", (long long)epoch_time); \ + ADD_URL_PARAM(qparam, timestamp, timestamp); \ } #define SORT_URL_PARAMETERS(name) \ @@ -398,8 +399,8 @@ struct pbcc_context { /** Initializes the Pubnub C core context */ void pbcc_init(struct pbcc_context* pbcc, - const char* publish_key, - const char* subscribe_key); + const char* publish_key, + const char* subscribe_key); /** Deinitializes the Pubnub C core context */ void pbcc_deinit(struct pbcc_context* p); @@ -475,14 +476,14 @@ void pbcc_via_post_headers(struct pbcc_context* p, char* header, size_t max_leng formatting the URI of the HTTP request. */ enum pubnub_res pbcc_publish_prep(struct pbcc_context* pb, - const char* channel, - const char* message, - const char* custom_message_type, - bool store_in_history, - bool norep, - char const* meta, - size_t ttl, - enum pubnub_method method); + const char* channel, + const char* message, + const char* custom_message_type, + bool store_in_history, + bool norep, + char const* meta, + size_t ttl, + enum pubnub_method method); /** Prepares the Signal operation (transaction), mostly by formatting the URI of the HTTP request. @@ -496,9 +497,9 @@ enum pubnub_res pbcc_signal_prep(struct pbcc_context* pb, formatting the URI of the HTTP request. */ enum pubnub_res pbcc_subscribe_prep(struct pbcc_context* p, - char const* channel, - char const* channel_group, - const unsigned* heartbeat); + char const* channel, + char const* channel_group, + const unsigned* heartbeat); /** Split @p buf string containing a JSON array (with arbitrary @@ -508,23 +509,23 @@ bool pbcc_split_array(char* buf); enum pubnub_res pbcc_append_url_param(struct pbcc_context* pb, - char const* param_name, - size_t param_name_len, - char const* param_val, - char separator); + char const* param_name, + size_t param_name_len, + char const* param_val, + char separator); enum pubnub_res pbcc_url_encode(struct pbcc_context* pb, char const* what, enum pubnub_trans pt); enum pubnub_res pbcc_append_url_param_encoded(struct pbcc_context* pb, - char const* param_name, - size_t param_name_len, + char const* param_name, + size_t param_name_len, char const* param_val, - char separator, + char separator, enum pubnub_trans pt); enum pubnub_res pbcc_sign_url(struct pbcc_context* pc, - const char* msg, - enum pubnub_method method, - bool v3sign); + const char* msg, + enum pubnub_method method, + bool v3sign); #endif /* !defined INC_PUBNUB_CCORE_PUBSUB */ diff --git a/core/pubnub_crypto.c b/core/pubnub_crypto.c index 7f3ef33a..76b6f1fb 100644 --- a/core/pubnub_crypto.c +++ b/core/pubnub_crypto.c @@ -610,9 +610,10 @@ char* pn_pam_hmac_sha256_sign(char const* key, char const* message) { enum pubnub_res pn_gen_pam_v2_sign(pubnub_t* p, char const* qs_to_sign, char const* partial_url, char* signature) { enum pubnub_res sign_status = PNR_OK; int str_to_sign_len = strlen(p->core.subscribe_key) + strlen(p->core.publish_key) + strlen(partial_url) + strlen(qs_to_sign); - char* str_to_sign = (char*)malloc(sizeof(char) * str_to_sign_len + 5); // 4 variables concat + 1 + size_t str_to_sign_size = sizeof(char) * str_to_sign_len + 5; + char* str_to_sign = (char*)malloc(str_to_sign_size); // 4 variables concat + 1 if (str_to_sign != NULL) { - sprintf(str_to_sign, "%s\n%s\n%s\n%s", p->core.subscribe_key, p->core.publish_key, partial_url, qs_to_sign); + snprintf(str_to_sign, str_to_sign_size, "%s\n%s\n%s\n%s", p->core.subscribe_key, p->core.publish_key, partial_url, qs_to_sign); } PUBNUB_LOG_DEBUG("\nv2 str_to_sign = %s\n", str_to_sign); char* part_sign = (char*)""; @@ -624,7 +625,7 @@ enum pubnub_res pn_gen_pam_v2_sign(pubnub_t* p, char const* qs_to_sign, char con #endif free((char*)str_to_sign); if (sign_status == PNR_OK) { - sprintf(signature, "%s", part_sign); + snprintf(signature, sizeof(signature), "%s", part_sign); } free(part_sign); return sign_status; @@ -661,13 +662,14 @@ enum pubnub_res pn_gen_pam_v3_sign(pubnub_t* p, char const* qs_to_sign, char con return PNR_CRYPTO_NOT_SUPPORTED; } int str_to_sign_len = strlen(method_verb) + strlen(p->core.publish_key) + strlen(partial_url) + strlen(qs_to_sign) + 4 * strlen("\n") + (hasBody ? strlen(msg) : 0); - char* str_to_sign = (char*)malloc(sizeof(char) * (str_to_sign_len + 1)); + size_t str_to_sign_size = sizeof(char) * (str_to_sign_len + 1); + char* str_to_sign = (char*)malloc(str_to_sign_size); if (str_to_sign != NULL) { if (hasBody) { - sprintf(str_to_sign, "%s\n%s\n%s\n%s\n%s", method_verb, p->core.publish_key, partial_url, qs_to_sign, msg); + snprintf(str_to_sign, str_to_sign_size, "%s\n%s\n%s\n%s\n%s", method_verb, p->core.publish_key, partial_url, qs_to_sign, msg); } else { - sprintf(str_to_sign, "%s\n%s\n%s\n%s\n", method_verb, p->core.publish_key, partial_url, qs_to_sign); + snprintf(str_to_sign, str_to_sign_size, "%s\n%s\n%s\n%s\n", method_verb, p->core.publish_key, partial_url, qs_to_sign); } } PUBNUB_LOG_DEBUG("\nv3 str_to_sign = %s\n", str_to_sign); @@ -685,7 +687,7 @@ enum pubnub_res pn_gen_pam_v3_sign(pubnub_t* p, char const* qs_to_sign, char con part_sign[strlen(part_sign) - 1] = '\0'; last_sign_char = part_sign[strlen(part_sign) - 1]; } - sprintf(signature, "v2.%s", part_sign); + snprintf(signature, sizeof(signature), "v2.%s", part_sign); } free(part_sign); return sign_status; diff --git a/core/pubnub_dns_servers.c b/core/pubnub_dns_servers.c index 57a63d33..bcf6570c 100644 --- a/core/pubnub_dns_servers.c +++ b/core/pubnub_dns_servers.c @@ -4,13 +4,13 @@ #if PUBNUB_SET_DNS_SERVERS #include "core/pubnub_dns_servers.h" #include "lib/pubnub_parse_ipv4_addr.h" +#if PUBNUB_USE_IPV6 +#include "lib/pubnub_parse_ipv6_addr.h" +#endif #else #error PUBNUB_SET_DNS_SERVERS must be defined and set to 1 before compiling this file #endif -#if PUBNUB_USE_IPV6 -#include "lib/pubnub_parse_ipv6_addr.h" -#endif #include "core/pubnub_assert.h" #include "core/pubnub_log.h" @@ -20,11 +20,15 @@ pubnub_mutex_static_decl_and_init(m_lock); -static struct pubnub_ipv4_address m_primary_dns_server_ipv4 pubnub_guarded_by(m_lock); -static struct pubnub_ipv4_address m_secondary_dns_server_ipv4 pubnub_guarded_by(m_lock); +static struct pubnub_ipv4_address m_primary_dns_server_ipv4 +pubnub_guarded_by(m_lock); +static struct pubnub_ipv4_address m_secondary_dns_server_ipv4 +pubnub_guarded_by(m_lock); #if PUBNUB_USE_IPV6 -static struct pubnub_ipv6_address m_primary_dns_server_ipv6 pubnub_guarded_by(m_lock); -static struct pubnub_ipv6_address m_secondary_dns_server_ipv6 pubnub_guarded_by(m_lock); +static struct pubnub_ipv6_address m_primary_dns_server_ipv6 +pubnub_guarded_by(m_lock); +static struct pubnub_ipv6_address m_secondary_dns_server_ipv6 +pubnub_guarded_by(m_lock); #endif /* PUBNUB_USE_IPV6 */ @@ -69,7 +73,8 @@ int pubnub_dns_set_primary_server_ipv4_str(char const* ipv4_str) } -int pubnub_dns_set_secondary_server_ipv4(struct pubnub_ipv4_address ipv4_address) +int pubnub_dns_set_secondary_server_ipv4( + struct pubnub_ipv4_address ipv4_address) { uint8_t* ipv4 = ipv4_address.ipv4; @@ -94,7 +99,8 @@ int pubnub_dns_set_secondary_server_ipv4_str(char const* ipv4_str) int ret; PUBNUB_ASSERT_OPT(ipv4_str != NULL); - PUBNUB_LOG_TRACE("pubnub_dns_set_secondary_server_ipv4_str(%s)\n", ipv4_str); + PUBNUB_LOG_TRACE("pubnub_dns_set_secondary_server_ipv4_str(%s)\n", + ipv4_str); pubnub_mutex_init_static(m_lock); pubnub_mutex_lock(m_lock); @@ -169,15 +175,16 @@ int pubnub_dns_set_primary_server_ipv6(struct pubnub_ipv6_address ipv6_address) { uint8_t* ipv6 = ipv6_address.ipv6; - PUBNUB_LOG_TRACE("pubnub_dns_set_primary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", - ipv6[0]*256 + ipv6[1], - ipv6[2]*256 + ipv6[3], - ipv6[4]*256 + ipv6[5], - ipv6[6]*256 + ipv6[7], - ipv6[8]*256 + ipv6[9], - ipv6[10]*256 + ipv6[11], - ipv6[12]*256 + ipv6[13], - ipv6[14]*256 + ipv6[15]); + PUBNUB_LOG_TRACE( + "pubnub_dns_set_primary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", + ipv6[0]*256 + ipv6[1], + ipv6[2]*256 + ipv6[3], + ipv6[4]*256 + ipv6[5], + ipv6[6]*256 + ipv6[7], + ipv6[8]*256 + ipv6[9], + ipv6[10]*256 + ipv6[11], + ipv6[12]*256 + ipv6[13], + ipv6[14]*256 + ipv6[15]); pubnub_mutex_init_static(m_lock); pubnub_mutex_lock(m_lock); @@ -205,19 +212,21 @@ int pubnub_dns_set_primary_server_ipv6_str(char const* ipv6_str) } -int pubnub_dns_set_secondary_server_ipv6(struct pubnub_ipv6_address ipv6_address) +int pubnub_dns_set_secondary_server_ipv6( + struct pubnub_ipv6_address ipv6_address) { uint8_t* ipv6 = ipv6_address.ipv6; - PUBNUB_LOG_TRACE("pubnub_dns_set_secondary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", - ipv6[0]*256 + ipv6[1], - ipv6[2]*256 + ipv6[3], - ipv6[4]*256 + ipv6[5], - ipv6[6]*256 + ipv6[7], - ipv6[8]*256 + ipv6[9], - ipv6[10]*256 + ipv6[11], - ipv6[12]*256 + ipv6[13], - ipv6[14]*256 + ipv6[15]); + PUBNUB_LOG_TRACE( + "pubnub_dns_set_secondary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", + ipv6[0]*256 + ipv6[1], + ipv6[2]*256 + ipv6[3], + ipv6[4]*256 + ipv6[5], + ipv6[6]*256 + ipv6[7], + ipv6[8]*256 + ipv6[9], + ipv6[10]*256 + ipv6[11], + ipv6[12]*256 + ipv6[13], + ipv6[14]*256 + ipv6[15]); pubnub_mutex_init_static(m_lock); pubnub_mutex_lock(m_lock); @@ -234,7 +243,8 @@ int pubnub_dns_set_secondary_server_ipv6_str(char const* ipv6_str) int ret; PUBNUB_ASSERT_OPT(ipv6_str != NULL); - PUBNUB_LOG_TRACE("pubnub_dns_set_secondary_server_ipv6_str(%s)\n", ipv6_str); + PUBNUB_LOG_TRACE("pubnub_dns_set_secondary_server_ipv6_str(%s)\n", + ipv6_str); pubnub_mutex_init_static(m_lock); pubnub_mutex_lock(m_lock); @@ -249,24 +259,27 @@ int pubnub_get_dns_primary_server_ipv6(struct pubnub_ipv6_address* o_ipv6) { int ret; const uint8_t* ipv6 = m_primary_dns_server_ipv6.ipv6; - uint8_t zero[sizeof m_primary_dns_server_ipv6.ipv6] = {0}; + uint8_t zero[sizeof m_primary_dns_server_ipv6.ipv6] = { 0 }; PUBNUB_ASSERT_OPT(o_ipv6 != NULL); pubnub_mutex_init_static(m_lock); pubnub_mutex_lock(m_lock); - PUBNUB_LOG_TRACE("pubnub_dns_get_primary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", - ipv6[0]*256 + ipv6[1], - ipv6[2]*256 + ipv6[3], - ipv6[4]*256 + ipv6[5], - ipv6[6]*256 + ipv6[7], - ipv6[8]*256 + ipv6[9], - ipv6[10]*256 + ipv6[11], - ipv6[12]*256 + ipv6[13], - ipv6[14]*256 + ipv6[15]); - - if (memcmp(m_primary_dns_server_ipv6.ipv6, zero, sizeof m_primary_dns_server_ipv6.ipv6) + PUBNUB_LOG_TRACE( + "pubnub_dns_get_primary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", + ipv6[0]*256 + ipv6[1], + ipv6[2]*256 + ipv6[3], + ipv6[4]*256 + ipv6[5], + ipv6[6]*256 + ipv6[7], + ipv6[8]*256 + ipv6[9], + ipv6[10]*256 + ipv6[11], + ipv6[12]*256 + ipv6[13], + ipv6[14]*256 + ipv6[15]); + + if (memcmp(m_primary_dns_server_ipv6.ipv6, + zero, + sizeof m_primary_dns_server_ipv6.ipv6) == 0) { ret = -1; } @@ -285,24 +298,27 @@ int pubnub_get_dns_secondary_server_ipv6(struct pubnub_ipv6_address* o_ipv6) { int ret; const uint8_t* ipv6 = m_secondary_dns_server_ipv6.ipv6; - uint8_t zero[sizeof m_secondary_dns_server_ipv6.ipv6] = {0}; + uint8_t zero[sizeof m_secondary_dns_server_ipv6.ipv6] = { 0 }; PUBNUB_ASSERT_OPT(o_ipv6 != NULL); pubnub_mutex_init_static(m_lock); pubnub_mutex_lock(m_lock); - PUBNUB_LOG_TRACE("pubnub_dns_get_secondary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", - ipv6[0]*256 + ipv6[1], - ipv6[2]*256 + ipv6[3], - ipv6[4]*256 + ipv6[5], - ipv6[6]*256 + ipv6[7], - ipv6[8]*256 + ipv6[9], - ipv6[10]*256 + ipv6[11], - ipv6[12]*256 + ipv6[13], - ipv6[14]*256 + ipv6[15]); - - if (memcmp(m_secondary_dns_server_ipv6.ipv6, zero, sizeof m_secondary_dns_server_ipv6.ipv6) + PUBNUB_LOG_TRACE( + "pubnub_dns_get_secondary_server_ipv6(%u:%u:%u:%u:%u:%u:%u:%u).\n", + ipv6[0]*256 + ipv6[1], + ipv6[2]*256 + ipv6[3], + ipv6[4]*256 + ipv6[5], + ipv6[6]*256 + ipv6[7], + ipv6[8]*256 + ipv6[9], + ipv6[10]*256 + ipv6[11], + ipv6[12]*256 + ipv6[13], + ipv6[14]*256 + ipv6[15]); + + if (memcmp(m_secondary_dns_server_ipv6.ipv6, + zero, + sizeof m_secondary_dns_server_ipv6.ipv6) == 0) { ret = -1; } diff --git a/core/pubnub_fetch_history.h b/core/pubnub_fetch_history.h index 2379a3d2..5b8b7dc5 100644 --- a/core/pubnub_fetch_history.h +++ b/core/pubnub_fetch_history.h @@ -7,7 +7,8 @@ #include "lib/pb_extern.h" /** Options for fetch history. */ -struct pubnub_fetch_history_options { +struct pubnub_fetch_history_options +{ /** The maximum number of messages to return per channel if multiple channels provided. * Has to be between 1 and 25 messages. Default is 25. * If single channel is provided, maximum 100 messages. Default is 100. @@ -50,7 +51,7 @@ struct pubnub_fetch_history_options { * false. */ bool include_user_id; - /** If true to recieve message actions with each history + /** If true to receive message actions with each history * message. If false, no message actions per message. Defaults to * false. */ @@ -83,9 +84,9 @@ PUBNUB_EXTERN struct pubnub_fetch_history_options pubnub_fetch_history_defopts(v @param opt Options for this fetch history transaction @return #PNR_STARTED on success, an error otherwise */ -PUBNUB_EXTERN enum pubnub_res pubnub_fetch_history(pubnub_t* pb, - char const* channel, - struct pubnub_fetch_history_options opt); +PUBNUB_EXTERN enum pubnub_res pubnub_fetch_history(pubnub_t* pb, + char const* channel, + struct pubnub_fetch_history_options opt); PUBNUB_EXTERN pubnub_chamebl_t pubnub_get_fetch_history(pubnub_t* pb); diff --git a/core/pubnub_grant_token_api.c b/core/pubnub_grant_token_api.c index 6d87dbfe..da3e815e 100644 --- a/core/pubnub_grant_token_api.c +++ b/core/pubnub_grant_token_api.c @@ -171,7 +171,7 @@ static CborError data_recursion(CborValue* it, int nestingLevel, char** json_res int64_t val; cbor_value_get_int64(it, &val); // can't fail char int_str[100]; - sprintf(int_str, "%lld", (long long)val); + snprintf(int_str, sizeof(int_str), "%lld", (long long)val); current_allocation_size = safe_alloc_strcat(json_result, int_str, current_allocation_size); break; } @@ -184,7 +184,7 @@ static CborError data_recursion(CborValue* it, int nestingLevel, char** json_res type = cbor_value_get_type(it); if (cbor_value_get_type(it) != CborInvalidType) { char byte_str[1000]; - sprintf(byte_str, "\"%s\":", buf); + snprintf(byte_str, sizeof(byte_str), "\"%s\":", buf); current_allocation_size = safe_alloc_strcat(json_result, byte_str, current_allocation_size); } else { @@ -202,7 +202,7 @@ static CborError data_recursion(CborValue* it, int nestingLevel, char** json_res } char base64_str[67]; // HMAC+SHA256 max size + quotes + tailing null - sprintf(base64_str, "\"%s\"", encoded_sig.ptr); + snprintf(base64_str, sizeof(base64_str), "\"%s\"", encoded_sig.ptr); free(encoded_sig.ptr); current_allocation_size = safe_alloc_strcat(json_result, base64_str, current_allocation_size); @@ -210,8 +210,9 @@ static CborError data_recursion(CborValue* it, int nestingLevel, char** json_res sig_flag = false; } else { - char* buff_str = (char*)malloc(sizeof(char) * (n+3)); - sprintf(buff_str, "\"%s\"", buf); + size_t buff_size = sizeof(char) * (n+3); + char* buff_str = (char*)malloc(buff_size); + snprintf(buff_str, buff_size, "\"%s\"", buf); current_allocation_size = safe_alloc_strcat(json_result, buff_str, current_allocation_size); free(buff_str); } @@ -234,15 +235,16 @@ static CborError data_recursion(CborValue* it, int nestingLevel, char** json_res size_t n; err = cbor_value_dup_text_string(it, &buf, &n, it); if (err) { return err; } // parse error - - char* txt_str = (char*)malloc(sizeof(char) * (n+4)); + + size_t txt_size = sizeof(char) * (n+4); + char* txt_str = (char*)malloc(txt_size); type = cbor_value_get_type(it); if (!uuid_flag) { - sprintf(txt_str, "\"%s\":", buf); + snprintf(txt_str, txt_size, "\"%s\":", buf); uuid_flag = false; } else { - sprintf(txt_str, "\"%s\",", buf); + snprintf(txt_str, txt_size, "\"%s\",", buf); } current_allocation_size = safe_alloc_strcat(json_result, txt_str, current_allocation_size); @@ -278,7 +280,7 @@ static CborError data_recursion(CborValue* it, int nestingLevel, char** json_res bool val; cbor_value_get_boolean(it, &val); // can't fail char bool_str[10]; - sprintf(bool_str, "%s:", val ? "true" : "false"); + snprintf(bool_str, sizeof(bool_str), "%s:", val ? "true" : "false"); current_allocation_size = safe_alloc_strcat(json_result, bool_str, current_allocation_size); break; @@ -296,7 +298,7 @@ static CborError data_recursion(CborValue* it, int nestingLevel, char** json_res cbor_value_get_double(it, &val); } char flt_str[1000]; - sprintf(flt_str, "%lf", val); + snprintf(flt_str, sizeof(flt_str), "%lf", val); current_allocation_size = safe_alloc_strcat(json_result, flt_str, current_allocation_size); break; @@ -358,7 +360,7 @@ char* pubnub_parse_token(pubnub_t* pb, char const* token){ unsigned int init_allocation_size = 5*(strlen(rawToken)/4); char * json_result = (char*)malloc(init_allocation_size); - sprintf(json_result, "%s", ""); + snprintf(json_result, init_allocation_size, "%s", ""); CborError err = cbor_parser_init(buf, length, 0, &parser, &it); if (!err){ diff --git a/core/pubnub_json_parse.c b/core/pubnub_json_parse.c index 8f26f0b0..ac63fab7 100644 --- a/core/pubnub_json_parse.c +++ b/core/pubnub_json_parse.c @@ -38,7 +38,7 @@ char const* pbjson_find_end_string(char const* start, char const* end) if (!in_escape) { return start; } - /*FALLTHRU*/ + /*FALLTHRU*/ default: in_escape = false; break; @@ -73,8 +73,8 @@ char const* pbjson_find_end_primitive(char const* start, char const* end) char const* pbjson_find_end_complex(char const* start, char const* end) { - bool in_string = false, in_escape = false; - int bracket_level = 0, brace_level = 0; + bool in_string = false, in_escape = false; + int bracket_level = 0, brace_level = 0; char c; char const* s; @@ -115,7 +115,7 @@ char const* pbjson_find_end_complex(char const* start, char const* end) in_string = false; break; } - /*FALLTHRU*/ + /*FALLTHRU*/ default: in_escape = false; break; @@ -171,8 +171,9 @@ pbjson_get_object_value(struct pbjson_elem const* p, if (*end != '"') { return jonmpStringNotTerminated; } - found = (end - s - 1 == name_len) && (0 == memcmp(s + 1, name, name_len)); - s = pbjson_skip_whitespace(end + 1, p->end); + found = (end - s - 1 == name_len) && ( + 0 == memcmp(s + 1, name, name_len)); + s = pbjson_skip_whitespace(end + 1, p->end); if (s == p->end) { return jonmpMissingColon; } @@ -217,7 +218,8 @@ bool pbjson_elem_equals_string(struct pbjson_elem const* e, char const* s) } -char const* pbjson_object_name_parse_result_2_string(enum pbjson_object_name_parse_result e) +char const* pbjson_object_name_parse_result_2_string( + enum pbjson_object_name_parse_result e) { switch (e) { case jonmpNoStartCurly: @@ -266,7 +268,10 @@ size_t pbjson_element_strcpy(struct pbjson_elem const* p, char* s, size_t n) return len + 1; } -bool pbjson_value_for_field_found(struct pbjson_elem const* p, char const* name, char const* value) { +bool pbjson_value_for_field_found(struct pbjson_elem const* p, + char const* name, + char const* value) +{ enum pbjson_object_name_parse_result result; struct pbjson_elem found; @@ -275,17 +280,20 @@ bool pbjson_value_for_field_found(struct pbjson_elem const* p, char const* name, return jonmpOK == result && pbjson_elem_equals_string(&found, value); } -char* pbjson_get_status_400_message_value(struct pbjson_elem const* el){ +char* pbjson_get_status_400_message_value(struct pbjson_elem const* el) +{ enum pbjson_object_name_parse_result json_rslt; - struct pbjson_elem parsed; + struct pbjson_elem parsed; json_rslt = pbjson_get_object_value(el, "message", &parsed); if (json_rslt == jonmpOK) { int parse_len = (int)(parsed.end - parsed.start); - PUBNUB_LOG_ERROR("pbjson_get_status_400_message_value: \"error\"='%.*s'\n", - parse_len, - parsed.start); - char* msgtext = (char*)malloc(sizeof(char) * (parse_len+3)); - sprintf(msgtext, "%.*s", parse_len, parsed.start); + PUBNUB_LOG_ERROR( + "pbjson_get_status_400_message_value: \"error\"='%.*s'\n", + parse_len, + parsed.start); + size_t text_size = sizeof(char) * (parse_len + 3); + char* msgtext = (char*)malloc(text_size); + snprintf(msgtext, text_size, "%.*s", parse_len, parsed.start); return msgtext; } diff --git a/core/pubnub_version_internal.h b/core/pubnub_version_internal.h index 2512985b..e47fc9bc 100644 --- a/core/pubnub_version_internal.h +++ b/core/pubnub_version_internal.h @@ -3,7 +3,7 @@ #define INC_PUBNUB_VERSION_INTERNAL -#define PUBNUB_SDK_VERSION "4.15.0" +#define PUBNUB_SDK_VERSION "4.16.0" #endif /* !defined INC_PUBNUB_VERSION_INTERNAL */ diff --git a/core/samples/pubnub_fetch_history_sample.c b/core/samples/pubnub_fetch_history_sample.c index 8cfb62b4..92f04071 100644 --- a/core/samples/pubnub_fetch_history_sample.c +++ b/core/samples/pubnub_fetch_history_sample.c @@ -146,6 +146,7 @@ int main(int argc, char* argv[]) struct pubnub_fetch_history_options opt = pubnub_fetch_history_defopts(); opt.include_custom_message_type = true; opt.include_message_type = true; + opt.include_user_id = true; opt.include_meta = true; res = pubnub_fetch_history(pbp, string_channels, opt); if (res == PNR_STARTED) { diff --git a/core/samples/subscribe_event_engine_sample.c b/core/samples/subscribe_event_engine_sample.c index 01e18735..4eddcd09 100644 --- a/core/samples/subscribe_event_engine_sample.c +++ b/core/samples/subscribe_event_engine_sample.c @@ -1,7 +1,11 @@ /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ #include +#if !defined _WIN32 #include +#else +#include +#endif #include #include @@ -87,7 +91,11 @@ static void wait_seconds(const double time_in_seconds) double time_passed_in_seconds; do { time_passed_in_seconds = difftime(time(NULL), start); +#if !defined _WIN32 usleep(10); +#else + Sleep(1); +#endif } while (time_passed_in_seconds < time_in_seconds); } @@ -166,7 +174,7 @@ void subscribe_message_listener_( char* msg = string_from_mem_block(message.payload); char* tt = string_from_mem_block(message.tt); char* type = message_type_2_string(message.message_type); - char client[100]; + char client[100]; if (global) { snprintf(client, sizeof(client), "PubNub (%p) received", pb); diff --git a/cpp/posix.mk b/cpp/posix.mk index 7f9113f5..a73c0254 100644 --- a/cpp/posix.mk +++ b/cpp/posix.mk @@ -1,177 +1,38 @@ -SOURCEFILES = ../core/pbcc_set_state.c ../core/pubnub_pubsubapi.c ../core/pubnub_coreapi.c ../core/pubnub_coreapi_ex.c ../core/pubnub_ccore_pubsub.c ../core/pubnub_ccore.c ../core/pubnub_netcore.c ../lib/sockets/pbpal_sockets.c ../lib/sockets/pbpal_resolv_and_connect_sockets.c ../lib/sockets/pbpal_handle_socket_error.c ../core/pubnub_alloc_std.c ../core/pubnub_assert_std.c ../core/pubnub_generate_uuid.c ../core/pubnub_blocking_io.c ../posix/posix_socket_blocking_io.c ../core/pubnub_timers.c ../core/pubnub_json_parse.c ../lib/md5/md5.c ../lib/base64/pbbase64.c ../lib/pb_strnlen_s.c ../lib/pb_strncasecmp.c ../core/pubnub_helper.c pubnub_version_posix.cpp ../posix/pubnub_generate_uuid_posix.c ../posix/pbpal_posix_blocking_io.c ../core/pubnub_free_with_timeout_std.c pubnub_subloop.cpp ../posix/msstopwatch_monotonic_clock.c ../posix/pbtimespec_elapsed_ms.c ../core/pubnub_url_encode.c ../core/pubnub_memory_block.c ../posix/pb_sleep_ms.c +# Makefile for PubNub C-core SDK. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. -ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -endif +# Making CPP version of the PubNub SDK. +WITH_CPP = 1 -ifndef USE_PROXY -USE_PROXY = 1 -endif +include ../make/posix_preprocessing.mk +include ../make/posix_source_files.mk +include ../make/posix_compiler_linker_flags.mk -ifndef USE_GZIP_COMPRESSION -USE_GZIP_COMPRESSION = 1 -endif -ifndef RECEIVE_GZIP_RESPONSE -RECEIVE_GZIP_RESPONSE = 1 -endif +############################################################################### +# Build targets # +############################################################################### -ifndef USE_SUBSCRIBE_V2 -USE_SUBSCRIBE_V2 = 1 -endif +TARGET_BUILD_PATH = -ifndef USE_ADVANCED_HISTORY -USE_ADVANCED_HISTORY = 1 -endif +include ../make/posix_cpp_targets.mk -ifndef USE_OBJECTS_API -USE_OBJECTS_API = 1 -endif - -ifndef USE_ACTIONS_API -USE_ACTIONS_API = 1 -endif - -ifndef USE_AUTO_HEARTBEAT -USE_AUTO_HEARTBEAT = 1 -endif - -ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 0 -endif - -ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 0 -endif - -ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -endif - -ifeq ($(USE_PROXY), 1) -SOURCEFILES += ../core/pubnub_proxy.c ../core/pubnub_proxy_core.c ../core/pbhttp_digest.c ../core/pbntlm_core.c ../core/pbntlm_packer_std.c -endif - -ifeq ($(USE_GZIP_COMPRESSION), 1) -SOURCEFILES += ../lib/miniz/miniz_tdef.c ../lib/miniz/miniz.c ../lib/pbcrc32.c ../core/pbgzip_compress.c -endif - -ifeq ($(RECEIVE_GZIP_RESPONSE), 1) -SOURCEFILES += ../lib/miniz/miniz_tinfl.c ../core/pbgzip_decompress.c -endif - -ifeq ($(USE_SUBSCRIBE_V2), 1) -SOURCEFILES += ../core/pbcc_subscribe_v2.c ../core/pubnub_subscribe_v2.c -endif - -ifeq ($(USE_ADVANCED_HISTORY), 1) -SOURCEFILES += ../core/pbcc_advanced_history.c ../core/pubnub_advanced_history.c -endif - -ifeq ($(USE_OBJECTS_API), 1) -SOURCEFILES += ../core/pbcc_objects_api.c ../core/pubnub_objects_api.c -endif - -ifeq ($(USE_ACTIONS_API), 1) -SOURCEFILES += ../core/pbcc_actions_api.c ../core/pubnub_actions_api.c -endif - -ifeq ($(USE_AUTO_HEARTBEAT), 1) -SOURCEFILES += ../core/pbauto_heartbeat.c ../posix/pbauto_heartbeat_init_posix.c ../lib/pbstr_remove_from_list.c -endif - -ifeq ($(USE_FETCH_HISTORY), 1) -SOURCEFILES += ../core/pubnub_fetch_history.c ../core/pbcc_fetch_history.c -endif - -OS := $(shell uname) -ifeq ($(OS),Darwin) -SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c -LDLIBS=-lpthread -else -SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c -LDLIBS=-lrt -lpthread -endif - -CFLAGS =-g -I .. -I ../posix -I . -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) -# -g enables debugging, remove to get a smaller executable - - -all: cpp11 cpp98 - -cpp98: pubnub_sync_sample pubnub_callback_sample cancel_subscribe_sync_sample subscribe_publish_callback_sample futres_nesting_sync futres_nesting_callback pubnub_sync_subloop_sample pubnub_callback_subloop_sample - -cpp11: pubnub_callback_cpp11_sample futres_nesting_callback_cpp11 fntest_runner pubnub_callback_cpp11_subloop_sample - -SYNC_INTF_SOURCEFILES=../core/pubnub_ntf_sync.c ../core/srand_from_pubnub_time.c - -pubnub_sync_sample: samples/pubnub_sample.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/pubnub_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -cancel_subscribe_sync_sample: samples/cancel_subscribe_sync_sample.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/cancel_subscribe_sync_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -futres_nesting_sync: samples/futres_nesting.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/futres_nesting.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -pubnub_sync_subloop_sample: samples/pubnub_subloop_sample.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/pubnub_subloop_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -## -# The socket poller module to use. You should use the `poll` poller, it -# doesn't have the weird restrictions of `select` poller. OTOH, -# select() on Windows is compatible w/BSD sockets select(), while -# WSAPoll() has some weird differences to poll(). The names are the -# same until the last `_`, then it's `poll` vs `select`. -SOCKET_POLLER_C=../lib/sockets/pbpal_ntf_callback_poller_poll.c - -CALLBACK_INTF_SOURCEFILES= ../posix/pubnub_ntf_callback_posix.c ../posix/pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c $(SOCKET_POLLER_C) ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c - -ifndef USE_DNS_SERVERS -USE_DNS_SERVERS = 1 -endif - -ifndef USE_IPV6 -USE_IPV6 = 1 -endif - -ifeq ($(USE_DNS_SERVERS), 1) -CALLBACK_INTF_SOURCEFILES += ../core/pubnub_dns_servers.c ../posix/pubnub_dns_system_servers.c ../lib/pubnub_parse_ipv4_addr.c -else ifeq ($(USE_PROXY), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv4_addr.c -endif - -ifeq ($(USE_IPV6), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c -endif - -CFLAGS_CALLBACK = -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_SET_DNS_SERVERS=$(USE_DNS_SERVERS) - -pubnub_callback_sample: samples/pubnub_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp - $(CXX) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -x c++ samples/pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp $(SOURCEFILES) $(LDLIBS) $(LDLIBS) - -pubnub_callback_cpp11_sample: samples/pubnub_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) -o $@ -std=c++11 -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -x c++ samples/pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(LDLIBS) - -subscribe_publish_callback_sample: samples/subscribe_publish_callback_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp - $(CXX) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/subscribe_publish_callback_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp $(SOURCEFILES) $(LDLIBS) - -futres_nesting_callback: samples/futres_nesting.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp - $(CXX) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/futres_nesting.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp $(SOURCEFILES) $(LDLIBS) - -futres_nesting_callback_cpp11: samples/futres_nesting.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) -o $@ -std=c++11 -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/futres_nesting.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(LDLIBS) - -pubnub_callback_subloop_sample: samples/pubnub_subloop_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp - $(CXX) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/pubnub_subloop_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp $(SOURCEFILES) $(LDLIBS) - -pubnub_callback_cpp11_subloop_sample: samples/pubnub_subloop_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) -o $@ -std=c++11 -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/pubnub_subloop_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(LDLIBS) - -fntest_runner: fntest/pubnub_fntest_runner.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest/pubnub_fntest.cpp fntest/pubnub_fntest_basic.cpp fntest/pubnub_fntest_medium.cpp - $(CXX) -o $@ -std=c++11 -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING $(CFLAGS) -x c++ fntest/pubnub_fntest_runner.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest/pubnub_fntest.cpp fntest/pubnub_fntest_basic.cpp fntest/pubnub_fntest_medium.cpp $(SOURCEFILES) $(LDLIBS) +all: \ + $(TARGET_BUILD_PATH)pubnub_callback_cpp11_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_cpp11_subloop_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_subloop_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)subscribe_publish_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_subloop_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)cancel_subscribe_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_sync$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback_cpp11$(APP_EXT) \ + $(TARGET_BUILD_PATH)fntest_runner$(APP_EXT) clean: find . -type d -iname "*.dSYM" -exec rm -rf {} \+ - find . -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf + find . -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf \ No newline at end of file diff --git a/cpp/posix_openssl.mk b/cpp/posix_openssl.mk index 5fa51c7e..204bd9ae 100644 --- a/cpp/posix_openssl.mk +++ b/cpp/posix_openssl.mk @@ -1,231 +1,45 @@ -SOURCEFILES = ../core/pbcc_set_state.c ../core/pubnub_pubsubapi.c ../core/pubnub_coreapi.c ../core/pubnub_ccore_pubsub.c ../core/pubnub_ccore.c ../core/pubnub_netcore.c ../lib/sockets/pbpal_resolv_and_connect_sockets.c ../lib/sockets/pbpal_handle_socket_error.c ../openssl/pbpal_openssl.c ../openssl/pbpal_connect_openssl.c ../openssl/pbpal_add_system_certs_posix.c ../core/pubnub_alloc_std.c ../core/pubnub_assert_std.c ../core/pubnub_generate_uuid.c ../core/pubnub_blocking_io.c ../posix/posix_socket_blocking_io.c ../core/pubnub_free_with_timeout_std.c ../core/pubnub_timers.c ../core/pubnub_json_parse.c ../lib/md5/md5.c ../lib/base64/pbbase64.c ../lib/pb_strnlen_s.c ../lib/pb_strncasecmp.c ../core/pubnub_helper.c pubnub_version_posix.cpp ../posix/pubnub_generate_uuid_posix.c ../openssl/pbpal_openssl_blocking_io.c ../core/pubnub_coreapi_ex.c ../posix/msstopwatch_monotonic_clock.c ../posix/pbtimespec_elapsed_ms.c ../core/pubnub_url_encode.c ../core/pubnub_memory_block.c ../posix/pb_sleep_ms.c -OBJFILES = pbcc_set_state.o pubnub_pubsubapi.o pubnub_coreapi.o pubnub_coreapi_ex.o pubnub_ccore_pubsub.o pubnub_ccore.o pubnub_netcore.o pbpal_resolv_and_connect_sockets.o pbpal_handle_socket_error.o pubnub_alloc_std.o pubnub_assert_std.o pubnub_generate_uuid.o pubnub_blocking_io.o posix_socket_blocking_io.o pubnub_timers.o pubnub_json_parse.o md5.o pbbase64.o pb_strnlen_s.o pb_strncasecmp.o pubnub_helper.o pubnub_version_posix.o pubnub_generate_uuid_posix.o pubnub_free_with_timeout_std.o msstopwatch_monotonic_clock.o pbtimespec_elapsed_ms.o pubnub_url_encode.o pubnub_memory_block.o pb_sleep_ms.o pubnub_futres_sync.o pbpal_connect_openssl.o pbpal_openssl.o pbpal_add_system_certs_posix.o pbpal_openssl_blocking_io.o pb_sleep_ms.o - -ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -endif - -ifndef USE_PROXY -USE_PROXY = 1 -endif - -ifndef USE_GZIP_COMPRESSION -USE_GZIP_COMPRESSION = 1 -endif - -ifndef RECEIVE_GZIP_RESPONSE -RECEIVE_GZIP_RESPONSE = 1 -endif - -ifndef USE_SUBSCRIBE_V2 -USE_SUBSCRIBE_V2 = 1 -endif - -ifndef USE_ADVANCED_HISTORY -USE_ADVANCED_HISTORY = 1 -endif - -ifndef USE_OBJECTS_API -USE_OBJECTS_API = 1 -endif - -ifndef USE_ACTIONS_API -USE_ACTIONS_API = 1 -endif - -ifndef USE_AUTO_HEARTBEAT -USE_AUTO_HEARTBEAT = 1 -endif - -ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 1 -endif - -ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 1 -endif - -ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -endif - -ifndef USE_CRYPTO_API -USE_CRYPTO_API = 1 -endif - -ifeq ($(USE_PROXY), 1) -SOURCEFILES += ../core/pubnub_proxy.c ../core/pubnub_proxy_core.c ../core/pbhttp_digest.c ../core/pbntlm_core.c ../core/pbntlm_packer_std.c -OBJFILES += pubnub_proxy.o pubnub_proxy_core.o pbhttp_digest.o pbntlm_core.o pbntlm_packer_std.o -endif - -ifeq ($(USE_GZIP_COMPRESSION), 1) -SOURCEFILES += ../lib/miniz/miniz_tdef.c ../lib/miniz/miniz.c ../lib/pbcrc32.c ../core/pbgzip_compress.c -OBJFILES += miniz_tdef.o miniz.o pbcrc32.o pbgzip_compress.o -endif - -ifeq ($(RECEIVE_GZIP_RESPONSE), 1) -SOURCEFILES += ../lib/miniz/miniz_tinfl.c ../core/pbgzip_decompress.c -OBJFILES += miniz_tinfl.o pbgzip_decompress.o -endif - -ifeq ($(USE_SUBSCRIBE_V2), 1) -SOURCEFILES += ../core/pbcc_subscribe_v2.c ../core/pubnub_subscribe_v2.c -OBJFILES += pbcc_subscribe_v2.o pubnub_subscribe_v2.o -endif - -ifeq ($(USE_ADVANCED_HISTORY), 1) -SOURCEFILES += ../core/pbcc_advanced_history.c ../core/pubnub_advanced_history.c -OBJFILES += pbcc_advanced_history.o pubnub_advanced_history.o -endif - -ifeq ($(USE_OBJECTS_API), 1) -SOURCEFILES += ../core/pbcc_objects_api.c ../core/pubnub_objects_api.c -OBJFILES += pbcc_objects_api.o pubnub_objects_api.o -endif - -ifeq ($(USE_ACTIONS_API), 1) -SOURCEFILES += ../core/pbcc_actions_api.c ../core/pubnub_actions_api.c -OBJFILES += pbcc_actions_api.o pubnub_actions_api.o -endif - -ifeq ($(USE_AUTO_HEARTBEAT), 1) -SOURCEFILES += ../core/pbauto_heartbeat.c ../openssl/pbauto_heartbeat_init_posix.c ../lib/pbstr_remove_from_list.c -OBJFILES += pbauto_heartbeat.o pbauto_heartbeat_init_posix.o pbstr_remove_from_list.o -endif - -ifeq ($(USE_GRANT_TOKEN), 1) -SOURCEFILES += ../core/pbcc_grant_token_api.c ../core/pubnub_grant_token_api.c ../lib/cbor/cborparser.c ../lib/cbor/cborerrorstrings.c ../lib/cbor/cborparser_dup_string.c -OBJFILES += pubnub_grant_token_api.o pbcc_grant_token_api.o cborparser.o cborerrorstrings.o cborparser_dup_string.o -endif - -ifeq ($(USE_FETCH_HISTORY), 1) -SOURCEFILES += ../core/pubnub_fetch_history.c ../core/pbcc_fetch_history.c -OBJFILES += pubnub_fetch_history.o pbcc_fetch_history.o -endif - -ifeq ($(USE_REVOKE_TOKEN), 1) -SOURCEFILES += ../core/pubnub_revoke_token_api.c ../core/pbcc_revoke_token_api.c -OBJFILES += pubnub_revoke_token_api.o pbcc_revoke_token_api.o -endif - -ifeq ($(USE_CRYPTO_API), 1) -SOURCEFILES += ../core/pbcc_crypto.c ../core/pbcc_crypto_aes_cbc.c ../core/pbcc_crypto_legacy.c ../core/pubnub_crypto.c ../openssl/pbaes256.c -OBJFILES += pbcc_crypto.o pbcc_crypto_aes_cbc.o pbcc_crypto_legacy.o pubnub_crypto.o pbaes256.o -endif - -CFLAGS =-g -I .. -I . -I ../openssl -I ../lib/base64 -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) -D PUBNUB_CRYPTO_API=$(USE_CRYPTO_API) -# -g enables debugging, remove to get a smaller executable - -OS := $(shell uname) -ifeq ($(OS),Darwin) - SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c - OBJFILES += monotonic_clock_get_time_darwin.o - LDLIBS=-lpthread -lssl -lcrypto - - # Ensure OpenSSL paths are set. - OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) - OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) - ifneq ($(OPENSSL_CFLAGS),) - CFLAGS += $(OPENSSL_CFLAGS) - endif - ifneq ($(OPENSSL_LIBS),) - LDLIBS += $(OPENSSL_LIBS) - endif -else - SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c - OBJFILES += monotonic_clock_get_time_posix.o - LDLIBS=-lrt -lpthread -lssl -lcrypto - - ifeq ($(shell test -d "/usr/local/opt/openssl" && echo yes || echo no),yes) - CFLAGS += -I/usr/local/opt/openssl/include - else - # Path on GitHub Action Runner (ubuntu-latest image) - ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) - CFLAGS += -I/usr/include - endif - endif - # Path on GitHub Action Runner (ubuntu-latest image) - ifeq ($(shell test -d "/usr/lib/x86_64-linux-gnu" && echo yes || echo no),yes) - LDLIBS += -L/usr/lib/x86_64-linux-gnu - endif -endif - - -all: openssl/pubnub_sync_sample openssl/pubnub_callback_sample openssl/pubnub_sync_grant_sample openssl/pubnub_callback_cpp11_sample openssl/cancel_subscribe_sync_sample openssl/subscribe_publish_callback_sample openssl/futres_nesting_sync openssl/fntest_runner openssl/futres_nesting_callback openssl/futres_nesting_callback_cpp11 - -SYNC_INTF_SOURCEFILES=../core/pubnub_ntf_sync.c ../core/srand_from_pubnub_time.c -SYNC_INTF_OBJFILES=pubnub_ntf_sync.o srand_from_pubnub_time.o - -openssl/pubnub_sync : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -c $(CFLAGS) -x c++ $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - ar rcs pubnub_sync.a $(OBJFILES) $(SYNC_INTF_OBJFILES) pubnub_futres_sync.o - -openssl/pubnub_sync_sample: samples/pubnub_sample.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/pubnub_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/pubnub_sync_grant_sample: samples/pubnub_sample_grant_token.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/pubnub_sample_grant_token.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/pubnub_sync_revoke_sample: samples/pubnub_sample_revoke_token.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/pubnub_sample_revoke_token.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/cancel_subscribe_sync_sample: samples/cancel_subscribe_sync_sample.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/cancel_subscribe_sync_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/futres_nesting_sync: samples/futres_nesting.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/futres_nesting.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/pubnub_crypto_module_sample: samples/pubnub_crypto_module_sample.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) -o $@ $(CFLAGS) -x c++ samples/pubnub_crypto_module_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/fntest_runner: fntest/pubnub_fntest_runner.cpp $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest/pubnub_fntest.cpp fntest/pubnub_fntest_basic.cpp fntest/pubnub_fntest_medium.cpp - $(CXX) -o $@ --std=c++11 $(CFLAGS) -x c++ fntest/pubnub_fntest_runner.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest/pubnub_fntest.cpp fntest/pubnub_fntest_basic.cpp fntest/pubnub_fntest_medium.cpp $(SOURCEFILES) $(LDLIBS) - -## -# The socket poller module to use. You should use the `poll` poller it -# doesn't have the weird restrictions of `select` poller. OTOH, -# select() on Windows is compatible w/BSD sockets select(), while -# WSAPoll() has some weird differences to poll(). The names are the -# same until the last `_`, then it's `poll` vs `select. -SOCKET_POLLER_C=../lib/sockets/pbpal_ntf_callback_poller_poll.c - -CALLBACK_INTF_SOURCEFILES= ../openssl/pubnub_ntf_callback_posix.c ../openssl/pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c $(SOCKET_POLLER_C) ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c - -ifndef USE_DNS_SERVERS -USE_DNS_SERVERS = 1 -endif - -ifndef USE_IPV6 -USE_IPV6 = 1 -endif - -ifeq ($(USE_DNS_SERVERS), 1) -CALLBACK_INTF_SOURCEFILES += ../core/pubnub_dns_servers.c ../posix/pubnub_dns_system_servers.c ../lib/pubnub_parse_ipv4_addr.c -else ifeq ($(USE_PROXY), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv4_addr.c -endif - -ifeq ($(USE_IPV6), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c -endif - -CFLAGS_CALLBACK = -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_SET_DNS_SERVERS=$(USE_DNS_SERVERS) - -openssl/pubnub_callback_sample: samples/pubnub_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp - $(CXX) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/pubnub_callback_cpp11_sample: samples/pubnub_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) -o $@ --std=c++11 -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/subscribe_publish_callback_sample: samples/subscribe_publish_callback_sample.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp - $(CXX) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/subscribe_publish_callback_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/futres_nesting_callback: samples/futres_nesting.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp - $(CXX) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/futres_nesting.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_posix.cpp $(SOURCEFILES) $(LDLIBS) - -openssl/futres_nesting_callback_cpp11: samples/futres_nesting.cpp $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) -o $@ --std=c++11 -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) -x c++ samples/futres_nesting.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(LDLIBS) +# Makefile for PubNub C-core SDK with SSL support. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. + +# Making CPP version of the PubNub SDK with OpenSSL support. +WITH_CPP = 1 +OPENSSL = 1 +USE_CRYPTO_API ?= 1 +USE_GRANT_TOKEN ?= 1 +USE_REVOKE_TOKEN ?= 1 + +include ../make/posix_preprocessing.mk +include ../make/posix_source_files.mk +include ../make/posix_compiler_linker_flags.mk + + +############################################################################### +# Build targets # +############################################################################### + +TARGET_BUILD_PATH = openssl/ + +include ../make/posix_cpp_targets.mk + + +all: \ + $(TARGET_BUILD_PATH)pubnub_callback_cpp11_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_cpp11_subloop_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_subloop_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_crypto_module_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)subscribe_publish_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_grant_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_subloop_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_revoke_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)cancel_subscribe_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_sync$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback_cpp11$(APP_EXT) \ + $(TARGET_BUILD_PATH)fntest_runner$(APP_EXT) clean: - find openssl -type d -iname "*.dSYM" -exec rm -rf {} \+ - find openssl -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf + find $(TARGET_BUILD_PATH:/=) -type d -iname "*.dSYM" -exec rm -rf {} \+ + find $(TARGET_BUILD_PATH:/=) -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf \ No newline at end of file diff --git a/cpp/windows.mk b/cpp/windows.mk index 4d1fcf81..24eced99 100644 --- a/cpp/windows.mk +++ b/cpp/windows.mk @@ -1,89 +1,37 @@ -SOURCEFILES = ..\core\pbcc_set_state.c ..\core\pubnub_pubsubapi.c ..\core\pubnub_coreapi.c ..\core\pubnub_coreapi_ex.c ..\core\pubnub_ccore_pubsub.c ..\core\pubnub_ccore.c ..\core\pubnub_netcore.c ..\lib\sockets\pbpal_sockets.c ..\lib\sockets\pbpal_resolv_and_connect_sockets.c ..\lib\sockets\pbpal_handle_socket_error.c ..\core\pubnub_alloc_std.c ..\core\pubnub_assert_std.c ..\core\pubnub_generate_uuid.c ..\core\pubnub_timers.c ..\core\pubnub_blocking_io.c ..\lib\base64\pbbase64.c ..\core\pubnub_json_parse.c ..\core\pubnub_free_with_timeout_std.c ..\windows\pbtimespec_elapsed_ms.c ..\lib\md5\md5.c ..\lib\pb_strnlen_s.c ..\lib\pb_strncasecmp.c ..\core\pubnub_helper.c pubnub_version_windows.cpp ..\windows\pubnub_generate_uuid_windows.c ..\windows\pbpal_windows_blocking_io.c ..\windows\windows_socket_blocking_io.c ..\core\c99\snprintf.c ..\lib\miniz\miniz_tinfl.c ..\lib\miniz\miniz_tdef.c ..\lib\miniz\miniz.c ..\lib\pbcrc32.c ..\core\pbgzip_compress.c ..\core\pbgzip_decompress.c ..\core\pbcc_subscribe_v2.c ..\core\pubnub_subscribe_v2.c ..\windows\msstopwatch_windows.c ..\core\pubnub_url_encode.c ..\core\pbcc_advanced_history.c ..\core\pubnub_advanced_history.c ..\core\pbcc_objects_api.c ..\core\pubnub_objects_api.c ..\core\pbcc_actions_api.c ..\core\pubnub_actions_api.c ..\core\pubnub_memory_block.c ..\lib\pbstr_remove_from_list.c ..\windows\pb_sleep_ms.c ..\core\pbauto_heartbeat.c ..\windows\pbauto_heartbeat_init_windows.c +# Makefile for PubNub C-core SDK. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. -LIBS=ws2_32.lib rpcrt4.lib +# Making CPP version of the PubNub SDK. +WITH_CPP = 1 -!ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -!endif +include ../make/posix_preprocessing.mk +include ../make/posix_source_files.mk +include ../make/posix_compiler_linker_flags.mk -!ifndef USE_PROXY -USE_PROXY = 1 -!endif -!ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 0 -!endif +############################################################################### +# Build targets # +############################################################################### -!ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 0 -!endif +TARGET_BUILD_PATH = -!ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -!endif +include ../make/windows_cpp_targets.mk -!if $(USE_PROXY) -PROXY_INTF_SOURCEFILES = ..\core\pubnub_proxy.c ..\core\pubnub_proxy_core.c ..\core\pbhttp_digest.c ..\core\pbntlm_core.c ..\core\pbntlm_packer_sspi.c ..\windows\pubnub_set_proxy_from_system_windows.c -!endif - -!if $(USE_FETCH_HISTORY) -FETCH_HIST_SOURCEFILES = ..\core\pubnub_fetch_history.c ..\core\pbcc_fetch_history.c -!endif - -CFLAGS = /EHsc /Zi /MP /TP /I .. /I . /I ..\core\c99 /I ..\windows /W3 /D PUBNUB_THREADSAFE /D HAVE_STRERROR_S /D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) /D PUBNUB_PROXY_API=$(USE_PROXY) /D _CRT_SECURE_NO_WARNINGS /D _WINSOCK_DEPRECATED_NO_WARNINGS /D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) /D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -# /Zi enables debugging, remove to get a smaller .exe and no .pdb -# /MP uses one compiler (`cl`) process for each input file, enabling faster build -# /TP means "compile all files as C++" -# /EHsc enables (standard) exception support -# /analyze runs static analysis - -all: fntest_runner.exe pubnub_sync_sample.exe pubnub_callback_sample.exe pubnub_callback_cpp11_sample.exe cancel_subscribe_sync_sample.exe subscribe_publish_callback_sample.exe futres_nesting_sync.exe futres_nesting_callback.exe futres_nesting_callback_cpp11.exe - -SYNC_INTF_SOURCEFILES= ..\core\pubnub_ntf_sync.c ..\core\srand_from_pubnub_time.c - -pubnub_sync_sample.exe: samples\pubnub_sample.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\pubnub_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -cancel_subscribe_sync_sample.exe: samples\cancel_subscribe_sync_sample.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\cancel_subscribe_sync_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -futres_nesting_sync.exe: samples\futres_nesting.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\futres_nesting.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -fntest_runner.exe: fntest\pubnub_fntest_runner.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest\pubnub_fntest.cpp fntest\pubnub_fntest_basic.cpp fntest\pubnub_fntest_medium.cpp - $(CXX) /Fe$@ $(CFLAGS) fntest\pubnub_fntest_runner.cpp $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest/pubnub_fntest.cpp fntest\pubnub_fntest_basic.cpp fntest\pubnub_fntest_medium.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - - -## -# The socket poller module to use. You should use the `poll` poller it -# doesn't have the weird restrictions of `select` poller. OTOH, -# select() on Windows is compatible w/BSD sockets poll(), while -# WSAPoll() has some weird differences to poll(). The names are the -# same until the last `_`, then it's `poll` vs `select. -SOCKET_POLLER_C=..\lib\sockets\pbpal_ntf_callback_poller_poll.c - -CALLBACK_INTF_SOURCEFILES=..\windows\pubnub_ntf_callback_windows.c ..\windows\pubnub_get_native_socket.c ..\core\pubnub_timer_list.c ..\lib\sockets\pbpal_adns_sockets.c ..\lib\pubnub_dns_codec.c ..\core\pubnub_dns_servers.c ..\windows\pubnub_dns_system_servers.c ..\lib\pubnub_parse_ipv4_addr.c ..\lib\pubnub_parse_ipv6_addr.c $(SOCKET_POLLER_C) ..\core\pbpal_ntf_callback_queue.c ..\core\pbpal_ntf_callback_admin.c ..\core\pbpal_ntf_callback_handle_timer_list.c ..\core\pubnub_callback_subscribe_loop.c - - -pubnub_callback_sample.exe: samples\pubnub_sample.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -pubnub_callback_cpp11_sample.exe: samples\pubnub_sample.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) /Fe$@ /D PUBNUB_CALLBACK_API $(CFLAGS) samples\pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -subscribe_publish_callback_sample.exe: samples\subscribe_publish_callback_sample.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\subscribe_publish_callback_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -futres_nesting_callback.exe: samples\futres_nesting.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\futres_nesting.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -futres_nesting_callback_cpp11.exe: samples\futres_nesting.cpp $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\futres_nesting.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) +all: \ + $(TARGET_BUILD_PATH)pubnub_callback_cpp11_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)subscribe_publish_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)cancel_subscribe_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_sync$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback_cpp11$(APP_EXT) \ + $(TARGET_BUILD_PATH)fntest_runner$(APP_EXT) clean: del *.obj del *.exe del *.pdb - del *.il? - + del *.il? \ No newline at end of file diff --git a/cpp/windows_openssl.mk b/cpp/windows_openssl.mk index a06aa6e1..932aee6c 100644 --- a/cpp/windows_openssl.mk +++ b/cpp/windows_openssl.mk @@ -1,109 +1,44 @@ -SOURCEFILES = ..\core\pbcc_set_state.c ..\core\pubnub_pubsubapi.c ..\core\pubnub_coreapi.c ..\core\pubnub_ccore_pubsub.c ..\core\pubnub_ccore.c ..\core\pubnub_netcore.c ..\lib\sockets\pbpal_resolv_and_connect_sockets.c ..\lib\sockets\pbpal_handle_socket_error.c ..\openssl\pbpal_openssl.c ..\openssl\pbpal_connect_openssl.c ..\core\pubnub_alloc_std.c ..\core\pubnub_assert_std.c ..\core\pubnub_generate_uuid.c ..\core\pubnub_blocking_io.c ..\lib\base64\pbbase64.c ..\core\pubnub_json_parse.c ..\core\pubnub_helper.c pubnub_version_windows.cpp ..\windows\pubnub_generate_uuid_windows.c ..\openssl\pbpal_openssl_blocking_io.c ..\windows\windows_socket_blocking_io.c ..\core\pubnub_timers.c ..\core\c99\snprintf.c ..\openssl\pbpal_add_system_certs_windows.c ..\core\pubnub_free_with_timeout_std.c ..\windows\pbtimespec_elapsed_ms.c ..\lib\md5\md5.c ..\lib\pb_strnlen_s.c ..\lib\pb_strncasecmp.c ..\core\pubnub_ssl.c ..\core\pubnub_crypto.c ..\core\pubnub_coreapi_ex.c ..\openssl\pbaes256.c ..\lib\miniz\miniz_tinfl.c ..\lib\miniz\miniz_tdef.c ..\lib\miniz\miniz.c ..\lib\pbcrc32.c ..\core\pbgzip_compress.c ..\core\pbgzip_decompress.c ..\core\pbcc_subscribe_v2.c ..\core\pubnub_subscribe_v2.c ..\windows\msstopwatch_windows.c ..\core\pubnub_url_encode.c ..\core\pbcc_advanced_history.c ..\core\pubnub_advanced_history.c ..\core\pbcc_objects_api.c ..\core\pubnub_objects_api.c ..\core\pbcc_actions_api.c ..\core\pubnub_actions_api.c ..\core\pubnub_memory_block.c ..\lib\pbstr_remove_from_list.c ..\windows\pb_sleep_ms.c ..\core\pbauto_heartbeat.c ..\windows\pbauto_heartbeat_init_windows.c ..\core\pbcc_crypto.c ..\core\pbcc_crypto_aes_cbc.c ..\core\pbcc_crypto_legacy.c +# Makefile for PubNub C-core SDK with SSL support. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. -!ifndef OPENSSLPATH -OPENSSLPATH=c:\OpenSSL-Win32 -!endif +# Making CPP version of the PubNub SDK with OpenSSL support. +WITH_CPP = 1 +OPENSSL = 1 +USE_CRYPTO_API ?= 1 +USE_GRANT_TOKEN ?= 1 +USE_REVOKE_TOKEN ?= 1 -!IF EXISTS($(OPENSSLPATH)\lib\libssl.lib) -OPENSSL_LIBS=$(OPENSSLPATH)\lib\libssl.lib $(OPENSSLPATH)\lib\libcrypto.lib -!ELSEIF EXISTS($(OPENSSLPATH)\lib\ssleay32.lib) -OPENSSL_LIBS=$(OPENSSLPATH)\lib\ssleay32.lib $(OPENSSLPATH)\lib\libeay32.lib -!ELSE -!ERROR Cannot find OpenSSL libraries -!ENDIF -LIBS=ws2_32.lib rpcrt4.lib $(OPENSSL_LIBS) +include ../make/posix_preprocessing.mk +include ../make/posix_source_files.mk +include ../make/posix_compiler_linker_flags.mk -!ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -!endif -!ifndef USE_PROXY -USE_PROXY = 1 -!endif +############################################################################### +# Build targets # +############################################################################### -!ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 1 -!endif +TARGET_BUILD_PATH = openssl$(PATH_SEP) -!ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 1 -!endif +include ../make/windows_cpp_targets.mk -!ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -!endif - - -!if $(USE_PROXY) -PROXY_INTF_SOURCEFILES = ..\core\pubnub_proxy.c ..\core\pubnub_proxy_core.c ..\core\pbhttp_digest.c ..\core\pbntlm_core.c ..\core\pbntlm_packer_sspi.c ..\windows\pubnub_set_proxy_from_system_windows.c -!endif - -!if $(USE_FETCH_HISTORY) -FETCH_HIST_SOURCEFILES = ..\core\pubnub_fetch_history.c ..\core\pbcc_fetch_history.c -!endif - -!if $(USE_REVOKE_TOKEN) -REVOKE_TOKEN_SOURCEFILES = ..\core\pubnub_revoke_token_api.c ..\core\pbcc_revoke_token_api.c -!endif - -!if $(USE_GRANT_TOKEN) -GRANT_TOKEN_SOURCEFILES = ..\core\pbcc_grant_token_api.c ..\core\pubnub_grant_token_api.c ..\lib\cbor\cborparser.c ..\lib\cbor\cborerrorstrings.c ..\lib\cbor\cborparser_dup_string.c ..\core\pubnub_revoke_token_api.c ..\core\pbcc_revoke_token_api.c -!endif - - -INCLUDES=-I .. -I . -I ..\core\c99 -I ..\openssl -I $(OPENSSLPATH)\include -I ..\lib\base64 - -CFLAGS = /EHsc /Zi /MP /TP /W3 $(INCLUDES) /D PUBNUB_THREADSAFE /D PUBNUB_USE_WIN_SSPI=1 /D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) /D PUBNUB_PROXY_API=$(USE_PROXY) /D _CRT_SECURE_NO_WARNINGS /D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) /D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -# /Zi enables debugging, remove to get a smaller .exe and no .pdb -# /MP uses one compiler (`cl`) process for each input file, enabling faster build -# /TP means "compile all files as C++" -# /EHsc enables (standard) exception support - -all: openssl\fntest_runner.exe openssl\pubnub_sync_sample.exe openssl\pubnub_sync_grant_sample.exe openssl\pubnub_callback_sample.exe openssl\pubnub_callback_cpp11_sample.exe openssl\cancel_subscribe_sync_sample.exe openssl\subscribe_publish_callback_sample.exe openssl\futres_nesting_sync.exe openssl\futres_nesting_callback.exe openssl\futres_nesting_callback_cpp11.exe - -SYNC_INTF_SOURCEFILES= ..\core\pubnub_ntf_sync.c ..\core\srand_from_pubnub_time.c - -openssl\pubnub_sync_sample.exe: samples\pubnub_sample.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\pubnub_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\pubnub_sync_grant_sample.exe: samples\pubnub_sample_grant_token.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\pubnub_sample_grant_token.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\pubnub_sync_revoke_sample.exe: samples\pubnub_sample_revoke_token.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\pubnub_sample_revoke_token.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\cancel_subscribe_sync_sample.exe: samples\cancel_subscribe_sync_sample.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\cancel_subscribe_sync_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\futres_nesting_sync.exe: samples\futres_nesting.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\futres_nesting.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\pubnub_crypto_module_sample.exe: samples\pubnub_crypto_module_sample.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp - $(CXX) /Fe$@ $(CFLAGS) samples\pubnub_crypto_module_sample.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\fntest_runner.exe: fntest\pubnub_fntest_runner.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest\pubnub_fntest.cpp fntest\pubnub_fntest_basic.cpp fntest\pubnub_fntest_medium.cpp - $(CXX) /Fe$@ $(CFLAGS) fntest\pubnub_fntest_runner.cpp $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp fntest/pubnub_fntest.cpp fntest\pubnub_fntest_basic.cpp fntest\pubnub_fntest_medium.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -CALLBACK_INTF_SOURCEFILES=..\openssl\pubnub_ntf_callback_windows.c ..\openssl\pubnub_get_native_socket.c ..\core\pubnub_timer_list.c ..\lib\sockets\pbpal_adns_sockets.c ..\lib\pubnub_dns_codec.c ..\core\pubnub_dns_servers.c ..\windows\pubnub_dns_system_servers.c ..\lib\pubnub_parse_ipv4_addr.c ..\lib\pubnub_parse_ipv6_addr.c ..\lib\sockets\pbpal_ntf_callback_poller_poll.c ..\core\pbpal_ntf_callback_queue.c ..\core\pbpal_ntf_callback_admin.c ..\core\pbpal_ntf_callback_handle_timer_list.c ..\core\pubnub_callback_subscribe_loop.c - -openssl\pubnub_callback_sample.exe: samples\pubnub_sample.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\pubnub_callback_cpp11_sample.exe: samples\pubnub_sample.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) /Fe$@ /D PUBNUB_CALLBACK_API $(CFLAGS) samples\pubnub_sample.cpp $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) /link $(LIBS) - -openssl\subscribe_publish_callback_sample.exe: samples\subscribe_publish_callback_sample.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\subscribe_publish_callback_sample.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp /link $(LIBS) - -openssl\futres_nesting_callback.exe: samples\futres_nesting.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\futres_nesting.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_windows.cpp /link $(LIBS) - -openssl\futres_nesting_callback_cpp11.exe: samples\futres_nesting.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp - $(CXX) /Fe$@ -D PUBNUB_CALLBACK_API $(CFLAGS) samples\futres_nesting.cpp $(SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) pubnub_futres_cpp11.cpp /link $(LIBS) +all: \ + $(TARGET_BUILD_PATH)pubnub_callback_cpp11_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_crypto_module_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)subscribe_publish_callback_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_grant_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)pubnub_sync_revoke_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)cancel_subscribe_sync_sample$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_sync$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback$(APP_EXT) \ + $(TARGET_BUILD_PATH)futres_nesting_callback_cpp11$(APP_EXT) \ + $(TARGET_BUILD_PATH)fntest_runner$(APP_EXT) clean: - del openssl\*.obj - del openssl\*.exe - del openssl\*.pdb - del openssl\*.il? + del $(TARGET_BUILD_PATH)*.obj + del $(TARGET_BUILD_PATH)*.exe + del $(TARGET_BUILD_PATH)*.pdb + del $(TARGET_BUILD_PATH)*.il? \ No newline at end of file diff --git a/make/common/preprocessing.mk b/make/common/preprocessing.mk new file mode 100644 index 00000000..af130e32 --- /dev/null +++ b/make/common/preprocessing.mk @@ -0,0 +1,45 @@ +# Common preprocessing flags. +# Description: Makefile used to declare platform-independent preprocessing +# flags. + + +############################################################################### +# Pre-processing flags # +############################################################################### + +# Included public headers. +INCLUDES_ = $(OPTION_PREFIX)I.. $(OPTION_PREFIX)I. $(INCLUDES_PLATFORM) $(INCLUDES_OPENSSL) +INCLUDES = $(strip $(INCLUDES_)) + +# Feature flags definition. +DEFINES_COMMON = \ + $(OPTION_PREFIX)D PUBNUB_CRYPTO_API=$(USE_CRYPTO_API) \ + $(OPTION_PREFIX)D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_$(LOG_LEVEL) \ + $(OPTION_PREFIX)D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) \ + $(OPTION_PREFIX)D PUBNUB_PROXY_API=$(USE_PROXY) \ + $(OPTION_PREFIX)D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) \ + $(OPTION_PREFIX)D PUBNUB_THREADSAFE=1 \ + $(OPTION_PREFIX)D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) \ + $(OPTION_PREFIX)D PUBNUB_USE_ADVANCED_HISTORY=$(USE_ADVANCED_HISTORY) \ + $(OPTION_PREFIX)D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) \ + $(OPTION_PREFIX)D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) \ + $(OPTION_PREFIX)D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) \ + $(OPTION_PREFIX)D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) \ + $(OPTION_PREFIX)D PUBNUB_USE_IPV6=$(USE_IPV6) \ + $(OPTION_PREFIX)D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) \ + $(OPTION_PREFIX)D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) \ + $(OPTION_PREFIX)D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) \ + $(OPTION_PREFIX)D PUBNUB_USE_SSL=$(USE_SSL) \ + $(OPTION_PREFIX)D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=$(USE_SUBSCRIBE_EVENT_ENGINE) \ + $(OPTION_PREFIX)D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) + +# Preprocessing flags for synchronous PubNub library version. +CPPFLAGS_ = $(INCLUDES) $(DEFINES_PLATFORM) $(DEFINES_COMMON) $(DEFINES_EXTERN_C) $(DEFINES_RANDOM_IV) +CPPFLAGS = $(strip $(CPPFLAGS_)) + +# Preprocessing flags for PubNub library with callback interface. +CALLBACK_CPPFLAGS_ = \ + $(CPPFLAGS_) \ + $(OPTION_PREFIX)D PUBNUB_CALLBACK_API \ + $(OPTION_PREFIX)D PUBNUB_SET_DNS_SERVERS=$(USE_DNS_SERVERS) +CALLBACK_CPPFLAGS = $(strip $(CALLBACK_CPPFLAGS_)) \ No newline at end of file diff --git a/make/common/preprocessing_defaults.mk b/make/common/preprocessing_defaults.mk new file mode 100644 index 00000000..7077c40c --- /dev/null +++ b/make/common/preprocessing_defaults.mk @@ -0,0 +1,84 @@ +# Preprocessing flags default values. +# Description: Common for all platforms preprocessing flags default values. + + +############################################################################### +# Default preprocessor flag values # +############################################################################### + +# Default compiler type. +# +# By default used GCC/Clang-compatible. +DEFAULT_COMPILER_TYPE = $(CC) + +# Logger level. +DEFAULT_LOG_LEVEL = WARNING + +# Whether address sanitizer should be enabled or not. +DEFAULT_ASAN = 0 + +# Whether OpenSSL should be used or not. +DEFAULT_OPENSSL = 0 + +# Whether should build with for CPP or not. +DEFAULT_WITH_CPP = 0 + +# Whether C++11 standard should be used for CPP build or not. +DEFAULT_USE_CPP11 = 0 + +# Whether extern C API should be used or not. +DEFAULT_USE_EXTERN_API = 0 + +# Whether PubNub should be built with callback interface or not. +DEFAULT_USE_CALLBACK_API = 0 + +# Whether only publish / subscribe API should be enabled or not. +DEFAULT_ONLY_PUBSUB_API = 0 + +# Whether compressed response processing should be enabled or not. +DEFAULT_RECEIVE_GZIP_RESPONSE = 1 + +# Whether message reactions feature should be enabled or not. +DEFAULT_USE_ACTIONS_API = 1 + +# Whether advanced message persistence feature should be enabled or not. +DEFAULT_USE_ADVANCED_HISTORY = 1 + +# Whether automatic heartbeat should be enabled or not. +DEFAULT_USE_AUTO_HEARTBEAT = 1 + +# Whether cryptography feature should be enabled or not. +DEFAULT_USE_CRYPTO_API = 0 + +# Whether message persistence feature should be enabled or not. +DEFAULT_USE_FETCH_HISTORY = 1 + +# Whether grant token permissions feature should be enabled or not. +DEFAULT_USE_GRANT_TOKEN = 0 + +# Whether should enable HTTP body compression or not. +DEFAULT_USE_GZIP_COMPRESSION = 1 + +# Whether IPv6 connection should be supported or not. +DEFAULT_USE_IPV6 = 1 + +# Whether to use random IV for legacy crypto module or not. +DEFAULT_USE_LEGACY_CRYPTO_RANDOM_IV = 1 + +# Whether App Context feature should be enabled or not. +DEFAULT_USE_OBJECTS_API = 1 + +# Whether request / connection proxy feature should be enabled or not. +DEFAULT_USE_PROXY = 1 + +# Whether failed request retry feature should be enabled or not. +DEFAULT_USE_RETRY_CONFIGURATION = 0 + +# Whether token permissions revoke feature should be enabled or not. +DEFAULT_USE_REVOKE_TOKEN = 0 + +# Whether subscribe event engine feature should be enabled or not. +DEFAULT_USE_SUBSCRIBE_EVENT_ENGINE = 0 + +# Whether subscribe v2 feature should be enabled or not. +DEFAULT_USE_SUBSCRIBE_V2 = 1 \ No newline at end of file diff --git a/make/common/source_files.mk b/make/common/source_files.mk new file mode 100644 index 00000000..9a4ba59b --- /dev/null +++ b/make/common/source_files.mk @@ -0,0 +1,348 @@ +# Common PubNub SDK source files. +# Description: Makefile used to declare scoped set of source files to build +# PubNub SDK core and its features. + + +############################################################################### +# PubNub Core source files # +############################################################################### + +# PubNub SDK core source files used for all platforms. +CORE_SOURCE_FILES = \ + ../core/pbcc_set_state.c \ + ../core/pubnub_alloc_std.c \ + ../core/pubnub_assert_std.c \ + ../core/pubnub_blocking_io.c \ + ../core/pubnub_ccore.c \ + ../core/pubnub_ccore_pubsub.c \ + ../core/pubnub_coreapi.c \ + ../core/pubnub_coreapi_ex.c \ + ../core/pubnub_free_with_timeout_std.c \ + ../core/pubnub_generate_uuid.c \ + ../core/pubnub_generate_uuid_v3_md5.c \ + ../core/pubnub_helper.c \ + ../core/pubnub_json_parse.c \ + ../core/pubnub_memory_block.c \ + ../core/pubnub_netcore.c \ + ../core/pubnub_pubsubapi.c \ + ../core/pubnub_timers.c \ + ../core/pubnub_url_encode.c \ + ../lib/base64/pbbase64.c \ + ../lib/pb_strncasecmp.c \ + ../lib/pb_strnlen_s.c \ + ../lib/sockets/pbpal_handle_socket_error.c \ + ../lib/sockets/pbpal_resolv_and_connect_sockets.c + +# `CORE_SOURCE_FILES` extension for POSIX build. +CORE_SOURCE_FILES_POSIX = \ + ../posix/msstopwatch_monotonic_clock.c \ + ../posix/pb_sleep_ms.c \ + ../posix/pbtimespec_elapsed_ms.c \ + ../posix/posix_socket_blocking_io.c \ + ../posix/pubnub_generate_uuid_posix.c + +# `CORE_SOURCE_FILES` extension for Windows build. +CORE_SOURCE_FILES_WINDOWS = \ + ../core/c99/snprintf.c \ + ../windows/msstopwatch_windows.c \ + ../windows/pbtimespec_elapsed_ms.c \ + ../windows/pb_sleep_ms.c \ + ../windows/pubnub_generate_uuid_windows.c \ + ../windows/windows_socket_blocking_io.c + +# `CORE_SOURCE_FILES_POSIX` extension for non-CPP build. +CORE_NON_CPP_SOURCE_FILES = + +# `CORE_NON_CPP_SOURCE_FILES` extension for non-CPP build. +CORE_NON_CPP_SOURCE_FILES_POSIX = \ + ../posix/pubnub_version_posix.c + +# `CORE_NON_CPP_SOURCE_FILES` extension for non-CPP build. +CORE_NON_CPP_SOURCE_FILES_WINDOWS = \ + ../windows/pubnub_version_windows.c + +# `CORE_SOURCE_FILES_POSIX` extension for CPP build. +CORE_CPP_SOURCE_FILES = \ + ../cpp/pubnub_subloop.cpp + +# `CORE_CPP_SOURCE_FILES` extension for CPP build. +CORE_CPP_SOURCE_FILES_POSIX = \ + ../cpp/pubnub_version_posix.cpp + +# `CORE_CPP_SOURCE_FILES` extension for CPP build. +CORE_CPP_SOURCE_FILES_WINDOWS = \ + ../cpp/pubnub_version_windows.cpp + +# `CORE_SOURCE_FILES` extension without OpenSSL support used for all +# platforms. +CORE_NON_OPENSSL_SOURCE_FILES = \ + ../lib/md5/md5.c \ + ../lib/sockets/pbpal_sockets.c + +# `CORE_NON_OPENSSL_SOURCE_FILES` extension for POSIX build. +CORE_NON_OPENSSL_SOURCE_FILES_POSIX = \ + ../posix/pbpal_posix_blocking_io.c + +# `CORE_NON_OPENSSL_SOURCE_FILES` extension for Windows build. +CORE_NON_OPENSSL_SOURCE_FILES_WINDOWS = \ + ../windows/pbpal_windows_blocking_io.c + +# `CORE_SOURCE_FILES` extension with OpenSSL support used for all +# platforms. +CORE_OPENSSL_SOURCE_FILES = \ + ../core/pubnub_ssl.c \ + ../openssl/pbpal_connect_openssl.c \ + ../openssl/pbpal_openssl.c \ + ../openssl/pbpal_openssl_blocking_io.c + +# `CORE_OPENSSL_SOURCE_FILES` extension for POSIX build. +CORE_OPENSSL_SOURCE_FILES_POSIX = \ + ../openssl/pbpal_add_system_certs_posix.c +CORE_OPENSSL_SOURCE_FILES_NOT_DARWIN = \ + ../lib/md5/md5.c + +# `CORE_OPENSSL_SOURCE_FILES` extension for Windows build. +CORE_OPENSSL_SOURCE_FILES_WINDOWS = \ + ../openssl/pbpal_add_system_certs_windows.c + + +############################################################################### +# PubNub Core sync source files # +############################################################################### + +# Core source files for a synchronous PubNub C-core client version support. +SYNC_CORE_SOURCE_FILES = \ + ../core/pubnub_ntf_sync.c \ + ../core/pubnub_sync_subscribe_loop.c \ + ../core/srand_from_pubnub_time.c + + +############################################################################### +# PubNub Core callback source files # +############################################################################### + +# Source files for a call-back based PubNub C-core client version support. +CALLBACK_CORE_SOURCE_FILES = \ + ../core/pbpal_ntf_callback_admin.c \ + ../core/pbpal_ntf_callback_handle_timer_list.c \ + ../core/pbpal_ntf_callback_queue.c \ + ../core/pubnub_callback_subscribe_loop.c \ + ../core/pubnub_timer_list.c \ + ../lib/pubnub_dns_codec.c \ + ../lib/sockets/pbpal_adns_sockets.c \ + ../lib/sockets/pbpal_ntf_callback_poller_poll.c + +# `CALLBACK_CORE_SOURCE_FILES` extension without OpenSSL support used for all +# platforms. +CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES = + +# `CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES` extension for POSIX build. +CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES_POSIX = \ + ../posix/pubnub_get_native_socket.c \ + ../posix/pubnub_ntf_callback_posix.c + +# `CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES` extension for Windows build. +CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES_WINDOWS = \ + ../windows/pubnub_get_native_socket.c \ + ../windows/pubnub_ntf_callback_windows.c + +# `CALLBACK_CORE_SOURCE_FILES` extension with OpenSSL support used for all +# platforms. +CALLBACK_CORE_OPENSSL_SOURCE_FILES = \ + ../openssl/pubnub_get_native_socket.c + +# `CALLBACK_CORE_OPENSSL_SOURCE_FILES` extension for POSIX build. +CALLBACK_CORE_OPENSSL_SOURCE_FILES_POSIX = \ + ../openssl/pubnub_ntf_callback_posix.c + +# `CALLBACK_CORE_OPENSSL_SOURCE_FILES` extension for Windows build. +CALLBACK_CORE_OPENSSL_SOURCE_FILES_WINDOWS = \ + ../openssl/pubnub_ntf_callback_windows.c + + +############################################################################### +# PubNub console source files # +############################################################################### + +CONSOLE_SOURCE_FILES = \ + ../core/samples/console/pnc_helpers.c \ + ../core/samples/console/pnc_readers.c \ + ../core/samples/console/pnc_subscriptions.c \ + ../core/samples/console/pubnub_console.c + + +############################################################################### +# PubNub feature source files # +############################################################################### + +# Published messages content compression feature source files. +GZIP_COMPRESSION_SOURCE_FILES = \ + ../core/pbgzip_compress.c \ + ../lib/miniz/miniz.c \ + ../lib/miniz/miniz_tdef.c \ + ../lib/pbcrc32.c + + +# Compressed service response de-compression feature source files. +GZIP_RESPONSE_SOURCE_FILES = \ + ../core/pbgzip_decompress.c \ + ../lib/miniz/miniz_tinfl.c + + +# Published message reactions feature source files. +MESSAGE_REACTION_SOURCE_FILES = \ + ../core/pbcc_actions_api.c \ + ../core/pubnub_actions_api.c + + +# Extended history feature source files. +# +# Extended history allows to fetch messages in batch for multiple channels, +# count messages and fetch with additional information. +ADVANCED_HISTORY_SOURCE_FILES = \ + ../core/pbcc_advanced_history.c \ + ../core/pubnub_advanced_history.c + + +# Auto heartbeat feature source files. +# +# Feature used together with `USE_SUBSCRIBE_V2` flag to send periodic heartbeat +# requests to update users' presence on subscribed channels. +AUTO_HEARTBEAT_SOURCE_FILES = \ + ../core/pbauto_heartbeat.c \ + ../lib/pbstr_remove_from_list.c + +# `AUTO_HEARTBEAT_SOURCE_FILES` extension without OpenSSL support used for all +# platforms. +AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES = + +# `AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES` extension for POSIX build. +AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES_POSIX = \ + ../posix/pbauto_heartbeat_init_posix.c + +# `AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES` extension for Windows build. +AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES_WINDOWS = \ + ../windows/pbauto_heartbeat_init_windows.c + +# `AUTO_HEARTBEAT_SOURCE_FILES` extension with OpenSSL support used for all +# platforms. +AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES = + +# `AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES` extension for POSIX build. +AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES_POSIX = \ + ../openssl/pbauto_heartbeat_init_posix.c + +# `AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES` extension for Windows build. +AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES_WINDOWS = \ + ../windows/pbauto_heartbeat_init_windows.c + + +# Published / received data encryption and decryption feature source files. +CRYPTO_SOURCE_FILES = \ + ../core/pbcc_crypto.c \ + ../core/pbcc_crypto_aes_cbc.c \ + ../core/pbcc_crypto_legacy.c \ + ../core/pubnub_crypto.c \ + ../openssl/pbaes256.c + + +# Custom DNS servers feature source files. +# +# Feature allows to specify custom DNS servers and send query to them. +# Important: Can be used only together with `PUBNUB_CALLBACK_API` flag. +DNS_SERVERS_SOURCE_FILES = \ + ../core/pubnub_dns_servers.c + +# `DNS_SERVERS_SOURCE_FILES` extension for POSIX build. +DNS_SERVERS_SOURCE_FILES_POSIX = \ + ../posix/pubnub_dns_system_servers.c + +# `DNS_SERVERS_SOURCE_FILES` extension for Windows build. +DNS_SERVERS_SOURCE_FILES_WINDOWS = \ + ../windows/pubnub_dns_system_servers.c + +# Custom DNS servers IPv4 support feature source files. +# +# Important: Can be used only together with `PUBNUB_CALLBACK_API` flag. +IPV4_SOURCE_FILES = \ + ../lib/pubnub_parse_ipv4_addr.c + +# Custom DNS servers IPv6 support feature source files. +# +# Important: Can be used only together with `PUBNUB_CALLBACK_API` flag. +IPV6_SOURCE_FILES = \ + ../lib/pubnub_parse_ipv6_addr.c + + +# Single channel history feature source files. +FETCH_HISTORY_SOURCE_FILES = \ + ../core/pbcc_fetch_history.c \ + ../core/pubnub_fetch_history.c + + +# Grant token permissions feature source files. +GRANT_TOKEN_SOURCE_FILES = \ + ../core/pbcc_grant_token_api.c \ + ../core/pubnub_grant_token_api.c \ + ../lib/cbor/cborerrorstrings.c \ + ../lib/cbor/cborparser.c \ + ../lib/cbor/cborparser_dup_string.c + + +# App Context feature source files. +APP_CONTEXT_SOURCE_FILES = \ + ../core/pbcc_objects_api.c \ + ../core/pubnub_objects_api.c + + +# Custom proxy feature source files. +PROXY_SOURCE_FILES = \ + ../core/pbhttp_digest.c \ + ../core/pbntlm_core.c \ + ../core/pbntlm_packer_std.c \ + ../core/pubnub_proxy.c \ + ../core/pubnub_proxy_core.c + +# `PROXY_SOURCE_FILES` extension for POSIX build. +PROXY_SOURCE_FILES_POSIX = + +# `PROXY_SOURCE_FILES` extension for Windows build. +PROXY_SOURCE_FILES_WINDOWS = \ + ../windows/pubnub_set_proxy_from_system_windows.c + + +# Automated failed request retry feature source files. +RETRY_CONFIGURATION_SOURCE_FILES = \ + ../core/pbcc_request_retry_timer.c \ + ../core/pubnub_retry_configuration.c + + +# Revoke token permissions feature source files. +REVOKE_TOKEN_SOURCE_FILES = \ + ../core/pbcc_revoke_token_api.c \ + ../core/pubnub_revoke_token_api.c + + +# Subscription event engine feature source files. +SUBSCRIBE_EVENT_ENGINE_SOURCE_FILES = \ + ../core/pbcc_event_engine.c \ + ../core/pbcc_memory_utils.c \ + ../core/pbcc_subscribe_event_engine.c \ + ../core/pbcc_subscribe_event_engine_effects.c \ + ../core/pbcc_subscribe_event_engine_events.c \ + ../core/pbcc_subscribe_event_engine_states.c \ + ../core/pbcc_subscribe_event_engine_transitions.c \ + ../core/pbcc_subscribe_event_listener.c \ + ../core/pubnub_entities.c \ + ../core/pubnub_subscribe_event_engine.c \ + ../core/pubnub_subscribe_event_listener.c \ + ../lib/pbarray.c \ + ../lib/pbhash_set.c \ + ../lib/pbref_counter.c \ + ../lib/pbstrdup.c + + +# Subscribe v2 feature source files. +SUBSCRIBE_V2_SOURCE_FILES = \ + ../core/pbcc_subscribe_v2.c \ + ../core/pubnub_subscribe_v2.c \ No newline at end of file diff --git a/make/common/targets_app.mk b/make/common/targets_app.mk new file mode 100644 index 00000000..f08d23c1 --- /dev/null +++ b/make/common/targets_app.mk @@ -0,0 +1,124 @@ +# Sample application targets. +# Description: Makefile used to declare list of targets to build sample app +# which demonstrates various features. +# +# Note: `nmake` can't handle `/` to `\` replacement in multiline prerequisites +# so they have been separated from targets for preprocessing. + +############################################################################### +# Sample application targets # +############################################################################### + +# ----------------- Samples based on sync PubNub library ----------------- + +SYNC_CANCEL_SUBSCRIBE_SOURCES_ = ../core/samples/cancel_subscribe_sync_sample.c +SYNC_CANCEL_SUBSCRIBE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_CANCEL_SUBSCRIBE_SOURCES_)) +cancel_subscribe_sync_sample$(APP_EXT): \ + $(SYNC_CANCEL_SUBSCRIBE_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_METADATA_SOURCES_ = ../core/samples/metadata.c +SYNC_METADATA_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_METADATA_SOURCES_)) +metadata$(APP_EXT): $(SYNC_METADATA_SOURCES) pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_ADVANCED_HISTORY_SOURCES_ = ../core/samples/pubnub_advanced_history_sample.c +SYNC_ADVANCED_HISTORY_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_ADVANCED_HISTORY_SOURCES_)) +pubnub_advanced_history_sample$(APP_EXT): \ + $(SYNC_ADVANCED_HISTORY_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_FETCH_HISTORY_SOURCES_ = ../core/samples/pubnub_fetch_history_sample.c +SYNC_FETCH_HISTORY_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_FETCH_HISTORY_SOURCES_)) +pubnub_fetch_history_sample$(APP_EXT): $(SYNC_FETCH_HISTORY_SOURCES) pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_PUBLISH_VIA_POST_SOURCES_ = ../core/samples/pubnub_publish_via_post_sample.c +SYNC_PUBLISH_VIA_POST_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_PUBLISH_VIA_POST_SOURCES_)) +pubnub_publish_via_post_sample$(APP_EXT): \ + $(SYNC_PUBLISH_VIA_POST_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_PUBLISH_RETRY_SOURCES_ = ../core/samples/pubnub_sync_publish_retry.c +SYNC_PUBLISH_RETRY_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_PUBLISH_RETRY_SOURCES_)) +pubnub_sync_publish_retry$(APP_EXT): \ + $(SYNC_PUBLISH_RETRY_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_SAMPLE_SOURCES_ = ../core/samples/pubnub_sync_sample.c +SYNC_SAMPLE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_SAMPLE_SOURCES_)) +pubnub_sync_sample$(APP_EXT): $(SYNC_SAMPLE_SOURCES) pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + + +# ----------------- Samples based on callback PubNub library ----------------- + +CALLBACK_PUBLISH_SUBLOOP_SOURCES_ = ../core/samples/publish_callback_subloop_sample.c +CALLBACK_PUBLISH_SUBLOOP_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_PUBLISH_SUBLOOP_SOURCES_)) +publish_callback_subloop_sample$(APP_EXT): \ + $(CALLBACK_PUBLISH_SUBLOOP_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +CALLBACK_PUBLISH_QUEUE_SUBLOOP_SOURCES_ = ../core/samples/publish_queue_callback_subloop.c +CALLBACK_PUBLISH_QUEUE_SUBLOOP_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_PUBLISH_QUEUE_SUBLOOP_SOURCES_)) +publish_queue_callback_subloop$(APP_EXT): \ + $(CALLBACK_PUBLISH_QUEUE_SUBLOOP_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +CALLBACK_SAMPLE_SOURCES_ = ../core/samples/pubnub_callback_sample.c +CALLBACK_SAMPLE_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_SAMPLE_SOURCES_)) +pubnub_callback_sample$(APP_EXT): \ + $(CALLBACK_SAMPLE_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +CALLBACK_SUBLOOP_SOURCES_ = ../core/samples/pubnub_callback_subloop_sample.c +CALLBACK_SUBLOOP_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_SUBLOOP_SOURCES_)) +pubnub_callback_subloop_sample$(APP_EXT): \ + $(CALLBACK_SUBLOOP_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +CALLBACK_EVENT_ENGINE_SOURCES_ = ../core/samples/subscribe_event_engine_sample.c +CALLBACK_EVENT_ENGINE_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_EVENT_ENGINE_SOURCES_)) +subscribe_event_engine_sample$(APP_EXT): \ + $(CALLBACK_EVENT_ENGINE_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +CALLBACK_SUBSCRIBE_PUBLISH_SOURCES_ = ../core/samples/subscribe_publish_callback_sample.c +CALLBACK_SUBSCRIBE_PUBLISH_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_SUBSCRIBE_PUBLISH_SOURCES_)) +subscribe_publish_callback_sample$(APP_EXT): \ + $(CALLBACK_SUBSCRIBE_PUBLISH_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +CALLBACK_PUBLISH_FROM_CALLBACK_SOURCES_ = ../core/samples/subscribe_publish_from_callback.c +CALLBACK_PUBLISH_FROM_CALLBACK_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_PUBLISH_FROM_CALLBACK_SOURCES_)) +subscribe_publish_from_callback$(APP_EXT): \ + $(CALLBACK_PUBLISH_FROM_CALLBACK_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + + +# --------------- Console based on sync PubNub library -------------- + +SYNC_CONSOLE_SOURCES_ = $(CONSOLE_SOURCE_FILES) ../core/samples/console/pnc_ops_sync.c +SYNC_CONSOLE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_CONSOLE_SOURCES_)) +pubnub_console_sync$(APP_EXT): \ + $(SYNC_CONSOLE_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +CALLBACK_CONSOLE_SOURCES_ = $(CONSOLE_SOURCE_FILES) ../core/samples/console/pnc_ops_callback.c +CALLBACK_CONSOLE_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_CONSOLE_SOURCES_)) +pubnub_console_callback$(APP_EXT): \ + $(CALLBACK_CONSOLE_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) \ No newline at end of file diff --git a/make/common/targets_app_openssl.mk b/make/common/targets_app_openssl.mk new file mode 100644 index 00000000..8707c7e0 --- /dev/null +++ b/make/common/targets_app_openssl.mk @@ -0,0 +1,84 @@ +# Sample application targets. +# Description: Makefile used to declare list of targets to build sample app +# which demonstrates various features with OpenSSL support. +# +# Note: `nmake` can't handle `/` to `\` replacement in multiline prerequisites +# so they have been separated from targets for preprocessing. + + +############################################################################### +# Sample application targets # +############################################################################### + + +# ----------------- Samples based on sync PubNub library ----------------- + +SYNC_CRYPTO_MODULE_SOURCES_ = ../core/samples/pubnub_crypto_module_sample.c +SYNC_CRYPTO_MODULE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_CRYPTO_MODULE_SOURCES_)) +pubnub_crypto_module_sample$(APP_EXT): \ + $(SYNC_CRYPTO_MODULE_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_CRYPTO_SOURCES_ = ../core/samples/pubnub_crypto_sync_sample.c +SYNC_CRYPTO_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_CRYPTO_SOURCES_)) +pubnub_crypto_sync_sample$(APP_EXT): $(SYNC_CRYPTO_SOURCES) pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_OBJECTS_SECRET_KEY_SOURCES_ = ../core/samples/pubnub_objects_secretkey_sample.c +SYNC_OBJECTS_SECRET_KEY_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_OBJECTS_SECRET_KEY_SOURCES_)) +pubnub_objects_secretkey_sample$(APP_EXT): \ + $(SYNC_OBJECTS_SECRET_KEY_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_PUBLISH_VIA_POST_SECRET_KEY_SOURCES_ = \ + ../core/samples/pubnub_publish_via_post_secretkey_sample.c +SYNC_PUBLISH_VIA_POST_SECRET_KEY_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_PUBLISH_VIA_POST_SECRET_KEY_SOURCES_)) +pubnub_publish_via_post_secretkey_sample$(APP_EXT): \ + $(SYNC_PUBLISH_VIA_POST_SECRET_KEY_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_GRANT_TOKEN_SOURCES_ = ../core/samples/pubnub_sync_grant_token_sample.c +SYNC_GRANT_TOKEN_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_GRANT_TOKEN_SOURCES_)) +pubnub_sync_grant_token_sample$(APP_EXT): \ + $(SYNC_GRANT_TOKEN_SOURCES) \ + pubnub_sync_dynamiciv$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_REVOKE_TOKEN_SOURCES_ = ../core/samples/pubnub_sync_revoke_token_sample.c +SYNC_REVOKE_TOKEN_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_REVOKE_TOKEN_SOURCES_)) +pubnub_sync_revoke_token_sample$(APP_EXT): \ + $(SYNC_REVOKE_TOKEN_SOURCES) \ + pubnub_sync_dynamiciv$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_SECRET_KEY_SOURCES_ = ../core/samples/pubnub_sync_secretkey_sample.c +SYNC_SECRET_KEY_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_SECRET_KEY_SOURCES_)) +pubnub_sync_secretkey_sample$(APP_EXT): \ + $(SYNC_SECRET_KEY_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +SYNC_ENCRYPT_DECRYPT_SOURCES_ = ../core/samples/pubnub_encrypt_decrypt_iv_sample.c +SYNC_ENCRYPT_DECRYPT_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_ENCRYPT_DECRYPT_SOURCES_)) +pubnub_encrypt_decrypt_static_iv_sample$(APP_EXT): \ + $(SYNC_ENCRYPT_DECRYPT_SOURCES) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_encrypt_decrypt_dynamic_iv_sample$(APP_EXT): \ + $(SYNC_ENCRYPT_DECRYPT_SOURCES) \ + pubnub_sync_dynamiciv$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + + +# --------------- Samples based on callback-based PubNub library -------------- + +CALLBACK_PUBLISH_SECRET_KEY_SOURCES_ = ../core/samples/subscribe_publish_callback_secretkey_sample.c +CALLBACK_PUBLISH_SECRET_KEY_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_PUBLISH_SECRET_KEY_SOURCES_)) +subscribe_publish_callback_secretkey_sample$(APP_EXT): \ + $(CALLBACK_PUBLISH_SECRET_KEY_SOURCES) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) \ No newline at end of file diff --git a/make/common/targets_cpp_app.mk b/make/common/targets_cpp_app.mk new file mode 100644 index 00000000..0e56adeb --- /dev/null +++ b/make/common/targets_cpp_app.mk @@ -0,0 +1,103 @@ +# Sample CPP application targets. +# Description: Makefile used to declare list of targets to build sample app +# which demonstrates various features. + + +############################################################################### +# Sample application targets # +############################################################################### + +# ----------------- Samples based on sync PubNub library ----------------- + +SYNC_SAMPLE_SOURCES_ = \ + ../cpp/samples/pubnub_sample.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) +SYNC_SAMPLE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_SAMPLE_SOURCES_)) +$(TARGET_BUILD_PATH)pubnub_sync_sample$(APP_EXT): $(SYNC_SAMPLE_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +SYNC_CANCEL_SUBSCRIBE_SOURCES_ = \ + ../cpp/samples/cancel_subscribe_sync_sample.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) +SYNC_CANCEL_SUBSCRIBE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_CANCEL_SUBSCRIBE_SOURCES_)) +$(TARGET_BUILD_PATH)cancel_subscribe_sync_sample$(APP_EXT): \ + $(SYNC_CANCEL_SUBSCRIBE_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +SYNC_FUTRES_NESTING_SOURCES_ = \ + ../cpp/samples/futres_nesting.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) +SYNC_FUTRES_NESTING_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_FUTRES_NESTING_SOURCES_)) +$(TARGET_BUILD_PATH)futres_nesting_sync$(APP_EXT): $(SYNC_FUTRES_NESTING_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +SYNC_FNTEST_RUNNER_SOURCES_ = \ + ../cpp/fntest/pubnub_fntest_runner.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) \ + ../cpp/fntest/pubnub_fntest.cpp \ + ../cpp/fntest/pubnub_fntest_basic.cpp \ + ../cpp/fntest/pubnub_fntest_medium.cpp +SYNC_FNTEST_RUNNER_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_FNTEST_RUNNER_SOURCES_)) +$(TARGET_BUILD_PATH)fntest_runner$(APP_EXT): $(SYNC_FNTEST_RUNNER_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPP11_STANDARD_FLAG) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + + +# ----------------- Samples based on callback PubNub library ----------------- + +CALLBACK_SAMPLE_SOURCES_ = \ + ../cpp/samples/pubnub_sample.cpp \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SOURCE_FILE) +CALLBACK_SAMPLE_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_SAMPLE_SOURCES_)) +$(TARGET_BUILD_PATH)pubnub_callback_sample$(APP_EXT): \ + $(CALLBACK_SAMPLE_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +CALLBACK_SAMPLE_CPP11_SOURCES_ = \ + ../cpp/samples/pubnub_sample.cpp \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + ../cpp/pubnub_futres_cpp11.cpp +CALLBACK_SAMPLE_CPP11_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_SAMPLE_CPP11_SOURCES_)) +$(TARGET_BUILD_PATH)pubnub_callback_cpp11_sample$(APP_EXT): \ + $(CALLBACK_SAMPLE_CPP11_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPP11_STANDARD_FLAG) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +CALLBACK_SUBSCRIBE_PUBLISH_SOURCES_ = \ + ../cpp/samples/subscribe_publish_callback_sample.cpp \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SOURCE_FILE) +CALLBACK_SUBSCRIBE_PUBLISH_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_SUBSCRIBE_PUBLISH_SOURCES_)) +$(TARGET_BUILD_PATH)subscribe_publish_callback_sample$(APP_EXT): \ + $(CALLBACK_SUBSCRIBE_PUBLISH_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +CALLBACK_FUTRES_NESTING_SOURCES_ = \ + ../cpp/samples/futres_nesting.cpp \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SOURCE_FILE) +CALLBACK_FUTRES_NESTING_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_FUTRES_NESTING_SOURCES_)) +$(TARGET_BUILD_PATH)futres_nesting_callback$(APP_EXT): \ + $(CALLBACK_FUTRES_NESTING_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +CALLBACK_FUTRES_NESTING_CPP11_SOURCES_ = \ + ../cpp/samples/futres_nesting.cpp \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + ../cpp/pubnub_futres_cpp11.cpp +CALLBACK_FUTRES_NESTING_CPP11_SOURCES = $(subst /,$(PATH_SEP),$(CALLBACK_FUTRES_NESTING_CPP11_SOURCES_)) +$(TARGET_BUILD_PATH)futres_nesting_callback_cpp11$(APP_EXT): \ + $(CALLBACK_FUTRES_NESTING_CPP11_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPP11_STANDARD_FLAG) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) diff --git a/make/common/targets_cpp_app_openssl.mk b/make/common/targets_cpp_app_openssl.mk new file mode 100644 index 00000000..fe1a3c8b --- /dev/null +++ b/make/common/targets_cpp_app_openssl.mk @@ -0,0 +1,39 @@ +# Sample CPP application targets. +# Description: Makefile used to declare list of targets to build sample app +# which demonstrates various features. + + +############################################################################### +# Sample application targets # +############################################################################### + +# ----------------- Samples based on sync PubNub library ----------------- + +SYNC_GRANT_SOURCES_ = \ + ../cpp/samples/pubnub_sample_grant_token.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) +SYNC_GRANT_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_GRANT_SOURCES_)) +$(TARGET_BUILD_PATH)pubnub_sync_grant_sample$(APP_EXT): $(SYNC_GRANT_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +SYNC_REVOKE_SOURCES_ = \ + ../cpp/samples/pubnub_sample_revoke_token.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) +SYNC_REVOKE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_REVOKE_SOURCES_)) +$(TARGET_BUILD_PATH)pubnub_sync_revoke_sample$(APP_EXT): \ + $(SYNC_REVOKE_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +SYNC_CRYPTO_MODULE_SOURCES_ = \ + ./cpp/samples/pubnub_crypto_module_sample.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) +SYNC_CRYPTO_MODULE_SOURCES = $(subst /,$(PATH_SEP),$(SYNC_CRYPTO_MODULE_SOURCES_)) +$(TARGET_BUILD_PATH)pubnub_crypto_module_sample$(APP_EXT): \ + $(SYNC_CRYPTO_MODULE_SOURCES) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) diff --git a/make/common/targets_lib.mk b/make/common/targets_lib.mk new file mode 100644 index 00000000..5d0b328e --- /dev/null +++ b/make/common/targets_lib.mk @@ -0,0 +1,58 @@ +# PubNub SDK library targets. +# Description: Makefile used to declare list of targets to build different +# versions of PubNub SDK. + + +############################################################################### +# PubNub SDK library targets # +############################################################################### + +# PubNub SDK library with synchronous interface and static initialization +# vector. +# Note: Initialization vector make sense only if `OPENSSL` preprocessing flag +# is set to `1`. +pubnub_sync$(LIB_EXT): $(SOURCE_FILES) $(SYNC_SOURCE_FILES) + $(COMPILER) \ + $(OPTION_PREFIX)c \ + $(COMPILER_FLAGS) \ + $(CPPFLAGS) \ + $(OPTION_PREFIX)U PUBNUB_RAND_INIT_VECTOR \ + $(OPTION_PREFIX)D PUBNUB_RAND_INIT_VECTOR=0 \ + $(PREREQUISITES) + $(LIB_TOOL) $(LIB_CMD) $(LIB_OUT_FLAG)$@ $(OBJECT_FILES) $(SYNC_OBJECT_FILES) + +# PubNub SDK library with synchronous interface and dynamic initialization +# vector. +# Note: Initialization vector make sense only if `OPENSSL` preprocessing flag +# is set to `1`. +pubnub_sync_dynamiciv$(LIB_EXT): $(SOURCE_FILES) $(SYNC_SOURCE_FILES) + $(COMPILER) \ + $(OPTION_PREFIX)c \ + $(COMPILER_FLAGS) \ + $(CPPFLAGS) \ + $(OPTION_PREFIX)U PUBNUB_RAND_INIT_VECTOR \ + $(OPTION_PREFIX)D PUBNUB_RAND_INIT_VECTOR=1 \ + $(PREREQUISITES) + $(LIB_TOOL) $(LIB_CMD) $(LIB_OUT_FLAG)$@ $(OBJECT_FILES) $(SYNC_OBJECT_FILES) + +# PubNub SDK library with callback-based interface and dynamic initialization +# vector. +# Note: Initialization vector make sense only if `OPENSSL` preprocessing flag +# is set to `1`. +pubnub_callback$(LIB_EXT): $(SOURCE_FILES) $(CALLBACK_SOURCE_FILES) + $(COMPILER) \ + $(OPTION_PREFIX)c \ + $(COMPILER_FLAGS) \ + $(CALLBACK_CPPFLAGS) \ + $(OPTION_PREFIX)U PUBNUB_RAND_INIT_VECTOR \ + $(OPTION_PREFIX)D PUBNUB_RAND_INIT_VECTOR=0 \ + $(PREREQUISITES) + $(LIB_TOOL) $(LIB_CMD) $(LIB_OUT_FLAG)$@ $(OBJECT_FILES) $(CALLBACK_OBJECT_FILES) + +# PubNub SDK library with callback-based interface and dynamic initialization +# vector. +# Note: Initialization vector make sense only if `OPENSSL` preprocessing flag +# is set to `1`. +pubnub_callback_dynamiciv$(LIB_EXT): $(SOURCE_FILES) $(CALLBACK_SOURCE_FILES) + $(COMPILER) -c $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) -D PUBNUB_RAND_INIT_VECTOR=1 $(PREREQUISITES) + $(LIB_TOOL) $(LIB_CMD) $(LIB_OUT_FLAG)$@ $(OBJECT_FILES) $(CALLBACK_OBJECT_FILES) \ No newline at end of file diff --git a/make/posix_compiler_linker_flags.mk b/make/posix_compiler_linker_flags.mk new file mode 100644 index 00000000..3a868299 --- /dev/null +++ b/make/posix_compiler_linker_flags.mk @@ -0,0 +1,49 @@ +# Compiler and linker flags for POSIX system +# Description: Makefile used to declare compiler and linker flags adjustable +# with environment variables. + + +############################################################################### +# Compiler flags # +############################################################################### + +CMAKE_FLAGS = -Wall + +# Enable address sanitizer if required. +ifeq ($(ASAN),1) + # -g - enables debugging but with price of larger binary + # -fsanitize=address - run address sanityzer + CMAKE_FLAGS += -g -fsanitize=address +endif + +ifeq ($(WITH_CPP), 1) + COMPILER_FLAGS = $(CMAKE_FLAGS) -x c++ $(USER_CXX_FLAGS) +else + COMPILER_FLAGS = $(CMAKE_FLAGS) $(USER_C_FLAGS) +endif + + +############################################################################### +# Linker flags # +############################################################################### + +ifeq ($(shell uname),Darwin) + LDLIBS = -lpthread +else + LDLIBS = -lrt -lpthread +endif + +ifeq ($(OPENSSL),1) + ifneq ($(and $(OPENSSL_ROOT_DIR),$(CUSTOM_OPENSSL_LIB_DIR)),) + LDLIBS += -L$(OPENSSL_ROOT_DIR)/$(CUSTOM_OPENSSL_LIB_DIR) + else ifeq ($(shell uname),Darwin) + # Set OpenSSL lib path. + OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + ifneq ($(OPENSSL_LIBS),) + LDLIBS += $(OPENSSL_LIBS) + endif + endif + LDLIBS += -lssl -lcrypto +endif + +LDLIBS := $(sort $(LDLIBS)) \ No newline at end of file diff --git a/make/posix_cpp_targets.mk b/make/posix_cpp_targets.mk new file mode 100644 index 00000000..d377939c --- /dev/null +++ b/make/posix_cpp_targets.mk @@ -0,0 +1,56 @@ +# Sample CPP application targets. +# Description: Makefile used to declare list of targets to build sample app +# which demonstrates various features. + + +############################################################################### +# Sample application targets # +############################################################################### + +PUBNUB_FUTRES_SYNC_SOURCE_FILE = ../cpp/pubnub_futres_sync.cpp +PUBNUB_FUTRES_SOURCE_FILE = ../cpp/pubnub_futres_posix.cpp + +include ../make/common/targets_cpp_app.mk + +ifeq ($(OPENSSL), 1) + include ../make/common/targets_cpp_app_openssl.mk +endif + +# ----------------- Samples based on sync PubNub library ----------------- + +#openssl/pubnub_sync : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp +# $(CXX) -c $(CFLAGS) -x c++ $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) pubnub_futres_sync.cpp +# ar rcs pubnub_sync.a $(OBJFILES) $(SYNC_INTF_OBJFILES) pubnub_futres_sync.o + +ifeq ($(OPENSSL), 1) + $(TARGET_BUILD_PATH)pubnub_sync$(APP_EXT): \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) + $(COMPILER) -c $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) + $(LIB_TOOL) $(LIB_CMD) $(LIB_OUT_FLAG)pubnub_sync$(LIB_EXT) $(OBJECT_FILES) $(SYNC_OBJECT_FILES) pubnub_futres_sync.o +endif + +$(TARGET_BUILD_PATH)pubnub_sync_subloop_sample$(APP_EXT): \ + ../cpp/samples/pubnub_subloop_sample.cpp \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + + +# ----------------- Samples based on callback PubNub library ----------------- + +$(TARGET_BUILD_PATH)pubnub_callback_subloop_sample$(APP_EXT): \ + ../cpp/samples/pubnub_subloop_sample.cpp \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(PUBNUB_FUTRES_SYNC_SOURCE_FILE) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +$(TARGET_BUILD_PATH)pubnub_callback_cpp11_subloop_sample$(APP_EXT): \ + ../cpp/samples/pubnub_subloop_sample.cpp \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + ../cpp/pubnub_futres_cpp11.cpp + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPP11_STANDARD_FLAG) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LDLIBS) diff --git a/make/posix_preprocessing.mk b/make/posix_preprocessing.mk new file mode 100644 index 00000000..8a902274 --- /dev/null +++ b/make/posix_preprocessing.mk @@ -0,0 +1,256 @@ +# POSIX system preprocessing flags. +# Description: Makefile used to declare platform-specific preprocessing flag +# defaults. + +include ../make/common/preprocessing_defaults.mk + + +############################################################################### +# Default preprocessor flag values # +############################################################################### + +# Logger level. +LOG_LEVEL ?= $(DEFAULT_LOG_LEVEL) + +# Whether address sanitizer should be enabled or not. +ASAN ?= $(DEFAULT_ASAN) + +# Whether OpenSSL should be used or not. +OPENSSL ?= $(DEFAULT_OPENSSL) +USE_SSL ?= $(OPENSSL) + +# Path relative to the `OPENSSL_ROOT_DIR` which points to the linked OpenSSL +# libraries. +# +# Important: This flag will be used only if OpenSSL root has been specified. +CUSTOM_OPENSSL_LIB_DIR ?= + +# Path relative to the `OPENSSL_ROOT_DIR` which points to the included OpenSSL +# headers. +# +# Important: This flag will be used only if OpenSSL root has been specified. +CUSTOM_OPENSSL_INCLUDE_DIR ?= + +# OpenSSL root directory +OPENSSL_ROOT_DIR ?= + +# Whether GCC should be used for build or not. +WITH_GCC = 1 + +# Whether should build with for CPP or not. +WITH_CPP ?= $(DEFAULT_WITH_CPP) + +# Decide on compiler which should be used to build library and sample +# applications. +COMPILER = $(DEFAULT_COMPILER_TYPE) +ifeq ($(WITH_CPP), 1) + COMPILER = $(CXX) + USE_EXTERN_API ?= $(DEFAULT_USE_EXTERN_API) + USE_CPP11 ?= $(DEFAULT_USE_CPP11) +endif +ifeq ($(COMPILER),) + $(error "Can't proceed without compiler!") +endif + +# Whether PubNub should be built with callback interface or not. +USE_CALLBACK_API ?= $(DEFAULT_USE_CALLBACK_API) + +# Whether only publish / subscribe API should be enabled or not. +ONLY_PUBSUB_API ?= $(DEFAULT_ONLY_PUBSUB_API) + +# Whether compressed response processing should be enabled or not. +# +# Note: If enabled, will include a third-party library got gzip inflate. +RECEIVE_GZIP_RESPONSE ?= $(DEFAULT_RECEIVE_GZIP_RESPONSE) + +# Whether message reactions feature should be enabled or not. +USE_ACTIONS_API ?= $(DEFAULT_USE_ACTIONS_API) + +# Whether advanced message persistence feature should be enabled or not. +USE_ADVANCED_HISTORY ?= $(DEFAULT_USE_ADVANCED_HISTORY) + +# Whether automatic heartbeat should be enabled or not. +# +# Note: This feature will require additional memory to store PubNub context +# clone and will spin a separate thread to keep an active heartbeat timer. +USE_AUTO_HEARTBEAT ?= $(DEFAULT_USE_AUTO_HEARTBEAT) + +# Whether cryptography feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +USE_CRYPTO_API ?= $(DEFAULT_USE_CRYPTO_API) +ifeq ($(USE_CRYPTO_API), 1) + ifeq ($(OPENSSL), 0) + $(error "You can't use Crypto API without OpenSSL!") + endif +endif + +# Whether custom DNS servers feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with callback interface. +USE_DNS_SERVERS ?= $(USE_CALLBACK_API) + +# Whether message persistence feature should be enabled or not. +USE_FETCH_HISTORY ?= $(DEFAULT_USE_FETCH_HISTORY) + +# Whether grant token permissions feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +USE_GRANT_TOKEN ?= $(DEFAULT_USE_GRANT_TOKEN) +ifeq ($(USE_GRANT_TOKEN), 1) + ifeq ($(OPENSSL), 0) + $(error "You can't use Grant Token API without OpenSSL!") + endif +endif + +# Whether should enable HTTP body compression or not. +# +# Note: If enabled, will include a third-party library got gzip deflate. +USE_GZIP_COMPRESSION ?= $(DEFAULT_USE_GZIP_COMPRESSION) + +# Whether IPv6 connection should be supported or not. +USE_IPV6 ?= $(DEFAULT_USE_IPV6) + +# Whether to use random IV for legacy crypto module or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +USE_LEGACY_CRYPTO_RANDOM_IV ?= $(DEFAULT_USE_LEGACY_CRYPTO_RANDOM_IV) + +# Whether App Context feature should be enabled or not. +USE_OBJECTS_API ?= $(DEFAULT_USE_OBJECTS_API) + +# Whether request / connection proxy feature should be enabled or not. +USE_PROXY ?= $(DEFAULT_USE_PROXY) + +# Whether failed request retry feature should be enabled or not. +USE_RETRY_CONFIGURATION ?= $(DEFAULT_USE_RETRY_CONFIGURATION) + +# Whether token permissions revoke feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +USE_REVOKE_TOKEN ?= $(DEFAULT_USE_REVOKE_TOKEN) +ifeq ($(USE_REVOKE_TOKEN), 1) + ifeq ($(OPENSSL), 0) + $(error "You can't use Revoke Token API without OpenSSL!") + endif +endif + +# Whether subscribe event engine feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with subscribe v2 enabled. +USE_SUBSCRIBE_EVENT_ENGINE ?= $(DEFAULT_USE_SUBSCRIBE_EVENT_ENGINE) + +# Whether subscribe v2 feature should be enabled or not. +USE_SUBSCRIBE_V2 ?= $(DEFAULT_USE_SUBSCRIBE_V2) + +# Additional user-provided compiler flags (C/C++). +USER_C_FLAGS ?= +USER_CXX_FLAGS ?= + +# Check whether OpenSSL include and lib folders need to be set. +ifeq ($(OPENSSL),1) + SHOULD_SEARCH_OPENSSL_DIR = 0 + + ifeq ($(shell uname),Darwin) + OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) + OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + ifeq ($(and $(OPENSSL_CFLAGS),$(OPENSSL_LIBS)),) + SHOULD_SEARCH_OPENSSL_DIR = 1 + endif + else + SHOULD_SEARCH_OPENSSL_DIR = 1 + endif + + ifeq ($(SHOULD_SEARCH_OPENSSL_DIR), 1) + ifeq ($(OPENSSL_ROOT_DIR),) + ifeq ($(shell test -d "/usr/local/opt/openssl" && echo yes || echo no),yes) + # Path on macOS with OpenSSL installed with Homebrew. + OPENSSL_ROOT_DIR = /usr/local/opt/openssl + CUSTOM_OPENSSL_INCLUDE_DIR = "include" + CUSTOM_OPENSSL_LIB_DIR = lib + else ifeq ($(shell test -d "/usr/lib/x86_64-linux-gnu" && echo yes || echo no),yes) + # Path on GitHub Action Runner (ubuntu-latest image) + OPENSSL_ROOT_DIR = /usr + CUSTOM_OPENSSL_INCLUDE_DIR = "include" + CUSTOM_OPENSSL_LIB_DIR = lib/x86_64-linux-gnu + endif + endif + endif +endif + + +############################################################################### +# Compiler-specific configuration # +############################################################################### + +# Platform-specific path separator. +# +# This separator used with `subst` function to normalize source file paths. +PATH_SEP = / + +# Library creation tool configuration +LIB_TOOL = ar +LIB_CMD = rcs +LIB_OUT_FLAG = + +# Built library file extension. +LIB_EXT = .a + +# Linker flag. +LINK_FLAG = + +# Build sample application extension. +APP_EXT = + +# Compiler's flag to enforce C++11 standard. +CPP11_STANDARD_FLAG = +ifeq ($(and $(WITH_CPP),$(USE_CPP11)),1) + CPP11_STANDARD_FLAG = -std=c++11 +endif + +# Compiler options flags prefix. +OPTION_PREFIX = - + +# Compiler's result output flag. +OUT_FLAG = -o + +# Pre-requisites compiler's command modifier. +PREREQUISITES = $^ + + +############################################################################### +# Pre-processing flags # +############################################################################### + +# Included public headers. +INCLUDES_PLATFORM = -I../lib/base64 + +DEFINES_PLATFORM = +DEFINES_EXTERN_C = +ifeq ($(WITH_CPP),1) + ifeq ($(USE_EXTERN_API),1) + DEFINES_EXTERN_C += -D PUBNUB_USE_EXTERN_C=$(USE_EXTERN_API) + endif +endif + +DEFINES_RANDOM_IV = +INCLUDES_OPENSSL = +ifeq ($(OPENSSL),1) + DEFINES_RANDOM_IV += -D PUBNUB_RAND_INIT_VECTOR=$(USE_LEGACY_CRYPTO_RANDOM_IV) + INCLUDES_PLATFORM += -I../openssl + + ifneq ($(and $(OPENSSL_ROOT_DIR),$(CUSTOM_OPENSSL_INCLUDE_DIR)),) + INCLUDES_OPENSSL += -I$(OPENSSL_ROOT_DIR)/$(CUSTOM_OPENSSL_INCLUDE_DIR) + else ifeq ($(shell uname),Darwin) + # Set OpenSSL includes path. + OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) + ifneq ($(OPENSSL_CFLAGS),) + INCLUDES_OPENSSL += $(OPENSSL_CFLAGS) + endif + endif +else + INCLUDES_PLATFORM += -I../posix +endif + +# Finish up pre-processing flags configuration with platform-specific data. +include ../make/common/preprocessing.mk \ No newline at end of file diff --git a/make/posix_source_files.mk b/make/posix_source_files.mk new file mode 100644 index 00000000..6800281c --- /dev/null +++ b/make/posix_source_files.mk @@ -0,0 +1,171 @@ +# PubNub SDK source files for POSIX system. +# Description: Makefile used to declare platform-specific list of PubNub SDK +# source files. + +include ../make/common/source_files.mk + + +############################################################################### +# PubNub Core source files # +############################################################################### + +# PubNub SDK core source files used for all platforms. +SOURCE_FILES = $(CORE_SOURCE_FILES) $(CORE_SOURCE_FILES_POSIX) + +# Core source files for a synchronous PubNub C-core client version support. +SYNC_SOURCE_FILES = $(SYNC_CORE_SOURCE_FILES) + +# Source files for a call-back based PubNub C-core client version support. +CALLBACK_SOURCE_FILES = $(CALLBACK_CORE_SOURCE_FILES) + +ifeq ($(WITH_CPP), 1) + SOURCE_FILES += \ + $(CORE_CPP_SOURCE_FILES) \ + $(CORE_CPP_SOURCE_FILES_POSIX) +else + SOURCE_FILES += \ + $(CORE_NON_CPP_SOURCE_FILES) \ + $(CORE_NON_CPP_SOURCE_FILES_POSIX) +endif + +ifeq ($(OPENSSL),1) + SOURCE_FILES += \ + $(CORE_OPENSSL_SOURCE_FILES) \ + $(CORE_OPENSSL_SOURCE_FILES_POSIX) + + ifneq ($(shell uname),Darwin) + SOURCE_FILES += $(CORE_OPENSSL_SOURCE_FILES_NOT_DARWIN) + endif + + CALLBACK_SOURCE_FILES += \ + $(CALLBACK_CORE_OPENSSL_SOURCE_FILES) \ + $(CALLBACK_CORE_OPENSSL_SOURCE_FILES_POSIX) +else + SOURCE_FILES += \ + $(CORE_NON_OPENSSL_SOURCE_FILES) \ + $(CORE_NON_OPENSSL_SOURCE_FILES_POSIX) + + CALLBACK_SOURCE_FILES += \ + $(CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES) \ + $(CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES_POSIX) +endif + +ifeq ($(shell uname),Darwin) + SOURCE_FILES += ../posix/monotonic_clock_get_time_darwin.c +else + SOURCE_FILES += ../posix/monotonic_clock_get_time_posix.c +endif + + +############################################################################### +# Add feature-relates source files # +############################################################################### + +# Published messages content compression feature source files. +ifeq ($(RECEIVE_GZIP_RESPONSE), 1) + SOURCE_FILES += $(GZIP_RESPONSE_SOURCE_FILES) +endif + +# Published message reactions feature source files. +ifeq ($(USE_ACTIONS_API), 1) + SOURCE_FILES += $(MESSAGE_REACTION_SOURCE_FILES) +endif + +# Extended history feature source files. +# +# Extended history allows to fetch messages in batch for multiple channels, +# count messages and fetch with additional information. +ifeq ($(USE_ADVANCED_HISTORY), 1) + SOURCE_FILES += $(ADVANCED_HISTORY_SOURCE_FILES) +endif + +# Auto heartbeat feature source files. +# +# Feature used together with `USE_SUBSCRIBE_V2` flag to send periodic heartbeat +# requests to update users' presence on subscribed channels. +ifeq ($(USE_AUTO_HEARTBEAT), 1) + SOURCE_FILES += $(AUTO_HEARTBEAT_SOURCE_FILES) + ifeq ($(OPENSSL), 1) + SOURCE_FILES += \ + $(AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES) \ + $(AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES_POSIX) + else + SOURCE_FILES += \ + $(AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES) \ + $(AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES_POSIX) + endif +endif + +# Published / received data encryption and decryption feature source files. +ifeq ($(and $(OPENSSL),$(USE_CRYPTO_API)),1) + SOURCE_FILES += $(CRYPTO_SOURCE_FILES) +endif + +# Custom DNS servers feature source files. +# +# Feature allows to specify custom DNS servers and send query to them. +# Important: Can be used only together with `PUBNUB_CALLBACK_API` flag. +ifeq ($(USE_DNS_SERVERS), 1) + CALLBACK_SOURCE_FILES += \ + $(DNS_SERVERS_SOURCE_FILES) \ + $(DNS_SERVERS_SOURCE_FILES_POSIX) +endif +ifeq ($(or $(USE_DNS_SERVERS),$(USE_PROXY)), 1) + CALLBACK_SOURCE_FILES += $(IPV4_SOURCE_FILES) + ifeq ($(USE_IPV6), 1) + CALLBACK_SOURCE_FILES += $(IPV6_SOURCE_FILES) + endif +endif + +# Single channel history feature source files. +ifeq ($(USE_FETCH_HISTORY), 1) + SOURCE_FILES += $(FETCH_HISTORY_SOURCE_FILES) +endif + +# Grant token permissions feature source files. +ifeq ($(and $(OPENSSL),$(USE_GRANT_TOKEN)), 1) + SOURCE_FILES += $(GRANT_TOKEN_SOURCE_FILES) +endif + +# Compressed service response de-compression feature source files. +ifeq ($(USE_GZIP_COMPRESSION), 1) + SOURCE_FILES += $(GZIP_COMPRESSION_SOURCE_FILES) +endif + +# App Context feature source files. +ifeq ($(USE_OBJECTS_API), 1) + SOURCE_FILES += $(APP_CONTEXT_SOURCE_FILES) +endif + +# Custom proxy feature source files. +ifeq ($(USE_PROXY), 1) + SOURCE_FILES += \ + $(PROXY_SOURCE_FILES) \ + $(PROXY_SOURCE_FILES_POSIX) +endif + +# Automated failed request retry feature source files. +ifeq ($(USE_RETRY_CONFIGURATION), 1) + SOURCE_FILES += $(RETRY_CONFIGURATION_SOURCE_FILES) +endif + +# Revoke token permissions feature source files. +ifeq ($(and $(OPENSSL),$(USE_REVOKE_TOKEN)), 1) + SOURCE_FILES += $(REVOKE_TOKEN_SOURCE_FILES) +endif + +# Subscription event engine feature source files. +ifeq ($(USE_SUBSCRIBE_EVENT_ENGINE), 1) + SOURCE_FILES += $(SUBSCRIBE_EVENT_ENGINE_SOURCE_FILES) +endif + +# Subscribe v2 feature source files. +ifeq ($(USE_SUBSCRIBE_V2), 1) + SOURCE_FILES += $(SUBSCRIBE_V2_SOURCE_FILES) +endif + + +# Resulting set of the compiled objects. +OBJECT_FILES = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(notdir $(SOURCE_FILES)))) +SYNC_OBJECT_FILES = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(notdir $(SYNC_SOURCE_FILES)))) +CALLBACK_OBJECT_FILES = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(notdir $(CALLBACK_SOURCE_FILES)))) diff --git a/make/posix_targets.mk b/make/posix_targets.mk new file mode 100644 index 00000000..25ca33ab --- /dev/null +++ b/make/posix_targets.mk @@ -0,0 +1,33 @@ +# Targets for POSIX system. +# Description: Makefile used to declare list of targets which can be built for +# POSIX systems. + + +############################################################################### +# Build targets # +############################################################################### + +include ../make/common/targets_app.mk + +ifeq ($(OPENSSL), 1) + include ../make/common/targets_app_openssl.mk +endif + +# ----------------- Samples based on sync PubNub library ----------------- + +pubnub_sync_subloop_sample$(APP_EXT): \ + ../core/samples/pubnub_sync_subloop_sample.c \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +# Test targets +pubnub_fntest$(APP_EXT): \ + ../core/fntest/pubnub_fntest_basic.c \ + ../core/fntest/pubnub_fntest_medium.c \ + ../core/fntest/pubnub_fntest.c \ + ../posix/fntest/pubnub_fntest_posix.c \ + ../posix/fntest/pubnub_fntest_runner.c \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +.PHONY: all clean \ No newline at end of file diff --git a/make/windows_compiler_linker_flags.mk b/make/windows_compiler_linker_flags.mk new file mode 100644 index 00000000..1645e315 --- /dev/null +++ b/make/windows_compiler_linker_flags.mk @@ -0,0 +1,79 @@ +# Compiler and linker flags for Windows system +# Description: Makefile used to declare compiler and linker flags adjustable +# with environment variables. + + +############################################################################### +# Compiler flags # +############################################################################### + +!if $(WITH_GCC) +# -std=c11 - enables `%z` and `%ll` in printf() - in general, we're "low" +# on C11 features +NMAKE_FLAGS = -std=c11 -W2l +!else +# /MP - uses one compiler (`cl`) process for each input file, enabling +# faster build +NMAKE_FLAGS = /W2 /MP +!endif + +!if $(ASAN) +!if $(WITH_GCC) +# -g - enables debugging but with price of larger binary +# -fsanitize=address - run address sanityzer +NMAKE_FLAGS = $(NMAKE_FLAGS) -g -fsanitize=address +!else +# /Zi - enables debugging, remove to get a smaller .exe and no .pdb +# /analyze - To run the static analyzer (not compatible w/clang-cl) +NMAKE_FLAGS = $(NMAKE_FLAGS) /Zi /analyze +!endif +!else +NMAKE_FLAGS = $(NMAKE_FLAGS) /wd4005 +!endif + +!if $(WITH_CPP) +!if $(WITH_GCC) +NMAKE_FLAGS = $(NMAKE_FLAGS) -x c++ +!else +NMAKE_FLAGS = $(NMAKE_FLAGS) /TP +!endif +!endif +COMPILER_FLAGS = $(NMAKE_FLAGS) $(USER_C_FLAGS) + + +############################################################################### +# Linker flags # +############################################################################### + +!if $(WITH_GCC) +LDLIBS = -lws2_32 -lrpcrt4 -lsecur32 +!else +LDLIBS = ws2_32.lib IPHlpAPI.lib rpcrt4.lib +!endif + +# TODO: Add support of OpenSSL when built with GCC if possible. +!if "$(OPENSSL)" == "1" && "$(WITH_GCC)" == "0" +OPENSSL_LIBS = +OPENSSL_FOUND = 0 +!if "$(OPENSSL_ROOT_DIR)" != "" && "$(CUSTOM_OPENSSL_LIB_DIR)" != "" +OPENSSL_ROOT_DIR_ = $(subst /,$(PATH_SEP),$(OPENSSL_ROOT_DIR)) +CUSTOM_OPENSSL_LIB_DIR_ = $(subst /,$(PATH_SEP),$(CUSTOM_OPENSSL_LIB_DIR)) + +!if EXISTS($(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libssl.lib) +OPENSSL_FOUND = 1 +OPENSSL_LIBS = \ + "$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libssl.lib" \ + "$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libcrypto.lib" +!elseif EXISTS($(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)ssleay32.lib) +OPENSSL_FOUND = 1 +OPENSSL_LIBS = \ + "$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)ssleay32.lib" \ + "$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libeay32.lib" +!endif +!endif +!if $(OPENSSL_FOUND) == 0 +!error Cannot find OpenSSL libraries, OPENSSLPATH="$(subst /,$(PATH_SEP),$(OPENSSL_ROOT_DIR))" +!else +LDLIBS = $(strip $(LDLIBS)) $(strip $(OPENSSL_LIBS)) +!endif +!endif \ No newline at end of file diff --git a/make/windows_cpp_targets.mk b/make/windows_cpp_targets.mk new file mode 100644 index 00000000..543a3a2f --- /dev/null +++ b/make/windows_cpp_targets.mk @@ -0,0 +1,29 @@ +# Sample CPP application targets. +# Description: Makefile used to declare list of targets to build sample app +# which demonstrates various features. + + +############################################################################### +# Sample application targets # +############################################################################### + +PUBNUB_FUTRES_SYNC_SOURCE_FILE = ../cpp/pubnub_futres_sync.cpp +PUBNUB_FUTRES_SOURCE_FILE = ../cpp/pubnub_futres_windows.cpp + +# Extending compiler flags (preprocessing macro). +COMPILER_FLAGS = \ + $(COMPILER_FLAGS) \ + $(OPTION_PREFIX)D _CRT_SECURE_NO_WARNINGS \ + $(OPTION_PREFIX)D _WINSOCK_DEPRECATED_NO_WARNINGS + +!if $(OPENSSL) +COMPILER_FLAGS = \ + $(COMPILER_FLAGS) \ + $(OPTION_PREFIX)D PUBNUB_USE_WIN_SSPI=1 +!endif + +!include <../make/common/targets_cpp_app.mk> + +!if $(OPENSSL) +!include <../make/common/targets_cpp_app_openssl.mk> +!endif \ No newline at end of file diff --git a/make/windows_preprocessing.mk b/make/windows_preprocessing.mk new file mode 100644 index 00000000..6c6b9d91 --- /dev/null +++ b/make/windows_preprocessing.mk @@ -0,0 +1,331 @@ +# Windows preprocessing flags. +# Description: Makefile used to declare platform-specific preprocessing flag +# defaults. + +!include <../make/common/preprocessing_defaults.mk> + + +############################################################################### +# Default preprocessor flag values # +############################################################################### + +# Logger level. +!ifndef LOG_LEVEL +LOG_LEVEL = $(DEFAULT_LOG_LEVEL) +!endif + +# Whether address sanitizer should be enabled or not. +!ifndef ASAN +ASAN = $(DEFAULT_ASAN) +!endif + +# Whether GCC should be used for build or not. +!ifndef WITH_GCC +WITH_GCC = 0 +!endif + +!if $(WITH_GCC) +# Platform-specific path separator. +# +# This separator used with `subst` function to normalize source file paths. +PATH_SEP = / +!else +# Platform-specific path separator. +# +# This separator used with `subst` function to normalize source file paths. +PATH_SEP = \\ +!endif + +# Whether OpenSSL should be used or not. +!ifndef OPENSSL +OPENSSL = $(DEFAULT_OPENSSL) +!endif +!ifndef USE_SSL +USE_SSL = $(OPENSSL) +!endif + +# Path relative to the `OPENSSL_ROOT_DIR` which points to the linked OpenSSL +# libraries. +# +# Important: This flag will be used only if OpenSSL root has been specified. +!ifndef CUSTOM_OPENSSL_LIB_DIR +CUSTOM_OPENSSL_LIB_DIR = lib +!endif + +# Path relative to the `OPENSSL_ROOT_DIR` which points to the included OpenSSL +# headers. +# +# Important: This flag will be used only if OpenSSL root has been specified. +!ifndef CUSTOM_OPENSSL_INCLUDE_DIR +CUSTOM_OPENSSL_INCLUDE_DIR = include +!endif + +# OpenSSL root directory +!ifdef OPENSSLPATH +OPENSSL_ROOT_DIR = $(OPENSSLPATH) +!elseifndef OPENSSL_ROOT_DIR +# Path will be updated if build is done using non-GCC compiler. +OPENSSL_ROOT_DIR = C:$(PATH_SEP)OpenSSL-Win32 +!endif + +# Whether should build with for CPP or not. +!ifndef WITH_CPP +WITH_CPP = $(DEFAULT_WITH_CPP) +!endif + +# Decide on compiler which should be used to build library and sample +# applications. +COMPILER = $(DEFAULT_COMPILER_TYPE) +!if $(WITH_CPP) +COMPILER = $(CXX) +!ifndef $(USE_EXTERN_API) +USE_EXTERN_API = $(DEFAULT_USE_EXTERN_API) +!endif +!ifndef $(USE_CPP11) +USE_CPP11 = $(DEFAULT_USE_CPP11) +!endif +!endif +!if "$(COMPILER)" == "" +!error "Can't proceed without compiler!" +!endif + +# Whether PubNub should be built with callback interface or not. +!ifndef USE_CALLBACK_API +USE_CALLBACK_API = $(DEFAULT_USE_CALLBACK_API) +!endif + +# Whether only publish / subscribe API should be enabled or not. +!ifndef ONLY_PUBSUB_API +ONLY_PUBSUB_API = $(DEFAULT_ONLY_PUBSUB_API) +!endif + +# Whether compressed response processing should be enabled or not. +# +# Note: If enabled, will include a third-party library got gzip inflate. +!ifndef RECEIVE_GZIP_RESPONSE +RECEIVE_GZIP_RESPONSE = $(DEFAULT_RECEIVE_GZIP_RESPONSE) +!endif + +# Whether message reactions feature should be enabled or not. +!ifndef USE_ACTIONS_API +USE_ACTIONS_API = $(DEFAULT_USE_ACTIONS_API) +!endif + +# Whether advanced message persistence feature should be enabled or not. +!ifndef USE_ADVANCED_HISTORY +USE_ADVANCED_HISTORY = $(DEFAULT_USE_ADVANCED_HISTORY) +!endif + +# Whether automatic heartbeat should be enabled or not. +# +# Note: This feature will require additional memory to store PubNub context +# clone and will spin a separate thread to keep an active heartbeat timer. +!ifndef USE_AUTO_HEARTBEAT +USE_AUTO_HEARTBEAT = $(DEFAULT_USE_AUTO_HEARTBEAT) +!endif + +# Whether cryptography feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +!ifndef USE_CRYPTO_API +USE_CRYPTO_API = $(DEFAULT_USE_CRYPTO_API) +!endif +!if $(USE_CRYPTO_API) +!if !$(OPENSSL) +!error "You can't use Crypto API without OpenSSL!" +!endif +!endif + +# Whether custom DNS servers feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with callback interface. +!ifndef USE_DNS_SERVERS +USE_DNS_SERVERS = $(USE_CALLBACK_API) +!endif + +# Whether message persistence feature should be enabled or not. +!ifndef USE_FETCH_HISTORY +USE_FETCH_HISTORY = $(DEFAULT_USE_FETCH_HISTORY) +!endif + +# Whether grant token permissions feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +!ifndef USE_GRANT_TOKEN +USE_GRANT_TOKEN = $(DEFAULT_USE_GRANT_TOKEN) +!endif +!if $(USE_GRANT_TOKEN) == 1 +!if $(OPENSSL) == 0 +!error "You can't use Grant Token API without OpenSSL!" +!endif +!endif + +# Whether should enable HTTP body compression or not. +# +# Note: If enabled, will include a third-party library got gzip deflate. +!ifndef USE_GZIP_COMPRESSION +USE_GZIP_COMPRESSION = $(DEFAULT_USE_GZIP_COMPRESSION) +!endif + +# Whether IPv6 connection should be supported or not. +!ifndef USE_IPV6 +USE_IPV6 = $(DEFAULT_USE_IPV6) +!endif + +# Whether to use random IV for legacy crypto module or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +!ifndef USE_LEGACY_CRYPTO_RANDOM_IV +USE_LEGACY_CRYPTO_RANDOM_IV = $(DEFAULT_USE_LEGACY_CRYPTO_RANDOM_IV) +!endif + +# Whether App Context feature should be enabled or not. +!ifndef USE_OBJECTS_API +USE_OBJECTS_API = $(DEFAULT_USE_OBJECTS_API) +!endif + +# Whether request / connection proxy feature should be enabled or not. +!ifndef USE_PROXY +USE_PROXY = $(DEFAULT_USE_PROXY) +!endif + +# Whether failed request retry feature should be enabled or not. +!ifndef USE_RETRY_CONFIGURATION +USE_RETRY_CONFIGURATION = $(DEFAULT_USE_RETRY_CONFIGURATION) +!endif + +# Whether token permissions revoke feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with OpenSSL. +!ifndef USE_REVOKE_TOKEN +USE_REVOKE_TOKEN = $(DEFAULT_USE_REVOKE_TOKEN) +!endif +!if $(USE_REVOKE_TOKEN) +!if !$(OPENSSL) +!error "You can't use Revoke Token API without OpenSSL!" +!endif +!endif + +# Whether subscribe event engine feature should be enabled or not. +# +# Important: This feature can be used ONLY for build with subscribe v2 enabled. +!ifndef USE_SUBSCRIBE_EVENT_ENGINE +USE_SUBSCRIBE_EVENT_ENGINE = $(DEFAULT_USE_SUBSCRIBE_EVENT_ENGINE) +!endif + +# Whether subscribe v2 feature should be enabled or not. +!ifndef USE_SUBSCRIBE_V2 +USE_SUBSCRIBE_V2 = $(DEFAULT_USE_SUBSCRIBE_V2) +!endif + +# Additional user-provided compiler flags (C/C++). +!ifndef USER_C_FLAGS +USER_C_FLAGS = +!endif +!ifndef USER_CXX_FLAGS +USER_CXX_FLAGS = +!endif + + +############################################################################### +# Compiler-specific configuration # +############################################################################### + +CPP11_STANDARD_FLAG = + +# Decide on prefix which should be used for options (`/D` or `-D`), +!if $(WITH_GCC) +OBJ_EXT = .o + +# Compiler options flags prefix. +OPTION_PREFIX = - +LIB_TOOL = ar +LIB_CMD = rcs +LIB_OUT_FLAG = + +# Built library file extension. +LIB_EXT = .a + +# Linker flag. +LINK_FLAG = + +# Build sample application extension. +APP_EXT = + +# Compiler's result output flag. +OUT_FLAG = -o + +# Compiler's flag to enforce C++11 standard. +!if "$(WITH_CPP)" == "1" && "$(USE_CPP11)" == "1" +CPP11_STANDARD_FLAG = -std=c++11 +!endif +!else +OBJ_EXT = .obj + +# Compiler options flags prefix. +OPTION_PREFIX = / + +# Library creation tool configuration +LIB_TOOL = lib +LIB_CMD = +LIB_OUT_FLAG = -OUT: + +# Built library file extension. +LIB_EXT = .lib + +# Linker flag. +LINK_FLAG = + +# Build sample application extension. +APP_EXT = .exe + +# Compiler's result output flag. +OUT_FLAG = /Fe + +# Compiler's flag to enforce C++11 standard. +!if $(WITH_CPP) +# Linker flag. +LINK_FLAG = /link +!if $(USE_CPP11) +CPP11_STANDARD_FLAG = /std:c++11 +!endif +!endif +!endif + +# Pre-requisites compiler's command modifier. +PREREQUISITES = $** + + +############################################################################### +# Pre-processing flags # +############################################################################### + +# Included public headers. +INCLUDES_PLATFORM = \ + $(OPTION_PREFIX)I..$(PATH_SEP)core$(PATH_SEP)c99 \ + $(OPTION_PREFIX)I..$(PATH_SEP)lib$(PATH_SEP)base64 + +DEFINES_PLATFORM = $(OPTION_PREFIX)D _WINSOCKAPI_ +DEFINES_EXTERN_C = +!if "$(WITH_CPP)" == "1" && "$(USE_EXTERN_API)" == "1" +DEFINE_EXTERN_C = $(OPTION_PREFIX)D PUBNUB_USE_EXTERN_C=$(USE_EXTERN_API) +!endif + +DEFINES_RANDOM_IV = +INCLUDES_OPENSSL = +!if $(OPENSSL) +DEFINE_RANDOM_IV = $(OPTION_PREFIX)D PUBNUB_RAND_INIT_VECTOR=$(USE_LEGACY_CRYPTO_RANDOM_IV) +INCLUDES_OPENSSL = $(OPTION_PREFIX)I..$(PATH_SEP)openssl + +!if "$(OPENSSL_ROOT_DIR)" != "" && "$(CUSTOM_OPENSSL_INCLUDE_DIR)" != "" +OPENSSL_ROOT_DIR_ = $(subst /,$(PATH_SEP),$(OPENSSL_ROOT_DIR)) +CUSTOM_OPENSSL_INCLUDE_DIR_ = $(subst /,$(PATH_SEP),$(CUSTOM_OPENSSL_INCLUDE_DIR)) +INCLUDES_OPENSSL = $(INCLUDES_OPENSSL) \ + $(OPTION_PREFIX)I"$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_INCLUDE_DIR_)" +!endif +!else +INCLUDES_PLATFORM = $(INCLUDES_PLATFORM) $(OPTION_PREFIX)I..$(PATH_SEP)windows +!endif + +# Finish up pre-processing flags configuration with platform-specific data. +!include <../make/common/preprocessing.mk> \ No newline at end of file diff --git a/make/windows_source_files.mk b/make/windows_source_files.mk new file mode 100644 index 00000000..af6ee81d --- /dev/null +++ b/make/windows_source_files.mk @@ -0,0 +1,271 @@ +# PubNub SDK source files for Windows system. +# Description: Makefile used to declare platform-specific list of PubNub SDK +# source files. + +!include <../make/common/source_files.mk> + + +############################################################################### +# PubNub Core source files # +############################################################################### + +# PubNub SDK core source files used for all platforms. +SOURCE_FILES_ = $(CORE_SOURCE_FILES) $(CORE_SOURCE_FILES_WINDOWS) + +# Core source files for a synchronous PubNub C-core client version support. +SYNC_SOURCE_FILES_ = $(SYNC_CORE_SOURCE_FILES) + +# Source files for a call-back based PubNub C-core client version support. +CALLBACK_SOURCE_FILES_ = $(CALLBACK_CORE_SOURCE_FILES) + +!if $(WITH_CPP) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(CORE_CPP_SOURCE_FILES) \ + $(CORE_CPP_SOURCE_FILES_WINDOWS) +!else +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(CORE_NON_CPP_SOURCE_FILES) \ + $(CORE_NON_CPP_SOURCE_FILES_WINDOWS) +!endif + +!if $(OPENSSL) +# Adding files required to provide OpenSSL support secured connections. +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(CORE_OPENSSL_SOURCE_FILES) \ + $(CORE_OPENSSL_SOURCE_FILES_WINDOWS) +CALLBACK_SOURCE_FILES_ = \ + $(CALLBACK_SOURCE_FILES_) \ + $(CALLBACK_CORE_OPENSSL_SOURCE_FILES) \ + $(CALLBACK_CORE_OPENSSL_SOURCE_FILES_WINDOWS) +!else +# Adding files required to provide support for regular connections. +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(CORE_NON_OPENSSL_SOURCE_FILES) \ + $(CORE_NON_OPENSSL_SOURCE_FILES_WINDOWS) +CALLBACK_SOURCE_FILES_ = \ + $(CALLBACK_SOURCE_FILES_) \ + $(CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES) \ + $(CALLBACK_CORE_NON_OPENSSL_SOURCE_FILES_WINDOWS) +!endif + + +############################################################################### +# Add feature-relates source files # +############################################################################### + +# Published messages content compression feature source files. +!if $(RECEIVE_GZIP_RESPONSE) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(GZIP_RESPONSE_SOURCE_FILES) +!endif + +# Published message reactions feature source files. +!if $(USE_ACTIONS_API) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(MESSAGE_REACTION_SOURCE_FILES) +!endif + +# Extended history feature source files. +# +# Extended history allows to fetch messages in batch for multiple channels, +# count messages and fetch with additional information. +!if $(USE_ADVANCED_HISTORY) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(ADVANCED_HISTORY_SOURCE_FILES) +!endif + +# Auto heartbeat feature source files. +# +# Feature used together with `USE_SUBSCRIBE_V2` flag to send periodic heartbeat +# requests to update users' presence on subscribed channels. +!if $(USE_AUTO_HEARTBEAT) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(AUTO_HEARTBEAT_SOURCE_FILES) + +!if $(OPENSSL) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES) \ + $(AUTO_HEARTBEAT_OPENSSL_SOURCE_FILES_WINDOWS) +!else +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES) \ + $(AUTO_HEARTBEAT_NON_OPENSSL_SOURCE_FILES_WINDOWS) +!endif +!endif + +# Published / received data encryption and decryption feature source files. +!if "$(OPENSSL)" =="1" && "$(USE_CRYPTO_API)" == "1" +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(CRYPTO_SOURCE_FILES) +!endif + +# Custom DNS servers feature source files. +# +# Feature allows to specify custom DNS servers and send query to them. +# Important: Can be used only together with `PUBNUB_CALLBACK_API` flag. +!if $(USE_DNS_SERVERS) +CALLBACK_SOURCE_FILES_ = \ + $(CALLBACK_SOURCE_FILES_) \ + $(DNS_SERVERS_SOURCE_FILES) \ + $(DNS_SERVERS_SOURCE_FILES_WINDOWS) +!endif +!if "$(USE_DNS_SERVERS)" == "1" || "$(USE_PROXY)" == "1" +CALLBACK_SOURCE_FILES_ = \ + $(CALLBACK_SOURCE_FILES_) \ + $(IPV4_SOURCE_FILES) +!if $(USE_IPV6) +CALLBACK_SOURCE_FILES_ = \ + $(CALLBACK_SOURCE_FILES_) \ + $(IPV6_SOURCE_FILES) +!endif +!endif + +# Single channel history feature source files. +!if $(USE_FETCH_HISTORY) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(FETCH_HISTORY_SOURCE_FILES) +!endif + +# Grant token permissions feature source files. +!if "$(OPENSSL)" == "1" && "$(USE_GRANT_TOKEN)" == "1" +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(GRANT_TOKEN_SOURCE_FILES) +!endif + +# Compressed service response de-compression feature source files. +!if $(USE_GZIP_COMPRESSION) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(GZIP_COMPRESSION_SOURCE_FILES) +!endif + +# App Context feature source files. +!if $(USE_OBJECTS_API) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(APP_CONTEXT_SOURCE_FILES) +!endif + +# Custom proxy feature source files. +!if $(USE_PROXY) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(PROXY_SOURCE_FILES) \ + $(PROXY_SOURCE_FILES_WINDOWS) +!endif + +# Automated failed request retry feature source files. +!if $(USE_RETRY_CONFIGURATION) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(RETRY_CONFIGURATION_SOURCE_FILES) +!endif + +# Revoke token permissions feature source files. +!if "$(OPENSSL)" == "1" && "$(USE_REVOKE_TOKEN)" == "1" +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(REVOKE_TOKEN_SOURCE_FILES) +!endif + +# Subscription event engine feature source files. +!if $(USE_SUBSCRIBE_EVENT_ENGINE) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(SUBSCRIBE_EVENT_ENGINE_SOURCE_FILES) +!endif + +# Subscribe v2 feature source files. +!if $(USE_SUBSCRIBE_V2) +SOURCE_FILES_ = \ + $(SOURCE_FILES_) \ + $(SUBSCRIBE_V2_SOURCE_FILES) +!endif + +# There is no suitable functions available in nmake to strip file path, +# so it needs to be done manually. +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_FILES_:../core/c99/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../core/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../cpp/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../lib/base64/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../lib/cbor/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../lib/md5/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../lib/miniz/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../lib/msstopwatch/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../lib/sockets/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../lib/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../openssl/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../posix/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../qt/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../unreal/=) +SOURCE_OBJECT_FILES_NAMES = $(SOURCE_OBJECT_FILES_NAMES:../windows/=) + +SYNC_OBJECT_FILES_NAMES = $(SYNC_SOURCE_FILES_:../core/c99/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../core/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../cpp/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../lib/base64/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../lib/cbor/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../lib/md5/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../lib/miniz/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../lib/msstopwatch/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../lib/sockets/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../lib/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../openssl/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../posix/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../qt/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../unreal/=) +SYNC_OBJECT_FILES_NAMES = $(SYNC_OBJECT_FILES_NAMES:../windows/=) + +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_SOURCE_FILES_:../core/c99/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../core/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../cpp/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../lib/base64/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../lib/cbor/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../lib/md5/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../lib/miniz/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../lib/msstopwatch/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../lib/sockets/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../lib/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../openssl/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../posix/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../qt/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../unreal/=) +CALLBACK_OBJECT_FILES_NAMES = $(CALLBACK_OBJECT_FILES_NAMES:../windows/=) + +CPP_OBJECT_FILES = $(subst .cpp,$(OBJ_EXT),$(SOURCE_OBJECT_FILES_NAMES)) +OBJECT_FILES = $(subst .c,$(OBJ_EXT),$(CPP_OBJECT_FILES)) +OBJECT_FILES = $(strip $(OBJECT_FILES)) +SYNC_CPP_OBJECT_FILES = $(subst .cpp,$(OBJ_EXT),$(SYNC_OBJECT_FILES_NAMES)) +SYNC_OBJECT_FILES = $(subst .c,$(OBJ_EXT),$(SYNC_CPP_OBJECT_FILES)) +SYNC_OBJECT_FILES = $(strip $(SYNC_OBJECT_FILES)) +CALLBACK_CPP_OBJECT_FILES = $(subst .cpp,$(OBJ_EXT),$(CALLBACK_OBJECT_FILES_NAMES)) +CALLBACK_OBJECT_FILES = $(subst .c,$(OBJ_EXT),$(CALLBACK_CPP_OBJECT_FILES)) +CALLBACK_OBJECT_FILES = $(strip $(CALLBACK_OBJECT_FILES)) + +# Update path separator (if building with GCC compiler). +!if "$(PATH_SEP)" != "/" +SOURCE_FILES = $(subst /,$(PATH_SEP),$(SOURCE_FILES_)) +SYNC_SOURCE_FILES = $(subst /,$(PATH_SEP),$(SYNC_SOURCE_FILES_)) +CALLBACK_SOURCE_FILES = $(subst /,$(PATH_SEP),$(CALLBACK_SOURCE_FILES_)) +!else +SOURCE_FILES = $(SOURCE_FILES_) +SYNC_SOURCE_FILES = $(SYNC_SOURCE_FILES_) +CALLBACK_SOURCE_FILES = $(CALLBACK_SOURCE_FILES_) +!endif + +SOURCE_FILES = $(strip $(SOURCE_FILES)) +SYNC_SOURCE_FILES = $(strip $(SYNC_SOURCE_FILES)) +CALLBACK_SOURCE_FILES = $(strip $(CALLBACK_SOURCE_FILES)) \ No newline at end of file diff --git a/make/windows_targets.mk b/make/windows_targets.mk new file mode 100644 index 00000000..5f97b722 --- /dev/null +++ b/make/windows_targets.mk @@ -0,0 +1,37 @@ +# Targets for Windows system. +# Description: Makefile used to declare list of targets which can be built for +# Windows systems. +# +# Note: `nmake` can't handle `/` to `\` replacement in multiline prerequisites +# so they have been separated from targets for preprocessing. + +!include <../make/common/targets_app.mk> + + +############################################################################### +# Build targets # +############################################################################### + +# --------------- Tests based on sync PubNub library -------------- + +FNTEST_SOURCES_ = \ + ../core/fntest/pubnub_fntest.c \ + ../core/fntest/pubnub_fntest_basic.c \ + ../core/fntest/pubnub_fntest_medium.c \ + ../windows/fntest/pubnub_fntest_runner.c \ + ../windows/fntest/pubnub_fntest_windows.c +FNTEST_SOURCES = $(subst /,$(PATH_SEP),$(FNTEST_SOURCES_)) +pubnub_fntest$(APP_EXT): $(FNTEST_SOURCES) pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +clean: + del *.exe + del *.obj + del *.pdb + del *.il? + del *.lib + del *.c~ + del *.h~ + del *~ + +.PHONY: all clean \ No newline at end of file diff --git a/openssl/posix.mk b/openssl/posix.mk index 5f96541f..1c8fe46b 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -1,292 +1,57 @@ -SOURCEFILES = ../core/pbcc_set_state.c ../core/pubnub_ssl.c ../core/pubnub_pubsubapi.c ../core/pubnub_coreapi.c ../core/pubnub_ccore_pubsub.c ../core/pubnub_ccore.c ../core/pubnub_netcore.c ../lib/sockets/pbpal_resolv_and_connect_sockets.c ../lib/sockets/pbpal_handle_socket_error.c pbpal_openssl.c pbpal_connect_openssl.c pbpal_add_system_certs_posix.c ../core/pubnub_alloc_std.c ../core/pubnub_assert_std.c ../core/pubnub_generate_uuid.c ../core/pubnub_blocking_io.c ../posix/posix_socket_blocking_io.c ../core/pubnub_timers.c ../core/pubnub_json_parse.c ../core/pubnub_helper.c ../posix/pubnub_version_posix.c ../posix/pubnub_generate_uuid_posix.c pbpal_openssl_blocking_io.c ../lib/base64/pbbase64.c ../lib/pb_strnlen_s.c ../lib/pb_strncasecmp.c ../core/pubnub_coreapi_ex.c ../core/pubnub_free_with_timeout_std.c ../posix/msstopwatch_monotonic_clock.c ../posix/pbtimespec_elapsed_ms.c ../core/pubnub_url_encode.c ../core/pubnub_memory_block.c ../posix/pb_sleep_ms.c - -OBJFILES = pbcc_set_state.o pubnub_ssl.o pubnub_pubsubapi.o pubnub_coreapi.o pubnub_ccore_pubsub.o pubnub_ccore.o pubnub_netcore.o pbpal_resolv_and_connect_sockets.o pbpal_handle_socket_error.o pbpal_openssl.o pbpal_connect_openssl.o pbpal_add_system_certs_posix.o pubnub_alloc_std.o pubnub_assert_std.o pubnub_generate_uuid.o pubnub_blocking_io.o posix_socket_blocking_io.o pubnub_timers.o pubnub_json_parse.o pubnub_helper.o pubnub_version_posix.o pubnub_generate_uuid_posix.o pbpal_openssl_blocking_io.o pbbase64.o pb_strnlen_s.o pb_strncasecmp.o pubnub_coreapi_ex.o pubnub_free_with_timeout_std.o msstopwatch_monotonic_clock.o pbtimespec_elapsed_ms.o pubnub_url_encode.o pubnub_memory_block.o pb_sleep_ms.o - -ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -endif - -ifndef USE_PROXY -USE_PROXY = 1 -endif - -ifndef USE_RETRY_CONFIGURATION -USE_RETRY_CONFIGURATION = 0 -endif - -ifndef USE_GZIP_COMPRESSION -USE_GZIP_COMPRESSION = 1 -endif - -ifndef RECEIVE_GZIP_RESPONSE -RECEIVE_GZIP_RESPONSE = 1 -endif - -ifndef USE_SUBSCRIBE_V2 -USE_SUBSCRIBE_V2 = 1 -endif - -ifndef USE_ADVANCED_HISTORY -USE_ADVANCED_HISTORY = 1 -endif - -ifndef USE_OBJECTS_API -USE_OBJECTS_API = 1 -endif - -ifndef USE_ACTIONS_API -USE_ACTIONS_API = 1 -endif - -ifndef USE_AUTO_HEARTBEAT -USE_AUTO_HEARTBEAT = 1 -endif - -ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 1 -endif - -ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 1 -endif - -ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -endif - -ifndef USE_CRYPTO_API -USE_CRYPTO_API = 1 -endif - -ifndef USE_IPV6 -USE_IPV6 = 1 -endif - -ifndef USE_DNS_SERVERS -USE_DNS_SERVERS = 1 -endif - -ifeq ($(USE_PROXY), 1) -SOURCEFILES += ../core/pubnub_proxy.c ../core/pubnub_proxy_core.c ../core/pbhttp_digest.c ../core/pbntlm_core.c ../core/pbntlm_packer_std.c -OBJFILES += pubnub_proxy.o pubnub_proxy_core.o pbhttp_digest.o pbntlm_core.o pbntlm_packer_std.o -endif - -ifeq ($(USE_GZIP_COMPRESSION), 1) -SOURCEFILES += ../lib/miniz/miniz_tdef.c ../lib/miniz/miniz.c ../lib/pbcrc32.c ../core/pbgzip_compress.c -OBJFILES += miniz_tdef.o miniz.o pbcrc32.o pbgzip_compress.o -endif - -ifeq ($(RECEIVE_GZIP_RESPONSE), 1) -SOURCEFILES += ../lib/miniz/miniz_tinfl.c ../core/pbgzip_decompress.c -OBJFILES += miniz_tinfl.o pbgzip_decompress.o -endif - -ifeq ($(USE_SUBSCRIBE_V2), 1) -SOURCEFILES += ../core/pbcc_subscribe_v2.c ../core/pubnub_subscribe_v2.c -OBJFILES += pbcc_subscribe_v2.o pubnub_subscribe_v2.o -endif - -ifeq ($(USE_ADVANCED_HISTORY), 1) -SOURCEFILES += ../core/pbcc_advanced_history.c ../core/pubnub_advanced_history.c -OBJFILES += pbcc_advanced_history.o pubnub_advanced_history.o -endif - -ifeq ($(USE_OBJECTS_API), 1) -SOURCEFILES += ../core/pbcc_objects_api.c ../core/pubnub_objects_api.c -OBJFILES += pbcc_objects_api.o pubnub_objects_api.o -endif - -ifeq ($(USE_ACTIONS_API), 1) -SOURCEFILES += ../core/pbcc_actions_api.c ../core/pubnub_actions_api.c -OBJFILES += pbcc_actions_api.o pubnub_actions_api.o -endif - -ifeq ($(USE_AUTO_HEARTBEAT), 1) -SOURCEFILES += ../core/pbauto_heartbeat.c ../openssl/pbauto_heartbeat_init_posix.c ../lib/pbstr_remove_from_list.c -OBJFILES += pbauto_heartbeat.o pbauto_heartbeat_init_posix.o pbstr_remove_from_list.o -endif - -ifeq ($(USE_GRANT_TOKEN), 1) -GRANT_TOKEN_SOURCEFILES = ../core/pbcc_grant_token_api.c ../core/pubnub_grant_token_api.c ../lib/cbor/cborparser.c ../lib/cbor/cborerrorstrings.c ../lib/cbor/cborparser_dup_string.c -GRANT_TOKEN_OBJFILES = pbcc_grant_token_api.o pubnub_grant_token_api.o cborparser.o cborerrorstrings.o cborparser_dup_string.o -endif - -ifeq ($(USE_FETCH_HISTORY), 1) -SOURCEFILES += ../core/pubnub_fetch_history.c ../core/pbcc_fetch_history.c -OBJFILES += pubnub_fetch_history.o pbcc_fetch_history.o -endif - -ifeq ($(USE_REVOKE_TOKEN), 1) -REVOKE_TOKEN_SOURCEFILES = ../core/pubnub_revoke_token_api.c ../core/pbcc_revoke_token_api.c -REVOKE_TOKEN_OBJFILES = pubnub_revoke_token_api.o pbcc_revoke_token_api.o -endif - -ifeq ($(USE_CRYPTO_API), 1) -SOURCEFILES += ../core/pbcc_crypto.c ../core/pbcc_crypto_aes_cbc.c ../core/pbcc_crypto_legacy.c ../core/pubnub_crypto.c ../openssl/pbaes256.c -OBJFILES += pbcc_crypto.o pbcc_crypto_aes_cbc.o pbcc_crypto_legacy.o pubnub_crypto.o pbaes256.o -endif - -CFLAGS = -g -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -Wall -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) -D PUBNUB_CRYPTO_API=$(USE_CRYPTO_API) -# -g enables debugging, remove to get a smaller executable -# -fsanitize=address Use AddressSanitizer -# -fsanitize=thread Use ThreadSanitizer - -OS := $(shell uname) -ifeq ($(OS),Darwin) - SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c - OBJFILES += monotonic_clock_get_time_darwin.o - LDLIBS = -lpthread -lssl -lcrypto - - # Ensure OpenSSL paths are set. - OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) - OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) - ifneq ($(OPENSSL_CFLAGS),) - CFLAGS += $(OPENSSL_CFLAGS) - endif - ifneq ($(OPENSSL_LIBS),) - LDLIBS += $(OPENSSL_LIBS) - endif -else - SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c - OBJFILES += monotonic_clock_get_time_posix.o - LDLIBS=-lrt -lpthread -lssl -lcrypto - - ifeq ($(shell test -d "/usr/local/opt/openssl" && echo yes || echo no),yes) - CFLAGS += -I/usr/local/opt/openssl/include - else - # Path on GitHub Action Runner (ubuntu-latest image) - ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) - CFLAGS += -I/usr/include - endif - endif - # Path on GitHub Action Runner (ubuntu-latest image) - ifeq ($(shell test -d "/usr/lib/x86_64-linux-gnu" && echo yes || echo no),yes) - LDLIBS += -L/usr/lib/x86_64-linux-gnu - endif -endif - -INCLUDES=-I .. -I . -I ../lib/base64/ - -all: pubnub_sync_sample pubnub_sync_grant_token_sample pubnub_sync_revoke_token_sample pubnub_objects_secretkey_sample metadata cancel_subscribe_sync_sample pubnub_sync_subloop_sample pubnub_publish_via_post_sample pubnub_publish_via_post_secretkey_sample pubnub_advanced_history_sample pubnub_fetch_history_sample pubnub_callback_sample subscribe_publish_callback_sample pubnub_callback_subloop_sample pubnub_fntest pubnub_console_sync pubnub_console_callback pubnub_crypto_sync_sample subscribe_publish_from_callback publish_callback_subloop_sample publish_queue_callback_subloop pubnub_crypto_module_sample - -SYNC_INTF_SOURCEFILES=../core/pubnub_ntf_sync.c ../core/pubnub_sync_subscribe_loop.c ../core/srand_from_pubnub_time.c -SYNC_INTF_OBJFILES=pubnub_ntf_sync.o pubnub_sync_subscribe_loop.o srand_from_pubnub_time.o - -ifeq ($(USE_IPV6), 1) -SYNC_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c -SYNC_INTF_OBJFILES += pubnub_parse_ipv6_addr.o -endif - -pubnub_sync.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - $(CC) -c $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_RAND_INIT_VECTOR=0 $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - ar rcs pubnub_sync.a $(OBJFILES) $(SYNC_INTF_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(GRANT_TOKEN_OBJFILES) - -pubnub_sync_dynamiciv.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - $(CC) -c $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_RAND_INIT_VECTOR=1 $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - ar rcs pubnub_sync_dynamiciv.a $(OBJFILES) $(SYNC_INTF_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(GRANT_TOKEN_OBJFILES) - -CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_posix.c pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_ntf_callback_poller_poll.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c -CALLBACK_INTF_OBJFILES=pubnub_ntf_callback_posix.o pubnub_get_native_socket.o pubnub_timer_list.o pbpal_ntf_callback_poller_poll.o pbpal_adns_sockets.o pubnub_dns_codec.o pbpal_ntf_callback_queue.o pbpal_ntf_callback_admin.o pbpal_ntf_callback_handle_timer_list.o pubnub_callback_subscribe_loop.o - - -ifeq ($(USE_DNS_SERVERS), 1) -CALLBACK_INTF_SOURCEFILES += ../core/pubnub_dns_servers.c ../posix/pubnub_dns_system_servers.c ../lib/pubnub_parse_ipv4_addr.c -CALLBACK_INTF_OBJFILES += pubnub_dns_servers.o pubnub_dns_system_servers.o pubnub_parse_ipv4_addr.o -else ifeq ($(USE_PROXY), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv4_addr.c -CALLBACK_INTF_OBJFILES += pubnub_parse_ipv4_addr.o -endif - -ifeq ($(USE_IPV6), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c -CALLBACK_INTF_OBJFILES += pubnub_parse_ipv6_addr.o -endif - -CFLAGS_CALLBACK = -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_SET_DNS_SERVERS=$(USE_DNS_SERVERS) - -pubnub_callback.a : $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - $(CC) -c $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) -D PUBNUB_CALLBACK_API $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - ar rcs pubnub_callback.a $(OBJFILES) $(CALLBACK_INTF_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(GRANT_TOKEN_OBJFILES) - -pubnub_sync_sample: ../core/samples/pubnub_sync_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_sync_grant_token_sample: ../core/samples/pubnub_sync_grant_token_sample.c pubnub_sync_dynamiciv.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_grant_token_sample.c pubnub_sync_dynamiciv.a $(LDLIBS) - -pubnub_sync_revoke_token_sample: ../core/samples/pubnub_sync_revoke_token_sample.c pubnub_sync_dynamiciv.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_revoke_token_sample.c pubnub_sync_dynamiciv.a $(LDLIBS) - -pubnub_encrypt_decrypt_static_iv_sample: ../core/samples/pubnub_encrypt_decrypt_iv_sample.c pubnub_sync.a - $(CC) $(CFLAGS) $(INCLUDES) -o pubnub_encrypt_decrypt_static_iv_sample ../core/samples/pubnub_encrypt_decrypt_iv_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_encrypt_decrypt_dynamic_iv_sample: ../core/samples/pubnub_encrypt_decrypt_iv_sample.c pubnub_sync_dynamiciv.a - $(CC) $(CFLAGS) $(INCLUDES) -o pubnub_encrypt_decrypt_dynamic_iv_sample ../core/samples/pubnub_encrypt_decrypt_iv_sample.c pubnub_sync_dynamiciv.a $(LDLIBS) - -pubnub_objects_secretkey_sample: ../core/samples/pubnub_objects_secretkey_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_objects_secretkey_sample.c pubnub_sync.a $(LDLIBS) - -metadata: ../core/samples/metadata.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/metadata.c pubnub_sync.a $(LDLIBS) - -pubnub_crypto_sync_sample: ../core/samples/pubnub_crypto_sync_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_crypto_sync_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_encrypt_decrypt_sample: ../core/samples/pubnub_encrypt_decrypt_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_encrypt_decrypt_sample.c pubnub_sync.a $(LDLIBS) - -cancel_subscribe_sync_sample: ../core/samples/cancel_subscribe_sync_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/cancel_subscribe_sync_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_sync_subloop_sample: ../core/samples/pubnub_sync_subloop_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_subloop_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_publish_via_post_sample: ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(INCLUDES) ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_publish_via_post_secretkey_sample: ../core/samples/pubnub_publish_via_post_secretkey_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_publish_via_post_secretkey_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_advanced_history_sample: ../core/samples/pubnub_advanced_history_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_advanced_history_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_fetch_history_sample: ../core/samples/pubnub_fetch_history_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_fetch_history_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_callback_sample: ../core/samples/pubnub_callback_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/pubnub_callback_sample.c pubnub_callback.a $(LDLIBS) - -subscribe_publish_callback_sample: ../core/samples/subscribe_publish_callback_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/subscribe_publish_callback_sample.c pubnub_callback.a $(LDLIBS) - -pubnub_callback_subloop_sample: ../core/samples/pubnub_callback_subloop_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/pubnub_callback_subloop_sample.c pubnub_callback.a $(LDLIBS) - -subscribe_publish_from_callback: ../core/samples/subscribe_publish_from_callback.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/subscribe_publish_from_callback.c pubnub_callback.a $(LDLIBS) - -publish_callback_subloop_sample: ../core/samples/publish_callback_subloop_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_callback_subloop_sample.c pubnub_callback.a $(LDLIBS) - -publish_queue_callback_subloop: ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a $(LDLIBS) - -pubnub_crypto_module_sample: ../core/samples/pubnub_crypto_module_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) -I ../core/ ../core/samples/pubnub_crypto_module_sample.c pubnub_sync.a $(LDLIBS) - - -pubnub_fntest: ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c ../posix/fntest/pubnub_fntest_posix.c ../posix/fntest/pubnub_fntest_runner.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c ../posix/fntest/pubnub_fntest_posix.c ../posix/fntest/pubnub_fntest_runner.c pubnub_sync.a $(LDLIBS) -lpthread - -CONSOLE_SOURCEFILES=../core/samples/console/pubnub_console.c ../core/samples/console/pnc_helpers.c ../core/samples/console/pnc_readers.c ../core/samples/console/pnc_subscriptions.c - -pubnub_console_sync: $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_sync.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_sync.c pubnub_sync.a $(LDLIBS) - -pubnub_console_callback: $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_callback.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_callback.c pubnub_callback.a $(LDLIBS) - +# Makefile for PubNub C-core SDK with SSL support. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. + +# Making OpenSSL version of the PubNub SDK. +OPENSSL = 1 +USE_CRYPTO_API ?= 1 +USE_GRANT_TOKEN ?= 1 +USE_REVOKE_TOKEN ?= 1 + +include ../make/posix_preprocessing.mk +include ../make/posix_source_files.mk +include ../make/posix_compiler_linker_flags.mk + + +############################################################################### +# Build targets # +############################################################################### + +include ../make/common/targets_lib.mk +include ../make/posix_targets.mk + +# There is also `subscribe_event_engine_sample$(APP_EXT)` target but it can't be built +# with `all` because requires `USE_SUBSCRIBE_EVENT_ENGINE=1`. + +all: \ + cancel_subscribe_sync_sample$(APP_EXT) \ + metadata$(APP_EXT) \ + pubnub_advanced_history_sample$(APP_EXT) \ + pubnub_crypto_module_sample$(APP_EXT) \ + pubnub_crypto_sync_sample$(APP_EXT) \ + pubnub_encrypt_decrypt_dynamic_iv_sample$(APP_EXT) \ + pubnub_encrypt_decrypt_static_iv_sample$(APP_EXT) \ + pubnub_objects_secretkey_sample$(APP_EXT) \ + subscribe_publish_callback_secretkey_sample$(APP_EXT) \ + pubnub_publish_via_post_sample$(APP_EXT) \ + pubnub_publish_via_post_secretkey_sample$(APP_EXT) \ + pubnub_sync_grant_token_sample$(APP_EXT) \ + pubnub_sync_publish_retry$(APP_EXT) \ + pubnub_sync_revoke_token_sample$(APP_EXT) \ + pubnub_sync_sample$(APP_EXT) \ + pubnub_sync_secretkey_sample$(APP_EXT) \ + pubnub_sync_subloop_sample$(APP_EXT) \ + pubnub_fetch_history_sample$(APP_EXT) \ + publish_callback_subloop_sample$(APP_EXT) \ + publish_queue_callback_subloop$(APP_EXT) \ + pubnub_callback_sample$(APP_EXT) \ + pubnub_callback_subloop_sample$(APP_EXT) \ + subscribe_publish_callback_sample$(APP_EXT) \ + subscribe_publish_from_callback$(APP_EXT) \ + pubnub_console_sync$(APP_EXT) \ + pubnub_console_callback$(APP_EXT) \ + pubnub_fntest$(APP_EXT) clean: find . -type d -iname "*.dSYM" -exec rm -rf {} \+ - find . -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf -rf + find . -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf -rf \ No newline at end of file diff --git a/openssl/windows.mk b/openssl/windows.mk index a6f8bc9b..9d737381 100644 --- a/openssl/windows.mk +++ b/openssl/windows.mk @@ -1,193 +1,59 @@ -SOURCEFILES = ..\core\pbcc_set_state.c ..\core\pubnub_pubsubapi.c ..\core\pubnub_coreapi.c ..\core\pubnub_ccore_pubsub.c ..\core\pubnub_ccore.c ..\core\pubnub_netcore.c ..\lib\sockets\pbpal_resolv_and_connect_sockets.c ..\lib\sockets\pbpal_handle_socket_error.c pbpal_openssl.c pbpal_connect_openssl.c pbpal_add_system_certs_windows.c ..\core\pubnub_alloc_std.c ..\core\pubnub_assert_std.c ..\core\pubnub_generate_uuid.c ..\core\pubnub_blocking_io.c ..\windows\windows_socket_blocking_io.c ..\core\pubnub_free_with_timeout_std.c ..\windows\pbtimespec_elapsed_ms.c ..\core\pubnub_timers.c ..\core\pubnub_json_parse.c ..\lib\md5\md5.c ..\lib\pb_strnlen_s.c ..\lib\pb_strncasecmp.c ..\core\pubnub_ssl.c ..\core\pubnub_helper.c ..\windows\pubnub_version_windows.c ..\windows\pubnub_generate_uuid_windows.c pbpal_openssl_blocking_io.c ..\core\pubnub_coreapi_ex.c pbaes256.c ..\core\c99\snprintf.c ..\lib\miniz\miniz_tinfl.c ..\lib\miniz\miniz_tdef.c ..\lib\miniz\miniz.c ..\lib\pbcrc32.c ..\core\pbgzip_compress.c ..\core\pbgzip_decompress.c ..\core\pbcc_subscribe_v2.c ..\core\pubnub_subscribe_v2.c ..\windows\msstopwatch_windows.c ..\core\pubnub_url_encode.c ..\core\pbcc_advanced_history.c ..\core\pubnub_advanced_history.c ..\core\pbcc_objects_api.c ..\core\pubnub_objects_api.c ..\core\pbcc_actions_api.c ..\core\pubnub_actions_api.c ..\core\pubnub_memory_block.c ..\lib\pbstr_remove_from_list.c ..\windows\pb_sleep_ms.c ..\core\pbauto_heartbeat.c ..\windows\pbauto_heartbeat_init_windows.c - -OBJFILES = pbcc_set_state.obj pubnub_pubsubapi.obj pubnub_coreapi.obj pubnub_ccore_pubsub.obj pubnub_ccore.obj pubnub_netcore.obj pbpal_resolv_and_connect_sockets.obj pbpal_handle_socket_error.obj pbpal_openssl.obj pbpal_connect_openssl.obj pbpal_add_system_certs_windows.obj pubnub_alloc_std.obj pubnub_assert_std.obj pubnub_generate_uuid.obj pubnub_blocking_io.obj pubnub_free_with_timeout_std.obj pbtimespec_elapsed_ms.obj pubnub_timers.obj pubnub_json_parse.obj md5.obj pb_strnlen_s.obj pb_strncasecmp.obj pubnub_ssl.obj pubnub_helper.obj pubnub_version_windows.obj pubnub_generate_uuid_windows.obj pbpal_openssl_blocking_io.obj windows_socket_blocking_io.obj pbbase64.obj pubnub_coreapi_ex.obj pbaes256.obj snprintf.obj miniz_tinfl.obj miniz_tdef.obj miniz.obj pbcrc32.obj pbgzip_compress.obj pbgzip_decompress.obj pbcc_subscribe_v2.obj pubnub_subscribe_v2.obj msstopwatch_windows.obj pubnub_url_encode.obj pbcc_advanced_history.obj pubnub_advanced_history.obj pbcc_objects_api.obj pubnub_objects_api.obj pbcc_actions_api.obj pubnub_actions_api.obj pubnub_memory_block.obj pbstr_remove_from_list.obj pb_sleep_ms.obj pbauto_heartbeat.obj pbauto_heartbeat_init_windows.obj - -!ifndef OPENSSLPATH -OPENSSLPATH=C:\OpenSSL-Win32 -!endif - -!IF EXISTS($(OPENSSLPATH)\lib\libssl.lib) -OPENSSL_LIBS=$(OPENSSLPATH)\lib\libssl.lib $(OPENSSLPATH)\lib\libcrypto.lib -!ELSEIF EXISTS($(OPENSSLPATH)\lib\ssleay32.lib) -OPENSSL_LIBS=$(OPENSSLPATH)\lib\ssleay32.lib $(OPENSSLPATH)\lib\libeay32.lib -!ELSE -!ERROR Cannot find OpenSSL libraries, OPENSSLPATH=$(OPENSSLPATH) -!ENDIF -LIBS=ws2_32.lib IPHlpAPI.lib rpcrt4.lib $(OPENSSL_LIBS) - -!ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -!endif - -!ifndef USE_PROXY -USE_PROXY = 1 -!endif - -!ifndef USE_SUBSCRIBE_V2 -USE_SUBSCRIBE_V2 = 1 -!endif - - -!ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 1 -!endif - -!ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 1 -!endif - -!ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -!endif +# Makefile for PubNub C-core SDK with SSL support. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. +# Making OpenSSL version of the PubNub SDK. +OPENSSL = 1 !ifndef USE_CRYPTO_API USE_CRYPTO_API = 0 !endif - -!ifndef USE_RETRY_CONFIGURATION -USE_RETRY_CONFIGURATION = 0 -!endif - -!if $(USE_PROXY) -PROXY_INTF_SOURCEFILES = ..\core\pubnub_proxy.c ..\core\pubnub_proxy_core.c ..\core\pbhttp_digest.c ..\core\pbntlm_core.c ..\core\pbntlm_packer_sspi.c ..\windows\pubnub_set_proxy_from_system_windows.c -PROXY_INTF_OBJFILES = pubnub_proxy.obj pubnub_proxy_core.obj pbhttp_digest.obj pbntlm_core.obj pbntlm_packer_sspi.obj pubnub_set_proxy_from_system_windows.obj -!endif - -!if $(USE_RETRY_CONFIGURATION) -PROXY_INTF_SOURCEFILES += ..\core\pbcc_request_retry_timer.c ..\core\pubnub_retry_configuration.c -PROXY_INTF_OBJFILES += pbcc_request_retry_timer.obj pubnub_retry_configuration.obj -!endif - -!if $(USE_REVOKE_TOKEN) -REVOKE_TOKEN_SOURCEFILES = ..\core\pubnub_revoke_token_api.c ..\core\pbcc_revoke_token_api.c -REVOKE_TOKEN_OBJFILES = pubnub_revoke_token_api.obj pbcc_revoke_token_api.obj -!endif - -!if $(USE_GRANT_TOKEN) -GRANT_TOKEN_SOURCEFILES = ..\core\pbcc_grant_token_api.c ..\core\pubnub_grant_token_api.c ..\lib\cbor\cborparser.c ..\lib\cbor\cborerrorstrings.c ..\lib\cbor\cborparser_dup_string.c -GRANT_TOKEN_OBJFILES = pbcc_grant_token_api.obj pubnub_grant_token_api.obj cborparser.obj cborerrorstrings.obj cborparser_dup_string.obj -!endif - -!if $(USE_FETCH_HISTORY) -FETCH_HIST_SOURCEFILES = ..\core\pubnub_fetch_history.c ..\core\pbcc_fetch_history.c -FETCH_HIST_OBJFILES = pubnub_fetch_history.obj pbcc_fetch_history.obj +!ifndef USE_GRANT_TOKEN +USE_GRANT_TOKEN = 1 !endif - -!if $(USE_CRYPTO_API) -FETCH_HIST_SOURCEFILES += ..\core\pbcc_crypto.c ..\core\pbcc_crypto_aes_cbc.c ..\core\pbcc_crypto_legacy.c ..\core\pubnub_crypto.c ..\openssl\pbaes256.c -FETCH_HIST_OBJFILES += pbcc_crypto.obj pbcc_crypto_aes_cbc.obj pbcc_crypto_legacy.obj pubnub_crypto.obj pbaes256.obj +!ifndef USE_REVOKE_TOKEN +USE_REVOKE_TOKEN = 1 !endif -CFLAGS = /Zi /MP -D PUBNUB_THREADSAFE /D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING /W3 /D PUBNUB_USE_WIN_SSPI=1 /D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) /D PUBNUB_PROXY_API=$(USE_PROXY) /D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) /D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) /D _CRT_SECURE_NO_WARNINGS /D PUBNUB_CRYPTO_API=$(USE_CRYPTO_API) /D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) /D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) /D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) -# /Zi enables debugging, remove to get a smaller .exe and no .pdb -# /MP uses one compiler (`cl`) process for each input file, enabling faster build -# /analyze To run the static analyzer (not compatible w/clang-cl) - -INCLUDES=-I .. -I . -I ..\core\c99 -I $(OPENSSLPATH)\include -I ..\lib\base64\ - - -all: pubnub_sync_sample.exe pubnub_sync_grant_token_sample.exe pubnub_sync_revoke_token_sample.exe pubnub_encrypt_decrypt_static_iv_sample.exe pubnub_encrypt_decrypt_dynamic_iv_sample.exe metadata.exe pubnub_crypto_sync_sample.exe cancel_subscribe_sync_sample.exe pubnub_publish_via_post_sample.exe pubnub_publish_via_post_secretkey_sample.exe subscribe_publish_callback_sample.exe subscribe_publish_callback_secretkey_sample.exe pubnub_callback_sample.exe pubnub_fntest.exe pubnub_console_sync.exe pubnub_advanced_history_sample.exe pubnub_fetch_history_sample.exe pubnub_console_callback.exe subscribe_publish_from_callback.exe publish_callback_subloop_sample.exe publish_queue_callback_subloop.exe pubnub_objects_secretkey_sample.exe - -SYNC_INTF_SOURCEFILES= ..\core\pubnub_ntf_sync.c ..\core\pubnub_sync_subscribe_loop.c ..\core\srand_from_pubnub_time.c -SYNC_INTF_OBJFILES= pubnub_ntf_sync.obj pubnub_sync_subscribe_loop.obj srand_from_pubnub_time.obj - -pubnub_sync.lib : $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) - $(CC) -c $(CFLAGS) /D PUBNUB_RAND_INIT_VECTOR=0 $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) - lib $(OBJFILES) $(SYNC_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(GRANT_TOKEN_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(FETCH_HIST_OBJFILES) -OUT:$@ - -pubnub_sync_dynamiciv.lib : $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) - $(CC) -c $(CFLAGS) /D PUBNUB_RAND_INIT_VECTOR=1 $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) - lib $(OBJFILES) $(SYNC_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(GRANT_TOKEN_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(FETCH_HIST_OBJFILES) -OUT:$@ - -CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_windows.c pubnub_get_native_socket.c ..\core\pubnub_timer_list.c ..\lib\sockets\pbpal_ntf_callback_poller_poll.c ..\lib\sockets\pbpal_adns_sockets.c ..\lib\pubnub_dns_codec.c ..\core\pubnub_dns_servers.c ..\windows\pubnub_dns_system_servers.c ..\lib\pubnub_parse_ipv4_addr.c ..\lib\pubnub_parse_ipv6_addr.c ..\core\pbpal_ntf_callback_queue.c ..\core\pbpal_ntf_callback_admin.c ..\core\pbpal_ntf_callback_handle_timer_list.c ..\core\pubnub_callback_subscribe_loop.c -CALLBACK_INTF_OBJFILES=pubnub_ntf_callback_windows.obj pubnub_get_native_socket.obj pubnub_timer_list.obj pbpal_ntf_callback_poller_poll.obj pbpal_adns_sockets.obj pubnub_dns_codec.obj pubnub_dns_servers.obj pubnub_dns_system_servers.obj pubnub_parse_ipv4_addr.obj pubnub_parse_ipv6_addr.obj pbpal_ntf_callback_queue.obj pbpal_ntf_callback_admin.obj pbpal_ntf_callback_handle_timer_list.obj pubnub_callback_subscribe_loop.obj - -pubnub_callback.lib : $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) - $(CC) -c $(CFLAGS) -DPUBNUB_CALLBACK_API -DPUBNUB_RAND_INIT_VECTOR=0 $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) - lib $(OBJFILES) $(CALLBACK_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(GRANT_TOKEN_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(FETCH_HIST_OBJFILES) -OUT:$@ - -pubnub_sync_sample.exe: ..\core\samples\pubnub_sync_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_sync_sample.c pubnub_sync.lib $(LIBS) - -pubnub_sync_grant_token_sample.exe: ..\core\samples\pubnub_sync_grant_token_sample.c pubnub_sync_dynamiciv.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_sync_grant_token_sample.c pubnub_sync_dynamiciv.lib $(LIBS) - -pubnub_sync_revoke_token_sample.exe: ..\core\samples\pubnub_sync_revoke_token_sample.c pubnub_sync_dynamiciv.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_sync_revoke_token_sample.c pubnub_sync_dynamiciv.lib $(LIBS) - -pubnub_encrypt_decrypt_static_iv_sample.exe: ..\core\samples\pubnub_encrypt_decrypt_iv_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) /Fe:pubnub_encrypt_decrypt_static_iv_sample.exe ..\core\samples\pubnub_encrypt_decrypt_iv_sample.c pubnub_sync.lib $(LIBS) - -pubnub_encrypt_decrypt_dynamic_iv_sample.exe: ..\core\samples\pubnub_encrypt_decrypt_iv_sample.c pubnub_sync_dynamiciv.lib - $(CC) $(CFLAGS) $(INCLUDES) /Fe:pubnub_encrypt_decrypt_dynamic_iv_sample.exe ..\core\samples\pubnub_encrypt_decrypt_iv_sample.c pubnub_sync_dynamiciv.lib $(LIBS) - - -pubnub_sync_secretkey_sample.exe: ..\core\samples\pubnub_sync_secretkey_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_sync_secretkey_sample.c pubnub_sync.lib $(LIBS) - -pubnub_objects_secretkey_sample.exe: ..\core\samples\pubnub_objects_secretkey_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_objects_secretkey_sample.c pubnub_sync.lib $(LIBS) - -metadata.exe: ..\core\samples\metadata.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\metadata.c pubnub_sync.lib $(LIBS) - -pubnub_crypto_sync_sample.exe: ..\core\samples\pubnub_crypto_sync_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_crypto_sync_sample.c pubnub_sync.lib $(LIBS) - -cancel_subscribe_sync_sample.exe: ..\core\samples\cancel_subscribe_sync_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\cancel_subscribe_sync_sample.c pubnub_sync.lib $(LIBS) - -pubnub_advanced_history_sample.exe: ..\core\samples\pubnub_advanced_history_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_advanced_history_sample.c pubnub_sync.lib $(LIBS) - -pubnub_fetch_history_sample.exe: ..\core\samples\pubnub_fetch_history_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_fetch_history_sample.c pubnub_sync.lib $(LIBS) - -pubnub_publish_via_post_sample.exe: ..\core\samples\pubnub_publish_via_post_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_publish_via_post_sample.c pubnub_sync.lib $(LIBS) - -pubnub_publish_via_post_secretkey_sample.exe: ..\core\samples\pubnub_publish_via_post_secretkey_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_publish_via_post_secretkey_sample.c pubnub_sync.lib $(LIBS) - -pubnub_callback_sample.exe: ..\core\samples\pubnub_callback_sample.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\pubnub_callback_sample.c pubnub_callback.lib $(LIBS) - -subscribe_publish_callback_sample.exe: ..\core\samples\subscribe_publish_callback_sample.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\subscribe_publish_callback_sample.c pubnub_callback.lib $(LIBS) - -subscribe_publish_callback_secretkey_sample.exe: ..\core\samples\subscribe_publish_callback_secretkey_sample.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\subscribe_publish_callback_secretkey_sample.c pubnub_callback.lib $(LIBS) -DPUBNUB_CRYPTO_API=1 -D_CRT_SECURE_NO_WARNINGS - -subscribe_publish_from_callback.exe: ..\core\samples\subscribe_publish_from_callback.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\subscribe_publish_from_callback.c pubnub_callback.lib $(LIBS) - -publish_callback_subloop_sample.exe: ..\core\samples\publish_callback_subloop_sample.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\publish_callback_subloop_sample.c pubnub_callback.lib $(LIBS) - -publish_queue_callback_subloop.exe: ..\core\samples\publish_queue_callback_subloop.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\publish_queue_callback_subloop.c pubnub_callback.lib $(LIBS) - -pubnub_fntest.exe: ..\core\fntest\pubnub_fntest.c ..\core\fntest\pubnub_fntest_basic.c ..\core\fntest\pubnub_fntest_medium.c ..\windows\fntest\pubnub_fntest_windows.c ..\windows\fntest\pubnub_fntest_runner.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\fntest\pubnub_fntest.c ..\core\fntest\pubnub_fntest_basic.c ..\core\fntest\pubnub_fntest_medium.c ..\windows\fntest\pubnub_fntest_windows.c ..\windows\fntest\pubnub_fntest_runner.c pubnub_sync.lib $(LIBS) - -pubnub_crypto_module_sample.exe: ..\core\samples\pubnub_crypto_module_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) -I ..\core ..\core\samples\pubnub_crypto_module_sample.c pubnub_sync.lib $(LIBS) - - -CONSOLE_SOURCEFILES=..\core\samples\console\pubnub_console.c ..\core\samples\console\pnc_helpers.c ..\core\samples\console\pnc_readers.c ..\core\samples\console\pnc_subscriptions.c - -pubnub_console_sync.exe: $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_sync.c pubnub_sync.lib - $(CC) /Fe:$@ $(CFLAGS) /D _CRT_SECURE_NO_WARNINGS $(INCLUDES) $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_sync.c pubnub_sync.lib $(LIBS) - -pubnub_console_callback.exe: $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_callback.c pubnub_callback.lib - $(CC) /Fe:$@ $(CFLAGS) /D _CRT_SECURE_NO_WARNINGS -D PUBNUB_CALLBACK_API $(INCLUDES) $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_callback.c pubnub_callback.lib $(LIBS) - -clean: - del *.exe - del *.obj - del *.pdb - del *.il? - del *.lib - del *.c~ - del *.h~ - del *~ +!include <../make/windows_preprocessing.mk> +!include <../make/windows_source_files.mk> +!include <../make/windows_compiler_linker_flags.mk> + + +############################################################################### +# Build targets # +############################################################################### + +!include <../make/common/targets_lib.mk> +!include <../make/common/targets_app_openssl.mk> +!include <../make/windows_targets.mk> + +# There is also `subscribe_event_engine_sample$(APP_EXT)` target but it can't be built +# with `all` because requires `USE_SUBSCRIBE_EVENT_ENGINE=1`. + +all: \ + cancel_subscribe_sync_sample$(APP_EXT) \ + metadata$(APP_EXT) \ + pubnub_advanced_history_sample$(APP_EXT) \ + pubnub_crypto_module_sample$(APP_EXT) \ + pubnub_crypto_sync_sample$(APP_EXT) \ + pubnub_encrypt_decrypt_dynamic_iv_sample$(APP_EXT) \ + pubnub_encrypt_decrypt_static_iv_sample$(APP_EXT) \ + pubnub_objects_secretkey_sample$(APP_EXT) \ + subscribe_publish_callback_secretkey_sample$(APP_EXT) \ + pubnub_publish_via_post_sample$(APP_EXT) \ + pubnub_publish_via_post_secretkey_sample$(APP_EXT) \ + pubnub_sync_grant_token_sample$(APP_EXT) \ + pubnub_sync_publish_retry$(APP_EXT) \ + pubnub_sync_revoke_token_sample$(APP_EXT) \ + pubnub_sync_sample$(APP_EXT) \ + pubnub_sync_secretkey_sample$(APP_EXT) \ + pubnub_fetch_history_sample$(APP_EXT) \ + publish_callback_subloop_sample$(APP_EXT) \ + publish_queue_callback_subloop$(APP_EXT) \ + pubnub_callback_sample$(APP_EXT) \ + pubnub_callback_subloop_sample$(APP_EXT) \ + subscribe_publish_callback_sample$(APP_EXT) \ + subscribe_publish_from_callback$(APP_EXT) \ + pubnub_console_sync$(APP_EXT) \ + pubnub_console_callback$(APP_EXT) \ + pubnub_fntest$(APP_EXT) \ No newline at end of file diff --git a/posix.mk b/posix.mk index 3fc2cd1d..52374a16 100644 --- a/posix.mk +++ b/posix.mk @@ -1,10 +1,10 @@ # Make all that can be made on POSIX all: - make -C posix -f posix.mk - make -C openssl -f posix.mk - make -C cpp -f posix.mk - make -C cpp -f posix_openssl.mk + make -C posix -f posix.mk pubnub_fntest + make -C openssl -f posix.mk pubnub_fntest + make -C cpp -f posix.mk fntest_runner + make -C cpp -f posix_openssl.mk openssl/fntest_runner unittest: make -C core diff --git a/posix/posix.mk b/posix/posix.mk index 0a1cab5f..e3306928 100644 --- a/posix/posix.mk +++ b/posix/posix.mk @@ -1,238 +1,44 @@ -SOURCEFILES = ../core/pbcc_set_state.c ../core/pubnub_pubsubapi.c ../core/pubnub_coreapi.c ../core/pubnub_coreapi_ex.c ../core/pubnub_ccore_pubsub.c ../core/pubnub_ccore.c ../core/pubnub_netcore.c ../lib/sockets/pbpal_sockets.c ../lib/sockets/pbpal_resolv_and_connect_sockets.c ../lib/sockets/pbpal_handle_socket_error.c ../core/pubnub_alloc_std.c ../core/pubnub_assert_std.c ../core/pubnub_generate_uuid.c ../core/pubnub_blocking_io.c ../posix/posix_socket_blocking_io.c ../core/pubnub_timers.c ../core/pubnub_json_parse.c ../lib/md5/md5.c ../lib/base64/pbbase64.c ../lib/pb_strnlen_s.c ../lib/pb_strncasecmp.c ../core/pubnub_helper.c pubnub_version_posix.c pubnub_generate_uuid_posix.c pbpal_posix_blocking_io.c ../core/pubnub_generate_uuid_v3_md5.c ../core/pubnub_free_with_timeout_std.c msstopwatch_monotonic_clock.c pbtimespec_elapsed_ms.c ../core/pubnub_url_encode.c ../core/pubnub_memory_block.c ../posix/pb_sleep_ms.c - -OBJFILES = pbcc_set_state.o pubnub_pubsubapi.o pubnub_coreapi.o pubnub_coreapi_ex.o pubnub_ccore_pubsub.o pubnub_ccore.o pubnub_netcore.o pbpal_sockets.o pbpal_resolv_and_connect_sockets.o pbpal_handle_socket_error.o pubnub_alloc_std.o pubnub_assert_std.o pubnub_generate_uuid.o pubnub_blocking_io.o posix_socket_blocking_io.o pubnub_timers.o pubnub_json_parse.o md5.o pbbase64.o pb_strnlen_s.o pb_strncasecmp.o pubnub_helper.o pubnub_version_posix.o pubnub_generate_uuid_posix.o pbpal_posix_blocking_io.o pubnub_generate_uuid_v3_md5.o pubnub_free_with_timeout_std.o msstopwatch_monotonic_clock.o pbtimespec_elapsed_ms.o pubnub_url_encode.o pubnub_memory_block.o pb_sleep_ms.o - -ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -endif - -ifndef USE_PROXY -USE_PROXY = 1 -endif - -ifndef USE_RETRY_CONFIGURATION -USE_RETRY_CONFIGURATION = 0 -endif - -ifndef USE_GZIP_COMPRESSION -USE_GZIP_COMPRESSION = 1 -endif - -ifndef RECEIVE_GZIP_RESPONSE -RECEIVE_GZIP_RESPONSE = 1 -endif - -ifndef USE_SUBSCRIBE_V2 -USE_SUBSCRIBE_V2 = 1 -endif - -ifndef USE_SUBSCRIBE_EVENT_ENGINE -USE_SUBSCRIBE_EVENT_ENGINE = 0 -endif - -ifndef USE_ADVANCED_HISTORY -USE_ADVANCED_HISTORY = 1 -endif - -ifndef USE_OBJECTS_API -USE_OBJECTS_API = 1 -endif - -ifndef USE_ACTIONS_API -USE_ACTIONS_API = 1 -endif - -ifndef USE_AUTO_HEARTBEAT -USE_AUTO_HEARTBEAT = 1 -endif - -ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 0 -endif - -ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 0 -endif - -ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -endif - -ifndef USE_IPV6 -USE_IPV6 = 1 -endif - -ifndef USE_DNS_SERVERS -USE_DNS_SERVERS = 1 -endif - -ifeq ($(USE_PROXY), 1) -SOURCEFILES += ../core/pubnub_proxy.c ../core/pubnub_proxy_core.c ../core/pbhttp_digest.c ../core/pbntlm_core.c ../core/pbntlm_packer_std.c -OBJFILES += pubnub_proxy.o pubnub_proxy_core.o pbhttp_digest.o pbntlm_core.o pbntlm_packer_std.o -endif - -ifeq ($(USE_RETRY_CONFIGURATION), 1) -SOURCEFILES += ../core/pbcc_request_retry_timer.c ../core/pubnub_retry_configuration.c -OBJFILES += pbcc_request_retry_timer.o pubnub_retry_configuration.o -endif - -ifeq ($(USE_GZIP_COMPRESSION), 1) -SOURCEFILES += ../lib/miniz/miniz_tdef.c ../lib/miniz/miniz.c ../lib/pbcrc32.c ../core/pbgzip_compress.c -OBJFILES += miniz_tdef.o miniz.o pbcrc32.o pbgzip_compress.o -endif - -ifeq ($(RECEIVE_GZIP_RESPONSE), 1) -SOURCEFILES += ../lib/miniz/miniz_tinfl.c ../core/pbgzip_decompress.c -OBJFILES += miniz_tinfl.o pbgzip_decompress.o -endif - -ifeq ($(USE_SUBSCRIBE_V2), 1) -SOURCEFILES += ../core/pbcc_subscribe_v2.c ../core/pubnub_subscribe_v2.c -OBJFILES += pbcc_subscribe_v2.o pubnub_subscribe_v2.o -endif - -ifeq ($(USE_SUBSCRIBE_EVENT_ENGINE), 1) -SOURCEFILES += ../core/pbcc_memory_utils.c ../core/pbcc_event_engine.c ../core/pbcc_subscribe_event_engine.c ../core/pbcc_subscribe_event_engine_effects.c ../core/pbcc_subscribe_event_engine_events.c ../core/pbcc_subscribe_event_engine_states.c ../core/pbcc_subscribe_event_engine_transitions.c ../core/pbcc_subscribe_event_listener.c ../core/pubnub_entities.c ../core/pubnub_subscribe_event_engine.c ../core/pubnub_subscribe_event_listener.c ../lib/pbarray.c ../lib/pbhash_set.c ../lib/pbref_counter.c ../lib/pbstrdup.c -OBJFILES += pbcc_memory_utils.o pbcc_event_engine.o pbcc_subscribe_event_engine.o pbcc_subscribe_event_engine_effects.o pbcc_subscribe_event_engine_events.o pbcc_subscribe_event_engine_states.o pbcc_subscribe_event_engine_transitions.o pbcc_subscribe_event_listener.o pubnub_entities.o pubnub_subscribe_event_engine.o pubnub_subscribe_event_listener.o pbarray.o pbhash_set.o pbref_counter.o pbstrdup.o -endif - -ifeq ($(USE_ADVANCED_HISTORY), 1) -SOURCEFILES += ../core/pbcc_advanced_history.c ../core/pubnub_advanced_history.c -OBJFILES += pbcc_advanced_history.o pubnub_advanced_history.o -endif - -ifeq ($(USE_OBJECTS_API), 1) -SOURCEFILES += ../core/pbcc_objects_api.c ../core/pubnub_objects_api.c -OBJFILES += pbcc_objects_api.o pubnub_objects_api.o -endif - -ifeq ($(USE_ACTIONS_API), 1) -SOURCEFILES += ../core/pbcc_actions_api.c ../core/pubnub_actions_api.c -OBJFILES += pbcc_actions_api.o pubnub_actions_api.o -endif - -ifeq ($(USE_AUTO_HEARTBEAT), 1) -SOURCEFILES += ../core/pbauto_heartbeat.c ../posix/pbauto_heartbeat_init_posix.c ../lib/pbstr_remove_from_list.c -OBJFILES += pbauto_heartbeat.o pbauto_heartbeat_init_posix.o pbstr_remove_from_list.o -endif - -ifeq ($(USE_FETCH_HISTORY), 1) -SOURCEFILES += ../core/pubnub_fetch_history.c ../core/pbcc_fetch_history.c -OBJFILES += pubnub_fetch_history.o pbcc_fetch_history.o -endif - -OS := $(shell uname) -ifeq ($(OS),Darwin) -SOURCEFILES += monotonic_clock_get_time_darwin.c -OBJFILES += monotonic_clock_get_time_darwin.o -LDLIBS=-lpthread -else -SOURCEFILES += monotonic_clock_get_time_posix.c -OBJFILES += monotonic_clock_get_time_posix.o -LDLIBS=-lrt -lpthread -endif - -CFLAGS =-g -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=$(USE_SUBSCRIBE_EVENT_ENGINE) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) -# -g # enables debugging, remove to get a smaller executable -# -fsanitize=address # Use AddressSanitizer -# -fsanitize=thread # Use ThreadSanitizer: - -INCLUDES=-I .. -I . - -all: pubnub_sync_sample metadata cancel_subscribe_sync_sample pubnub_advanced_history_sample pubnub_fetch_history_sample pubnub_sync_subloop_sample pubnub_sync_publish_retry pubnub_publish_via_post_sample pubnub_callback_sample pubnub_callback_subloop_sample subscribe_publish_callback_sample pubnub_fntest pubnub_console_sync pubnub_console_callback subscribe_publish_from_callback publish_callback_subloop_sample publish_queue_callback_subloop - -SYNC_INTF_SOURCEFILES=../core/pubnub_ntf_sync.c ../core/pubnub_sync_subscribe_loop.c ../core/srand_from_pubnub_time.c -SYNC_INTF_OBJFILES=pubnub_ntf_sync.o pubnub_sync_subscribe_loop.o srand_from_pubnub_time.o - -ifeq ($(USE_IPV6), 1) -SYNC_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c -SYNC_INTF_OBJFILES += pubnub_parse_ipv6_addr.o -endif - -pubnub_sync.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) - $(CC) -c $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) - ar rcs pubnub_sync.a $(OBJFILES) $(SYNC_INTF_OBJFILES) - -CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_posix.c pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_ntf_callback_poller_poll.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c -CALLBACK_INTF_OBJFILES=pubnub_ntf_callback_posix.o pubnub_get_native_socket.o pubnub_timer_list.o pbpal_ntf_callback_poller_poll.o pbpal_adns_sockets.o pubnub_dns_codec.o pbpal_ntf_callback_queue.o pbpal_ntf_callback_admin.o pbpal_ntf_callback_handle_timer_list.o pubnub_callback_subscribe_loop.o - - -ifeq ($(USE_DNS_SERVERS), 1) -CALLBACK_INTF_SOURCEFILES += ../core/pubnub_dns_servers.c ../posix/pubnub_dns_system_servers.c ../lib/pubnub_parse_ipv4_addr.c -CALLBACK_INTF_OBJFILES += pubnub_dns_servers.o pubnub_dns_system_servers.o pubnub_parse_ipv4_addr.o -else ifeq ($(USE_PROXY), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv4_addr.c -CALLBACK_INTF_OBJFILES += pubnub_parse_ipv4_addr.o -endif - -ifeq ($(USE_IPV6), 1) -CALLBACK_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c -CALLBACK_INTF_OBJFILES += pubnub_parse_ipv6_addr.o -endif - -CFLAGS_CALLBACK = -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_SET_DNS_SERVERS=$(USE_DNS_SERVERS) - -pubnub_callback.a : $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) - $(CC) -c $(CFLAGS) $(CFLAGS_CALLBACK) -D PUBNUB_CALLBACK_API $(INCLUDES) $(SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) - ar rcs pubnub_callback.a $(OBJFILES) $(CALLBACK_INTF_OBJFILES) - -pubnub_sync_sample: ../core/samples/pubnub_sync_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_sample.c pubnub_sync.a $(LDLIBS) - -metadata: ../core/samples/metadata.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/metadata.c pubnub_sync.a $(LDLIBS) - -pubnub_sync_subloop_sample: ../core/samples/pubnub_sync_subloop_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_subloop_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_sync_publish_retry: ../core/samples/pubnub_sync_publish_retry.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_publish_retry.c pubnub_sync.a $(LDLIBS) - -pubnub_publish_via_post_sample: ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(INCLUDES) ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_advanced_history_sample: ../core/samples/pubnub_advanced_history_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_advanced_history_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_fetch_history_sample: ../core/samples/pubnub_fetch_history_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_fetch_history_sample.c pubnub_sync.a $(LDLIBS) - -cancel_subscribe_sync_sample: ../core/samples/cancel_subscribe_sync_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/cancel_subscribe_sync_sample.c pubnub_sync.a $(LDLIBS) - -pubnub_callback_sample: ../core/samples/pubnub_callback_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/pubnub_callback_sample.c pubnub_callback.a $(LDLIBS) - -pubnub_callback_subloop_sample: ../core/samples/pubnub_callback_subloop_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_callback_subloop_sample.c pubnub_callback.a $(LDLIBS) - -subscribe_publish_callback_sample: ../core/samples/subscribe_publish_callback_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/subscribe_publish_callback_sample.c pubnub_callback.a $(LDLIBS) - -subscribe_publish_from_callback: ../core/samples/subscribe_publish_from_callback.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/subscribe_publish_from_callback.c pubnub_callback.a $(LDLIBS) - -# Subscribe Event Engine rely on callback -subscribe_event_engine_sample: ../core/samples/subscribe_event_engine_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/subscribe_event_engine_sample.c pubnub_callback.a $(LDLIBS) - -publish_callback_subloop_sample: ../core/samples/publish_callback_subloop_sample.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_callback_subloop_sample.c pubnub_callback.a $(LDLIBS) - -publish_queue_callback_subloop: ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a $(LDLIBS) - -pubnub_fntest: ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c fntest/pubnub_fntest_posix.c fntest/pubnub_fntest_runner.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c fntest/pubnub_fntest_posix.c fntest/pubnub_fntest_runner.c pubnub_sync.a $(LDLIBS) -lpthread - -CONSOLE_SOURCEFILES=../core/samples/console/pubnub_console.c ../core/samples/console/pnc_helpers.c ../core/samples/console/pnc_readers.c ../core/samples/console/pnc_subscriptions.c - -pubnub_console_sync: $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_sync.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_sync.c pubnub_sync.a $(LDLIBS) - -pubnub_console_callback: $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_callback.c pubnub_callback.a - $(CC) -o $@ $(CFLAGS) $(CFLAGS_CALLBACK) -D PUBNUB_CALLBACK_API $(INCLUDES) $(CONSOLE_SOURCEFILES) ../core/samples/console/pnc_ops_callback.c pubnub_callback.a $(LDLIBS) +# Makefile for PubNub C-core SDK. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. + +USE_CALLBACK_API = 1 + +include ../make/posix_preprocessing.mk +include ../make/posix_source_files.mk +include ../make/posix_compiler_linker_flags.mk + + +############################################################################### +# Build targets # +############################################################################### + +include ../make/common/targets_lib.mk +include ../make/posix_targets.mk + +# There is also `subscribe_event_engine_sample$(APP_EXT)` target but it can't be built +# with `all` because requires `USE_SUBSCRIBE_EVENT_ENGINE=1`. + +all: \ + cancel_subscribe_sync_sample$(APP_EXT) \ + metadata$(APP_EXT) \ + pubnub_advanced_history_sample$(APP_EXT) \ + pubnub_fetch_history_sample$(APP_EXT) \ + pubnub_publish_via_post_sample$(APP_EXT) \ + pubnub_sync_publish_retry$(APP_EXT) \ + pubnub_sync_sample$(APP_EXT) \ + pubnub_sync_secretkey_sample$(APP_EXT) \ + pubnub_sync_subloop_sample$(APP_EXT) \ + publish_callback_subloop_sample$(APP_EXT) \ + publish_queue_callback_subloop$(APP_EXT) \ + pubnub_callback_sample$(APP_EXT) \ + pubnub_callback_subloop_sample$(APP_EXT) \ + subscribe_publish_callback_sample$(APP_EXT) \ + subscribe_publish_from_callback$(APP_EXT) \ + pubnub_console_sync$(APP_EXT) \ + pubnub_console_callback$(APP_EXT) \ + pubnub_fntest$(APP_EXT) clean: find . -type d -iname "*.dSYM" -exec rm -rf {} \+ - find . -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf + find . -type f ! -name "*.*" -o -name "*.a" -o -name "*.o" | xargs -r rm -rf -rf \ No newline at end of file diff --git a/windows/windows-gcc.mk b/windows/windows-gcc.mk index a1792bb4..c4c0f562 100644 --- a/windows/windows-gcc.mk +++ b/windows/windows-gcc.mk @@ -1,85 +1,39 @@ -SOURCEFILES = ../core/pbcc_set_state.c ../core/pubnub_pubsubapi.c ../core/pubnub_coreapi.c ../core/pubnub_coreapi_ex.c ../core/pubnub_ccore_pubsub.c ../core/pubnub_ccore.c ../core/pubnub_netcore.c ../lib/sockets/pbpal_sockets.c ../lib/sockets/pbpal_resolv_and_connect_sockets.c ../core/pubnub_alloc_std.c ../core/pubnub_assert_std.c ../core/pubnub_generate_uuid.c ../core/pubnub_blocking_io.c ../windows/windows_socket_blocking_io.c ../core/pubnub_free_with_timeout_std.c ../lib/base64/pbbase64.c ../core/pubnub_timers.c ../core/pubnub_json_parse.c ../lib/md5/md5.c ../core/pubnub_helper.c pubnub_version_windows.c pubnub_generate_uuid_windows.c pbpal_windows_blocking_io.c ../core/c99/snprintf.c ../lib/miniz/miniz_tinfl.c ../lib/miniz/miniz_tdef.c ../lib/miniz/miniz.c ../lib/pbcrc32.c ../core/pbgzip_compress.c ../core/pbgzip_decompress.c ../core/pubnub_subscribe_v2.c msstopwatch_windows.c ../core/pubnub_url_encode.c ../core/pbcc_advanced_history.c ../core/pubnub_advanced_history.c - -OBJFILES = pbcc_set_state.obj pubnub_pubsubapi.obj pubnub_coreapi.obj pubnub_coreapi_ex.obj pubnub_ccore_pubsub.obj pubnub_ccore.obj pubnub_netcore.obj pbpal_sockets.obj pbpal_resolv_and_connect_sockets.obj pubnub_alloc_std.obj pubnub_assert_std.obj pubnub_generate_uuid.obj pubnub_blocking_io.obj windows_socket_blocking_io.obj pubnub_free_with_timeout_std.obj pbbase64.obj pubnub_timers.obj pubnub_json_parse.obj md5.obj pubnub_helper.obj pubnub_version_windows.obj pubnub_generate_uuid_windows.obj pbpal_windows_blocking_io.obj snprintf.obj miniz_tinfl.obj miniz_tdef.obj miniz.obj pbcrc32.obj pbgzip_compress.obj pbgzip_decompress.obj pubnub_subscribe_v2.obj msstopwatch_windows.obj pubnub_url_encode.obj pbcc_advanced_history.obj pubnub_advanced_history.obj - - -!ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -!endif - -!ifndef USE_PROXY -USE_PROXY = 1 -!endif - -!if $(USE_PROXY) -PROXY_INTF_SOURCEFILES = ..\core\pubnub_proxy.c ..\core\pubnub_proxy_core.c ..\core\pbhttp_digest.c ..\core\pbntlm_core.c ..\core\pbntlm_packer_sspi.c pubnub_set_proxy_from_system_windows.c -PROXY_INTF_OBJFILES = pubnub_proxy.obj pubnub_proxy_core.obj pbhttp_digest.obj pbntlm_core.obj pbntlm_packer_sspi.obj pubnub_set_proxy_from_system_windows.obj -!endif - -DEFINES=-D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -D HAVE_STRERROR_S -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) - - -# -D HAVE_STRERROR_R -CFLAGS = -std=c11 -g -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_DEBUG -# -g enables debugging, remove to get a smaller executable -# -std=c11 enables `%z` and `%ll` in printf() - in general, we're "low" on C11 features -# -fsanitize=address Uses the Address Sanitizer (supported by GCC and Clang) - -INCLUDES=-I .. -I . - -LIBFILES=-lws2_32 -lrpcrt4 -lsecur32 - -## -# We don't build the callback examples, because some older versions of MINGW -# don't have WSAPOLLFD defined. If you have a newer version of MING, uncomment -# the callback examples. -# - -all: pubnub_sync_sample.exe cancel_subscribe_sync_sample.exe -# pubnub_console_sync.exe -#subscribe_publish_callback_sample.exe pubnub_callback_sample.exe pubnub_fntest.exe pubnub_console_callback.exe - -SYNC_INTF_SOURCEFILES= ../core/pubnub_ntf_sync.c ../core/pubnub_sync_subscribe_loop.c ../core/srand_from_pubnub_time.c -SYNC_INTF_OBJFILES=pubnub_ntf_sync.obj pubnub_sync_subscribe_loop.obj srand_from_pubnub_time.obj - - -pubnub_sync.a: $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) - "$(CC)" -c $(CFLAGS) $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) - $(AR) rcs $@ $(OBJFILES) $(SYNC_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) - -## -# The socket poller module to use. The `poll` poller doesn't have the -# weird restrictions of `select` poller. OTOH, select() on Windows is -# compatible w/BSD sockets select(), while WSAPoll() has some weird -# differences to poll(). The names are the same until the last `_`, -# then it's `poll` vs `select. -SOCKET_POLLER_C=..\lib\sockets\pbpal_ntf_callback_poller_poll.c -SOCKET_POLLER_OBJ=pbpal_ntf_callback_poller_poll.obj - -CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_windows.c pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c ../core/pubnub_dns_servers.c ../windows/pubnub_dns_system_servers.c ../lib/pubnub_parse_ipv4_addr.c ../lib/pubnub_parse_ipv6_addr.c $(SOCKET_POLLER_C) ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c -CALLBACK_INTF_OBJFILES=pubnub_ntf_callback_windows.obj pubnub_get_native_socket.obj pubnub_timer_list.obj pbpal_adns_sockets.obj pubnub_dns_codec.obj pubnub_dns_servers.obj pubnub_dns_system_servers.obj pubnub_parse_ipv4_addr.obj pubnub_parse_ipv6_addr.obj $(SOCKET_POLLER_OBJ) pbpal_ntf_callback_queue.obj pbpal_ntf_callback_admin.obj pbpal_ntf_callback_handle_timer_list.obj pubnub_callback_subscribe_loop.obj - - -pubnub_callback.a : $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) - "$(CC)" -c $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) - $(AR) rcs $@ $(OBJFILES) $(PROXY_INTF_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) - -pubnub_sync_sample.exe: ../core/samples/pubnub_sync_sample.c pubnub_sync.a - "$(CC)" -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_sample.c pubnub_sync.a $(LIBFILES) - -cancel_subscribe_sync_sample.exe: ../core/samples/cancel_subscribe_sync_sample.c pubnub_sync.a - "$(CC)" -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/cancel_subscribe_sync_sample.c pubnub_sync.a $(LIBFILES) - -#pubnub_callback_sample.exe: ../core/samples/pubnub_callback_sample.c $(SOURCEFILES) pubnub_ntf_callback_windows.c -# $(CC) -o $@ $(CFLAGS) -DPUBNUB_CALLBACK_API ../core/samples/pubnub_callback_sample.c $(SOURCEFILES) pubnub_ntf_callback_windows.c $(LIBFILES) - -#subscribe_publish_callback_sample.exe: ../core/samples/subscribe_publish_callback_sample.c $(SOURCEFILES) pubnub_ntf_callback_windows.c -# $(CC) -o $@ $(CFLAGS) -DPUBNUB_CALLBACK_API ../core/samples/subscribe_publish_callback_sample.c $(SOURCEFILES) pubnub_ntf_callback_windows.c $(LIBFILES) - -pubnub_fntest.exe: ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c fntest/pubnub_fntest_windows.c fntest/pubnub_fntest_runner.c $(SOURCEFILES) ../core/pubnub_ntf_sync.c - $(CC) -o $@ $(CFLAGS) ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c fntest/pubnub_fntest_windows.c fntest/pubnub_fntest_runner.c $(SOURCEFILES) ../core/pubnub_ntf_sync.c $(LIBFILES) - -clean: - $(RM) *.exe - $(RM) *.o - $(RM) *.a +# Makefile for PubNub C-core SDK. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. + +WITH_GCC = 1 + +!include <../make/windows_preprocessing.mk> +!include <../make/windows_source_files.mk> +!include <../make/windows_compiler_linker_flags.mk> + + +############################################################################### +# Build targets # +############################################################################### + +!include <../make/common/targets_lib.mk> +!include <../make/windows_targets.mk> + +# There is also `subscribe_event_engine_sample$(APP_EXT)` target but it can't be built +# with `all` because requires `USE_SUBSCRIBE_EVENT_ENGINE=1`. + +all: \ + cancel_subscribe_sync_sample$(APP_EXT) \ + metadata$(APP_EXT) \ + pubnub_advanced_history_sample$(APP_EXT) \ + pubnub_fetch_history_sample$(APP_EXT) \ + pubnub_publish_via_post_sample$(APP_EXT) \ + pubnub_sync_publish_retry$(APP_EXT) \ + pubnub_sync_sample$(APP_EXT) \ + pubnub_sync_secretkey_sample$(APP_EXT) \ + publish_callback_subloop_sample$(APP_EXT) \ + publish_queue_callback_subloop$(APP_EXT) \ + pubnub_callback_sample$(APP_EXT) \ + pubnub_callback_subloop_sample$(APP_EXT) \ + subscribe_publish_callback_sample$(APP_EXT) \ + subscribe_publish_from_callback$(APP_EXT) \ + pubnub_console_sync$(APP_EXT) \ + pubnub_console_callback$(APP_EXT) \ + pubnub_fntest$(APP_EXT) diff --git a/windows/windows.mk b/windows/windows.mk index 426fc1f6..b1f1aac0 100644 --- a/windows/windows.mk +++ b/windows/windows.mk @@ -1,141 +1,41 @@ -SOURCEFILES = ..\core\pbcc_set_state.c ..\core\pubnub_pubsubapi.c ..\core\pubnub_coreapi.c ..\core\pubnub_coreapi_ex.c ..\core\pubnub_ccore_pubsub.c ..\core\pubnub_ccore.c ..\core\pubnub_netcore.c ..\lib\sockets\pbpal_sockets.c ..\lib\sockets\pbpal_resolv_and_connect_sockets.c ..\lib\sockets\pbpal_handle_socket_error.c ..\core\pubnub_alloc_std.c ..\core\pubnub_assert_std.c ..\core\pubnub_generate_uuid.c ..\core\pubnub_blocking_io.c ..\windows\windows_socket_blocking_io.c ..\core\pubnub_free_with_timeout_std.c pbtimespec_elapsed_ms.c ..\lib\base64\pbbase64.c ..\core\pubnub_timers.c ..\core\pubnub_json_parse.c ..\lib\md5\md5.c ..\lib\pb_strnlen_s.c ..\lib\pb_strncasecmp.c ..\core\pubnub_helper.c pubnub_version_windows.c pubnub_generate_uuid_windows.c pbpal_windows_blocking_io.c ..\core\c99\snprintf.c ..\lib\miniz\miniz_tinfl.c ..\lib\miniz\miniz_tdef.c ..\lib\miniz\miniz.c ..\lib\pbcrc32.c ..\core\pbgzip_compress.c ..\core\pbgzip_decompress.c ..\core\pbcc_subscribe_v2.c ..\core\pubnub_subscribe_v2.c msstopwatch_windows.c ..\core\pubnub_url_encode.c ..\core\pbcc_advanced_history.c ..\core\pubnub_advanced_history.c ..\core\pbcc_objects_api.c ..\core\pubnub_objects_api.c ..\core\pbcc_actions_api.c ..\core\pubnub_actions_api.c ..\core\pubnub_memory_block.c ..\lib\pbstr_remove_from_list.c ..\windows\pb_sleep_ms.c ..\core\pbauto_heartbeat.c ..\windows\pbauto_heartbeat_init_windows.c - -OBJFILES = pbcc_set_state.obj pubnub_pubsubapi.obj pubnub_coreapi.obj pubnub_coreapi_ex.obj pubnub_ccore_pubsub.obj pubnub_ccore.obj pubnub_netcore.obj pbpal_sockets.obj pbpal_resolv_and_connect_sockets.obj pbpal_handle_socket_error.obj pubnub_alloc_std.obj pubnub_assert_std.obj pubnub_generate_uuid.obj pubnub_blocking_io.obj windows_socket_blocking_io.obj pubnub_free_with_timeout_std.obj pbtimespec_elapsed_ms.obj pbbase64.obj pubnub_timers.obj pubnub_json_parse.obj md5.obj pb_strnlen_s.obj pb_strncasecmp.obj pubnub_helper.obj pubnub_version_windows.obj pubnub_generate_uuid_windows.obj pbpal_windows_blocking_io.obj snprintf.obj miniz_tinfl.obj miniz_tdef.obj miniz.obj pbcrc32.obj pbgzip_compress.obj pbgzip_decompress.obj pbcc_subscribe_v2.obj pubnub_subscribe_v2.obj msstopwatch_windows.obj pubnub_url_encode.obj pbcc_advanced_history.obj pubnub_advanced_history.obj pbcc_objects_api.obj pubnub_objects_api.obj pbcc_actions_api.obj pubnub_actions_api.obj pubnub_memory_block.obj pbstr_remove_from_list.obj pb_sleep_ms.obj pbauto_heartbeat.obj pbauto_heartbeat_init_windows.obj - -LDLIBS=ws2_32.lib IPHlpAPI.lib rpcrt4.lib - -!ifndef ONLY_PUBSUB_API -ONLY_PUBSUB_API = 0 -!endif - -!ifndef USE_REVOKE_TOKEN -USE_REVOKE_TOKEN = 0 -!endif - -!ifndef USE_GRANT_TOKEN -USE_GRANT_TOKEN = 0 -!endif - -!ifndef USE_FETCH_HISTORY -USE_FETCH_HISTORY = 1 -!endif - -!ifndef USE_PROXY -USE_PROXY = 1 -!endif - -!ifndef USE_RETRY_CONFIGURATION -USE_RETRY_CONFIGURATION = 0 -!endif - -!if $(USE_PROXY) -PROXY_INTF_SOURCEFILES = ..\core\pubnub_proxy.c ..\core\pubnub_proxy_core.c ..\core\pbhttp_digest.c ..\core\pbntlm_core.c ..\core\pbntlm_packer_sspi.c pubnub_set_proxy_from_system_windows.c -PROXY_INTF_OBJFILES = pubnub_proxy.obj pubnub_proxy_core.obj pbhttp_digest.obj pbntlm_core.obj pbntlm_packer_sspi.obj pubnub_set_proxy_from_system_windows.obj -!endif - -!if $(USE_RETRY_CONFIGURATION) -PROXY_INTF_SOURCEFILES += ..\core\pbcc_request_retry_timer.c ..\core\pubnub_retry_configuration.c -PROXY_INTF_OBJFILES += pbcc_request_retry_timer.obj pubnub_retry_configuration.obj -!endif - -!if $(USE_FETCH_HISTORY) -FETCH_HIST_SOURCEFILES = ..\core\pubnub_fetch_history.c ..\core\pbcc_fetch_history.c -FETCH_HIST_OBJFILES = pubnub_fetch_history.obj pbcc_fetch_history.obj -!endif - -DEFINES=-D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -D HAVE_STRERROR_S -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) -CFLAGS = -Zi -MP -W3 $(DEFINES) -# -Zi enables debugging, remove to get a smaller .exe and no .pdb -# -MP use one compiler process for each input, faster on multi-core (ignored by clang-cl) -# -analyze To run the static analyzer (not compatible w/clang-cl) - -INCLUDES=-I .. -I . -I ..\core\c99 - -all: pubnub_sync_sample.exe metadata.exe cancel_subscribe_sync_sample.exe pubnub_publish_via_post_sample.exe subscribe_publish_callback_sample.exe pubnub_callback_sample.exe pubnub_callback_subloop_sample.exe pubnub_fntest.exe pubnub_console_sync.exe pubnub_advanced_history_sample.exe pubnub_fetch_history_sample.exe pubnub_console_callback.exe subscribe_publish_from_callback.exe publish_callback_subloop_sample.exe publish_queue_callback_subloop.exe - -SYNC_INTF_SOURCEFILES= ..\core\pubnub_ntf_sync.c ..\core\pubnub_sync_subscribe_loop.c ..\core\srand_from_pubnub_time.c -SYNC_INTF_OBJFILES=pubnub_ntf_sync.obj pubnub_sync_subscribe_loop.obj srand_from_pubnub_time.obj - -pubnub_sync.lib : $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) - $(CC) -c $(CFLAGS) $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) - lib $(OBJFILES) $(SYNC_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(FETCH_HIST_OBJFILES) -OUT:$@ - -## -# The socket poller module to use. The `poll` poller doesn't have the -# weird restrictions of `select` poller. OTOH, select() on Windows is -# compatible w/BSD sockets select(), while WSAPoll() has some weird -# differences to poll(). The names are the same until the last `_`, -# then it's `poll` vs `select. -SOCKET_POLLER_C=..\lib\sockets\pbpal_ntf_callback_poller_poll.c -SOCKET_POLLER_OBJ=pbpal_ntf_callback_poller_poll.obj - -CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_windows.c pubnub_get_native_socket.c ..\core\pubnub_timer_list.c ..\lib\sockets\pbpal_adns_sockets.c ..\lib\pubnub_dns_codec.c ..\core\pubnub_dns_servers.c ..\windows\pubnub_dns_system_servers.c ..\lib\pubnub_parse_ipv4_addr.c ..\lib\pubnub_parse_ipv6_addr.c $(SOCKET_POLLER_C) ..\core\pbpal_ntf_callback_queue.c ..\core\pbpal_ntf_callback_admin.c ..\core\pbpal_ntf_callback_handle_timer_list.c ..\core\pubnub_callback_subscribe_loop.c -CALLBACK_INTF_OBJFILES=pubnub_ntf_callback_windows.obj pubnub_get_native_socket.obj pubnub_timer_list.obj pbpal_adns_sockets.obj pubnub_dns_codec.obj pubnub_dns_servers.obj pubnub_dns_system_servers.obj pubnub_parse_ipv4_addr.obj pubnub_parse_ipv6_addr.obj $(SOCKET_POLLER_OBJ) pbpal_ntf_callback_queue.obj pbpal_ntf_callback_admin.obj pbpal_ntf_callback_handle_timer_list.obj pubnub_callback_subscribe_loop.obj - -pubnub_callback.lib : $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) - $(CC) -c $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) - lib $(OBJFILES) $(CALLBACK_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(FETCH_HIST_OBJFILES) -OUT:$@ - -SYNC_SAMPLE_SOURCEFILES= ..\core\samples\pubnub_sync_sample.c - -pubnub_sync_sample.exe: $(SYNC_SAMPLE_SOURCEFILES) pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) $(SYNC_SAMPLE_SOURCEFILES) pubnub_sync.lib $(LDLIBS) - -METADATA_SOURCEFILES= ..\core\samples\metadata.c - -metadata.exe: $(METADATA_SOURCEFILES) pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) $(METADATA_SOURCEFILES) pubnub_sync.lib $(LDLIBS) - -cancel_subscribe_sync_sample.exe: ..\core\samples\cancel_subscribe_sync_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\cancel_subscribe_sync_sample.c pubnub_sync.lib $(LDLIBS) - -pubnub_advanced_history_sample.exe: ..\core\samples\pubnub_advanced_history_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_advanced_history_sample.c pubnub_sync.lib $(LDLIBS) - -pubnub_fetch_history_sample.exe: ..\core\samples\pubnub_fetch_history_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_fetch_history_sample.c pubnub_sync.lib $(LDLIBS) - -pubnub_publish_via_post_sample.exe: ..\core\samples\pubnub_publish_via_post_sample.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_publish_via_post_sample.c pubnub_sync.lib $(LDLIBS) - -pubnub_callback_sample.exe: ..\core\samples\pubnub_callback_sample.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API -DPUBNUB_USE_ADNS=1 $(INCLUDES) ..\core\samples\pubnub_callback_sample.c pubnub_callback.lib $(LDLIBS) - -subscribe_publish_callback_sample.exe: ..\core\samples\subscribe_publish_callback_sample.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\subscribe_publish_callback_sample.c pubnub_callback.lib $(LDLIBS) - -subscribe_publish_from_callback.exe: ..\core\samples\subscribe_publish_from_callback.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\subscribe_publish_from_callback.c pubnub_callback.lib $(LDLIBS) - -publish_callback_subloop_sample.exe: ..\core\samples\publish_callback_subloop_sample.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\publish_callback_subloop_sample.c pubnub_callback.lib $(LDLIBS) - -publish_queue_callback_subloop.exe: ..\core\samples\publish_queue_callback_subloop.c pubnub_callback.lib - $(CC) $(CFLAGS) -DPUBNUB_CALLBACK_API $(INCLUDES) ..\core\samples\publish_queue_callback_subloop.c pubnub_callback.lib $(LDLIBS) - -pubnub_callback_subloop_sample.exe: ..\core\samples\pubnub_callback_subloop_sample.c ..\core\pubnub_create.c pubnub_callback.lib - $(CC) -D PUBNUB_CALLBACK_API $(CFLAGS) $(INCLUDES) ..\core\samples\pubnub_callback_subloop_sample.c ..\core\pubnub_create.c pubnub_callback.lib $(LDLIBS) - -pubnub_fntest.exe: ..\core\fntest\pubnub_fntest.c ..\core\fntest\pubnub_fntest_basic.c ..\core\fntest\pubnub_fntest_medium.c fntest\pubnub_fntest_windows.c fntest\pubnub_fntest_runner.c pubnub_sync.lib - $(CC) $(CFLAGS) $(INCLUDES) ..\core\fntest\pubnub_fntest.c ..\core\fntest\pubnub_fntest_basic.c ..\core\fntest\pubnub_fntest_medium.c fntest\pubnub_fntest_windows.c fntest\pubnub_fntest_runner.c pubnub_sync.lib $(LDLIBS) - -CONSOLE_SOURCEFILES=..\core\samples\console\pubnub_console.c ..\core\samples\console\pnc_helpers.c ..\core\samples\console\pnc_readers.c ..\core\samples\console\pnc_subscriptions.c - -pubnub_console_sync.exe: $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_sync.c pubnub_sync.lib - $(CC) /Fe$@ $(CFLAGS) /D _CRT_SECURE_NO_WARNINGS $(INCLUDES) $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_sync.c pubnub_sync.lib $(LDLIBS) - -pubnub_console_callback.exe: $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_callback.c pubnub_callback.lib - $(CC) /Fe$@ $(CFLAGS) /D _CRT_SECURE_NO_WARNINGS -D PUBNUB_CALLBACK_API $(INCLUDES) $(CONSOLE_SOURCEFILES) ..\core\samples\console\pnc_ops_callback.c pubnub_callback.lib $(LDLIBS) - -cppcheck: $(SOURCEFILES) $(CONSOLE_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(SYNC_SAMPLE_SOURCEFILES) - cppcheck $(INCLUDES) $(DEFINES) --force --enable=all $(SOURCEFILES) $(CONSOLE_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(SYNC_SAMPLE_SOURCEFILES) - -clean: - del *.exe - del *.obj - del *.pdb - del *.il? - del *.lib - del *.c~ - del *.h~ - del *~ +# Makefile for PubNub C-core SDK. +# Description: All-in-one make file which show how to build various versions of +# PubNub SDK which has specific features and link them with application. + +USE_CALLBACK_API = 1 + +!include <../make/windows_preprocessing.mk> +!include <../make/windows_source_files.mk> +!include <../make/windows_compiler_linker_flags.mk> + + +############################################################################### +# Build targets # +############################################################################### + +!include <../make/common/targets_lib.mk> +!include <../make/windows_targets.mk> + +cppcheck: $(SOURCE_FILES) $(SYNC_SOURCE_FILES) $(CALLBACK_SOURCE_FILES) + cppcheck $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) --force --enable=all $(PREREQUISITES) + +# There is also `subscribe_event_engine_sample$(APP_EXT)` target but it can't be built +# with `all` because requires `USE_SUBSCRIBE_EVENT_ENGINE=1`. + +all: \ + cancel_subscribe_sync_sample$(APP_EXT) \ + metadata$(APP_EXT) \ + pubnub_advanced_history_sample$(APP_EXT) \ + pubnub_fetch_history_sample$(APP_EXT) \ + pubnub_publish_via_post_sample$(APP_EXT) \ + pubnub_sync_publish_retry$(APP_EXT) \ + pubnub_sync_sample$(APP_EXT) \ + publish_callback_subloop_sample$(APP_EXT) \ + publish_queue_callback_subloop$(APP_EXT) \ + pubnub_callback_sample$(APP_EXT) \ + pubnub_callback_subloop_sample$(APP_EXT) \ + subscribe_publish_callback_sample$(APP_EXT) \ + subscribe_publish_from_callback$(APP_EXT) \ + pubnub_console_sync$(APP_EXT) \ + pubnub_console_callback$(APP_EXT) \ + pubnub_fntest$(APP_EXT) \ No newline at end of file