Skip to content
Snippets Groups Projects
configure.ac 82.2 KiB
Newer Older
# Process this file with autoconf to produce a configure script.
#
# Make sure we use autoconf 2.60 to generate the "configure" script,
# in case we want to commit it. Other than that, version 2.59 is
# perfectly fine for our purposes, so people who want to modify
# this file just have to remember to set the AC_PREREQ argument
# to something that suits their needs.
AC_INIT([asterisk], [trunk], [https://issues.asterisk.org])

# cross-compile macros
AC_CANONICAL_BUILD
AC_CANONICAL_HOST

# check existence of the package
AC_CONFIG_SRCDIR([main/asterisk.c])
AC_CONFIG_AUX_DIR(`pwd`)

AC_COPYRIGHT("Asterisk")
AC_REVISION($Revision$)

# preserve any CFLAGS or LDFLAGS that may be set
# NOTE: This must be done before calling any macros that end up
# calling AC_PROG_CC or the like, since they will set a default
# set of CFLAGS ("-g -O2") if the user did not supply any, and
# we don't want those default flags to be carried over into the
# rest of the build system since we have other means of controlling
# debugging symbol generation and optimization.
CONFIG_CFLAGS="${CFLAGS}"
CONFIG_LDFLAGS="${LDFLAGS}"
AC_SUBST(CONFIG_CFLAGS)
AC_SUBST(CONFIG_LDFLAGS)

# specify output header file
AC_CONFIG_HEADER(include/asterisk/autoconfig.h)

# Note: AC_PROG_CC *must* be specified before AC_USE_SYSTEM_EXTENSIONS or any
# other macro that uses the C compiler, or the default order will be used.
AC_PROG_CC([gcc cc])
AC_USE_SYSTEM_EXTENSIONS	dnl note- does not work on FreeBSD

# System default paths
AC_SUBST([astsbindir],        ['${sbindir}'])dnl
AC_SUBST([astetcdir],         ['${sysconfdir}/asterisk'])dnl
AC_SUBST([astheaderdir],      ['${includedir}/asterisk'])dnl
AC_SUBST([astlibdir],         ['${libdir}'])dnl
AC_SUBST([astmoddir],         ['${libdir}/asterisk/modules'])dnl
AC_SUBST([astmandir],         ['${mandir}'])dnl
AC_SUBST([astvarlibdir],      ['${localstatedir}/lib/asterisk'])dnl
AC_SUBST([astdatadir],        ['${astvarlibdir}'])dnl
AC_SUBST([astdbdir],          ['${astvarlibdir}'])dnl
AC_SUBST([astkeydir],         ['${astvarlibdir}'])dnl
AC_SUBST([astspooldir],       ['${localstatedir}/spool/asterisk'])dnl
AC_SUBST([astlogdir],         ['${localstatedir}/log/asterisk'])dnl
AC_SUBST([astvarrundir],      ['${localstatedir}/run/asterisk'])dnl

case "${host_os}" in
     *bsd*)
     if test ${prefix} = 'NONE'; then
        astvarlibdir='${prefix}/share/asterisk'
        astdbdir='${localstatedir}/db/asterisk'
     fi
     ;;
     darwin*)
     if test ${prefix} = 'NONE'; then
        astvarrundir='/Library/Application Support/Asterisk/Run'
     fi
     ;;
esac
     ac_default_prefix=/usr/local
     CPPFLAGS=-I/usr/local/include
     LDFLAGS=-L/usr/local/lib
     ac_default_prefix=/usr/local
     if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then
        if test ${sysconfdir} = '${prefix}/etc'; then
           astetcdir=/etc/asterisk
        fi
        if test ${mandir} = '${prefix}/man'; then
           astmandir=/usr/share/man
        fi
     fi
     CPPFLAGS=-I/usr/local/include
     LDFLAGS=-L/usr/local/lib
     ;;
     ac_default_prefix=/usr/local
     if test ${prefix} = 'NONE'; then
        astmoddir='/Library/Application Support/Asterisk/Modules'
        astvarlibdir='/Library/Application Support/Asterisk'
        astlogdir=/Library/Logs/Asterisk
        astvarrundir='/Library/Application Support/Asterisk/Run'
     AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.])
     AC_DEFINE([_DARWIN_UNLIMITED_SELECT], 1, [Define to 1 if running on Darwin.])
     solaris*)
     if test ${prefix} = 'NONE'; then
        astetcdir=/var/etc/asterisk
        astsbindir=/opt/asterisk/sbin
        astlibdir=/opt/asterisk/lib
        astheaderdir=/opt/asterisk/include
        astmandir=/opt/asterisk/man
        astvarlibdir=/var/opt/asterisk
        astspooldir=/var/spool/asterisk
        astlogdir=/var/log/asterisk
        astvarrundir=/var/run/asterisk
     fi
     ;;
     ac_default_prefix=/usr
     if test ${prefix} = '/usr' || test ${prefix} = 'NONE'; then
        if test ${sysconfdir} = '${prefix}/etc'; then
           sysconfdir=/etc
        fi
        if test ${mandir} = '${prefix}/man'; then
           mandir=/usr/share/man
        fi
