diff --git a/Makefile b/Makefile
index e8501114a2406d246f9a782898fefbcd704af849..0632039bc2441485a21d9f23962eaee04af3fe20 100644
--- a/Makefile
+++ b/Makefile
@@ -307,7 +307,7 @@ MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
 
 ifneq ($(findstring darwin,$(OSARCH)),)
   ASTCFLAGS+=-D__Darwin__
-  SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
+  SOLINK=-bundle -undefined suppress -force_flat_namespace
 else
 # These are used for all but Darwin
   SOLINK=-shared
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 9227423a4924c665fd683e208666df1abca2e3bb..e32caa78d19093746616db1f2ddca2709aeadc0f 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -4256,18 +4256,16 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
 				else
 					which = peer;
 				ast_channel_unlock(qe->chan);
-				if (ast_monitor_start) {
-					if (monitorfilename) {
-						ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1, X_REC_IN | X_REC_OUT);
-					} else if (qe->chan->cdr && ast_monitor_start) {
-						ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, 1, X_REC_IN | X_REC_OUT);
-					} else if (ast_monitor_start) {
-						/* Last ditch effort -- no CDR, make up something */
-						snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random());
-						ast_monitor_start(which, qe->parent->monfmt, tmpid, 1, X_REC_IN | X_REC_OUT);
-					}
+				if (monitorfilename) {
+					ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1, X_REC_IN | X_REC_OUT);
+				} else if (qe->chan->cdr) {
+					ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, 1, X_REC_IN | X_REC_OUT);
+				} else {
+					/* Last ditch effort -- no CDR, make up something */
+					snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random());
+					ast_monitor_start(which, qe->parent->monfmt, tmpid, 1, X_REC_IN | X_REC_OUT);
 				}
