/configure.in

http://datacard.googlecode.com/ · Autoconf · 244 lines · 190 code · 33 blank · 21 comment · 27 complexity · af1b06f141e56594c24d6ecf21ffb11b MD5 · raw file

  1. dnl init
  2. dnl AC_REVISION($Revision: 1.30 $)
  3. AC_PREREQ([2.60])
  4. AC_INIT([chan_datacard],[1.0],[http://code.google.com/p/datacard/issues/list],[chan_datacard],[http://code.google.com/p/datacard])
  5. PACKAGE_REVISION="318"
  6. AC_CONFIG_HEADERS([config.h])
  7. AC_CONFIG_SRCDIR([chan_datacard.c])
  8. AC_CANONICAL_SYSTEM
  9. AC_CANONICAL_HOST
  10. CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
  11. dnl Checks for user settings.
  12. dnl Set asterisk headers patch
  13. AC_ARG_WITH(
  14. [asterisk],
  15. AS_HELP_STRING([--with-asterisk=path], [set asterisk headers location]),
  16. [ if test "x$with_asterisk" = "xyes" -o "x$with_asterisk" = "xno" ; then AC_MSG_ERROR([Invalid --with-asterisk=path value]); fi ],
  17. [ with_asterisk="../include /usr/include /usr/local/include /opt/local/include" ]
  18. )
  19. AC_ARG_ENABLE(
  20. [debug],
  21. AS_HELP_STRING([--enable-debug], [enable code debugging]),
  22. [ if test "x$enable_debug" != "xyes" ; then enable_debug="no" ; fi],
  23. [ enable_debug="no"]
  24. )
  25. dnl Optionally disable manager.
  26. AC_ARG_ENABLE(
  27. [manager],
  28. AS_HELP_STRING([--enable-manager], [enable manager code]),
  29. [ if test "x$enable_manager" != "xyes" ; then enable_manager="no" ; fi ],
  30. [ enable_manager="yes" ]
  31. )
  32. dnl Optionally disable applications
  33. AC_ARG_ENABLE(
  34. [apps],
  35. AS_HELP_STRING([--enable-apps], [enable applications code]),
  36. [ if test "x$enable_apps" != "xyes" ; then enable_apps="no" ; fi],
  37. [ enable_apps="yes" ]
  38. )
  39. dnl Checks for programs.
  40. AC_PROG_CC([gcc cl cc])
  41. AC_PROG_CPP
  42. AC_PROG_INSTALL
  43. AC_CHECK_PROG(STRIP,strip,strip)
  44. if test -z "$STRIP" ; then
  45. AC_MSG_ERROR([Can't find strip])
  46. fi
  47. AC_CHECK_PROG(RM,rm,rm)
  48. if test -z "$RM" ; then
  49. AC_MSG_ERROR([Can't find rm])
  50. fi
  51. dnl Checks for libraries.
  52. dnl AC_CHECK_LIB([pthread], [pthread_create])
  53. dnl AC_CHECK_LIB([iconv], [iconv])
  54. AC_SEARCH_LIBS([iconv], [c iconv])
  55. dnl Checks for header files.
  56. AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h termios.h])
  57. AC_DEFUN([AC_HEADER_FIND], [
  58. file=$1
  59. for path in $2 ; do
  60. AC_MSG_CHECKING([whether $file in $path])
  61. if test -f $path/$file ; then
  62. found="yes"
  63. CPPFLAGS="$CPPFLAGS -I${path}"
  64. AC_MSG_RESULT([yes])
  65. AC_CHECK_HEADER([$file])
  66. break;
  67. else
  68. AC_MSG_RESULT([no])
  69. fi
  70. done
  71. if test -z "$found" ; then
  72. AC_MSG_ERROR([Can't find "$file"])
  73. fi
  74. ]
  75. )
  76. AC_HEADER_FIND([asterisk.h], $with_asterisk)
  77. AC_HEADER_FIND([iconv.h], /usr/include /usr/local/include /opt/local/include)
  78. AC_DEFINE([ICONV_CONST],[], [Define to const if you has iconv() const declaration of input buffer])
  79. AC_MSG_CHECKING([for iconv use const inbuf])
  80. AC_EGREP_HEADER([^extern.+iconv[[:space:]]*\(.+const], [iconv.h],
  81. [
  82. AC_DEFINE([ICONV_CONST],[const])
  83. AC_MSG_RESULT([yes])
  84. ],
  85. [AC_MSG_RESULT([no])]
  86. )
  87. AC_MSG_CHECKING([for iconv_t in iconv.h])
  88. AC_EGREP_HEADER([iconv_t], [iconv.h],
  89. [
  90. AC_DEFINE([ICONV_T], [iconv_t], , [Define to iconv_t if you has iconv_t in iconv.h])
  91. AC_MSG_RESULT(yes)
  92. ],
  93. [
  94. AC_DEFINE([ICONV_T], [int], [Define to iconv_t if you has iconv_t in iconv.h])
  95. AC_MSG_RESULT(no)
  96. ])
  97. AC_MSG_CHECKING([for AST_CONTROL_SRCCHANGE in asterisk/frame.h])
  98. AC_EGREP_HEADER([AST_CONTROL_SRCCHANGE], [asterisk/frame.h],
  99. [
  100. AC_DEFINE([HAVE_AST_CONTROL_SRCCHANGE], [], [Define to 1 if you have HAVE_AST_CONTROL_SRCCHANGE in asterisk/frame.h])
  101. AC_MSG_RESULT([yes])
  102. ],
  103. [AC_MSG_RESULT([no])]
  104. )
  105. dnl Checking for library options
  106. dnl Checks for typedefs, structures, and compiler characteristics.
  107. AC_C_CONST
  108. AC_C_INLINE
  109. AC_TYPE_SIZE_T
  110. AC_TYPE_SSIZE_T
  111. AC_TYPE_UINT64_T
  112. dnl AC_CHECK_TYPE(size_t, unsigned long)
  113. dnl AC_CHECK_TYPE(ssize_t, long)
  114. dnl AC_CHECK_TYPE(uint64_t, unsigned long long)
  115. dnl checking compiler options
  116. AC_DEFUN([AC_CC_OPT], [
  117. my_save_cflags="$CFLAGS"
  118. CFLAGS="$1"
  119. AC_MSG_CHECKING([whether CC supports $1])
  120. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  121. [AC_MSG_RESULT([yes])]
  122. [AC_CFLAGS="$AC_CFLAGS $2"],
  123. [AC_MSG_RESULT([no])]
  124. )
  125. CFLAGS="$my_save_cflags"]
  126. )
  127. AC_CFLAGS=
  128. my_save_cflags="$CFLAGS"
  129. CFLAGS=-fvisibility=hidden
  130. AC_MSG_CHECKING([whether CC supports -fvisibility=hidden])
  131. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  132. [AC_MSG_RESULT([yes])]
  133. [TARGET="chan_datacard.so"]
  134. [AC_CFLAGS="$AC_CFLAGS -fvisibility=hidden"],
  135. [AC_MSG_RESULT([no])]
  136. [TARGET="chan_datacards.so"]
  137. )
  138. CFLAGS="$my_save_cflags"
  139. AC_SUBST([TARGET])
  140. AC_CC_OPT([-fPIC],[-fPIC])
  141. AC_CC_OPT([-Wall],[-Wall])
  142. AC_CC_OPT([-Wextra],[-Wextra])
  143. AC_CC_OPT([-MD -MT conftest.o -MF /dev/null -MP],[-MD -MT \$@ -MF .\$(subst /,_,\$@).d -MP])
  144. AC_DEFUN([AC_CHECK_DESTDIR], [
  145. if test -z "$DESTDIR" ; then
  146. for path in $1 ; do
  147. AC_MSG_CHECKING([whether DESTDIR is $path])
  148. if test -f $path/pbx_config.so ; then
  149. AC_MSG_RESULT([yes])
  150. found="yes"
  151. DESTDIR=$path
  152. break;
  153. else
  154. AC_MSG_RESULT([no])
  155. fi
  156. done
  157. if test -z "$found" ; then
  158. AC_MSG_ERROR(DESTDIR is unknown, please explicite set like DESTDIR=/usr/lib/asterisk/modules ./configure)
  159. fi
  160. fi
  161. ])
  162. AC_CHECK_DESTDIR([/usr/lib/asterisk/modules /usr/local/lib/asterisk/modules /opt/local/lib/asterisk/modules])
  163. dnl Checks for library functions.
  164. AC_FUNC_MEMCMP
  165. AC_CHECK_FUNCS([memchr memmove memset memmem strcasecmp strchr strncasecmp strtol realpath])
  166. dnl Apply options to defines
  167. if test "x$enable_debug" = "xyes" ; then
  168. CFLAGS="$CFLAGS -O0 -g"
  169. AC_DEFINE([__DEBUG__], [1], [Build with debugging])
  170. fi
  171. if test "x$enable_manager" = "xyes" ; then
  172. AC_DEFINE([BUILD_MANAGER],[1], [Build Manager extentions])
  173. fi
  174. if test "x$enable_apps" = "xyes" ; then
  175. AC_DEFINE([BUILD_APPLICATIONS],[1],[Build extention applications])
  176. fi
  177. case "$target_os" in
  178. linux*)
  179. SOLINK="-shared -Xlinker -x"
  180. DC_LDFLAGS=""
  181. ;;
  182. freebsd*)
  183. SOLINK="-shared -Xlinker -x"
  184. DC_LDFLAGS="-L/usr/local/lib"
  185. ;;
  186. openbsd*)
  187. SOLINK="-shared -Xlinker -x"
  188. DC_LDFLAGS="-L/usr/local/lib -pthread"
  189. AC_CFLAGS="$AC_CFLAGS -pthread"
  190. ;;
  191. darwin*)
  192. SOLINK="-dynamic -bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace"
  193. DC_LDFLAGS="-L/opt/local/lib"
  194. [ `/usr/bin/sw_vers -productVersion | cut -c1-4` == "10.6" ] && SOLINK="$SOLINK /usr/lib/bundle1.o"
  195. esac
  196. LDFLAGS="$LDFLAGS $DC_LDFLAGS"
  197. dnl AC_DEFINE_UNQUOTED([MODULE_], "$PACKAGE_", [])
  198. dnl AC_DEFINE_UNQUOTED([MODULE_], "$PACKAGE_", [])
  199. AC_DEFINE_UNQUOTED([MODULE_BUGREPORT], "$PACKAGE_BUGREPORT", [Define to the address where bug reports for this package should be sent])
  200. AC_DEFINE_UNQUOTED([MODULE_URL], "$PACKAGE_URL", [Define to the home page for this package])
  201. AC_DEFINE_UNQUOTED([MODULE_VERSION], "$PACKAGE_VERSION", [Define to the version of this package])
  202. AC_DEFINE_UNQUOTED([AST_MODULE],"$PACKAGE_NAME",[name of asterisk module])
  203. AC_DEFINE_UNQUOTED([PACKAGE_REVISION], "$PACKAGE_REVISION",[Revision of package])
  204. AC_SUBST([SOLINK])
  205. AC_SUBST([PACKAGE_TARNAME])
  206. AC_SUBST([PACKAGE_REVISION])
  207. AC_SUBST([PACKAGE_VERSION])
  208. AC_SUBST([DESTDIR])
  209. AC_SUBST([AC_CFLAGS])
  210. AC_CONFIG_FILES([Makefile])
  211. AC_OUTPUT