if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then
     if test ${localstatedir} = '${prefix}/var'; then
        localstatedir=/var
     fi
BUILD_PLATFORM=${build}
BUILD_CPU=${build_cpu}
BUILD_VENDOR=${build_vendor}
BUILD_OS=${build_os}

AC_SUBST(BUILD_PLATFORM)
AC_SUBST(BUILD_CPU)
AC_SUBST(BUILD_VENDOR)
AC_SUBST(BUILD_OS)

HOST_PLATFORM=${host}
HOST_CPU=${host_cpu}
HOST_VENDOR=${host_vendor}
HOST_OS=${host_os}

AC_SUBST(HOST_PLATFORM)
AC_SUBST(HOST_CPU)
AC_SUBST(HOST_VENDOR)
AC_SUBST(HOST_OS)
     netbsd*)
     OSARCH=NetBSD
     ;;
Jason Parker's avatar
Jason Parker committed
     openbsd*)
     OSARCH=OpenBSD
     ;;
     solaris*)
     OSARCH=SunOS
     ;;
     linux-gnueabi* |  linux-gnuspe)
Tzafrir Cohen's avatar
Tzafrir Cohen committed
     kfreebsd*-gnu)
     OSARCH=kfreebsd-gnu
     ;;
     OSARCH=${host_os}
#  check for uname
AC_PATH_TOOL([UNAME], [uname], No)
if test ! x"${UNAME}" = xNo; then
   PBX_OSREV=$(${UNAME} -r)
fi
AC_SUBST(PBX_OSREV)

AH_TOP(
#ifndef ASTERISK_AUTOCONFIG_H
#define ASTERISK_AUTOCONFIG_H

if test "${cross_compiling}" = "yes";
then
   AC_CHECK_TOOL(CC, gcc, :)
   AC_CHECK_TOOL(CXX, g++, :)
   AC_CHECK_TOOL(RANLIB, ranlib, :)
fi

# Checks for programs.
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXXCPP
# This macro is just copied into our local acinclude.m4 from libtool.m4 so that
# the developers regenerating the configure script don't have to install libtool.
AST_PROG_LD	# note, does not work on FreeBSD
AC_CHECK_TOOLS([STRIP], [strip gstrip], :)
AC_CHECK_TOOLS([AR], [ar gar], :)
GNU_LD=0
if test "x$with_gnu_ld" = "xyes" ; then
   GNU_LD=1
fi
AC_SUBST(GNU_LD)

AC_PATH_PROG([BISON], [bison], :)
AC_PATH_PROG([CMP], [cmp], :)
AC_PATH_PROG([FLEX], [flex], :)
AC_PATH_PROG([PYTHON], [python], :)
AC_PATH_PROG([FIND], [find], :)
AC_PATH_PROG([COMPRESS], [compress], :)
AC_PATH_PROG([BASENAME], [basename], :)
AC_PATH_PROG([DIRNAME], [dirname], :)
AC_PATH_PROG([SHELL], [sh], :)
AC_PATH_PROG([LN], [ln], :)
Andrew Latham's avatar
Andrew Latham committed
AC_PATH_PROG([DOXYGEN], [doxygen], :)
AC_PATH_PROG([WGET], [wget], :)
AC_PATH_PROG([CURL], [curl], :)
AC_PATH_PROG([RUBBER], [rubber], :)
AC_PATH_PROG([CATDVI], [catdvi], :)
AC_PATH_PROG([KPATHSEA], [kpsewhich], :)
AC_PATH_PROG([XMLLINT], [xmllint], :)
if test "${WGET}" != ":" ; then
  DOWNLOAD=${WGET}
else if test "${CURL}" != ":" ; then
  DOWNLOAD="${CURL} -O --progress-bar -w \"%{url_effective}\n\""
else
  AC_PATH_PROG([FETCH], [fetch], [:])
  DOWNLOAD=${FETCH}
fi
AC_SUBST(DOWNLOAD)
AC_PATH_PROG([LDCONFIG], [ldconfig], :)
AC_PATH_PROG([SHA1SUM], [sha1sum], $ac_aux_dir/build_tools/sha1sum-sh)
AC_PATH_PROG([OPENSSL], [openssl], :)
AC_CACHE_CHECK([for bison that supports parse-param], [ac_cv_path_BISON2], [
	if test "x$BISON" != "x:" ; then
		# Create a temporary directory $tmp in $TMPDIR (default /tmp).
		# Use mktemp if possible; otherwise fall back on mkdir,
		# with $RANDOM to make collisions less likely.
		: ${TMPDIR=/tmp}
		{
		  tmp=`
		    (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
		  ` &&
		  test -n "$tmp" && test -d "$tmp"
		} || {
		  tmp=$TMPDIR/foo$$-$RANDOM
		  (umask 077 && mkdir "$tmp")
		} || exit $?
		cat >$tmp/test.y <<__EOL__
%parse-param {struct parse_io *parseio}
%%
file : { \$\$ = parseio->pval = 1; }
	;
%%
__EOL__
		${BISON} -o ${tmp}/test.tab.c ${tmp}/test.y >/dev/null 2>&1
		if test -e "${tmp}/test.tab.c"; then
			ac_cv_path_BISON2=${BISON}
		fi
		rm -rf ${tmp}
	fi
	])
if test "x${ac_cv_path_BISON2}" = "x" ; then
	BISON=:
	PBX_BISON=0
else
	PBX_BISON=1
fi
AC_SUBST(PBX_BISON)
if test "x${FLEX}" = "x:" ; then
	PBX_FLEX=0
else
	PBX_FLEX=1
AC_SUBST(PBX_FLEX)
AC_CHECK_TOOL([SOXMIX], [soxmix], [:])
if test "${SOXMIX}" != ":" ; then
	AC_DEFINE([HAVE_SOXMIX], 1, [Define to 1 if your system has soxmix application.])
fi

AC_CHECK_PROGS([MD5], [md5 md5sum gmd5sum digest])

if test "${MD5}" = "digest" ; then
AC_ARG_ENABLE([dev-mode],
	[AS_HELP_STRING([--enable-dev-mode],
		[Turn on developer mode])],
	[case "${enableval}" in
	      y|ye|yes) AST_DEVMODE=yes ;;
	      n|no)  AST_DEVMODE=no ;;
	      strict)
	      AST_DEVMODE=yes
	      AST_DEVMODE_STRICT=yes
	      ;;
	      *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
	esac])