-				if (!ast_strlen_zero(monexec) && ast_monitor_setjoinfiles) {
+				if (!ast_strlen_zero(monexec)) {
 					ast_monitor_setjoinfiles(which, 1);
 				}
 			} else {
diff --git a/apps/app_stack.c b/apps/app_stack.c
index bc3054d3f927032a9a779d04d74600e17bd1950a..100a59603a64d0489a122cdc3bac70d5e91e3753 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -647,9 +647,7 @@ struct agi_command gosub_agi_command =
 
 static int unload_module(void)
 {
-	if (ast_agi_unregister) {
-		 ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
-	}
+	ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
 
 	ast_unregister_application(app_return);
 	ast_unregister_application(app_pop);
@@ -663,9 +661,7 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-	if (ast_agi_register) {
-		 ast_agi_register(ast_module_info->self, &gosub_agi_command);
-	}
+	ast_agi_register(ast_module_info->self, &gosub_agi_command);
 
 	ast_register_application_xml(app_pop, pop_exec);
 	ast_register_application_xml(app_return, return_exec);
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 824c425329f1520413ba376051055ad600c1951a..1c14f2e4fea222b56859c76626c008750445cf47 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -10699,10 +10699,10 @@ static int load_config(int reload)
 		if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
 			ast_debug(1, "Enabled SMDI voicemail notification\n");
 			if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
-				smdi_iface = ast_smdi_interface_find ? ast_smdi_interface_find(val) : NULL;
+				smdi_iface = ast_smdi_interface_find(val);
 			} else {
 				ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
-				smdi_iface = ast_smdi_interface_find ? ast_smdi_interface_find("/dev/ttyS0") : NULL;
+				smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
 			}
 			if (!smdi_iface) {
 				ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
diff --git a/configure b/configure
index 95bedfd0eec69ae42e3ef6d186cd0ce6ad167491..926cf7f5a0ed97e16895634d276c92423d892525 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 196981 .
+# From configure.ac Revision: 197738 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.63 for asterisk 1.6.
 #
@@ -18924,12 +18924,12 @@ CFLAGS="$saved_CFLAGS"
 
 
 
-{ $as_echo "$as_me:$LINENO: checking for compiler 'attribute weak' support" >&5
-$as_echo_n "checking for compiler 'attribute weak' support... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for compiler 'attribute weakref' support" >&5
+$as_echo_n "checking for compiler 'attribute weakref' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 
-if test "x" = "x"
+if test "xweakref("foo")" = "x"
 then
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -18937,7 +18937,7 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-void __attribute__((weak)) *test(void *muffin, ...) {}
+void __attribute__((weakref)) *test(void *muffin, ...) {}
 int
 main ()
 {
@@ -18968,7 +18968,7 @@ $as_echo "$ac_try_echo") >&5
 $as_echo "yes" >&6; }
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_weak 1
+#define HAVE_ATTRIBUTE_weakref 1
 _ACEOF
 
 else
@@ -18988,7 +18988,7 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-void __attribute__(()) *test(void *muffin, ...) {}
+void __attribute__((weakref("foo"))) *test(void *muffin, ...) {}
 int
 main ()
 {
@@ -19019,7 +19019,7 @@ $as_echo "$ac_try_echo") >&5
 $as_echo "yes" >&6; }
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_weak 1
+#define HAVE_ATTRIBUTE_weakref 1
 _ACEOF
 
 else
@@ -19152,120 +19152,6 @@ CFLAGS="$saved_CFLAGS"
 
 
 
-{ $as_echo "$as_me:$LINENO: checking for compiler 'attribute alias' support" >&5
-$as_echo_n "checking for compiler 'attribute alias' support... " >&6; }
-saved_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Werror"
-
-if test "xalias("foo")" = "x"
-then
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-void __attribute__((alias)) *test(void *muffin, ...) {}
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_alias 1
-_ACEOF
-
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-void __attribute__((alias("foo"))) *test(void *muffin, ...) {}
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_alias 1
-_ACEOF
-
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-CFLAGS="$saved_CFLAGS"
-
-
-
 { $as_echo "$as_me:$LINENO: checking for -ffunction-sections support" >&5
 $as_echo_n "checking for -ffunction-sections support... " >&6; }
 saved_CFLAGS="${CFLAGS}"
diff --git a/configure.ac b/configure.ac
index 898cfb6f7acd3558df33e9e4090ad0d9e8e633fc..cfb53fd7f5ebbef2df03f6ec2a67f1ecf537141c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -514,9 +514,8 @@ AST_GCC_ATTRIBUTE(always_inline)
 AST_GCC_ATTRIBUTE(deprecated)
 AST_GCC_ATTRIBUTE(sentinel)
 AST_GCC_ATTRIBUTE(warn_unused_result)
-AST_GCC_ATTRIBUTE(weak)
+AST_GCC_ATTRIBUTE(weakref, [weakref("foo")])
 AST_GCC_ATTRIBUTE(weak_import)
-AST_GCC_ATTRIBUTE(alias, [alias("foo")])
 
 AC_MSG_CHECKING(for -ffunction-sections support)
 saved_CFLAGS="${CFLAGS}"
diff --git a/include/asterisk/agi.h b/include/asterisk/agi.h
index c44aafc3fc928508da5923dc142730b220d12136..210b895ad9ebfc37683a4889e112efc87148b040 100644
--- a/include/asterisk/agi.h
+++ b/include/asterisk/agi.h
@@ -72,7 +72,8 @@ typedef struct agi_command {
  * \return 1 on success, 0 if the command is already registered
  *
  */
-AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd),
+AST_OPTIONAL_API(int, ast_agi_register,
+		 (struct ast_module *mod, agi_command *cmd),
 		 { return AST_OPTIONAL_API_UNAVAILABLE; });
 
 /*!
@@ -85,7 +86,8 @@ AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cm
  * \return 1 on success, 0 if the command was not already registered
  *
  */
-AST_OPTIONAL_API(int, ast_agi_unregister, (struct ast_module *mod, agi_command *cmd),
+AST_OPTIONAL_API(int, ast_agi_unregister,
+		 (struct ast_module *mod, agi_command *cmd),
 		 { return AST_OPTIONAL_API_UNAVAILABLE; });
 
 /*!
@@ -103,7 +105,8 @@ AST_OPTIONAL_API(int, ast_agi_unregister, (struct ast_module *mod, agi_command *
  * will be unregistered. In other words, this function registers all the provided commands, or none
  * of them.
  */
-AST_OPTIONAL_API(int, ast_agi_register_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
+AST_OPTIONAL_API(int, ast_agi_register_multiple,
+		 (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
 		 { return AST_OPTIONAL_API_UNAVAILABLE; });
 
 /*!
@@ -120,7 +123,8 @@ AST_OPTIONAL_API(int, ast_agi_register_multiple, (struct ast_module *mod, struct
  * \note If any command fails to unregister, this function will continue to unregister the
  * remaining commands in the array; it will not reregister the already-unregistered commands.
  */
-AST_OPTIONAL_API(int, ast_agi_unregister_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
+AST_OPTIONAL_API(int, ast_agi_unregister_multiple,
+		 (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
 		 { return AST_OPTIONAL_API_UNAVAILABLE; });
 
 /*!
@@ -134,7 +138,8 @@ AST_OPTIONAL_API(int, ast_agi_unregister_multiple, (struct ast_module *mod, stru
  * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
  *
  */
-AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send, (int fd, struct ast_channel *chan, char *fmt, ...),
+AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send,
+		      (int fd, struct ast_channel *chan, char *fmt, ...),
 		      { return AST_OPTIONAL_API_UNAVAILABLE; });
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 33b6d2f49b3b8503d1ac2ff12c2c1d113a88c336..e11ea6b1f4efa15eee88952a755dda92b018dff7 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -94,9 +94,6 @@
 /* Define to 1 if you have the `atexit' function. */
 #undef HAVE_ATEXIT
 
-/* Define to 1 if your GCC C compiler supports the 'alias' attribute. */
-#undef HAVE_ATTRIBUTE_alias
-
 /* Define to 1 if your GCC C compiler supports the 'always_inline' attribute.
    */
 #undef HAVE_ATTRIBUTE_always_inline
@@ -123,12 +120,12 @@
    attribute. */
 #undef HAVE_ATTRIBUTE_warn_unused_result
 
-/* Define to 1 if your GCC C compiler supports the 'weak' attribute. */
-#undef HAVE_ATTRIBUTE_weak
-
 /* Define to 1 if your GCC C compiler supports the 'weak_import' attribute. */
 #undef HAVE_ATTRIBUTE_weak_import
 
+/* Define to 1 if your GCC C compiler supports the 'weakref' attribute. */
+#undef HAVE_ATTRIBUTE_weakref
+
 /* Define this to indicate the ${BKTR_DESCRIP} library */
 #undef HAVE_BKTR
 
@@ -1214,9 +1211,6 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* Define to 1 if the C compiler supports function prototypes. */
-#undef PROTOTYPES
-
 /* Define to necessary symbol if this constant uses a non-standard name on
    your system. */
 #undef PTHREAD_CREATE_JOINABLE
@@ -1233,11 +1227,6 @@
 /* Define to the type of arg 5 for `select'. */
 #undef SELECT_TYPE_ARG5
 
-/* Define to 1 if the `setvbuf' function takes the buffering type as its
-   second argument and the buffer pointer as the third, as on System V before
-   release 3. */
-#undef SETVBUF_REVERSED
-
 /* The size of `int', as computed by sizeof. */
 #undef SIZEOF_INT
 
@@ -1258,20 +1247,30 @@
 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
 #undef TM_IN_SYS_TIME
 
-/* Define to 1 if on AIX 3.
-   System headers sometimes define this.
-   We just want to avoid a redefinition error message.  */
+/* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
 #endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
 /* Enable GNU extensions on systems that have them.  */
 #ifndef _GNU_SOURCE
 # undef _GNU_SOURCE
 #endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
 
 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
 #undef _LARGEFILE_SOURCE
@@ -1289,20 +1288,6 @@
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
 
-/* Enable extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
-
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
diff --git a/include/asterisk/compiler.h b/include/asterisk/compiler.h
index 15a750f9c1e77bf7302996273c7e5ff989c52aa6..b2db7ffdb31c034a999d8e93e5b1a177b2a6bf09 100644
--- a/include/asterisk/compiler.h
+++ b/include/asterisk/compiler.h
@@ -68,16 +68,4 @@
 /* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */
 #define SENTINEL ((char *)NULL)
 
-#ifdef HAVE_ATTRIBUTE_weak
-#define attribute_weak __attribute__((weak))
-#else
-#define attribute_weak
-#endif
-
-#ifdef HAVE_ATTRIBUTE_weak_import
-#define attribute_weak_import __attribute__((weak_import))
-#else
-#define attribute_weak_import
-#endif
-
 #endif /* _ASTERISK_COMPILER_H */
diff --git a/include/asterisk/monitor.h b/include/asterisk/monitor.h
index 4014939bb6f5a26f5158773af3d82e9a6ae60342..e29622ea8dfeab7b9361c133ad7b00dd539ea7ae 100644
--- a/include/asterisk/monitor.h
+++ b/include/asterisk/monitor.h
@@ -51,27 +51,34 @@ struct ast_channel_monitor {
 };
 
 /* Start monitoring a channel */
-AST_OPTIONAL_API(int, ast_monitor_start, (struct ast_channel *chan, const char
-	*format_spec, const char *fname_base, int need_lock, int stream_action),
-	{ return -1; });
+AST_OPTIONAL_API(int, ast_monitor_start,
+		 (struct ast_channel *chan, const char *format_spec,
+		  const char *fname_base, int need_lock, int stream_action),
+		 { return -1; });
 
 /* Stop monitoring a channel */
-AST_OPTIONAL_API(int, ast_monitor_stop, (struct ast_channel *chan, int
-	need_lock), { return -1; });
+AST_OPTIONAL_API(int, ast_monitor_stop,
+		 (struct ast_channel *chan, int need_lock),
+		 { return -1; });
 
 /* Change monitoring filename of a channel */
-AST_OPTIONAL_API(int, ast_monitor_change_fname, (struct ast_channel *chan,
-	const char *fname_base, int need_lock), { return -1; });
+AST_OPTIONAL_API(int, ast_monitor_change_fname,
+		 (struct ast_channel *chan, const char *fname_base,
+		  int need_lock),
+		 { return -1; });
 
-AST_OPTIONAL_API(void, ast_monitor_setjoinfiles, (struct ast_channel *chan,
-	int turnon), { return; });
+AST_OPTIONAL_API(void, ast_monitor_setjoinfiles,
+		 (struct ast_channel *chan, int turnon),
+		 { return; });
 
 /* Pause monitoring of a channel */
-AST_OPTIONAL_API(int, ast_monitor_pause, (struct ast_channel *chan),
-	{ return -1; });
+AST_OPTIONAL_API(int, ast_monitor_pause,
+		 (struct ast_channel *chan),
+		 { return -1; });
 
 /* Unpause monitoring of a channel */
-AST_OPTIONAL_API(int, ast_monitor_unpause, (struct ast_channel *chan),
-	{ return -1; });
+AST_OPTIONAL_API(int, ast_monitor_unpause,
+		 (struct ast_channel *chan),
+		 { return -1; });
 
 #endif /* _ASTERISK_MONITOR_H */
diff --git a/include/asterisk/optional_api.h b/include/asterisk/optional_api.h
index 1af596ec1a4e01b96e0be67302a8fe7441ce21fa..df875a8498b9d046787e906c435a730697c5fa3b 100644
--- a/include/asterisk/optional_api.h
+++ b/include/asterisk/optional_api.h
@@ -32,14 +32,14 @@
  *
  * To accomodate this situation, the AST_OPTIONAL_API macro allows an API
  * function to be declared in a special way, if Asterisk being built on a
- * platform that supports the GCC 'weak' and 'alias' attributes. If so,
- * the API function is actually a weak symbol, which means if the provider
- * of the API is not loaded, the symbol can still be referenced (unlike a
+ * platform that supports special compiler and dynamic linker attributes.
+ * If so the API function will actually be a weak symbol, which means if the
+ * provider of the API is not loaded, the symbol can still be referenced (unlike a
  * strong symbol, which would cause an immediate fault if not defined when
  * referenced), but it will return NULL signifying the linker/loader was
  * not able to resolve the symbol. In addition, the macro defines a hidden
  * 'stub' version of the API call, using a provided function body, and uses
- * the alias attribute to make the API function symbol actually resolve to
+ * various methods to make the API function symbol actually resolve to
  * that hidden stub, but only when the *real* provider of the symbol has
  * not been found.
  *
@@ -57,13 +57,25 @@
  * safely know that the API is not available, and to avoid using any
  * other APIs from the not-present provider.
  *
+ * In addition to this declaration in the header file, the actual definition of
+ * the API function must use the AST_OPTIONAL_API_NAME macro to (possibly)
+ * modify the real name of the API function, depending on the specific
+ * implementation requirements. The corresponding example from res_agi.c:
+ *
+ * \code
+ * int AST_OPTIONAL_API_NAME(ast_agi_register)(struct ast_module *mod, agi_command *cmd)
+ * {
+ * ...
+ * }
+ * \endcode
+ *
  * In the module providing the API, the AST_OPTIONAL_API macro must
  * be informed that it should not build the hidden stub function or
  * apply special aliases to the function prototype; this can be done
  * by defining AST_API_MODULE just before including the header file
  * containing the AST_OPTIONAL_API macro calls.
  *
- * \note If the GCC 'weak' and 'alias' attributes are not available,
+ * \note If the platform does not provide adequate resources,
  * then the AST_OPTIONAL_API macro will result in a non-optional function
  * definition; this means that any consumers of the API functions so
  * defined will require that the provider of the API functions be
@@ -83,17 +95,115 @@
  */
 #define AST_OPTIONAL_API_UNAVAILABLE	INT_MIN
 
-#if defined(HAVE_ATTRIBUTE_weak_import) && !defined(AST_API_MODULE)
-#define AST_OPTIONAL_API(result, name, proto, stub)	result name proto __attribute__((weak_import));
-#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub)	result name proto __attribute__((weak_import,attr));
-#elif defined(HAVE_ATTRIBUTE_weak) && defined(HAVE_ATTRIBUTE_alias) && !defined(AST_API_MODULE) && !defined(HAVE_ATTRIBUTE_weak_import)
-#define AST_OPTIONAL_API(result, name, proto, stub)	\
-	static result __##name proto stub;		\
-	result __attribute__((weak, alias("__" __stringify(name)))) name proto;
-#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub)		\
-	static result __attribute__((attr)) __##name proto stub;	\
-	result __attribute__((weak, alias("__" __stringify(name)), attr)) name proto;
+
+#if defined(HAVE_ATTRIBUTE_weak_import)
+
+/*
+ * This is the Darwin (Mac OS/X) implementation, that only provides the
+ * 'weak_import' compiler attribute for weak symbols. On this platform,
+ *
+ * - The module providing the API will only provide a '__' prefixed version
+ *   of the API function to other modules (this will be hidden from the other
+ *   modules by the macros), so any modules compiled against older versions
+ *   of the module that provided a non-prefixed version of the API function
+ *   will fail to link at runtime.
+ * - In the API module itself, access to the API function without using a
+ *   prefixed name is provided by a static pointer variable that holds the
+ *   function address.
+ * - 'Consumer' modules of the API will use a combination of a weak_import
+ *   symbol, a local stub function, a pointer variable and a constructor function
+ *   (which initializes that pointer variable as the module is being loaded)
+ *   to provide safe, optional access to the API function without any special
+ *   code being required.
+ */
+
+#define AST_OPTIONAL_API_NAME(name) __##name
+
+#if defined(AST_API_MODULE)
+
+#define AST_OPTIONAL_API(result, name, proto, stub) \
+	result AST_OPTIONAL_API_NAME(name) proto; \
+	static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name);
+
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub)	\
+	result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \
+	static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name);
+
+#else
+
+#define AST_OPTIONAL_API(result, name, proto, stub) \
+	static result __stub__##name proto stub; \
+	__attribute__((weak_import)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \
+	static attribute_unused typeof(__stub__##name) * name; \
+	static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; }
+
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
+	static __attribute__((attr)) result __stub__##name proto stub; \
+	__attribute__((attr, weak_import)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \
+	static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \
+	static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; }
+
+
+#endif
+
+/* End of Darwin (Mac OS/X) implementation */
+
+#elif defined(HAVE_ATTRIBUTE_weakref)
+
+/*
+ * This is the generic GCC implementation, used when the 'weakref'
+ * compiler attribute is available. On these platforms:
+ *
+ * - The module providing the API will provide a '__' prefixed version
+ *   of the API function to other modules (this will be hidden from the other
+ *   modules by the macros), and also a non-prefixed alias so that modules
+ *   compiled against older versions of the module that provided a non-prefixed
+ *    version of the API function will continue to link properly.
+ * - In the API module itself, access to the API function without using a
+ *   prefixed name is provided by the non-prefixed alias described above.
+ * - 'Consumer' modules of the API will use a combination of a weakref
+ *   symbol, a local stub function, a pointer variable and a constructor function
+ *   (which initializes that pointer variable as the module is being loaded)
+ *   to provide safe, optional access to the API function without any special
+ *   code being required.
+ */
+
+#define AST_OPTIONAL_API_NAME(name) __##name
+
+#if defined(AST_API_MODULE)
+
+#define AST_OPTIONAL_API(result, name, proto, stub) \
+	result AST_OPTIONAL_API_NAME(name) proto; \
+	__attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name;
+
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub)	\
+	result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \
+	__attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name;
+
+#else
+
+#define AST_OPTIONAL_API(result, name, proto, stub) \
+	static result __stub__##name proto stub; \
+	static __attribute__((weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \
+	static attribute_unused typeof(__stub__##name) * name; \
+	static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; }
+
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
+	static __attribute__((attr)) result __stub__##name proto stub; \
+	static __attribute__((attr, weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \
+	static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \
+	static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; }
+
+#endif
+
+/* End of GCC implementation */
+
 #else
+
+/* This is the non-optional implementation. */
+
+#define AST_OPTIONAL_API_NAME(name) name
+
 /*!
  * \brief Define an optional API function
  *
@@ -108,7 +218,8 @@
  *                  { return AST_OPTIONAL_API_UNAVAILABLE; });
  * \endcode		 
  */
-#define AST_OPTIONAL_API(result, name, proto, stub) result name proto;
+#define AST_OPTIONAL_API(result, name, proto, stub) result AST_OPTIONAL_API_NAME(name) proto
+
 /*!
  * \brief Define an optional API function with compiler attributes
  *
@@ -118,7 +229,10 @@
  * \param proto The prototype (arguments) of the function
  * \param stub The code block that will be used by the hidden stub when needed
  */
-#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) result __attribute__((attr)) name proto;
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto
+
+/* End of non-optional implementation */
+
 #endif
 
 #undef AST_API_MODULE
diff --git a/include/asterisk/smdi.h b/include/asterisk/smdi.h
index 9dbec6288eb1a970bdd17e9907e5f43ce240417d..9d80c90714a34770aeb10cbae124c5fc1c9b560b 100644
--- a/include/asterisk/smdi.h
+++ b/include/asterisk/smdi.h
@@ -85,8 +85,9 @@ struct ast_smdi_md_message {
  */
 struct ast_smdi_interface;
 
-AST_OPTIONAL_API(void, ast_smdi_interface_unref, (struct ast_smdi_interface
-	*iface), { return; });
+AST_OPTIONAL_API(void, ast_smdi_interface_unref,
+		 (struct ast_smdi_interface *iface),
+		 { return; });
 
 /*! 
  * \brief Get the next SMDI message from the queue.
@@ -98,8 +99,9 @@ AST_OPTIONAL_API(void, ast_smdi_interface_unref, (struct ast_smdi_interface
  *
  * \return the next SMDI message, or NULL if there were no pending messages.
  */
-AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_pop, (struct
-	ast_smdi_interface *iface), { return NULL; });
+AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_pop,
+		 (struct ast_smdi_interface *iface),
+		 { return NULL; });
 
 /*!
  * \brief Get the next SMDI message from the queue.
@@ -114,7 +116,8 @@ AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_pop, (struct
  * the timeout has expired.
  */
 AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_wait,
-	(struct ast_smdi_interface *iface, int timeout), { return NULL; });
+		 (struct ast_smdi_interface *iface, int timeout),
+		 { return NULL; });
 
 /*!
  * \brief Put an SMDI message back in the front of the queue.
@@ -125,8 +128,9 @@ AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_wait,
  * should be used if a message was popped but is not going to be processed for
  * some reason, and the message needs to be returned to the queue.
  */
-AST_OPTIONAL_API(void, ast_smdi_md_message_putback, (struct ast_smdi_interface
-	*iface, struct ast_smdi_md_message *msg), { return; });
+AST_OPTIONAL_API(void, ast_smdi_md_message_putback,
+		 (struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg),
+		 { return; });
 
 /*!
  * \brief Get the next SMDI message from the queue.
@@ -139,7 +143,8 @@ AST_OPTIONAL_API(void, ast_smdi_md_message_putback, (struct ast_smdi_interface
  * \return the next SMDI message, or NULL if there were no pending messages.
  */
 AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_pop,
-	(struct ast_smdi_interface *iface), { return NULL; });
+		 (struct ast_smdi_interface *iface),
+		 { return NULL; });
 
 /*!
  * \brief Get the next SMDI message from the queue.
@@ -154,10 +159,12 @@ AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_pop,
  * the timeout has expired.
  */
 AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_wait,
-	(struct ast_smdi_interface *iface, int timeout), { return NULL; });
-AST_OPTIONAL_API(struct ast_smdi_mwi_message *,
-	ast_smdi_mwi_message_wait_station, (struct ast_smdi_interface *iface, int
-	timeout, const char *station), { return NULL; });
+		 (struct ast_smdi_interface *iface, int timeout),
+		 { return NULL; });
+
+AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_wait_station,
+		 (struct ast_smdi_interface *iface, int	timeout, const char *station),
+		 { return NULL; });
 
 /*!
  * \brief Put an SMDI message back in the front of the queue.
@@ -168,8 +175,9 @@ AST_OPTIONAL_API(struct ast_smdi_mwi_message *,
  * should be used if a message was popped but is not going to be processed for
  * some reason, and the message needs to be returned to the queue.
  */
