Для сборки понадобится установленный Homebrew
Что это и как установить, смотреть здесь
Для сборки Asterisk clang не подходит, так как он пока не поддерживает вложенные функции (и, вероятно, никогда не будет)
Поэтому с помощью Homebrew устанавливаем gcc, а также библиотеку jansson
brew install gcc jansson
Когда gcc установлен, распаковываем и конфигурируем исходники Asterisk
Я предпочитаю устанавливать его в /opt/asterisk, а кому-то может быть удобнее /usr/local
CC=gcc-4.9 CXX=g++-4.9 ./configure --prefix=/opt/asterisk --with-jansson=/usr/local
Скачивание исходников модуля format_mp3 по желанию
contrib/scripts/get_mp3_source.sh
К сожалению, при конфигурировании исходников, скрипт не может найти некоторые функции в системных хедерах, хотя они есть (не там, где обычно, и это касается только OS X 10.10)
Во-вторых, у gcc нет системного хедера, в котором бы объявлялись макросы для __attribute__
Ну, и наконец, хедеры snmp в OS X используют т.н. «новый» api, и объявление RONLY недоступно по-умолчанию.
Так что, после конфигурирования накладываем следующий патч:
patch -p1 <<EOF diff --git a/Makefile b/Makefile index 66a8411..0c7606c 100644 --- a/Makefile +++ b/Makefile @@ -255,7 +255,7 @@ MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree) ifneq ($(findstring darwin,$(OSARCH)),) _ASTCFLAGS+=-D__Darwin__ -mmacosx-version-min=10.6 _SOLINK=-mmacosx-version-min=10.6 -Xlinker -undefined -Xlinker dynamic_lookup - _SOLINK+=/usr/lib/bundle1.o +# _SOLINK+=/usr/lib/bundle1.o SOLINK=-bundle $(_SOLINK) DYLINK=-Xlinker -dylib $(_SOLINK) _ASTLDFLAGS+=-L/usr/local/lib diff --git a/include/asterisk/autoconfig.h b/include/asterisk/autoconfig.h index b4d56af..e2efed6 100644 --- a/include/asterisk/autoconfig.h +++ b/include/asterisk/autoconfig.h @@ -326,7 +326,7 @@ /* #undef HAVE_HOARD */ /* Define to 1 if you have the `htonll' function. */ -/* #undef HAVE_HTONLL */ +#define HAVE_HTONLL 1 /* Define to 1 if you have the iCal library. */ /* #undef HAVE_ICAL */ @@ -526,7 +526,7 @@ /* #undef HAVE_NEWT */ /* Define to 1 if you have the `ntohll' function. */ -/* #undef HAVE_NTOHLL */ +#define HAVE_NTOHLL 1 /* Define to 1 if your C library can safely print NULL to string formats. */ #define HAVE_NULLSAFE_PRINTF 1 @@ -1354,5 +1354,45 @@ code using `volatile' can become incorrect without. Disable with care. */ /* #undef volatile */ +#ifndef __attribute_malloc__ +#define __attribute_malloc__ __attribute__ ((__malloc__)) +#endif + +#ifndef __attribute_pure__ +#define __attribute_pure__ __attribute__ ((__pure__)) +#endif + +#ifndef __attribute_used__ +#define __attribute_used__ __attribute__ ((__used__)) +#endif + +#ifndef __attribute_noinline__ +#define __attribute_noinline__ __attribute__ ((__noinline__)) +#endif + +#ifndef __attribute_deprecated__ +#define __attribute_deprecated__ __attribute__ ((__deprecated__)) +#endif + +#ifndef __attribute_format_arg__ +#define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x))) +#endif + +#ifndef __attribute_format_strfmon__ +#define __attribute_format_strfmon__(a,b) __attribute__ ((__format__ (__strfmon__, a, b))) +#endif + +#ifndef __nonnull +#define __nonnull(params) __attribute__ ((__nonnull__ params)) +#endif + +#ifndef __restrict_arr +#define __restrict_arr __restrict +#endif + +#ifndef __attribute_warn_unused_result__ +#define __attribute_warn_unused_result__ __attribute__ ((warn_unused_result)) +#endif + #endif diff --git a/main/Makefile b/main/Makefile index 0fa2192..d4659bd 100644 --- a/main/Makefile +++ b/main/Makefile @@ -60,7 +60,7 @@ endif ifneq ($(findstring darwin,$(OSARCH)),) AST_LIBS+=-lresolv ASTLINK=-mmacosx-version-min=10.6 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace - ASTLINK+=/usr/lib/bundle1.o +# ASTLINK+=/usr/lib/bundle1.o else # These are used for all but Darwin ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) diff --git a/res/snmp/agent.c b/res/snmp/agent.c index b607ecf..5af346b 100644 --- a/res/snmp/agent.c +++ b/res/snmp/agent.c @@ -63,6 +63,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419592 $") #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> +#if !defined(RONLY) && defined(NETSNMP_OLDAPI_RONLY) +#define RONLY NETSNMP_OLDAPI_RONLY +#endif + #include "asterisk/paths.h" /* need ast_config_AST_SOCKET */ #include "asterisk/channel.h" #include "asterisk/logger.h" EOF
Выбираем набор модулей
make menuselect
Строим Asterisk, устанавливаем и радуемся
make && make install && make samples
Чтобы Asterisk автоматически запускался под учетной записью текущего пользователя, можно создать файл ~/Library/LaunchAgents/org.asterisk.asterisk.plist со следующим содержимым
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>org.asterisk.asterisk</string> <key>ProgramArguments</key> <array> <string>/opt/asterisk/sbin/asterisk</string> <string>-fvvvvv</string> </array> <key>RunAtLoad</key> <true/> <key>WorkingDirectory</key> <string>/opt/asterisk</string> </dict> </plist>
и выполнить
launchctl ~/Library/LaunchAgents/org.asterisk.asterisk.plist