AC_SUBST(AST_DEVMODE_STRICT)
AST_CODE_COVERAGE=no
AC_ARG_ENABLE([coverage],
	[AS_HELP_STRING([--enable-coverage],
		[Turn on code coverage tracking (for gcov)])],
	[case "${enableval}" in
	      y|ye|yes) AST_CODE_COVERAGE=yes ;;
	      n|no) AST_CODE_COVERAGE=no ;;
	      *) AC_MSG_ERROR(bad value ${enableval} for --enable-coverage)  ;;
	esac])
AC_SUBST(AST_CODE_COVERAGE)

# AST_EXT_LIB_SETUP is used to tell configure to handle variables for
# various packages.
# $1 is the prefix for the variables in makeopts and autoconfig.h
# $2 is the short comment, $4 is the long comment
# $3 is the name used in --with- or --without- flags for configure.
#
# Package option names should be in alphabetical order
# by the --with option name (the third field),
# to make things easier for the users.
AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
AST_EXT_LIB_SETUP([BFD], [Debug symbol decoding], [bfd])

# BKTR is used for backtrace support on platforms that do not
# have it natively.
AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo])
AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth])
AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap])
AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg])
AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg])
AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
AST_EXT_LIB_SETUP([CRYPT], [password and data encryption], [crypt])
AST_EXT_LIB_SETUP([CRYPTO], [OpenSSL Cryptography], [crypto])
AST_EXT_LIB_SETUP_OPTIONAL([OPENSSL_SRTP], [OpenSSL SRTP Extension Support], [CRYPTO], [crypto])
AST_EXT_LIB_SETUP_OPTIONAL([OPENSSL_EC], [OpenSSL Elliptic Curve Support], [CRYPTO], [crypto])
AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec], [avcodec])
AST_EXT_LIB_SETUP([GSM], [External GSM], [gsm], [, use 'internal' GSM otherwise])
AST_EXT_LIB_SETUP([ILBC], [System iLBC], [ilbc], [, use 'internal' iLBC otherwise])
AST_EXT_LIB_SETUP([GTK2], [gtk2], [gtk2])
AST_EXT_LIB_SETUP([GMIME], [GMime], [gmime])
AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
AST_EXT_LIB_SETUP([HOARD], [Hoard Memory Allocator], [hoard])
AST_EXT_LIB_SETUP([ICAL], [iCal], [ical])
AST_EXT_LIB_SETUP([ICONV], [Iconv], [iconv])
AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber], [iksemel])
AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
AST_EXT_LIB_SETUP([INOTIFY], [inotify support], [inotify])
AST_EXT_LIB_SETUP([IODBC], [iODBC], [iodbc])
AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux], [isdnnet])
AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
David M. Lee's avatar
David M. Lee committed
AST_EXT_LIB_SETUP([JANSSON], [Jansson JSON library], [jansson])
Joshua Colp's avatar
Joshua Colp committed
AST_EXT_LIB_SETUP([URIPARSER], [uriparser library], [uriparser])
AST_EXT_LIB_SETUP([KQUEUE], [kqueue support], [kqueue])
AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
AST_LIBCURL_CHECK_CONFIG([], [7.10.1])
AST_EXT_LIB_SETUP([LIBEDIT], [NetBSD Editline library], [libedit], [, use 'internal' Editline otherwise])
AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2])
AST_EXT_LIB_SETUP([LIBXSLT], [LibXSLT], [libxslt])
AST_EXT_LIB_SETUP_OPTIONAL([LIBXSLT_CLEANUP], [LibXSLT Library Cleanup Function], [LIBXSLT], [libxslt])
AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
AST_EXT_LIB_SETUP([MISDN], [mISDN user], [misdn])
AST_EXT_LIB_SETUP([MYSQLCLIENT], [MySQL client], [mysqlclient])
AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
AST_EXT_LIB_SETUP([NEON], [neon], [neon])
AST_EXT_LIB_SETUP([NEON29], [neon29], [neon29])
AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
AST_EXT_LIB_SETUP([OPENR2], [MFR2], [openr2])
AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
AST_EXT_LIB_SETUP([PJPROJECT], [PJPROJECT], [pjproject])
AST_EXT_LIB_SETUP([POPT], [popt], [popt])
AST_EXT_LIB_SETUP_OPTIONAL([PJ_TRANSACTION_GRP_LOCK], [PJSIP Transaction Group Lock Support], [PJPROJECT], [pjsip])
AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_REPLACE_MEDIA_STREAM], [PJSIP Media Stream Replacement Support], [PJPROJECT], [pjsip])
AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_SETUP_ACK_INBAND], [ISDN PRI progress inband ie in SETUP ACK], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_L2_PERSISTENCE], [ISDN Layer 2 persistence option], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_DATETIME_SEND], [ISDN PRI Date/time ie send policy], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_MWI_V2], [ISDN PRI Message Waiting Indication (Fixed)], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_DISPLAY_TEXT], [ISDN PRI user display text IE contents during call], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_MWI], [ISDN PRI Message Waiting Indication], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_MCID], [ISDN PRI Malicious Call ID], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_WAITING], [ISDN PRI call waiting supplementary service], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_AOC_EVENTS], [ISDN PRI advice of charge supplementary service events], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_TRANSFER], [ISDN PRI call transfer supplementary service], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_CCSS], [ISDN PRI call completion supplementary service], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_HANGUP_FIX], [ISDN PRI hangup fix], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_SUBADDR], [ISDN PRI subaddressing], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_HOLD], [ISDN PRI call hold], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_REROUTING], [ISDN PRI call rerouting and call deflection], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_SETUP_KEYPAD], [ISDN PRI keypad facility in SETUP], [PRI], [pri])
# ------------------------------------v
# TODO: The code can be changed to always include these features now.
# These features will always be present if pri_connected_line_update is available.
AST_EXT_LIB_SETUP_OPTIONAL([PRI_INBANDDISCONNECT], [ISDN PRI set_inbanddisconnect], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_PROG_W_CAUSE], [ISDN progress with cause], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_SERVICE_MESSAGES], [ISDN service messages], [PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_REVERSE_CHARGE], [ISDN reverse charge], [PRI], [pri])
# ------------------------------------^
AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
Sean Bright's avatar
Sean Bright committed
AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
AST_EXT_LIB_SETUP([RESAMPLE], [LIBRESAMPLE], [resample])
AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image], [SDL_image])
AST_OPTION_ONLY([sounds-cache], [SOUNDS_CACHE_DIR], [cached sound tarfiles], [])
AST_EXT_LIB_SETUP([SPANDSP], [SPANDSP], [spandsp])
AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7])
AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
AST_EXT_LIB_SETUP([SPEEX_PREPROCESS], [Speex preprocess routines], [speex])
AST_EXT_LIB_SETUP([SPEEXDSP], [SpeexDSP], [speexdsp])
AST_EXT_LIB_SETUP_DEPENDENT([SPEEX_PREPROCESS], [speex_preprocess_ctl], [], [speex])
AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
AST_EXT_LIB_SETUP([SQLITE3], [SQLite], [sqlite3])
AST_EXT_LIB_SETUP([SRTP], [Secure RTP], [srtp])
AST_EXT_LIB_SETUP_OPTIONAL([SRTP_SHUTDOWN], [SRTP Library Shutdown Function], [SRTP], [srtp])
AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL Secure Sockets Layer], [ssl])
AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap])
AST_EXT_LIB_SETUP([TIMERFD], [timerfd], [timerfd])
AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [unixodbc])
AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
AST_EXT_LIB_SETUP([X11], [X11], [x11])
AST_EXT_LIB_SETUP([ZLIB], [zlib compression], [z])
# check for basic system features and functionality before
# checking for package libraries
AC_FUNC_ALLOCA
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/event.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h utime.h arpa/nameser.h sys/io.h])
# Any one of these packages support a mandatory requirement, so we want to check on them as early as possible.
AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])