-AST_OPTIONAL_API(void, ast_smdi_mwi_message_putback, (struct ast_smdi_interface
-	*iface, struct ast_smdi_mwi_message *msg), { return; });
+AST_OPTIONAL_API(void, ast_smdi_mwi_message_putback,
+		 (struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg),
+		 { return; });
 
 /*!
  * \brief Find an SMDI interface with the specified name.
@@ -180,30 +188,35 @@ AST_OPTIONAL_API(void, ast_smdi_mwi_message_putback, (struct ast_smdi_interface
  * #ASTOBJ_UNREF(iface, ast_smdi_interface_destroy).
  */
 AST_OPTIONAL_API(struct ast_smdi_interface *, ast_smdi_interface_find,
-	(const char *iface_name), { return NULL; });
+		 (const char *iface_name),
+		 { return NULL; });
 
 /*!
  * \brief Set the MWI indicator for a mailbox.
  * \param iface the interface to use.
  * \param mailbox the mailbox to use.
  */
-AST_OPTIONAL_API(int, ast_smdi_mwi_set, (struct ast_smdi_interface *iface,
-	const char *mailbox), { return -1; });
+AST_OPTIONAL_API(int, ast_smdi_mwi_set,
+		 (struct ast_smdi_interface *iface, const char *mailbox),
+		 { return -1; });
 
 /*! 
  * \brief Unset the MWI indicator for a mailbox.
  * \param iface the interface to use.
  * \param mailbox the mailbox to use.
  */
