Index: pbx/pbx_loopback.c =================================================================== --- pbx/pbx_loopback.c (revision 282825) +++ pbx/pbx_loopback.c (working copy) @@ -41,7 +41,6 @@ #include "asterisk/sched.h" #include "asterisk/io.h" #include "asterisk/utils.h" -#include "asterisk/crypto.h" #include "asterisk/astdb.h" Index: pbx/pbx_realtime.c =================================================================== --- pbx/pbx_realtime.c (revision 282825) +++ pbx/pbx_realtime.c (working copy) @@ -46,7 +46,6 @@ #include "asterisk/sched.h" #include "asterisk/io.h" #include "asterisk/utils.h" -#include "asterisk/crypto.h" #include "asterisk/astdb.h" #include "asterisk/app.h" #include "asterisk/astobj2.h" Index: pbx/pbx_dundi.c =================================================================== --- pbx/pbx_dundi.c (revision 282825) +++ pbx/pbx_dundi.c (working copy) @@ -4880,5 +4880,8 @@ .load = load_module, .unload = unload_module, .reload = reload, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_crypto", +#endif ); Index: channels/chan_dahdi.c =================================================================== --- channels/chan_dahdi.c (revision 282825) +++ channels/chan_dahdi.c (working copy) @@ -38,7 +38,7 @@ */ /*** MODULEINFO - res_smdi + res_smdi dahdi tonezone pri @@ -17916,4 +17916,7 @@ .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_adsi,res_smdi", +#endif ); Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 282825) +++ channels/chan_sip.c (working copy) @@ -28497,4 +28497,7 @@ .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_crypto", +#endif ); Index: channels/chan_agent.c =================================================================== --- channels/chan_agent.c (revision 282825) +++ channels/chan_agent.c (working copy) @@ -2484,4 +2484,7 @@ .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_monitor", +#endif ); Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 282825) +++ channels/chan_iax2.c (working copy) @@ -14620,4 +14620,7 @@ .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_crypto", +#endif ); Index: channels/chan_mgcp.c =================================================================== --- channels/chan_mgcp.c (revision 282825) +++ channels/chan_mgcp.c (working copy) @@ -30,7 +30,7 @@ */ /*** MODULEINFO - res_pktccops + res_pktccops ***/ #include "asterisk.h" @@ -4915,4 +4915,7 @@ .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_pktccops", +#endif ); Index: apps/app_stack.c =================================================================== --- apps/app_stack.c (revision 282825) +++ apps/app_stack.c (working copy) @@ -704,4 +704,10 @@ return 0; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dialplan subroutines (Gosub, Return, etc)"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Dialplan subroutines (Gosub, Return, etc)", + .load = load_module, + .unload = unload_module, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_agi", +#endif + ); Index: apps/app_adsiprog.c =================================================================== --- apps/app_adsiprog.c (revision 282825) +++ apps/app_adsiprog.c (working copy) @@ -1591,4 +1591,10 @@ return AST_MODULE_LOAD_SUCCESS; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Asterisk ADSI Programming Application"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk ADSI Programming Application", + .load = load_module, + .unload = unload_module, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_adsi", +#endif + ); Index: apps/app_getcpeid.c =================================================================== --- apps/app_getcpeid.c (revision 282825) +++ apps/app_getcpeid.c (working copy) @@ -132,4 +132,10 @@ return ast_register_application_xml(app, cpeid_exec); } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Get ADSI CPE ID"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Get ADSI CPE ID", + .load = load_module, + .unload = unload_module, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_adsi", +#endif + ); Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 282825) +++ apps/app_voicemail.c (working copy) @@ -38,7 +38,7 @@ */ /*** MODULEINFO - res_smdi + res_smdi ***/ /*** MAKEOPTS @@ -13085,4 +13085,7 @@ .load = load_module, .unload = unload_module, .reload = reload, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_adsi", +#endif ); Index: apps/app_speech_utils.c =================================================================== --- apps/app_speech_utils.c (revision 282825) +++ apps/app_speech_utils.c (working copy) @@ -955,4 +955,10 @@ return res; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dialplan Speech Applications"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Dialplan Speech Applications", + .load = load_module, + .unload = unload_module, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_speech", +#endif + ); Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 282825) +++ apps/app_queue.c (working copy) @@ -57,7 +57,7 @@ */ /*** MODULEINFO - res_monitor + res_monitor ***/ #include "asterisk.h" @@ -8197,5 +8197,8 @@ .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_DEVSTATE_CONSUMER, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_monitor", +#endif ); Index: apps/app_followme.c =================================================================== --- apps/app_followme.c (revision 282825) +++ apps/app_followme.c (working copy) @@ -51,7 +51,6 @@ #include "asterisk/cli.h" #include "asterisk/manager.h" #include "asterisk/config.h" -#include "asterisk/monitor.h" #include "asterisk/utils.h" #include "asterisk/causes.h" #include "asterisk/astdb.h" Index: funcs/func_aes.c =================================================================== --- funcs/func_aes.c (revision 282825) +++ funcs/func_aes.c (working copy) @@ -163,4 +163,10 @@ return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "AES dialplan functions"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "AES dialplan functions", + .load = load_module, + .unload = unload_module, +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + .required_resource = "res_crypto", +#endif + ); Index: include/asterisk/module.h =================================================================== --- include/asterisk/module.h (revision 282825) +++ include/asterisk/module.h (working copy) @@ -242,6 +242,10 @@ * this value will never be read and the module will be given the lowest possible priority * on load. */ unsigned char load_pri; + +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + const char *required_resource; +#endif }; void ast_module_register(const struct ast_module_info *); Index: main/loader.c =================================================================== --- main/loader.c (revision 282825) +++ main/loader.c (working copy) @@ -414,6 +414,24 @@ return NULL; } + /* This section is a workaround for a gcc 4.1 bug that has already been + * fixed in later versions. Unfortunately, some distributions, such as + * RHEL/CentOS 5, distribute gcc 4.1, so we're stuck with having to deal + * with this issue. This basically ensures that optional_api modules are + * loaded before any module which requires their functionality. */ +#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) + if (!ast_strlen_zero(mod->info->required_resource)) { + /* Force any required dependencies to load */ + char *each, *required_resource = ast_strdupa(mod->info->required_resource); + while ((each = strsep(&required_resource, ","))) { + /* Is it already loaded? */ + if (!find_resource(each, 0)) { + load_dynamic_module(each, global_symbols_only); + } + } + } +#endif + while (!dlclose(lib)); resource_being_loaded = NULL;