EDITLINE_LIB=""
if test "x$TERMCAP_LIB" != "x" ; then
  EDITLINE_LIB="$TERMCAP_LIB"
elif test "x$TINFO_LIB" != "x" ; then
  EDITLINE_LIB="$TINFO_LIB"
elif test "x$CURSES_LIB" != "x" ; then
  EDITLINE_LIB="$CURSES_LIB"
elif test "x$NCURSES_LIB" != "x" ; then
  EDITLINE_LIB="$NCURSES_LIB"
else
  AC_MSG_ERROR([*** termcap support not found (on modern systems, this typically means the ncurses development package is missing)])
fi
AC_SUBST(EDITLINE_LIB)

# Find required UUID support.
#  * -luuid on Linux
#  * -le2fs-uuid on OpenBSD
#  * in libsystem on OS X
AST_EXT_LIB_CHECK([LIBUUID], [uuid], [uuid_generate_random], [uuid/uuid.h], [])
AST_EXT_LIB_CHECK([E2FSUUID], [e2fs-uuid], [uuid_generate_random], [uuid/uuid.h], [])
AC_CHECK_FUNCS([uuid_generate_random], [SYSUUID=true], [SYSUUID=""])

if test "x$LIBUUID_LIB" != "x" ; then
  UUID_INCLUDE="$LIBUUID_INCLUDE"
  UUID_LIB="$LIBUUID_LIB"