-AST_OPTIONAL_API(int, ast_smdi_mwi_unset, (struct ast_smdi_interface *iface,
-	const char *mailbox), { return -1; });
+AST_OPTIONAL_API(int, ast_smdi_mwi_unset,
+		 (struct ast_smdi_interface *iface, const char *mailbox),
+		 { return -1; });
 
 /*! \brief ast_smdi_md_message destructor. */
 AST_OPTIONAL_API(void, ast_smdi_md_message_destroy,
-	(struct ast_smdi_md_message *msg), { return; });
+		 (struct ast_smdi_md_message *msg),
+		 { return; });
 
 /*! \brief ast_smdi_mwi_message destructor. */
-AST_OPTIONAL_API(void, ast_smdi_mwi_message_destroy, (struct
-	ast_smdi_mwi_message *msg), { return; });
+AST_OPTIONAL_API(void, ast_smdi_mwi_message_destroy,
+		 (struct ast_smdi_mwi_message *msg),
+		 { return; });
 
 #endif /* !ASTERISK_SMDI_H */
diff --git a/main/Makefile b/main/Makefile
index 3d3d298286f5db0bbfa20d8fb04b48cacab36425..5b8ecf88bd13263cf4eef8cc2c1ce62ca56545fa 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -44,9 +44,7 @@ endif
 
 ifneq ($(findstring darwin,$(OSARCH)),)
   AST_LIBS+=-lresolv
