configure.ac 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.59])
  4. AC_INIT([freetdm], [0.1], [bugs@freeswitch.org])
  5. AC_CONFIG_SRCDIR([src/ftdm_io.c])
  6. AC_CONFIG_AUX_DIR([build])
  7. AC_CONFIG_MACRO_DIR([build])
  8. AM_INIT_AUTOMAKE
  9. # >=automake-1.11
  10. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  11. # override some default libtool behavior and invoke AC_PROG_LIBTOOL
  12. # (see http://lists.gnu.org/archive/html/libtool/2007-03/msg00000.html)
  13. m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
  14. m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
  15. m4_defun([_LT_AC_LANG_RC_CONFIG], [:])
  16. # Checks for programs.
  17. AC_PROG_CC
  18. AC_PROG_MAKE_SET
  19. AM_PROG_CC_C_O
  20. AC_PROG_LIBTOOL
  21. AC_PROG_INSTALL
  22. # NOTE: pkg-config is used to detect libisdn
  23. m4_ifdef([PKG_PROG_PKG_CONFIG],
  24. [PKG_PROG_PKG_CONFIG],
  25. [AC_MSG_WARN([pkg-config missing (required for libisdn detection)])]
  26. )
  27. AX_COMPILER_VENDOR
  28. # AC_PREFIX_DEFAULT does not get expanded until too late so we need
  29. # to do this to use prefix in this script
  30. AC_PREFIX_DEFAULT([/usr/local/freetdm])
  31. if test "x${prefix}" = "xNONE" ; then
  32. prefix='/usr/local/freetdm'
  33. fi
  34. # Absolute source/build directory
  35. FT_SRCDIR=`(cd $srcdir && pwd)`
  36. ft_builddir=`pwd`
  37. AC_SUBST([FT_SRCDIR])
  38. AC_SUBST([ft_builddir])
  39. if test "$sysconfdir" = "\${prefix}/etc" ; then
  40. confdir="$prefix/conf"
  41. else
  42. confdir="$sysconfdir"
  43. fi
  44. AC_SUBST([confdir])
  45. DEFAULT_INCLUDES="-I. -I./src/include -I\$(srcdir)"
  46. AC_SUBST([DEFAULT_INCLUDES])
  47. # Where to install the modules
  48. AC_ARG_WITH([modinstdir],
  49. [AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: ${prefix}/mod)])],
  50. [case "${withval}" in
  51. no|yes) AC_MSG_ERROR([Invalid value \"${withval}\", option requires a valid path]) ;;
  52. *) modinstdir="${withval}" ;;
  53. esac],
  54. [modinstdir="${prefix}/mod"]
  55. )
  56. AC_SUBST([modinstdir])
  57. # freetdm.pc pkgconfig file
  58. AC_ARG_WITH([pkgconfigdir],
  59. [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])],
  60. [case "${withval}" in
  61. yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;;
  62. *) pkgconfigdir="${withval}" ;;
  63. esac
  64. ],
  65. [pkgconfigdir="${libdir}/pkgconfig"]
  66. )
  67. AC_SUBST([pkgconfigdir])
  68. AC_ARG_ENABLE([enable_64],
  69. [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])],
  70. [enable_64="${enableval}"],
  71. [enable_64="no"]
  72. )
  73. case "${ax_cv_c_compiler_vendor}" in
  74. gnu)
  75. COMP_VENDOR_CFLAGS="-ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -O0"
  76. ;;
  77. sun)
  78. COMP_VENDOR_CFLAGS="-xc99=all -mt -xCC -xvpara"
  79. if test "$enable_64" != "no" ; then
  80. COMP_VENDOR_CFLAGS="-m64 $COMP_VENDOR_CFLAGS"
  81. fi
  82. ;;
  83. *)
  84. COMP_VENDOR_COMPAT_CFLAGS="-Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
  85. COMP_VENDOR_CFLAGS="-std=c99 $COMP_VENDOR_COMPAT_CFLAGS"
  86. ;;
  87. esac
  88. AC_SUBST([COMP_VENDOR_COMPAT_CFLAGS])
  89. AC_SUBST([COMP_VENDOR_CFLAGS])
  90. # Enable debugging
  91. AC_ARG_ENABLE([debug],
  92. [AC_HELP_STRING([--enable-debug], [build with debug information])],
  93. [enable_debug="${enableval}"],
  94. [enable_debug="yes"]
  95. )
  96. if test "${enable_debug}" != "no"; then
  97. AC_DEFINE([DEBUG], [], [Enable extra debugging.])
  98. if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
  99. COMP_VENDOR_CFLAGS="$COMP_VENDOR_CFLAGS -g -ggdb"
  100. fi
  101. fi
  102. AC_SUBST([COMP_VENDOR_CFLAGS])
  103. AC_CHECK_LIB([dl], [dlopen])
  104. AC_CHECK_LIB([pthread], [pthread_create])
  105. AC_CHECK_LIB([m], [cos])
  106. AC_CHECK_HEADERS([netdb.h sys/select.h execinfo.h])
  107. AC_CHECK_FUNC([gethostbyname_r],
  108. [], [AC_CHECK_LIB([nsl], [gethostbyname_r])]
  109. )
  110. if test "$ac_cv_func_gethostbyname_r" = "yes" -o "$ac_cv_lib_nsl_gethostbyname_r" = "yes"
  111. then
  112. AC_MSG_CHECKING([whether gethostbyname_r requires five arguments])
  113. ac_cv_func_gethostbyname_r_five_args="no"
  114. AC_TRY_COMPILE([#include <netdb.h>],
  115. [char *name;
  116. struct hostent *he, *res;
  117. char buffer[2048];
  118. int buflen = 2048;
  119. (void)gethostbyname_r(name, he, buffer, buflen, &res)],
  120. [ac_cv_func_gethostbyname_r_five_args="yes"
  121. AC_DEFINE([HAVE_GETHOSTBYNAME_R_FIVE], [1], [gethostbyname_r has five arguments])]
  122. )
  123. AC_MSG_RESULT([$ac_cv_func_gethostbyname_r_five_args])
  124. AC_DEFINE([HAVE_GETHOSTBYNAME_R], [1], [threadsafe gethostbyname])
  125. fi
  126. ##
  127. ## Modules and optional features
  128. ##
  129. AC_MSG_RESULT([${as_nl}<<>> Modules and optional features])
  130. ##
  131. # pritap (TODO: add checks)
  132. #
  133. HAVE_PRITAP="no"
  134. AC_ARG_WITH([pritap],
  135. [AS_HELP_STRING([--with-pritap], [Install ftmod_pritap])],
  136. [case "${withval}" in
  137. no) enable_pritap="no" ;;
  138. *) enable_pritap="yes" ;;
  139. esac],
  140. [enable_pritap="no"]
  141. )
  142. HAVE_PRITAP="${enable_pritap}"
  143. AM_CONDITIONAL([HAVE_PRITAP],[test "${enable_pritap}" = "yes"])
  144. ##
  145. # OpenR2 stack
  146. #
  147. HAVE_OPENR2="no"
  148. AC_CHECK_LIB([openr2], [openr2_context_set_io_type], [HAVE_OPENR2="yes"])
  149. AC_MSG_RESULT([checking whether to build ftmod_r2... ${HAVE_OPENR2}])
  150. AM_CONDITIONAL([HAVE_OPENR2], [test "${HAVE_OPENR2}" = "yes"])
  151. ##
  152. # WAT GSM stack
  153. #
  154. HAVE_WAT="no"
  155. AC_CHECK_LIB([wat], [wat_version], [HAVE_WAT="yes"])
  156. AC_MSG_RESULT([checking whether to build ftmod_wat... ${HAVE_WAT}])
  157. AM_CONDITIONAL([HAVE_WAT], [test "${HAVE_WAT}" = "yes"])
  158. ##
  159. # Digium libpri (TODO: add checks)
  160. #
  161. HAVE_LIBPRI="no"
  162. AC_ARG_WITH([libpri],
  163. [AS_HELP_STRING([--with-libpri@<:@=PREFIX@:>@], [Install ftmod_libpri])],
  164. [case "${withval}" in
  165. no|yes) with_libpri="${withval}" ;;
  166. *) AS_IF([test -d "${withval}"],
  167. [with_libpri="${withval}"],
  168. [AC_MSG_ERROR([Invalid argument for --with-libpri, \"${withval}\" is not a directory])]
  169. ) ;;
  170. esac],
  171. [with_libpri="no"]
  172. )
  173. if test "x${with_libpri}" != "xno"
  174. then
  175. save_LIBS="${LIBS}"
  176. save_CPPFLAGS="${CPPFLAGS}"
  177. save_LDFLAGS="${LDFLAGS}"
  178. LIBPRI_CPPFLAGS=""
  179. LIBPRI_LDFLAGS=""
  180. AC_MSG_RESULT([${as_nl}<<>> Digium libpri])
  181. AS_IF([test "x${with_libpri}" != "xyes"],
  182. [LIBPRI_CPPFLAGS="-I${with_libpri}/include"
  183. LIBPRI_LDFLAGS="-L${with_libpri}/lib"],
  184. )
  185. LDFLAGS="${save_LDFLAGS} ${LIBPRI_LDFLAGS}"
  186. CPPFLAGS="${save_CPPFLAGS} ${LIBPRI_CPPFLAGS}"
  187. LIBS="${LIBS} -lpri"
  188. AC_MSG_CHECKING([whether libpri is usable])
  189. AC_LINK_IFELSE(
  190. [AC_LANG_PROGRAM(
  191. [#include <libpri.h>],
  192. [const char *version = pri_get_version();
  193. (void)version;]
  194. )],
  195. [AC_MSG_RESULT([yes])
  196. HAVE_LIBPRI="yes"],
  197. [AC_MSG_RESULT([no])
  198. AC_MSG_ERROR([libpri not found or unusable (see config.log for details)])]
  199. )
  200. AC_MSG_CHECKING([whether libpri is too old])
  201. AC_PREPROC_IFELSE(
  202. [AC_LANG_PROGRAM(
  203. [#include <libpri.h>],
  204. [#if !defined(PRI_IO_FUNCS)
  205. #error "libpri is lacking PRI_IO_FUNCS"
  206. #elif !defined(PRI_NEW_SET_API)
  207. #error "libpri is lacking PRI_NEW_SET_API"
  208. #endif]
  209. )],
  210. [AC_MSG_RESULT([no])],
  211. [AC_MSG_RESULT([yes])
  212. AC_MSG_ERROR([Your version of libpri is too old (pre 1.2), please update!])]
  213. )
  214. AC_MSG_CHECKING([whether libpri has BRI support])
  215. AC_LINK_IFELSE(
  216. [AC_LANG_PROGRAM(
  217. [extern void pri_new_bri_cb(void);],
  218. [pri_new_bri_cb();]
  219. )],
  220. [AC_DEFINE([HAVE_LIBPRI_BRI], [1], [libpri has BRI support])
  221. AC_MSG_RESULT([yes])],
  222. [AC_MSG_RESULT([no])
  223. AC_MSG_NOTICE([You will need libpri-1.4.12_beta1 or newer for BRI support])]
  224. )
  225. AC_MSG_CHECKING([whether libpri has AOC event support])
  226. AC_LINK_IFELSE(
  227. [AC_LANG_PROGRAM(
  228. [extern void pri_aoc_events_enable(void);],
  229. [pri_aoc_events_enable();]
  230. )],
  231. [AC_DEFINE([HAVE_LIBPRI_AOC], [1], [libpri has AOC event support])
  232. AC_MSG_RESULT([yes])],
  233. [AC_MSG_RESULT([no])
  234. AC_MSG_NOTICE([You will need libpri-1.4.12_beta1 or newer for AOC event support])]
  235. )
  236. AC_MSG_CHECKING([whether libpri has pri_maintenance_service()])
  237. AC_LINK_IFELSE(
  238. [AC_LANG_PROGRAM(
  239. [extern int pri_maintenance_service(void);],
  240. [pri_maintenance_service();]
  241. )],
  242. [AC_DEFINE([HAVE_LIBPRI_MAINT_SERVICE], [1], [libpri has pri_maintenance_service()])
  243. AC_MSG_RESULT([yes])],
  244. [AC_MSG_RESULT([no])
  245. AC_MSG_NOTICE([You will need libpri-1.4.11 or newer for the ftdm libpri maintenance set of commands])]
  246. )
  247. # libpri is available, set variables for Makefile(.am)
  248. AC_SUBST([LIBPRI_LIBS], [-lpri])
  249. AC_SUBST([LIBPRI_LDFLAGS])
  250. AC_SUBST([LIBPRI_CPPFLAGS])
  251. LIBS="${save_LIBS}"
  252. LDFLAGS="${save_LDFLAGS}"
  253. CPPFLAGS="${save_CPPFLAGS}"
  254. fi
  255. AM_CONDITIONAL([HAVE_LIBPRI],[test "x${HAVE_LIBPRI}" = "xyes"])
  256. ##
  257. # Sangoma Wanpipe
  258. #
  259. HAVE_LIBSANGOMA="no"
  260. AC_MSG_RESULT([${as_nl}<<>> Sangoma Wanpipe])
  261. AC_CHECK_LIB([sangoma], [sangoma_span_chan_toif], [HAVE_LIBSANGOMA="yes"])
  262. AC_MSG_RESULT([checking whether to build ftmod_wanpipe... ${HAVE_LIBSANGOMA}])
  263. AM_CONDITIONAL([HAVE_LIBSANGOMA], [test "${HAVE_LIBSANGOMA}" = "yes"])
  264. ##
  265. # Sangoma ISDN stack
  266. #
  267. HAVE_SNG_ISDN="no"
  268. AC_MSG_RESULT([${as_nl}<<>> Sangoma ISDN stack])
  269. AC_CHECK_LIB([sng_isdn], [sng_isdn_init], [HAVE_SNG_ISDN="yes"])
  270. AC_MSG_RESULT([checking whether to build ftmod_sangoma_isdn... ${HAVE_SNG_ISDN}])
  271. AM_CONDITIONAL([HAVE_SNG_ISDN], [test "${HAVE_SNG_ISDN}" = "yes"])
  272. if test "${HAVE_SNG_ISDN}" = "yes"; then
  273. if test "${build}" = "${host}"
  274. then
  275. case "${host}" in
  276. x86_64-*)
  277. # X86_64 machines need additional flags when compiling against libsng_isdn
  278. CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT"
  279. ;;
  280. esac
  281. fi
  282. fi
  283. ##
  284. # Sangoma SS7 stack
  285. #
  286. HAVE_SNG_SS7="no"
  287. AC_MSG_RESULT([${as_nl}<<>> Sangoma SS7 stack])
  288. AC_CHECK_LIB([sng_ss7], [sng_isup_init_gen], [HAVE_SNG_SS7="yes"])
  289. AC_MSG_RESULT([checking whether to build ftmod_sangoma_ss7... ${HAVE_SNG_SS7}])
  290. AM_CONDITIONAL([HAVE_SNG_SS7], [test "${HAVE_SNG_SS7}" = "yes"])
  291. if test "${HAVE_SNG_SS7}" = "yes"; then
  292. if test "${build}" = "${host}"
  293. then
  294. case "${host}" in
  295. x86_64-*)
  296. # X86_64 machines need additional flags when compiling against libsng_isdn
  297. CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT"
  298. ;;
  299. esac
  300. fi
  301. fi
  302. ##
  303. # zlib (required for Sangoma SS7 Transparent IAM)
  304. #
  305. HAVE_ZLIB="no"
  306. AC_MSG_RESULT([${as_nl}<<>> zlib])
  307. AC_CHECK_LIB([z], [compress], [HAVE_ZLIB="yes"])
  308. AC_MSG_RESULT([checking whether zlib is installed... ${HAVE_ZLIB}])
  309. AM_CONDITIONAL([HAVE_ZLIB], [test "{HAVE_ZLIB]" = "yes"])
  310. if test "${HAVE_ZLIB}" = "yes"; then
  311. CFLAGS="$CFLAGS -DHAVE_ZLIB"
  312. fi
  313. ##
  314. # libisdn
  315. #
  316. HAVE_LIBISDN="no"
  317. AC_ARG_WITH([libisdn],
  318. [AS_HELP_STRING([--with-libisdn], [Install ftmod_isdn (libisdn stack)])],
  319. [case "${withval}" in
  320. no) with_libisdn="no" ;;
  321. *) with_libisdn="yes" ;;
  322. esac
  323. ],
  324. [with_libisdn="no"]
  325. )
  326. if test "${with_libisdn}" != "no"
  327. then
  328. AC_MSG_RESULT([${as_nl}<<>> ftmod_isdn (libisdn stack)])
  329. m4_ifdef([PKG_CHECK_MODULES],
  330. [PKG_CHECK_MODULES([libisdn],
  331. [libisdn >= 0.0.1],
  332. [AC_MSG_CHECKING([libisdn version])
  333. LIBISDN_VERSION="`${PKG_CONFIG} --modversion libisdn`"
  334. if test -z "${LIBISDN_VERSION}"; then
  335. AC_MSG_ERROR([Failed to retrieve libisdn version])
  336. fi
  337. AC_MSG_RESULT([${LIBISDN_VERSION}])
  338. # check features
  339. AC_MSG_CHECKING([for new experimental API])
  340. AC_COMPILE_IFELSE(
  341. [AC_LANG_PROGRAM(
  342. [#include <libisdn/version.h>
  343. #if !LIBISDN_FEATURE(API2)
  344. #error "libisdn API v2 not available"
  345. #endif
  346. ],
  347. [;]
  348. )],
  349. [AC_MSG_RESULT([yes])],
  350. [AC_MSG_RESULT([no])]
  351. )
  352. HAVE_LIBISDN="yes"
  353. AC_DEFINE([HAVE_LIBISDN], [1], [libisdn support])
  354. AC_SUBST([LIBISDN_CFLAGS], [${libisdn_CFLAGS}])
  355. AC_SUBST([LIBISDN_CPPFLAGS],[${libisdn_CPPFLAGS}])
  356. AC_SUBST([LIBISDN_LDFLAGS], [${libisdn_LDFLAGS}])
  357. AC_SUBST([LIBISDN_LIBS], [${libisdn_LIBS}])
  358. AC_SUBST([LIBISDN_VERSION])
  359. ],
  360. [AC_MSG_ERROR([Need libisdn-0.0.1 or higher])]
  361. )
  362. AX_LIB_PCAP],
  363. [AC_MSG_WARN([pkg-config missing (required for libisdn detection)])]
  364. )
  365. fi
  366. AM_CONDITIONAL([HAVE_LIBISDN], [test "${HAVE_LIBISDN}" = "yes"])
  367. ##
  368. # mISDN dependencies
  369. #
  370. HAVE_MISDN="no"
  371. AC_ARG_WITH([misdn],
  372. [AS_HELP_STRING([--with-misdn], [Install ftmod_misdn (mISDN I/O plugin)])],
  373. [case "${withval}" in
  374. no|yes) with_misdn="${withval}" ;;
  375. *) AC_MSG_ERROR([Invalid value \"${with_misdn}\" for --with-misdn option]) ;;
  376. esac],
  377. [with_misdn="auto"]
  378. )
  379. AS_IF([test "${with_misdn}" != "no"],
  380. [AC_MSG_RESULT([${as_nl}<<>> ftmod_misdn (Linux mISDN I/O plugin)])
  381. AC_CHECK_HEADER([mISDN/mISDNif.h],
  382. [HAVE_MISDN="yes"
  383. AC_CHECK_LIB([rt], [clock_gettime])],
  384. [AS_IF([test "${with_misdn}" = "yes"],
  385. [AC_MSG_ERROR([mISDN/mISDNif.h not found])],
  386. [AC_MSG_NOTICE([mISDN/mISDNif.h not found])]
  387. )],
  388. [#include <sys/socket.h>]
  389. )]
  390. )
  391. AM_CONDITIONAL([HAVE_MISDN], [test "${HAVE_MISDN}" = "yes"])
  392. AC_MSG_RESULT([${as_nl}<<>> Creating output files])
  393. AC_CONFIG_FILES([
  394. Makefile
  395. freetdm.pc
  396. mod_freetdm/Makefile
  397. ])
  398. AC_OUTPUT
  399. #
  400. # summary screen
  401. #
  402. AC_MSG_RESULT([
  403. ============================ FreeTDM configuration ============================
  404. + Modules
  405. Signalling:
  406. ftmod_analog....................... yes
  407. ftmod_analog_em.................... yes
  408. ftmod_isdn......................... ${HAVE_LIBISDN}
  409. ftmod_libpri....................... ${HAVE_LIBPRI}
  410. ftmod_sangoma_isdn................. ${HAVE_SNG_ISDN}
  411. ftmod_sangoma_ss7.................. ${HAVE_SNG_SS7}
  412. ftmod_r2........................... ${HAVE_OPENR2}
  413. ftmod_gsm.......................... ${HAVE_WAT}
  414. ftmod_pritap....................... ${HAVE_PRITAP}
  415. I/O:
  416. ftmod_zt........................... yes
  417. ftmod_wanpipe...................... ${HAVE_LIBSANGOMA}
  418. ftmod_misdn........................ ${HAVE_MISDN}
  419. ===============================================================================
  420. ])