elif test "x$E2FSUUID_LIB" != "x" ; then
  UUID_INCLUDE="$E2FSUUID_INCLUDE"
  UUID_LIB="$E2FSUUID_LIB"
elif test "x$SYSUUID" != "x" ; then
  UUID_INCLUDE=""
  UUID_LIB=""
else
  AC_MSG_ERROR([*** uuid support not found (this typically means the uuid development package is missing)])
fi
AC_SUBST(UUID_INCLUDE)
AC_SUBST(UUID_LIB)

# Find required JSON support.
AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_dumps], [jansson.h])
if test "x$JANSSON_LIB" == "x"; then
  AC_MSG_ERROR([*** JSON support not found (this typically means the libjansson development package is missing)])
fi

AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , ,
        [#include <libxml/tree.h>
        #include <libxml/parser.h>],
        [LIBXML_TEST_VERSION])

if test "${PBX_LIBXML2}" != 1; then
	AC_MSG_NOTICE(*** The Asterisk menuselect tool requires the 'libxml2' development package.)
	AC_MSG_NOTICE(*** Please install the 'libxml2' development package.)
Joshua Colp's avatar
Joshua Colp committed
AST_EXT_LIB_CHECK([URIPARSER], [uriparser], [uriParseUriA], [uriparser/Uri.h])

# Another mandatory item (unless it's explicitly disabled)
AC_ARG_ENABLE([xmldoc],
	[AS_HELP_STRING([--disable-xmldoc],
		[Explicitly disable XML documentation])],
	[case "${enableval}" in
		y|ye|yes) disable_xmldoc=no ;;
		n|no)  disable_xmldoc=yes ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --disable-xmldoc)  ;;
	esac], [disable_xmldoc=no])

if test "${disable_xmldoc}" != "yes"; then
        AST_EXT_LIB_CHECK([LIBXSLT], [xslt], [xsltLoadStylesheetPI], [libxslt/xsltInternals.h], [${LIBXML2_LIB}], [${LIBXML2_INCLUDE}])
        AST_EXT_LIB_CHECK([LIBXSLT_CLEANUP], [xslt], [xsltCleanupGlobals], [libxslt/xsltInternals.h], [${LIBXML2_LIB}], [${LIBXML2_INCLUDE}])
# some embedded systems omit internationalization (locale) support
AC_CHECK_HEADERS([xlocale.h])

AC_CHECK_HEADERS([winsock.h winsock2.h])

AC_CHECK_HEADER([sys/poll.h],
	 [],
     AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.]))