-  ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
-    ASTLINK=-Wl,-dynamic
-  endif
+  ASTLINK=-undefined suppress -force_flat_namespace
 else
 # These are used for all but Darwin
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
diff --git a/res/res_agi.c b/res/res_agi.c
index 6c6e88290256f2585f4716155ce604291301ccf3..dff477e09d9017d461e7e023686d80700e1a08e9 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -927,7 +927,7 @@ static agi_command *find_command(const char * const cmds[], int exact);
 AST_THREADSTORAGE(agi_buf);
 #define AGI_BUF_INITSIZE 256
 
-int ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...)
+int AST_OPTIONAL_API_NAME(ast_agi_send)(int fd, struct ast_channel *chan, char *fmt, ...)
 {
 	int res = 0;
 	va_list ap;
@@ -2925,7 +2925,7 @@ static char *help_workhorse(int fd, const char * const match[])
 	return CLI_SUCCESS;
 }
 
-int ast_agi_register(struct ast_module *mod, agi_command *cmd)
+int AST_OPTIONAL_API_NAME(ast_agi_register)(struct ast_module *mod, agi_command *cmd)
 {
 	char fullcmd[MAX_CMD_LEN];
 
@@ -2956,7 +2956,7 @@ int ast_agi_register(struct ast_module *mod, agi_command *cmd)
 	}
 }
 
