Import DAHDI-Tools r9159
[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_MSG_CHECKING(for -Wdeclaration-after-statement support)
83 if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
84         AC_MSG_RESULT(yes)
85         DAHDI_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
86 else
87         AC_MSG_RESULT(no)
88         DAHDI_DECLARATION_AFTER_STATEMENT=
89 fi
90 AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
91
92 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
93 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
94 AST_EXT_LIB_SETUP([USB], [usb], [usb])
95
96 AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
97 DAHDI23_DIR="${DAHDI_DIR}"
98 AST_C_DEFINE_CHECK([DAHDI23], [DAHDI_CONFIG_NTTE], [dahdi/user.h])
99 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
100 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h])
101
102 PBX_HDLC=0
103 AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
104 AC_COMPILE_IFELSE(
105     [ AC_LANG_PROGRAM( [#include <linux/hdlc.h>],
106             [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
107                 int foo = 0;
108                 #else
109                 int foo = bar;
110                 #endif
111                 0])],
112         [AC_MSG_RESULT(yes)
113          PBX_HDLC=1],
114         [AC_MSG_RESULT(no)]
115 )
116 if test $PBX_HDLC = 0; then
117     AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc/ioctl.h])
118     AC_COMPILE_IFELSE(
119             [ AC_LANG_PROGRAM( [
120                     #include <sys/socket.h>
121                         #include <linux/if.h>],
122                         [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
123                         int foo = 0;
124                         #else
125                         int foo = bar;
126                         #endif
127                         0])],
128                 [AC_MSG_RESULT(yes)
129                  PBX_HDLC=1],
130                 [AC_MSG_RESULT(no)]
131         )
132 fi
133
134 if test "x${PBX_HDLC}" != "x1"; then
135    AC_MSG_NOTICE([GENERIC_HDLC_VERSION (version 4) not found, disabling sethdlc.])
136 fi
137
138 AC_SUBST(PBX_HDLC)
139
140 AC_ARG_WITH(selinux,
141         [AS_HELP_STRING([--with-selinux],
142                         [enable (with) / disable (without) SELinux])],
143         [USE_SELINUX=$withval],
144         [ if test ! -x /usr/sbin/sestatus; then 
145                 USE_SELINUX=no;
146           elif /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"; then
147                 USE_SELINUX=yes
148           fi
149         ]
150 )
151
152
153 AC_SUBST(USE_SELINUX)
154
155 # for asciidoc before ver. 7, the backend must be stated explicitly:
156 ASCIIDOC='asciidoc'
157 asciidoc_ver=`asciidoc --version 2>&1 | awk '/^asciidoc /{print $2}' | cut -d. -f 1 | head -n 1`
158 if test "$asciidoc_ver" != '' && test $asciidoc_ver -lt 7; then
159         ASCIIDOC="asciidoc -b xhtml"
160 fi
161 AC_SUBST(ASCIIDOC)
162
163 AC_ARG_WITH(ppp,
164             [AS_HELP_STRING([--with-ppp=PATH],[Use PPP support from PATH])],
165             [],
166             [with_ppp=check]
167             )
168 # somebody will fix that
169 default_ppp_path=/usr
170
171 case "$with_ppp" in
172         yes|check) ppp_path="$default_ppp_path";;
173         no) ppp_path='' ;;
174         *) ppp_path="$with_ppp" ;;
175 esac
176
177 level_file="$ppp_path/include/pppd/patchlevel.h"
178 PPP_VERSION=
179 if test "$ppp_path" != '' && test -r "$level_file"; then
180         PPPD_VERSION=`awk -F '"' '/VERSION/ { print $$2; }' $level_file`
181 fi
182
183 case "$with_ppp" in 
184         check|no) :;;
185         *) 
186         # If we asked explicitly for ppp support
187         if test "$PPPD_VERSION" = ''; then
188                 # but have not detected it
189                 AC_MSG_ERROR(failed to find pppd/patchlevel.h: no ppp support.)
190         fi
191         ;;
192 esac
193
194 if test "x${PBX_DAHDI}" != "x1"; then
195    AC_MSG_NOTICE([***])
196    AC_MSG_NOTICE([*** Building this package requires DAHDI support. *** ])
197    AC_MSG_NOTICE([*** Please install the dahdi-linux package. ***])
198    AC_MSG_NOTICE([***])
199    exit 1
200 fi
201
202 if test "x${PBX_DAHDI23}" != "x1"; then
203    AC_MSG_NOTICE([***])
204    AC_MSG_NOTICE([*** Building this package requires DAHDI support (>= 2.3) *** ])
205    AC_MSG_NOTICE([*** Please install a recent dahdi-linux package. ***])
206    AC_MSG_NOTICE([***])
207    exit 1
208 fi
209
210 AC_SUBST(PPPD_VERSION)
211
212 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
213 AC_OUTPUT
214
215 AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)