AC_SYS_LARGEFILE

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_UID_T
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_MEMBERS([struct stat.st_blksize])
AC_CHECK_MEMBERS([struct ucred.uid, struct ucred.cr_uid, struct sockpeercred.uid], [], [], [#include <sys/types.h>
#include <sys/socket.h> ])
AC_CHECK_MEMBERS([struct ifreq.ifr_ifru.ifru_hwaddr], [], [], [#include <net/if.h>])
AC_HEADER_TIME
AC_STRUCT_TM
AC_C_VOLATILE
AC_CHECK_TYPES([ptrdiff_t])
stat_nsec_found=no
AC_CHECK_MEMBERS([struct stat.st_mtim, struct stat.st_mtimensec, struct stat.st_mtimespec], [stat_nsec_found=yes], [], [[#include <sys/stat.h>]])

if test "${stat_nsec_found}" != yes; then
	AC_MSG_WARN(Cannot determine nanosecond field of struct stat)
fi

# Checks for library functions.
AC_FUNC_CHOWN
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE
# XXX: these are commented out until we determine whether it matters if our malloc()
# acts exactly like glibc's or not
# AC_FUNC_MALLOC
# AC_FUNC_REALLOC
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRCOLL
AC_FUNC_STRFTIME
AC_FUNC_STRNLEN
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap ntohll newlocale ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
# NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
# so that AC_CHECK_FUNCS can detect functions in that library.
AC_CHECK_LIB([m], [sqrt])
AC_CHECK_FUNCS([exp2 log2 exp10 log10 sin cos tan asin acos atan atan2 pow rint exp log remainder fmod round roundf trunc floor ceil])

# Certain architectures don't really have long double, even though
# AC_CHECK_FUNCS would otherwise find the following functions.
if test "x${ac_cv_type_long_double_wider}" = "xyes" ; then
	AC_CHECK_FUNCS([exp2l log2l exp10l log10l sinl cosl tanl asinl acosl atanl atan2l powl sqrtl rintl expl logl remainderl fmodl roundl truncl floorl ceill])
fi
AC_MSG_CHECKING(for LLONG_MAX in limits.h)
AC_LINK_IFELSE(
	[AC_LANG_PROGRAM([#include <limits.h>],
		[long long foo = LLONG_MAX])],
	AC_MSG_RESULT(yes)
	AC_DEFINE([HAVE_LLONG_MAX], 1, [Define to 1 if limits.h includes a LLONG_MAX definition.]),
	AC_MSG_RESULT(no)
)

	[AC_LANG_PROGRAM([#include <sys/time.h>],
		[struct timeval *a; timersub(a, a, a);])],
	AC_MSG_RESULT(yes)
		AC_DEFINE([HAVE_TIMERSUB], 1, [Define to 1 if your system defines timersub.]),
	AC_MSG_RESULT(no)
)

Tilghman Lesher's avatar
Tilghman Lesher committed
AC_MSG_CHECKING(for a version of GNU ld that supports the --dynamic-list flag)
old_LDFLAGS=${LDFLAGS}
cat >conftest.dynamics <<_ACEOF
{
	*ast_*;
};
_ACEOF
LDFLAGS="${LDFLAGS} -Wl,--dynamic-list,conftest.dynamics"
Tilghman Lesher's avatar
Tilghman Lesher committed
PBX_DYNAMIC_LIST=0
AC_LINK_IFELSE(
Tilghman Lesher's avatar
Tilghman Lesher committed
	PBX_DYNAMIC_LIST=1
	AC_MSG_RESULT(yes),
	AC_MSG_RESULT(no)
)
AC_SUBST(PBX_DYNAMIC_LIST)
LDFLAGS=${old_LDFLAGS}
rm -f conftest.dynamics
   [HAS_POLL=1]
   AC_DEFINE([HAVE_SYS_POLL_H], 1, [Define to 1 if your system has working sys/poll.h]),
   )
AC_ARG_ENABLE([internal-poll],
	[AS_HELP_STRING([--enable-internal-poll],
		[Use Asterisk's poll implementation])],
	[case "${enableval}" in
		y|ye|yes) HAS_POLL="";;
		n|no) HAS_POLL="${HAS_POLL}" ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-internal-poll) ;;
	esac])
AC_ARG_ENABLE([asteriskssl],
	[AS_HELP_STRING([--disable-asteriskssl],
		[Disable Asterisk's SSL wrapper library])],
	[case "${enableval}" in
		y|ye|yes) AST_ASTERISKSSL=yes ;;
		n|no)  AST_ASTERISKSSL=no ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --disable-asteriskssl)  ;;
	esac], [AST_ASTERISKSSL=yes])
AC_SUBST(AST_ASTERISKSSL)
# https support (in main/http.c) uses funopen on BSD systems,
# fopencookie on linux
AC_CHECK_FUNCS([funopen fopencookie])

# check if we have IP_PKTINFO constant defined
		[AC_LANG_PROGRAM([#include <netinet/in.h>],
						[int pi = IP_PKTINFO;])],
		AC_MSG_RESULT(yes)
		AC_DEFINE([HAVE_PKTINFO], 1, [Define to 1 if your system defines IP_PKTINFO.]),
		AC_MSG_RESULT(no)
)

# some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])

AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
AC_LINK_IFELSE(
                         #include <netdb.h>],
                        [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);])],
        AC_MSG_RESULT(yes)
        AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
        AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
AC_LINK_IFELSE(
	                 #include <netdb.h>],
                        [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);])],
        AC_MSG_RESULT(yes)
        AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
        AC_MSG_RESULT(no)
)
AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])])