-int ast_agi_unregister(struct ast_module *mod, agi_command *cmd)
+int AST_OPTIONAL_API_NAME(ast_agi_unregister)(struct ast_module *mod, agi_command *cmd)
 {
 	struct agi_command *e;
 	int unregistered = 0;
@@ -2995,7 +2995,7 @@ int ast_agi_unregister(struct ast_module *mod, agi_command *cmd)
 	return unregistered;
 }
 
-int ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
+int AST_OPTIONAL_API_NAME(ast_agi_register_multiple)(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
 {
 	unsigned int i, x = 0;
 
@@ -3025,7 +3025,7 @@ int ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, u
 	return 0;
 }
 
-int ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
+int AST_OPTIONAL_API_NAME(ast_agi_unregister_multiple)(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
 {
 	unsigned int i;
 	int res = 0;
diff --git a/res/res_agi.exports b/res/res_agi.exports
index e1b11968fae25f30ece29f83ae6ed0c0a4abf33c..a305cf2b9055d4d34c26235e422e6b227668b76f 100644
--- a/res/res_agi.exports
+++ b/res/res_agi.exports
@@ -1,7 +1,10 @@
 {
 	global:
-		ast_agi_register;
-		ast_agi_unregister;
+		*ast_agi_register;
+		*ast_agi_unregister;
+		*ast_agi_register_multiple;
+		*ast_agi_unregister_multiple;
+		*ast_agi_send;
 	local:
 		*;
 };
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 5f25d8dceaf23b2458ce1e8fab5e8bf05372dcbe..f296cf612d0f8eaa0503d9edf558ca5ab4aa0bee 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -283,8 +283,8 @@ static int ast_monitor_set_state(struct ast_channel *chan, int state)
  * \retval 0 on success
  * \retval -1 on failure
  */
-int ast_monitor_start(	struct ast_channel *chan, const char *format_spec,
-		const char *fname_base, int need_lock, int stream_action)
+int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const char *format_spec,
+					     const char *fname_base, int need_lock, int stream_action)
 {
 	int res = 0;
 
@@ -423,7 +423,7 @@ static const char *get_soxmix_format(const char *format)
  * Stop the recording, close any open streams, mix in/out channels if required
  * \return Always 0
 */
-int ast_monitor_stop(struct ast_channel *chan, int need_lock)
+int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_lock)
 {
 	int delfiles = 0;
 
@@ -516,13 +516,13 @@ int ast_monitor_stop(struct ast_channel *chan, int need_lock)
 
 
 /*! \brief Pause monitoring of channel */
-int ast_monitor_pause(struct ast_channel *chan)
+int AST_OPTIONAL_API_NAME(ast_monitor_pause)(struct ast_channel *chan)
 {
 	return ast_monitor_set_state(chan, AST_MONITOR_PAUSED);
 }
 
 /*! \brief Unpause monitoring of channel */
-int ast_monitor_unpause(struct ast_channel *chan)
+int AST_OPTIONAL_API_NAME(ast_monitor_unpause)(struct ast_channel *chan)
 {
 	return ast_monitor_set_state(chan, AST_MONITOR_RUNNING);
 }
@@ -547,7 +547,7 @@ static int unpause_monitor_exec(struct ast_channel *chan, const char *data)
  * \retval 0 on success.
  * \retval -1 on failure.
 */
-int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, int need_lock)
+int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, const char *fname_base, int need_lock)
 {
 	if (ast_strlen_zero(fname_base)) {
 		ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to null\n", chan->name);
@@ -808,7 +808,7 @@ static int change_monitor_action(struct mansession *s, const struct message *m)
 	return 0;
 }
 
-void ast_monitor_setjoinfiles(struct ast_channel *chan, int turnon)
+void AST_OPTIONAL_API_NAME(ast_monitor_setjoinfiles)(struct ast_channel *chan, int turnon)
 {
 	if (chan->monitor)
 		chan->monitor->joinfiles = turnon;
diff --git a/res/res_monitor.exports b/res/res_monitor.exports
index 4352dc8b61a1043873935b525e2ec8ea55e7dc35..0c97f6a808cd46d8313f7c0a012e4fc8097d2e97 100644
--- a/res/res_monitor.exports
+++ b/res/res_monitor.exports
@@ -1,11 +1,11 @@
 {
 	global:
-		ast_monitor_change_fname;
-		ast_monitor_pause;
-		ast_monitor_setjoinfiles;
-		ast_monitor_start;
-		ast_monitor_stop;
-		ast_monitor_unpause;
+		*ast_monitor_change_fname;
+		*ast_monitor_pause;
+		*ast_monitor_setjoinfiles;
+		*ast_monitor_start;
+		*ast_monitor_stop;
+		*ast_monitor_unpause;
 	local:
 		*;
 };
diff --git a/res/res_smdi.c b/res/res_smdi.c
index e6cf8b4f64e803d7d2cf637956768c271f782977..3f714992659031af9159ce84d987b2641d6715fd 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -251,7 +251,7 @@ static void ast_smdi_interface_destroy(struct ast_smdi_interface *iface)
 	ast_module_unref(ast_module_info->self);
 }
 
-void ast_smdi_interface_unref(struct ast_smdi_interface *iface)
+void AST_OPTIONAL_API_NAME(ast_smdi_interface_unref)(struct ast_smdi_interface *iface)
 {
 	ASTOBJ_UNREF(iface, ast_smdi_interface_destroy);
 }
@@ -311,17 +311,17 @@ static int smdi_toggle_mwi(struct ast_smdi_interface *iface, const char *mailbox
 	return 0;
 }
 
-int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
+int AST_OPTIONAL_API_NAME(ast_smdi_mwi_set)(struct ast_smdi_interface *iface, const char *mailbox)
 {
 	return smdi_toggle_mwi(iface, mailbox, 1);
 }
 
-int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
+int AST_OPTIONAL_API_NAME(ast_smdi_mwi_unset)(struct ast_smdi_interface *iface, const char *mailbox)
 {
 	return smdi_toggle_mwi(iface, mailbox, 0);
 }
 
-void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_md_message *md_msg)
+void AST_OPTIONAL_API_NAME(ast_smdi_md_message_putback)(struct ast_smdi_interface *iface, struct ast_smdi_md_message *md_msg)
 {
 	ast_mutex_lock(&iface->md_q_lock);
 	ASTOBJ_CONTAINER_LINK_START(&iface->md_q, md_msg);
@@ -329,7 +329,7 @@ void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_sm
 	ast_mutex_unlock(&iface->md_q_lock);
 }
 
-void ast_smdi_mwi_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *mwi_msg)
+void AST_OPTIONAL_API_NAME(ast_smdi_mwi_message_putback)(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *mwi_msg)
 {
 	ast_mutex_lock(&iface->mwi_q_lock);
 	ASTOBJ_CONTAINER_LINK_START(&iface->mwi_q, mwi_msg);
@@ -590,36 +590,36 @@ static void *smdi_message_wait(struct ast_smdi_interface *iface, int timeout,
 	return NULL;
 }
 
-struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface)
+struct ast_smdi_md_message * AST_OPTIONAL_API_NAME(ast_smdi_md_message_pop)(struct ast_smdi_interface *iface)
 {
 	return smdi_msg_pop(iface, SMDI_MD);
 }
 
-struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
+struct ast_smdi_md_message * AST_OPTIONAL_API_NAME(ast_smdi_md_message_wait)(struct ast_smdi_interface *iface, int timeout)
 {
 	struct ast_flags options = { 0 };
 	return smdi_message_wait(iface, timeout, SMDI_MD, NULL, options);
 }
 
-struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface)
+struct ast_smdi_mwi_message * AST_OPTIONAL_API_NAME(ast_smdi_mwi_message_pop)(struct ast_smdi_interface *iface)
 {
 	return smdi_msg_pop(iface, SMDI_MWI);
 }
 
-struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout)
+struct ast_smdi_mwi_message * AST_OPTIONAL_API_NAME(ast_smdi_mwi_message_wait)(struct ast_smdi_interface *iface, int timeout)
 {
 	struct ast_flags options = { 0 };
 	return smdi_message_wait(iface, timeout, SMDI_MWI, NULL, options);
 }
 
-struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait_station(struct ast_smdi_interface *iface, int timeout,
+struct ast_smdi_mwi_message * AST_OPTIONAL_API_NAME(ast_smdi_mwi_message_wait_station)(struct ast_smdi_interface *iface, int timeout,
 	const char *station)
 {
 	struct ast_flags options = { 0 };
 	return smdi_message_wait(iface, timeout, SMDI_MWI, station, options);
 }
 
-struct ast_smdi_interface *ast_smdi_interface_find(const char *iface_name)
+struct ast_smdi_interface * AST_OPTIONAL_API_NAME(ast_smdi_interface_find)(const char *iface_name)
 {
 	return (ASTOBJ_CONTAINER_FIND(&smdi_ifaces, iface_name));
 }
@@ -816,12 +816,12 @@ static void *smdi_read(void *iface_p)
 	return NULL;
 }
 
