diff --git a/Makefile.am b/Makefile.am index 95c53dd128..343d98a2bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -130,7 +130,7 @@ endif lib_LTLIBRARIES = libfreeswitch.la libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS) libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_DEPLIBS) -libfreeswitch_la_LIBADD = $(CORE_LIBS) +libfreeswitch_la_LIBADD = $(CORE_LIBS) $(LIBCURL) libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES) if HAVE_ODBC @@ -180,7 +180,8 @@ library_include_HEADERS = \ libs/libteletone/src/libteletone_generate.h \ libs/libteletone/src/libteletone.h \ src/include/switch_limit.h \ - src/include/switch_odbc.h + src/include/switch_odbc.h \ + src/include/switch_curl.h nodist_libfreeswitch_la_SOURCES = \ src/include/switch_frame.h \ @@ -240,6 +241,7 @@ libfreeswitch_la_SOURCES = \ src/switch_pcm.c \ src/switch_profile.c \ src/switch_json.c \ + src/switch_curl.c \ libs/stfu/stfu.c \ libs/libteletone/src/libteletone_detect.c \ libs/libteletone/src/libteletone_generate.c \ diff --git a/build/modmake.rules.in b/build/modmake.rules.in index 51923ec3dd..f0db222f71 100644 --- a/build/modmake.rules.in +++ b/build/modmake.rules.in @@ -80,9 +80,9 @@ TOUCH_TARGET=@TOUCH_TARGET@ MAKE_OPTS = `test -n "$(VERBOSE)" || echo -s` RECURSE_MODNAME=`pwd | sed -e 's|^.*/||'` RECURSE_SOURCEFILE=`if test -f "$$modname.cpp" -o -f "$(MODDIR)/$$modname.cpp"; then echo "$$modname.cpp"; else echo "$$modname.c"; fi` -RECURSE_OUR_DEPS=`test -z "$(WANT_CURL)" || if test ! -z "$(LIBCURL_DEPS)"; then echo $(CURLLA); fi ` -RECURSE_OUR_CFLAGS=`test -z "$(WANT_CURL)" || echo $(LIBCURL_CPPFLAGS) ; $(LOCAL_INSERT_CFLAGS) ` -RECURSE_OUR_LDFLAGS=`test -z "$(WANT_CURL)" || echo $(LIBCURL) ; $(LOCAL_INSERT_LDFLAGS) ` +RECURSE_OUR_DEPS= +RECURSE_OUR_CFLAGS=`$(LOCAL_INSERT_CFLAGS)` +RECURSE_OUR_LDFLAGS=`$(LOCAL_INSERT_LDFLAGS)` RECURSE_MODDIR=`if test -z $(MODDIR); then pwd | sed -e 's|$(switch_builddir)|$(switch_srcdir)|'; else echo $(MODDIR); fi` RECURSE_MAKE=+modname="$(RECURSE_MODNAME)" ; \ sourcefile="$(RECURSE_SOURCEFILE)" ; \ diff --git a/configure.in b/configure.in index 389e4985b6..50351d69d6 100644 --- a/configure.in +++ b/configure.in @@ -790,6 +790,11 @@ if test "$ac_cv_use_system_curl" != "yes" ; then LIBCURL_DEPS='${switch_builddir}/libs/curl/lib/libcurl.la' LIBCURL='${switch_builddir}/libs/curl/lib/libcurl.la' LIBCURL_CPPFLAGS='-I${switch_srcdir}/libs/curl/include' +else + AC_CHECK_LIB(curl, curl_global_init, have_curl=yes, have_curl=no) + if test "x$have_curl" = "xyes" ; then + APR_ADDTO(SWITCH_AM_LDFLAGS, -lcurl) + fi fi AC_SUBST(LIBCURL_DEPS) diff --git a/src/include/switch.h b/src/include/switch.h index de099f1b94..268243e989 100644 --- a/src/include/switch.h +++ b/src/include/switch.h @@ -137,6 +137,9 @@ #include "switch_odbc.h" #include "switch_json.h" #include "switch_limit.h" +#ifndef WIN32 +#include "switch_curl.h" +#endif #include diff --git a/src/mod/applications/mod_cidlookup/Makefile b/src/mod/applications/mod_cidlookup/Makefile index 5ffe1d8476..24790d0d39 100644 --- a/src/mod/applications/mod_cidlookup/Makefile +++ b/src/mod/applications/mod_cidlookup/Makefile @@ -1,4 +1,3 @@ -WANT_CURL=yes BASE=../../../.. include $(BASE)/build/modmake.rules diff --git a/src/mod/applications/mod_curl/Makefile b/src/mod/applications/mod_curl/Makefile index b276633355..6cae5a8595 100644 --- a/src/mod/applications/mod_curl/Makefile +++ b/src/mod/applications/mod_curl/Makefile @@ -1,6 +1,5 @@ json-c=json-c-0.9 BASE=../../../.. -WANT_CURL=yes JSON_DIR=$(switch_srcdir)/libs/$(json-c) JSON_BUILDDIR=$(switch_builddir)/libs/$(json-c) diff --git a/src/mod/applications/mod_memcache/Makefile b/src/mod/applications/mod_memcache/Makefile index 80c1d2b936..0f469ff9e2 100644 --- a/src/mod/applications/mod_memcache/Makefile +++ b/src/mod/applications/mod_memcache/Makefile @@ -1,8 +1,6 @@ MEMCACHED=libmemcached-0.32 BASE=../../../.. -WANT_CURL=yes - MEMCACHED_DIR=$(switch_srcdir)/libs/$(MEMCACHED) MEMCACHED_BUILDDIR=$(switch_builddir)/libs/$(MEMCACHED) diff --git a/src/mod/event_handlers/mod_json_cdr/Makefile b/src/mod/event_handlers/mod_json_cdr/Makefile index d5043e017d..1819f0a4c3 100644 --- a/src/mod/event_handlers/mod_json_cdr/Makefile +++ b/src/mod/event_handlers/mod_json_cdr/Makefile @@ -1,6 +1,5 @@ json-c=json-c-0.9 BASE=../../../.. -WANT_CURL=yes JSON_DIR=$(switch_srcdir)/libs/$(json-c) JSON_BUILDDIR=$(switch_builddir)/libs/$(json-c) diff --git a/src/mod/formats/mod_shout/Makefile b/src/mod/formats/mod_shout/Makefile index 7388bc0c67..50dc9d5b3a 100644 --- a/src/mod/formats/mod_shout/Makefile +++ b/src/mod/formats/mod_shout/Makefile @@ -3,8 +3,6 @@ SHOUT=libshout-2.2.2 MPG123=mpg123-1.13.2 BASE=../../../.. -WANT_CURL=yes - LAME_DIR=$(switch_srcdir)/libs/$(LAME) SHOUT_DIR=$(switch_srcdir)/libs/$(SHOUT) MPG123_DIR=$(switch_srcdir)/libs/$(MPG123) diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 377cfe520c..c506e18933 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -1480,8 +1480,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load) supported_formats[0] = "shout"; supported_formats[1] = "mp3"; - curl_global_init(CURL_GLOBAL_ALL); - /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); @@ -1507,7 +1505,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_shout_shutdown) { - curl_global_cleanup(); mpg123_exit(); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 7341a2b1e1..30ec8789d6 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2551,7 +2551,6 @@ static JSBool js_fetchurl_file(JSContext * cx, JSObject * obj, uintN argc, jsval url = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); filename = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); - curl_global_init(CURL_GLOBAL_ALL); curl_handle = curl_easy_init(); if (!strncasecmp(url, "https", 5)) { curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); @@ -2600,7 +2599,6 @@ static JSBool js_fetchurl(JSContext * cx, JSObject * obj, uintN argc, jsval * ar JS_ValueToInt32(cx, argv[1], &buffer_size); } - curl_global_init(CURL_GLOBAL_ALL); curl_handle = curl_easy_init(); if (!strncasecmp(url, "https", 5)) { curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); @@ -3803,8 +3801,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load) SWITCH_ADD_APP(app_interface, "javascript", "Launch JS ivr", "Run a javascript ivr on a channel", js_dp_function, "