AC_MSG_CHECKING(for __swap16 variant of <sys/endian.h> byteswapping macros)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = __swap16(a);])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_SYS_ENDIAN_SWAP16], 1, [Define to 1 if your sys/endian.h header file provides the __swap16 macro.]),
AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(for bswap16 variant of <sys/endian.h> byteswapping macros)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = bswap16(a);])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_SYS_ENDIAN_BSWAP16], 1, [Define to 1 if your sys/endian.h header file provides the bswap16 macro.]),
AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(for locale_t in locale.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <locale.h>], [locale_t lt = NULL])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_LOCALE_T_IN_LOCALE_H], 1, [Define to 1 if your system defines the locale_t type in locale.h]),
AC_MSG_RESULT(no)
  AC_MSG_CHECKING(for locale_t in xlocale.h)
  AC_LINK_IFELSE(
  [AC_LANG_PROGRAM([#include <xlocale.h>], [locale_t lt = NULL])],
  AC_MSG_RESULT(yes)
  AC_DEFINE([HAVE_LOCALE_T_IN_XLOCALE_H], 1, [Define to 1 if your system defines the locale_t type in xlocale.h]),
  AC_MSG_RESULT(no)
  )
)

AC_MSG_CHECKING(for O_EVTONLY in fcntl.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <fcntl.h>], [int a = O_EVTONLY;])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_O_EVTONLY], 1, [Define to 1 if your system defines the file flag O_EVTONLY in fcntl.h]),
AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(for O_SYMLINK in fcntl.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <fcntl.h>], [int a = O_SYMLINK;])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_O_SYMLINK], 1, [Define to 1 if your system defines the file flag O_SYMLINK in fcntl.h]),
AC_MSG_RESULT(no)
)

AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_INITIALIZER], [PTHREAD_RWLOCK_INITIALIZER], [pthread.h])

AC_MSG_CHECKING(for PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <pthread.h>], [int a = PTHREAD_RWLOCK_PREFER_WRITER_NP;])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP], 1, [Define to 1 if your system defines PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h]),
AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE_NP in pthread.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <pthread.h>], [int a = PTHREAD_MUTEX_RECURSIVE_NP;])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1, [Define to 1 if your system defines PTHREAD_MUTEX_RECURSIVE_NP in pthread.h]),
AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(for PTHREAD_MUTEX_ADAPTIVE_NP in pthread.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <pthread.h>], [int a = PTHREAD_MUTEX_ADAPTIVE_NP;])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1, [Define to 1 if your system defines PTHREAD_MUTEX_ADAPTIVE_NP in pthread.h]),
AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(for pthread_spinlock_t in pthread.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <pthread.h>], [pthread_spinlock_t spin;])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_PTHREAD_SPINLOCK], 1, [Define to 1 if your system has pthread_spinlock_t in pthread.h]),
AC_MSG_RESULT(no)
)

save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"

AC_MSG_CHECKING(for pthread_rwlock_timedwrlock() in pthread.h)
AC_LINK_IFELSE(
  [AC_LANG_PROGRAM(
    [#include <pthread.h>
     #include <time.h>],
    [pthread_rwlock_t foo; struct timespec bar; pthread_rwlock_timedwrlock(&foo, &bar)])
  ],[
    AC_MSG_RESULT(yes)
    ac_cv_pthread_rwlock_timedwrlock="yes"
  ],[
    AC_MSG_RESULT(no)
    ac_cv_pthread_rwlock_timedwrlock="no"
  ]
)

# Some platforms define sem_init(), but only support sem_open(). joyous.
AC_MSG_CHECKING(for working unnamed semaphores)
AC_RUN_IFELSE(
	[AC_LANG_PROGRAM([#include <semaphore.h>],
		[sem_t sem; return sem_init(&sem, 0, 0);])],
	AC_MSG_RESULT(yes)
	AC_DEFINE([HAS_WORKING_SEMAPHORE], 1, [Define to 1 if anonymous semaphores work.]),
	AC_MSG_RESULT(no)
)

if test "${ac_cv_pthread_rwlock_timedwrlock}" = "yes"; then
  AC_DEFINE([HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK], 1, [Define if your system has pthread_rwlock_timedwrlock()])
fi

AC_MSG_CHECKING(if PTHREAD_ONCE_INIT needs braces)
saved_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -Werror -Wmissing-braces"
AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM(
    [#include <pthread.h>
     void empty(){}],
	[pthread_once_t once = PTHREAD_ONCE_INIT; pthread_once(&once, empty);])
  ],[
    AC_MSG_RESULT(no)
    ac_cv_pthread_once_needsbraces="no"
  ],[
    AC_MSG_RESULT(yes)
    ac_cv_pthread_once_needsbraces="yes"
  ]
)
CFLAGS="${saved_CFLAGS}"
if test "${ac_cv_pthread_once_needsbraces}" = "yes"; then
  AC_DEFINE([PTHREAD_ONCE_INIT_NEEDS_BRACES], 1, [Define if your system needs braces around PTHREAD_ONCE_INIT])
