diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c26259..092b3325 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) 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/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/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..a690de3a 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..7bcfbed7 100644 --- a/cpp/windows.mk +++ b/cpp/windows.mk @@ -1,3 +1,43 @@ +# 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. + +# Making CPP version of the PubNub SDK. +WITH_CPP = 1 + +include ../make/posix_preprocessing.mk +include ../make/posix_source_files.mk +include ../make/posix_compiler_linker_flags.mk + + +############################################################################### +# Build targets # +############################################################################### + +TARGET_BUILD_PATH = + +include ../make/windows_cpp_targets.mk + + +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? + +#/D HAVE_STRERROR_S /D _CRT_SECURE_NO_WARNINGS /D _WINSOCK_DEPRECATED_NO_WARNINGS + 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 LIBS=ws2_32.lib rpcrt4.lib @@ -81,9 +121,3 @@ futres_nesting_callback_cpp11.exe: samples\futres_nesting.cpp $(SOURCEFILES) $(P $(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) -clean: - del *.obj - del *.exe - del *.pdb - del *.il? - 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..fec2f868 --- /dev/null +++ b/make/common/preprocessing.mk @@ -0,0 +1,41 @@ +# 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) + +# 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_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_COMMON) $(DEFINES_EXTERN_C) $(DEFINES_RANDOM_IV) + +# 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) \ 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..3a8b03a0 --- /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 = 1 + +# 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..b479048a --- /dev/null +++ b/make/common/source_files.mk @@ -0,0 +1,346 @@ +# 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` 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..3178cc41 --- /dev/null +++ b/make/common/targets_app.mk @@ -0,0 +1,103 @@ +# Sample 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 ----------------- + +cancel_subscribe_sync_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/cancel_subscribe_sync_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +metadata$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/metadata.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_advanced_history_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_advanced_history_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_fetch_history_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_fetch_history_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_publish_via_post_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_publish_via_post_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_sync_publish_retry$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_sync_publish_retry.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_sync_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_sync_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_sync_secretkey_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_sync_secretkey_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + + +# ----------------- Samples based on callback PubNub library ----------------- + +publish_callback_subloop_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/publish_callback_subloop_sample.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +publish_queue_callback_subloop$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/publish_queue_callback_subloop.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_callback_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_callback_sample.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_callback_subloop_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_callback_subloop_sample.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +subscribe_event_engine_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/subscribe_event_engine_sample.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +subscribe_publish_callback_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/subscribe_publish_callback_sample.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +subscribe_publish_from_callback$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/subscribe_publish_from_callback.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + + +# --------------- Console based on sync PubNub library -------------- + +pubnub_console_sync$(APP_EXT): \ + $(subst /,$(PATH_SEP),$(CONSOLE_SOURCE_FILES)) \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_console_sync.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_console_callback$(APP_EXT): \ + $(subst /,$(PATH_SEP),$(CONSOLE_SOURCE_FILES)) \ + $(subst /,$(PATH_SEP),../core/samples/pnc_ops_callback.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(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..2291afe3 --- /dev/null +++ b/make/common/targets_app_openssl.mk @@ -0,0 +1,59 @@ +# Sample application targets. +# Description: Makefile used to declare list of targets to build sample app +# which demonstrates various features with OpenSSL support. + + +############################################################################### +# Sample application targets # +############################################################################### + + +# ----------------- Samples based on sync PubNub library ----------------- + +pubnub_crypto_module_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_crypto_module_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_crypto_sync_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_crypto_sync_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_objects_secretkey_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_objects_secretkey_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_publish_via_post_secretkey_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_publish_via_post_secretkey_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_sync_grant_token_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_sync_grant_token_sample.c) \ + pubnub_sync_dynamiciv$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_sync_revoke_token_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_sync_revoke_token_sample.c) \ + pubnub_sync_dynamiciv$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_encrypt_decrypt_static_iv_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_encrypt_decrypt_iv_sample.c) \ + pubnub_sync$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + +pubnub_encrypt_decrypt_dynamic_iv_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/pubnub_encrypt_decrypt_iv_sample.c) \ + pubnub_sync_dynamiciv$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LDLIBS) + + +# --------------- Samples based on callback-based PubNub library -------------- + +subscribe_publish_callback_secretkey_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/samples/subscribe_publish_callback_secretkey_sample.c) \ + pubnub_callback$(LIB_EXT) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(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..d7464cd6 --- /dev/null +++ b/make/common/targets_cpp_app.mk @@ -0,0 +1,79 @@ +# 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 ----------------- + +$(TARGET_BUILD_PATH)pubnub_sync_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/pubnub_sample.cpp) \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)cancel_subscribe_sync_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/cancel_subscribe_sync_sample.cpp) \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)futres_nesting_sync$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/futres_nesting.cpp) \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)fntest_runner$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/fntest/pubnub_fntest_runner.cpp) \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)) \ + $(subst /,$(PATH_SEP),../cpp/fntest/pubnub_fntest.cpp) \ + $(subst /,$(PATH_SEP),../cpp/fntest/pubnub_fntest_basic.cpp) \ + $(subst /,$(PATH_SEP),../cpp/fntest/pubnub_fntest_medium.cpp) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPP11_STANDARD_FLAG) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + + +# ----------------- Samples based on callback PubNub library ----------------- + +$(TARGET_BUILD_PATH)pubnub_callback_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/pubnub_sample.cpp) \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)pubnub_callback_cpp11_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/pubnub_sample.cpp) \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),../cpp/pubnub_futres_cpp11.cpp) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPP11_STANDARD_FLAG) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)subscribe_publish_callback_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/subscribe_publish_callback_sample.cpp) \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)futres_nesting_callback$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/futres_nesting.cpp) \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CALLBACK_CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)futres_nesting_callback_cpp11$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/futres_nesting.cpp) \ + $(SOURCE_FILES) \ + $(CALLBACK_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),../cpp/pubnub_futres_cpp11.cpp) + $(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..4ebf6653 --- /dev/null +++ b/make/common/targets_cpp_app_openssl.mk @@ -0,0 +1,31 @@ +# 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 ----------------- + +$(TARGET_BUILD_PATH)pubnub_sync_grant_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/pubnub_sample_grant_token.cpp) \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)pubnub_sync_revoke_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/pubnub_sample_revoke_token.cpp) \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)) + $(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS) + +$(TARGET_BUILD_PATH)pubnub_crypto_module_sample$(APP_EXT): \ + $(subst /,$(PATH_SEP),../cpp/samples/pubnub_crypto_module_sample.cpp) \ + $(SOURCE_FILES) \ + $(SYNC_SOURCE_FILES) \ + $(subst /,$(PATH_SEP),$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)) + $(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..d16ae6c6 --- /dev/null +++ b/make/posix_cpp_targets.mk @@ -0,0 +1,43 @@ +# 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 ----------------- + +$(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..fbeb15ac --- /dev/null +++ b/make/posix_preprocessing.mk @@ -0,0 +1,254 @@ +# 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) + +# 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_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..27d801dd --- /dev/null +++ b/make/posix_source_files.mk @@ -0,0 +1,167 @@ +# 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) + + 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..9ad63b46 --- /dev/null +++ b/make/windows_compiler_linker_flags.mk @@ -0,0 +1,71 @@ +# 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 -Wall +!else + # /MP - uses one compiler (`cl`) process for each input file, enabling + # faster build + NMAKE_FLAGS = /Wall /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 +!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) && !$(WITH_GCC) + OPENSSL_LIBS = + !if $(OPENSSL_ROOT_DIR) != "" && $(CUSTOM_OPENSSL_LIB_DIR) != "" + !if EXISTS($(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR)$(PATH_SEP)libssl.lib) + 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_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_LIBS) == "" + !error "Cannot find OpenSSL libraries, OPENSSLPATH=$(OPENSSL_ROOT_DIR)" + !else + LDLIBS = $(LDLIBS) $(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..3bb73d12 --- /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..be9cbf58 --- /dev/null +++ b/make/windows_preprocessing.mk @@ -0,0 +1,325 @@ +# Windows preprocessing flags. +# Description: Makefile used to declare platform-specific preprocessing flag +# defaults. + +!include + + +############################################################################### +# 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 + +# 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) && $(USE_CPP11) + 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_EXTERN_C = +!if $(WITH_CPP) && $(USE_EXTERN_API) + 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) != "" + 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 \ 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..c514ffad --- /dev/null +++ b/make/windows_source_files.mk @@ -0,0 +1,257 @@ +# PubNub SDK source files for Windows system. +# Description: Makefile used to declare platform-specific list of PubNub SDK +# source files. + +!include + + +############################################################################### +# 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) && $(USE_CRYPTO_API) + 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) || $(USE_PROXY) + 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) && $(USE_GRANT_TOKEN) + 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) && $(USE_REVOKE_TOKEN) + 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 = $(SOURCE_FILES:../core/c99/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../core/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../cpp/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../lib/base64/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../lib/cbor/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../lib/md5/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../lib/miniz/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../lib/msstopwatch/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../lib/sockets/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../openssl/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../posix/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../qt/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../unreal/=) +SOURCE_OBJECT_FILES = $(SOURCE_OBJECT_FILES:../windows/=) + +SYNC_OBJECT_FILES = $(SYNC_SOURCE_FILES:../core/c99/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../core/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../cpp/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../lib/base64/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../lib/cbor/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../lib/md5/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../lib/miniz/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../lib/msstopwatch/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../lib/sockets/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../openssl/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../posix/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../qt/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../unreal/=) +SYNC_OBJECT_FILES = $(SYNC_OBJECT_FILES:../windows/=) + +CALLBACK_OBJECT_FILES = $(CALLBACK_SOURCE_FILES:../core/c99/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../core/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../cpp/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../lib/base64/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../lib/cbor/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../lib/md5/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../lib/miniz/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../lib/msstopwatch/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../lib/sockets/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../openssl/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../posix/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../qt/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../unreal/=) +CALLBACK_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:../windows/=) + +# Update path separator (if building with GCC). +!if $(PATH_SEP) != "/" + SOURCE_FILES = $(SOURCE_FILES:/=$(PATH_SEP)) + SYNC_SOURCE_FILES = $(SYNC_SOURCE_FILES:/=$(PATH_SEP)) + CALLBACK_SOURCE_FILES = $(CALLBACK_SOURCE_FILES:/=$(PATH_SEP)) +!endif + +CPP_OBJECT_FILES = $(SOURCE_OBJECT_FILES:.cpp=.obj) +OBJECT_FILES = $(CPP_OBJECT_FILES:.c=.obj) +SYNC_CPP_OBJECT_FILES = $(SYNC_OBJECT_FILES:.cpp=.obj) +SYNC_OBJECT_FILES = $(SYNC_CPP_OBJECT_FILES:.c=.obj) +CALLBACK_CPP_OBJECT_FILES = $(CALLBACK_OBJECT_FILES:.cpp=.obj) +CALLBACK_SOURCE_FILES = $(CALLBACK_CPP_OBJECT_FILES:.c=.obj) \ No newline at end of file diff --git a/make/windows_targets.mk b/make/windows_targets.mk new file mode 100644 index 00000000..b5cc530d --- /dev/null +++ b/make/windows_targets.mk @@ -0,0 +1,33 @@ +# Targets for Windows system. +# Description: Makefile used to declare list of targets which can be built for +# Windows systems. + +!include + + +############################################################################### +# Build targets # +############################################################################### + +# --------------- Tests based on sync PubNub library -------------- + +pubnub_fntest$(APP_EXT): \ + $(subst /,$(PATH_SEP),../core/fntest/pubnub_fntest.c) \ + $(subst /,$(PATH_SEP),../core/fntest/pubnub_fntest_basic.c) \ + $(subst /,$(PATH_SEP),../core/fntest/pubnub_fntest_medium.c) \ + $(subst /,$(PATH_SEP),../windows/fntest/pubnub_fntest_runner.c) \ + $(subst /,$(PATH_SEP),../windows/fntest/pubnub_fntest_windows.c) \ + 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..0ad9a574 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -1,292 +1,55 @@ -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 + +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_event_engine_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 5859b505..5f1d162a 100644 --- a/openssl/windows.mk +++ b/openssl/windows.mk @@ -1,193 +1,57 @@ -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 ..\lib\base64\pbbase64.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_RETRY_SOURCEFILES = ..\core\pbcc_request_retry_timer.c ..\core\pubnub_retry_configuration.c -PROXY_INTF_RETRY_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 + USE_CRYPTO_API = 0 !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 -!endif - -!if $(USE_CRYPTO_API) -CRYPTO_API_SOURCEFILES = ..\core\pbcc_crypto.c ..\core\pbcc_crypto_aes_cbc.c ..\core\pbcc_crypto_legacy.c ..\core\pubnub_crypto.c ..\openssl\pbaes256.c -CRYPTO_API_OBJFILES = pbcc_crypto.obj pbcc_crypto_aes_cbc.obj pbcc_crypto_legacy.obj pubnub_crypto.obj pbaes256.obj +!ifndef USE_GRANT_TOKEN + USE_GRANT_TOKEN = 1 !endif - -CFLAGS = $(APP_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) $(PROXY_INTF_RETRY_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CRYPTO_API_SOURCEFILES) - $(CC) -c $(CFLAGS) /D PUBNUB_RAND_INIT_VECTOR=0 $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(PROXY_INTF_RETRY_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CRYPTO_API_SOURCEFILES) - lib $(OBJFILES) $(SYNC_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(PROXY_INTF_RETRY_OBJFILES) $(GRANT_TOKEN_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(FETCH_HIST_OBJFILES) $(CRYPTO_API_OBJFILES) -OUT:$@ - -pubnub_sync_dynamiciv.lib : $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(PROXY_INTF_RETRY_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CRYPTO_API_SOURCEFILES) - $(CC) -c $(CFLAGS) /D PUBNUB_RAND_INIT_VECTOR=1 $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(PROXY_INTF_RETRY_SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CRYPTO_API_SOURCEFILES) - lib $(OBJFILES) $(SYNC_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(PROXY_INTF_RETRY_OBJFILES) $(GRANT_TOKEN_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(FETCH_HIST_OBJFILES) $(CRYPTO_API_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) $(PROXY_INTF_RETRY_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CRYPTO_API_SOURCEFILES) - $(CC) -c $(CFLAGS) -DPUBNUB_CALLBACK_API -DPUBNUB_RAND_INIT_VECTOR=0 $(INCLUDES) $(SOURCEFILES) $(PROXY_INTF_SOURCEFILES) $(PROXY_INTF_RETRY_SOURCEFILES) $(CALLBACK_INTF_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(FETCH_HIST_SOURCEFILES) $(CRYPTO_API_SOURCEFILES) - lib $(OBJFILES) $(CALLBACK_INTF_OBJFILES) $(PROXY_INTF_OBJFILES) $(PROXY_INTF_RETRY_OBJFILES) $(GRANT_TOKEN_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(FETCH_HIST_OBJFILES) $(CRYPTO_API_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 *~ +!ifndef USE_REVOKE_TOKEN + USE_REVOKE_TOKEN = 1 +!endif + +!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> + +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_event_engine_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/posix.mk b/posix/posix.mk index 0a1cab5f..e1039464 100644 --- a/posix/posix.mk +++ b/posix/posix.mk @@ -1,238 +1,42 @@ -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 + +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_event_engine_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..b85aff5a 100644 --- a/windows/windows-gcc.mk +++ b/windows/windows-gcc.mk @@ -1,85 +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 ../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> + +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_event_engine_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..2bcc1421 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) + +all: \ + cancel_subscribe_sync_sample$(APP_EXT) \ + cppcheck \ + 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_event_engine_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