-void ast_smdi_md_message_destroy(struct ast_smdi_md_message *msg)
+void AST_OPTIONAL_API_NAME(ast_smdi_md_message_destroy)(struct ast_smdi_md_message *msg)
 {
 	ast_free(msg);
 }
 
-void ast_smdi_mwi_message_destroy(struct ast_smdi_mwi_message *msg)
+void AST_OPTIONAL_API_NAME(ast_smdi_mwi_message_destroy)(struct ast_smdi_mwi_message *msg)
 {
 	ast_free(msg);
 }
diff --git a/res/res_smdi.exports b/res/res_smdi.exports
index 7fe3edff30dc14de8cbd859c37d290fdcbb6e869..e140aba9f1dc258a420d2a5bf6ae4904c245a0b5 100644
--- a/res/res_smdi.exports
+++ b/res/res_smdi.exports
@@ -1,18 +1,18 @@
 {
 	global:
-		ast_smdi_interface_find;
-		ast_smdi_interface_unref;
-		ast_smdi_md_message_destroy;
-		ast_smdi_md_message_pop;
-		ast_smdi_md_message_putback;
-		ast_smdi_md_message_wait;
-		ast_smdi_mwi_message_destroy;
-		ast_smdi_mwi_message_pop;
-		ast_smdi_mwi_message_putback;
-		ast_smdi_mwi_message_wait;
-		ast_smdi_mwi_message_wait_station;
-		ast_smdi_mwi_set;
-		ast_smdi_mwi_unset;
+		*ast_smdi_interface_find;
+		*ast_smdi_interface_unref;
+		*ast_smdi_md_message_destroy;
+		*ast_smdi_md_message_pop;
+		*ast_smdi_md_message_putback;
+		*ast_smdi_md_message_wait;
+		*ast_smdi_mwi_message_destroy;
+		*ast_smdi_mwi_message_pop;
+		*ast_smdi_mwi_message_putback;
+		*ast_smdi_mwi_message_wait;
+		*ast_smdi_mwi_message_wait_station;
+		*ast_smdi_mwi_set;
+		*ast_smdi_mwi_unset;
 	local:
 		*;
 };