xpp: migrate everything to libxtalk
[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([short_version],
6           m4_bpatsubst(m4_esyscmd([build_tools/make_version . dahdi/tools]),
7                        [\([0-9.]*\)\(\w\|\W\)*],
8                        [\1]))
9 AC_INIT([dahdi-tools], short_version, [www.asterisk.org])
10
11 # check existence of the package
12 AC_CONFIG_SRCDIR([dahdi_cfg.c])
13 AC_CONFIG_AUX_DIR([auxdir])
14 AC_CONFIG_MACRO_DIR([m4])
15 AM_INIT_AUTOMAKE([foreign subdir-objects])
16
17 build_version=`build_tools/make_version . dahdi/tools`
18 AC_SUBST([BUILD_VERSION], "$build_version")
19
20 # enable nice build output on automake1.11
21 m4_pattern_allow([AM_DEFAULT_VERBOSITY])
22 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],[AM_DEFAULT_VERBOSITY=1])
23 AM_CONDITIONAL([SILENT_RULES], [test "$AM_DEFAULT_VERBOSITY" = '0'])
24
25 AC_COPYRIGHT("dahdi-tools")
26 AC_REVISION($Revision$)
27
28 # Preserve old defaults if called without --prefix or --prefix=/usr
29 #  prefix=/usr
30 #  sysconfdir=/etc
31
32 ac_default_prefix=/usr
33 if test "$prefix" = 'NONE' -o "$prefix" = '/usr'; then
34         if test ${sysconfdir} = '${prefix}/etc'; then
35            sysconfdir=/etc
36         fi
37         if test ${mandir} = '${prefix}/man'; then
38            mandir=/usr/share/man
39         fi
40
41         if test ${localstatedir} = '${prefix}/var'; then
42              localstatedir=/var
43         fi
44 fi
45 AC_SUBST([dahditoolsdir], ['${datadir}/dahdi'])
46 AC_SUBST([dahdiincludedir], ['${includedir}/dahdi'])
47
48 # Where to install udev rules?
49 #  * Our default is $sysconfdir/udev/rules.d:
50 #    - This preserve legacy location.
51 #    - It doesn't write into modern vendor supplied location (/lib/udev/rules.d)
52 #    - It doesn't break "make distcheck" (where everything should be relative
53 #      to prefix.
54 #  * Packagers are encouraged to use --udevrules=/lib/udev/rules.d
55 #
56 m4_define([_UDEV_RULES_DIR_DEFAULT], [${sysconfdir}/udev/rules.d])dnl
57 AC_ARG_WITH(udevrules,
58         [AS_HELP_STRING([--with-udevrules=PATH],
59                 [Location of UDEV rules @<:@default=]_UDEV_RULES_DIR_DEFAULT[@:>@])],
60         [udevrulesdir=$withval],
61         [udevrulesdir=]'_UDEV_RULES_DIR_DEFAULT'
62 )
63 AC_SUBST([udevrulesdir], "$udevrulesdir")
64
65 # specify output header file
66 AC_CONFIG_HEADER(autoconfig.h)
67
68 # This needs to be before any macros that use the C compiler
69 AC_GNU_SOURCE
70
71 AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
72
73 AC_CHECK_TOOL([LD], [ld])
74
75 # Checks for programs.
76 AC_PROG_CXX
77 AC_PROG_CC
78 AC_PROG_CPP
79 AM_PROG_CC_C_O
80 AC_PROG_INSTALL
81 AC_PROG_LN_S
82 AC_PROG_MAKE_SET
83 AC_PROG_AWK
84 AC_PROG_LIBTOOL
85 AST_CHECK_GNU_MAKE
86
87 test_obj=conftest.o
88 AC_COMPILE_IFELSE(AC_LANG_SOURCE(),[
89         BDFNAME=`LANG=C objdump -f $test_obj | grep -e "$test_obj:" | sed "s/.*file format \(.*\)/\1/"`
90         BDFARCH=`LANG=C objdump -f $test_obj | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`    
91 ],[])
92 AC_SUBST(BDFNAME)
93 AC_SUBST(BDFARCH)
94
95 # Set the default value of HOSTCC from CC if --host was not provided:
96 HOSTCC=${HOSTCC:=${CC}}
97 AC_SUBST(HOSTCC)
98
99 AC_PATH_PROG([GREP], [grep], :)
100 AC_PATH_PROG([SHELL], [sh], :)
101 AC_PATH_PROG([LN], [ln], :)
102
103 AC_PATH_PROG([WGET], [wget], :)
104 if test "${WGET}" != ":" ; then
105   DOWNLOAD=${WGET}
106 else
107   AC_PATH_PROG([FETCH], [fetch], [:])
108   DOWNLOAD=${FETCH}
109 fi
110 AC_SUBST(DOWNLOAD)
111
112 AC_LANG(C)
113
114 AC_PATH_PROG([PERL], [perl])
115 if test "$PERL" = ''; then
116               AC_MSG_ERROR(perl is mandatory)
117 fi
118 # Where to install perl modules?
119 #  * Packagers are encouraged to use the result of "perl -V:vendorlib"
120 #  * Our default is:
121 #    - The result of "perl -V:sitelib" for our default prefix (/usr)
122 #    - The "$datadir/perl5" directory otherwise (e.g: during "make distcheck")
123 #
124 AC_MSG_CHECKING(for perl libdir)
125 m4_define([_PERL_LIBDIR_DEFAULT], [${datadir}/perl5])dnl
126 AC_ARG_WITH(perllib,
127         [AS_HELP_STRING([--with-perllib=PATH],
128                 [Location of perl modules @<:@default=]_PERL_LIBDIR_DEFAULT[, or perl -V:sitelib@:>@])],
129         [perllibdir=$withval],
130         [
131                 if test "$prefix" = 'NONE' -o "$prefix" = '/usr'; then
132                         eval `"$PERL" -V:sitelib`
133                         perllibdir="$sitelib"
134                 else
135                         perllibdir='_PERL_LIBDIR_DEFAULT'
136                 fi
137         ]
138 )
139 AC_SUBST([perllibdir], "$perllibdir")
140 AC_MSG_RESULT([$perllibdir])
141 AM_CONDITIONAL([PERL], [test "$perllibdir" != ''])
142
143 AC_ARG_ENABLE(dev-mode,
144         [  --enable-dev-mode    Turn on developer mode],
145         [case "${enableval}" in
146               y|ye|yes) DAHDI_DEVMODE=yes ;;
147               n|no)  DAHDI_DEVMODE=no ;;
148               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
149         esac])
150 AC_SUBST(DAHDI_DEVMODE)
151 AM_CONDITIONAL([DAHDI_DEVMODE], [test "$DAHDI_DEVMODE" = 'yes'])
152
153 AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
154 if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
155         AC_MSG_RESULT(yes)
156         DAHDI_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
157 else
158         AC_MSG_RESULT(no)
159         DAHDI_DECLARATION_AFTER_STATEMENT=
160 fi
161 AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
162
163 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
164 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
165 AST_EXT_LIB_SETUP([USB], [usb], [usb])
166 AST_EXT_LIB_SETUP([PCAP], [pcap], [pcap])
167
168 AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
169 DAHDI23_DIR="${DAHDI_DIR}"
170 AST_C_DEFINE_CHECK([DAHDI23], [DAHDI_CONFIG_NTTE], [dahdi/user.h])
171 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
172 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h])
173 AST_EXT_LIB_CHECK([PCAP], [pcap], [pcap_compile], [pcap.h])
174
175 saved_CPPFLAGS="$CPPFLAGS"
176 CPPFLAGS="$CPPFLAGS $DAHDI_INCLUDE"
177 AC_CHECK_DECL([DAHDI_TXMIRROR], [DAHDI_TXMIRROR=1], [DAHDI_TXMIRROR=0], [#include <dahdi/user.h>])
178 CPPFLAGS="$saved_CPPFLAGS"
179
180 AM_CONDITIONAL([PBX_NEWT], [test "$PBX_NEWT" = "1"])
181 AM_CONDITIONAL([PBX_PCAP], [test "$PBX_PCAP" = "1" -a "$DAHDI_TXMIRROR" = "1"])
182
183 AC_CHECK_FUNCS([semtimedop])
184
185 # What the user asked for? libusb/libusbx
186 AC_ARG_WITH([libusbx],
187         [AS_HELP_STRING([--without-libusbx], [Disable libusbx @<:@default=check@:>@])],
188         [],
189         [with_libusbx=check])
190 AC_ARG_WITH([libusb],
191         [AS_HELP_STRING([--without-libusb], [Disable libusb-0.1 @<:@default=check@:>@])],
192         [],
193         [with_libusb=check])
194
195 # LIBUSBX tests
196 have_libusbx=
197 AS_IF([test "$with_libusbx" = "yes"],
198         [PKG_CHECK_MODULES([LIBUSBX], [libusb-1.0],
199                 [AC_CHECK_LIB([usb-1.0], [libusb_error_name],
200                         [
201                                 have_libusbx="yes"
202                                 AC_SUBST([PKG_CONFIG_LIBUSB], [libusb-1.0])
203                                 AC_DEFINE([HAVE_LIBUSBX], [1], [Define to 1 if you have <libusb.h>.])
204                                 AC_SUBST([PBX_USB], [1])
205                         ], [
206                                 if test "$with_libusbx" != "yes"; then
207                                         AC_MSG_NOTICE([Ignoring old libusb-1.0, trying fallback to old libusb])
208                                 fi
209                         ])
210                 ], [:])
211         ], [])
212
213 AS_IF([test "$with_libusbx" = "yes" -a "$have_libusbx" = ""],
214         [AC_MSG_ERROR([No libusbx found (--with-libusbx was given)])])
215
216 # LIBUSB tests
217 have_libusb=
218 AS_IF([test "$with_libusb" != "no"],
219         [AS_IF([test "$have_libusbx" != ""],
220                 [
221                         AS_IF([test "$with_libusbx" = "check"], [
222                                 AC_MSG_NOTICE([Skipping LIBUSB tests (have good LIBUSBX)])
223                                 ])
224                 ], [
225                         PKG_CHECK_MODULES([LIBUSB], [libusb],
226                                 [
227                                         have_libusb="yes"
228                                         AC_SUBST([PKG_CONFIG_LIBUSB], [libusb])
229                                         AC_SUBST([PBX_USB], [1])
230                                 ]
231                                 [AC_DEFINE([HAVE_LIBUSB], [1], [Define to 1 if you have <usb.h>.])],
232                                 [:]
233                                 )
234                 ])
235         ], [])
236
237 AS_IF([test "$with_libusb" = "yes" -a "$have_libusb" = ""],
238         [AC_MSG_ERROR([No libusb found (--with-libusb was given)])])
239
240 AM_CONDITIONAL([LIBUSBX], [test "$have_libusbx" != ""])
241 AM_CONDITIONAL([LIBUSB], [test "$have_libusb" != ""])
242 AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
243
244
245 PBX_HDLC=0
246 AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
247 AC_COMPILE_IFELSE(
248     [ AC_LANG_PROGRAM( [#include <linux/hdlc.h>],
249             [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
250                 int foo = 0;
251                 #else
252                 int foo = bar;
253                 #endif
254                 0])],
255         [AC_MSG_RESULT(yes)
256          PBX_HDLC=1],
257         [AC_MSG_RESULT(no)]
258 )
259 if test $PBX_HDLC = 0; then
260     AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc/ioctl.h])
261     AC_COMPILE_IFELSE(
262             [ AC_LANG_PROGRAM( [
263                     #include <sys/socket.h>
264                         #include <linux/if.h>],
265                         [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
266                         int foo = 0;
267                         #else
268                         int foo = bar;
269                         #endif
270                         0])],
271                 [AC_MSG_RESULT(yes)
272                  PBX_HDLC=1],
273                 [AC_MSG_RESULT(no)]
274         )
275 fi
276
277 if test "x${PBX_HDLC}" != "x1"; then
278    AC_MSG_NOTICE([GENERIC_HDLC_VERSION (version 4) not found, disabling sethdlc.])
279 fi
280
281 AC_SUBST(PBX_HDLC)
282 AM_CONDITIONAL([PBX_HDLC], [test "$PBX_HDLC" = "1"])
283
284 AC_ARG_WITH(selinux,
285         [AS_HELP_STRING([--with-selinux],
286                         [enable (with) / disable (without) SELinux])],
287         [USE_SELINUX=$withval],
288         [ if test ! -x /usr/sbin/sestatus; then 
289                 USE_SELINUX=no;
290           elif /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"; then
291                 USE_SELINUX=yes
292           fi
293         ]
294 )
295
296
297 AC_SUBST(USE_SELINUX)
298
299 # for asciidoc before ver. 7, the backend must be stated explicitly:
300 ASCIIDOC='asciidoc'
301 asciidoc_ver=`asciidoc --version 2>&1 | awk '/^asciidoc /{print $2}' | cut -d. -f 1 | head -n 1`
302 if test "$asciidoc_ver" != '' && test $asciidoc_ver -lt 7; then
303         ASCIIDOC="asciidoc -b xhtml"
304 fi
305 AC_SUBST(ASCIIDOC)
306
307 AC_ARG_WITH(ppp,
308             [AS_HELP_STRING([--with-ppp=PATH],[Use PPP support from PATH])],
309             [],
310             [with_ppp=check]
311             )
312 # somebody will fix that
313 default_ppp_path=/usr
314
315 case "$with_ppp" in
316         yes|check) ppp_path="$default_ppp_path";;
317         no) ppp_path='' ;;
318         *) ppp_path="$with_ppp" ;;
319 esac
320
321 level_file="$ppp_path/include/pppd/patchlevel.h"
322 PPP_VERSION=
323 if test "$ppp_path" != '' && test -r "$level_file"; then
324         PPPD_VERSION=`awk -F '"' '/VERSION/ { print $$2; }' $level_file`
325 fi
326
327 case "$with_ppp" in 
328         check|no) :;;
329         *) 
330         # If we asked explicitly for ppp support
331         if test "$PPPD_VERSION" = ''; then
332                 # but have not detected it
333                 AC_MSG_ERROR(failed to find pppd/patchlevel.h: no ppp support.)
334         fi
335         ;;
336 esac
337
338 AC_SUBST(PPPD_VERSION)
339 AM_CONDITIONAL([PPPD], [test "$PPPD_VERSION" != ''])
340
341 if test "x${PBX_DAHDI}" != "x1"; then
342    AC_MSG_NOTICE([***])
343    AC_MSG_NOTICE([*** Building this package requires DAHDI support. *** ])
344    AC_MSG_NOTICE([*** Please install the dahdi-linux package. ***])
345    AC_MSG_NOTICE([***])
346    exit 1
347 fi
348
349 if test "x${PBX_DAHDI23}" != "x1"; then
350    AC_MSG_NOTICE([***])
351    AC_MSG_NOTICE([*** Building this package requires DAHDI support (>= 2.3) *** ])
352    AC_MSG_NOTICE([*** Please install a recent dahdi-linux package. ***])
353    AC_MSG_NOTICE([***])
354    exit 1
355 fi
356
357 AC_SUBST(PPPD_VERSION)
358
359 # Taken from octasic-helper
360 AC_SUBST([USE_OCTASIC], [yes])
361 AM_CONDITIONAL([USE_OCTASIC], [test "$USE_OCTASIC" = 'yes'])
362 octasic_dir='$(top_srcdir)/xpp/oct612x'
363 AC_SUBST([OCTASIC_CFLAGS], ["-I$octasic_dir/include -I$octasic_dir/octdeviceapi -I$octasic_dir/octdeviceapi/oct6100api"])
364
365 AC_SUBST([TOOLSVERSION], m4_esyscmd([build_tools/make_version . dahdi/tools]))
366
367 AC_CONFIG_FILES([
368         makeopts
369         version.c
370         Makefile
371         doc/Makefile
372         hotplug/Makefile
373         ppp/Makefile
374         xpp/Makefile
375         xpp/xtalk/Makefile
376         xpp/oct612x/Makefile
377         xpp/perl_modules/Makefile
378         ])
379 AC_OUTPUT
380
381 AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)