PageRenderTime 55ms CodeModel.GetById 2ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 0ms

/configure.in

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