fi

AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
# Can we compare a mutex to its initial value?
# Generally yes on OpenBSD/FreeBSD and no on Mac OS X.
AC_MSG_CHECKING(whether we can compare a mutex to its initial value)
AC_LINK_IFELSE(
	[AC_LANG_PROGRAM([#include <pthread.h>], [pthread_mutex_t lock;
	if ((lock) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
		return 0;
	}
	AC_MSG_RESULT(yes)
	AC_DEFINE([CAN_COMPARE_MUTEX_TO_INIT_VALUE], 1, [Define to 1 if your system's implementation of mutexes supports comparison of a mutex to its initializer.]),
	AC_MSG_RESULT(no)
)

#if test "${cross_compiling}" = "no";
#then
#AC_MSG_CHECKING(for working epoll support)
#AC_LINK_IFELSE(
#AC_LANG_PROGRAM([#include <sys/epoll.h>], [int res = epoll_create(10);
#					  if (res < 0)
#					     return 1;
#					  close (res);
#					  return 0;]),
#AC_MSG_RESULT(yes)
#AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]),
#AC_MSG_RESULT(no)
#)
#fi
# for FreeBSD thr_self
AC_CHECK_HEADERS([sys/thr.h])

AC_MSG_CHECKING(for compiler atomic operations)
[AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
AC_MSG_RESULT(no)
)

# glibc, AFAIK, is the only C library that makes printing a NULL to a string safe.
AC_MSG_CHECKING([if your system printf is NULL-safe.])
AC_RUN_IFELSE(
	[AC_LANG_PROGRAM([#include <stdio.h>],
		[printf("%s", NULL)])],
	AC_DEFINE([HAVE_NULLSAFE_PRINTF], 1, [Define to 1 if your C library can safely print NULL to string formats.])
	AC_MSG_RESULT(yes),
	AC_MSG_RESULT(no),
	# It's unlikely an embedded system will have this.
	AC_MSG_RESULT(unknown)
)

AC_MSG_CHECKING(if we can increase the maximum select-able file descriptor)
AC_RUN_IFELSE(
#include <stdio.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
], [[
	struct rlimit rlim = { FD_SETSIZE * 2, FD_SETSIZE * 2 };
	int fd0, fd1;
	struct timeval tv = { 0, };
	struct ast_fdset { long fds_bits[[1024]]; } fds = { { 0, } };
	if (setrlimit(RLIMIT_NOFILE, &rlim)) { exit(1); }
	if ((fd0 = open("/dev/null", O_RDONLY)) < 0) { exit(1); }
	if (dup2(fd0, (fd1 = FD_SETSIZE + 1)) < 0) { exit(1); }
	FD_SET(fd0, (fd_set *) &fds);
	FD_SET(fd1, (fd_set *) &fds);
	if (select(FD_SETSIZE + 2, (fd_set *) &fds, NULL, NULL, &tv) < 0) { exit(1); }
	AC_MSG_RESULT(yes)
	AC_DEFINE([HAVE_VARIABLE_FDSET], 1, [Define to 1 if your system can support larger than default select bitmasks.]),
	AC_MSG_RESULT(no),
	AC_MSG_RESULT(cross-compile)
)

if test "${ac_cv_have_variable_fdset}x" = "0x"; then
	AC_RUN_IFELSE(
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
		AC_DEFINE([CONFIGURE_RAN_AS_ROOT], 1, [Some configure tests will unexpectedly fail if configure is run by a non-root user.  These may be able to be tested at runtime.]))
fi

AST_GCC_ATTRIBUTE(pure)
AST_GCC_ATTRIBUTE(malloc)
AST_GCC_ATTRIBUTE(const)
AST_GCC_ATTRIBUTE(unused)
AST_GCC_ATTRIBUTE(always_inline)
AST_GCC_ATTRIBUTE(sentinel)