Add support for Digium's new te13x line of cards
[dahdi/tools.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2
3 AC_PREREQ(2.59)
4  
5 m4_define([TOOLSVERSION],
6           m4_bpatsubst(m4_esyscmd([build_tools/make_version . dahdi/tools]),
7                        [\([0-9.]*\)\(\w\|\W\)*],
8                        [\1]))
9 AC_INIT(dahdi, TOOLSVERSION, www.asterisk.org)
10
11 # check existence of the package
12 AC_CONFIG_SRCDIR([dahdi_cfg.c])
13
14 AC_COPYRIGHT("dahdi-tools")
15 AC_REVISION($Revision$)
16
17 ac_default_prefix=/usr
18 if test ${sysconfdir} = '${prefix}/etc'; then
19    sysconfdir=/etc
20 fi
21 if test ${mandir} = '${prefix}/man'; then
22    mandir=/usr/share/man
23 fi
24
25 if test ${localstatedir} = '${prefix}/var'; then
26      localstatedir=/var
27 fi
28
29 # specify output header file
30 AC_CONFIG_HEADER(autoconfig.h)
31
32 # This needs to be before any macros that use the C compiler
33 AC_GNU_SOURCE
34
35 AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
36
37 AC_CHECK_TOOL([LD], [ld])
38
39 # Checks for programs.
40 AC_PROG_CC
41 AC_PROG_CPP
42 AC_PROG_INSTALL
43 AC_PROG_LN_S
44 AST_CHECK_GNU_MAKE
45
46 test_obj=conftest.o
47 AC_COMPILE_IFELSE(AC_LANG_SOURCE(),[
48         BDFNAME=`LANG=C objdump -f $test_obj | grep -e "$test_obj:" | sed "s/.*file format \(.*\)/\1/"`
49         BDFARCH=`LANG=C objdump -f $test_obj | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`    
50 ],[])
51 AC_SUBST(BDFNAME)
52 AC_SUBST(BDFARCH)
53
54 # Set the default value of HOSTCC from CC if --host was not provided:
55 HOSTCC=${HOSTCC:=${CC}}
56 AC_SUBST(HOSTCC)
57
58 AC_PATH_PROG([GREP], [grep], :)
59 AC_PATH_PROG([SHELL], [sh], :)
60 AC_PATH_PROG([LN], [ln], :)
61
62 AC_PATH_PROG([WGET], [wget], :)
63 if test "${WGET}" != ":" ; then
64   DOWNLOAD=${WGET}
65 else
66   AC_PATH_PROG([FETCH], [fetch], [:])
67   DOWNLOAD=${FETCH}
68 fi
69 AC_SUBST(DOWNLOAD)
70
71 AC_LANG(C)
72
73 AC_ARG_ENABLE(dev-mode,
74         [  --enable-dev-mode    Turn on developer mode],
75         [case "${enableval}" in
76               y|ye|yes) DAHDI_DEVMODE=yes ;;
77               n|no)  DAHDI_DEVMODE=no ;;
78               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
79         esac])
80 AC_SUBST(DAHDI_DEVMODE)
81
82 AC_ARG_ENABLE(pinned,
83         [  --enable-pinned    Install pinned-spans support],
84         [case "${enableval}" in
85               y|ye|yes) DAHDI_PINNED=yes ;;
86               n|no)  DAHDI_PINNED=no ;;
87               *) AC_MSG_ERROR(bad value ${enableval} for --enable-pinned)  ;;
88         esac])
89 AC_SUBST(DAHDI_PINNED)
90
91 AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
92 if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
93         AC_MSG_RESULT(yes)
94         DAHDI_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
95 else
96         AC_MSG_RESULT(no)
97         DAHDI_DECLARATION_AFTER_STATEMENT=
98 fi
99 AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
100
101 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
102 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
103 AST_EXT_LIB_SETUP([USB], [usb], [usb])
104
105 AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
106 DAHDI23_DIR="${DAHDI_DIR}"
107 AST_C_DEFINE_CHECK([DAHDI23], [DAHDI_CONFIG_NTTE], [dahdi/user.h])
108 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
109 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h])
110
111 AC_CHECK_FUNCS([semtimedop])
112
113 PBX_HDLC=0
114 AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
115 AC_COMPILE_IFELSE(
116     [ AC_LANG_PROGRAM( [#include <linux/hdlc.h>],
117             [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
118                 int foo = 0;
119                 #else
120                 int foo = bar;
121                 #endif
122                 0])],
123         [AC_MSG_RESULT(yes)
124          PBX_HDLC=1],
125         [AC_MSG_RESULT(no)]
126 )
127 if test $PBX_HDLC = 0; then
128     AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc/ioctl.h])
129     AC_COMPILE_IFELSE(
130             [ AC_LANG_PROGRAM( [
131                     #include <sys/socket.h>
132                         #include <linux/if.h>],
133                         [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
134                         int foo = 0;
135                         #else
136                         int foo = bar;
137                         #endif
138                         0])],
139                 [AC_MSG_RESULT(yes)
140                  PBX_HDLC=1],
141                 [AC_MSG_RESULT(no)]
142         )
143 fi
144
145 if test "x${PBX_HDLC}" != "x1"; then
146    AC_MSG_NOTICE([GENERIC_HDLC_VERSION (version 4) not found, disabling sethdlc.])
147 fi
148
149 AC_SUBST(PBX_HDLC)
150
151 AC_ARG_WITH(selinux,
152         [AS_HELP_STRING([--with-selinux],
153                         [enable (with) / disable (without) SELinux])],
154         [USE_SELINUX=$withval],
155         [ if test ! -x /usr/sbin/sestatus; then 
156                 USE_SELINUX=no;
157           elif /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"; then
158                 USE_SELINUX=yes
159           fi
160         ]
161 )
162
163
164 AC_SUBST(USE_SELINUX)
165
166 # for asciidoc before ver. 7, the backend must be stated explicitly:
167 ASCIIDOC='asciidoc'
168 asciidoc_ver=`asciidoc --version 2>&1 | awk '/^asciidoc /{print $2}' | cut -d. -f 1 | head -n 1`
169 if test "$asciidoc_ver" != '' && test $asciidoc_ver -lt 7; then
170         ASCIIDOC="asciidoc -b xhtml"
171 fi
172 AC_SUBST(ASCIIDOC)
173
174 AC_ARG_WITH(ppp,
175             [AS_HELP_STRING([--with-ppp=PATH],[Use PPP support from PATH])],
176             [],
177             [with_ppp=check]
178             )
179 # somebody will fix that
180 default_ppp_path=/usr
181
182 case "$with_ppp" in
183         yes|check) ppp_path="$default_ppp_path";;
184         no) ppp_path='' ;;
185         *) ppp_path="$with_ppp" ;;
186 esac
187
188 level_file="$ppp_path/include/pppd/patchlevel.h"
189 PPP_VERSION=
190 if test "$ppp_path" != '' && test -r "$level_file"; then
191         PPPD_VERSION=`awk -F '"' '/VERSION/ { print $$2; }' $level_file`
192 fi
193
194 case "$with_ppp" in 
195         check|no) :;;
196         *) 
197         # If we asked explicitly for ppp support
198         if test "$PPPD_VERSION" = ''; then
199                 # but have not detected it
200                 AC_MSG_ERROR(failed to find pppd/patchlevel.h: no ppp support.)
201         fi
202         ;;
203 esac
204
205 if test "x${PBX_DAHDI}" != "x1"; then
206    AC_MSG_NOTICE([***])
207    AC_MSG_NOTICE([*** Building this package requires DAHDI support. *** ])
208    AC_MSG_NOTICE([*** Please install the dahdi-linux package. ***])
209    AC_MSG_NOTICE([***])
210    exit 1
211 fi
212
213 if test "x${PBX_DAHDI23}" != "x1"; then
214    AC_MSG_NOTICE([***])
215    AC_MSG_NOTICE([*** Building this package requires DAHDI support (>= 2.3) *** ])
216    AC_MSG_NOTICE([*** Please install a recent dahdi-linux package. ***])
217    AC_MSG_NOTICE([***])
218    exit 1
219 fi
220
221 AC_SUBST(PPPD_VERSION)
222
223 AC_CONFIG_FILES([makeopts])
224 AC_OUTPUT
225
226 AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)