xpp: README: hwid attribute of the xpd sysfs node
[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_TOOL([LD], [ld])
72
73 # Checks for programs.
74 AC_PROG_CXX
75 AC_PROG_CC
76 AC_PROG_CPP
77 AM_PROG_CC_C_O
78 AC_PROG_INSTALL
79 AC_PROG_LN_S
80 AC_PROG_MAKE_SET
81 AC_PROG_AWK
82 AC_PROG_LIBTOOL
83 AST_CHECK_GNU_MAKE
84
85 test_obj=conftest.o
86 AC_COMPILE_IFELSE(AC_LANG_SOURCE(),[
87         BDFNAME=`LANG=C objdump -f $test_obj | grep -e "$test_obj:" | sed "s/.*file format \(.*\)/\1/"`
88         BDFARCH=`LANG=C objdump -f $test_obj | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`    
89 ],[])
90 AC_SUBST(BDFNAME)
91 AC_SUBST(BDFARCH)
92
93 # Set the default value of HOSTCC from CC if --host was not provided:
94 HOSTCC=${HOSTCC:=${CC}}
95 AC_SUBST(HOSTCC)
96
97 AC_PATH_PROG([GREP], [grep], :)
98 AC_PATH_PROG([SHELL], [sh], :)
99 AC_PATH_PROG([LN], [ln], :)
100
101 AC_PATH_PROG([WGET], [wget], :)
102 if test "${WGET}" != ":" ; then
103   DOWNLOAD=${WGET}
104 else
105   AC_PATH_PROG([FETCH], [fetch], [:])
106   DOWNLOAD=${FETCH}
107 fi
108 AC_SUBST(DOWNLOAD)
109
110 AC_LANG(C)
111
112 AC_PATH_PROG([PERL], [perl])
113 if test "$PERL" = ''; then
114               AC_MSG_ERROR(perl is mandatory)
115 fi
116 # Where to install perl modules?
117 #  * Packagers are encouraged to use the result of "perl -V:vendorlib"
118 #  * Our default is:
119 #    - The result of "perl -V:sitelib" for our default prefix (/usr)
120 #    - The "$datadir/perl5" directory otherwise (e.g: during "make distcheck")
121 #
122 AC_MSG_CHECKING(for perl libdir)
123 m4_define([_PERL_LIBDIR_DEFAULT], [${datadir}/perl5])dnl
124 AC_ARG_WITH(perllib,
125         [AS_HELP_STRING([--with-perllib=PATH],
126                 [Location of perl modules @<:@default=]_PERL_LIBDIR_DEFAULT[, or perl -V:sitelib@:>@])],
127         [perllibdir=$withval],
128         [
129                 if test "$prefix" = 'NONE' -o "$prefix" = '/usr'; then
130                         eval `"$PERL" -V:sitelib`
131                         perllibdir="$sitelib"
132                 else
133                         perllibdir='_PERL_LIBDIR_DEFAULT'
134                 fi
135         ]
136 )
137 AC_SUBST([perllibdir], "$perllibdir")
138 AC_MSG_RESULT([$perllibdir])
139 AM_CONDITIONAL([PERL], [test "$perllibdir" != ''])
140
141 AC_ARG_ENABLE(dev-mode,
142         [  --enable-dev-mode    Turn on developer mode],
143         [case "${enableval}" in
144               y|ye|yes) DAHDI_DEVMODE=yes ;;
145               n|no)  DAHDI_DEVMODE=no ;;
146               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
147         esac])
148 AC_SUBST(DAHDI_DEVMODE)
149 AM_CONDITIONAL([DAHDI_DEVMODE], [test "$DAHDI_DEVMODE" = 'yes'])
150
151 AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
152 if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
153         AC_MSG_RESULT(yes)
154         DAHDI_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
155 else
156         AC_MSG_RESULT(no)
157         DAHDI_DECLARATION_AFTER_STATEMENT=
158 fi
159 AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
160
161 # Checks for header files.
162 AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
163 AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])
164
165 # Checks for typedefs, structures, and compiler characteristics.
166 AC_C_INLINE
167 AC_TYPE_SIZE_T
168 AC_TYPE_SSIZE_T
169 AC_TYPE_UINT16_T
170 AC_TYPE_UINT32_T
171 AC_TYPE_UINT8_T
172
173 # Checks for libraries.
174 AC_CHECK_LIB([m], [cos])
175 AC_CHECK_LIB([pthread], [pthread_create])
176
177 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
178 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
179 AST_EXT_LIB_SETUP([USB], [usb], [usb])
180 AST_EXT_LIB_SETUP([PCAP], [pcap], [pcap])
181
182 AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
183 DAHDI23_DIR="${DAHDI_DIR}"
184 AST_C_DEFINE_CHECK([DAHDI23], [DAHDI_CONFIG_NTTE], [dahdi/user.h])
185 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
186 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h])
187 AST_EXT_LIB_CHECK([PCAP], [pcap], [pcap_compile], [pcap.h])
188
189 saved_CPPFLAGS="$CPPFLAGS"
190 CPPFLAGS="$CPPFLAGS $DAHDI_INCLUDE"
191 AC_CHECK_DECL([DAHDI_TXMIRROR], [DAHDI_TXMIRROR=1], [DAHDI_TXMIRROR=0], [#include <dahdi/user.h>])
192 CPPFLAGS="$saved_CPPFLAGS"
193
194 AM_CONDITIONAL([PBX_NEWT], [test "$PBX_NEWT" = "1"])
195 AM_CONDITIONAL([PBX_PCAP], [test "$PBX_PCAP" = "1" -a "$DAHDI_TXMIRROR" = "1"])
196
197 AC_CHECK_FUNCS([semtimedop])
198 AC_CHECK_FUNCS([alarm bzero gettimeofday memset pow regcomp select socket strcasecmp strchr strdup strerror strrchr strstr strtol strtoul])
199 AC_FUNC_ERROR_AT_LINE
200 AC_FUNC_MALLOC
201
202 # What the user asked for? libusb/libusbx
203 AC_ARG_WITH([libusbx],
204         [AS_HELP_STRING([--without-libusbx], [Disable libusbx @<:@default=check@:>@])],
205         [],
206         [with_libusbx=check])
207 AC_ARG_WITH([libusb],
208         [AS_HELP_STRING([--without-libusb], [Disable libusb-0.1 @<:@default=check@:>@])],
209         [],
210         [with_libusb=check])
211
212 # LIBUSBX tests
213 have_libusbx=
214 AS_IF([test "$with_libusbx" != "no"],
215         [PKG_CHECK_MODULES([LIBUSBX], [libusb-1.0],
216                 [AC_CHECK_LIB([usb-1.0], [libusb_error_name],
217                         [
218                                 have_libusbx="yes"
219                                 AC_DEFINE([HAVE_LIBUSBX], [1], [Define to 1 if you have <libusb.h>.])
220                                 AC_SUBST([PBX_USB], [1])
221                         ], [
222                                 if test "$with_libusbx" != "yes"; then
223                                         AC_MSG_NOTICE([Ignoring old libusb-1.0, trying fallback to old libusb])
224                                 fi
225                         ])
226                 ], [:])
227         ], [])
228
229 AS_IF([test "$with_libusbx" = "yes" -a "$have_libusbx" = ""],
230         [AC_MSG_ERROR([No libusbx found (--with-libusbx was given)])])
231
232 # LIBUSB tests
233 have_libusb=
234 AS_IF([test "$with_libusb" != "no"],
235         [AS_IF([test "$have_libusbx" != ""],
236                 [
237                         AS_IF([test "$with_libusbx" = "check"], [
238                                 AC_MSG_NOTICE([Skipping LIBUSB tests (have good LIBUSBX)])
239                                 ])
240                 ], [
241                         PKG_CHECK_MODULES([LIBUSB], [libusb],
242                                 [
243                                         have_libusb="yes"
244                                         AC_SUBST([PBX_USB], [1])
245                                 ]
246                                 [AC_DEFINE([HAVE_LIBUSB], [1], [Define to 1 if you have <usb.h>.])],
247                                 [:]
248                                 )
249                 ])
250         ], [])
251
252 AS_IF([test "$with_libusb" = "yes" -a "$have_libusb" = ""],
253         [AC_MSG_ERROR([No libusb found (--with-libusb was given)])])
254
255 AM_CONDITIONAL([LIBUSBX], [test "$have_libusbx" != ""])
256 AM_CONDITIONAL([LIBUSB], [test "$have_libusb" != ""])
257 AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
258
259
260 PBX_HDLC=0
261 AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
262 AC_COMPILE_IFELSE(
263     [ AC_LANG_PROGRAM( [#include <linux/hdlc.h>],
264             [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
265                 int foo = 0;
266                 #else
267                 int foo = bar;
268                 #endif
269                 0])],
270         [AC_MSG_RESULT(yes)
271          PBX_HDLC=1],
272         [AC_MSG_RESULT(no)]
273 )
274 if test $PBX_HDLC = 0; then
275     AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc/ioctl.h])
276     AC_COMPILE_IFELSE(
277             [ AC_LANG_PROGRAM( [
278                     #include <sys/socket.h>
279                         #include <linux/if.h>],
280                         [#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
281                         int foo = 0;
282                         #else
283                         int foo = bar;
284                         #endif
285                         0])],
286                 [AC_MSG_RESULT(yes)
287                  PBX_HDLC=1],
288                 [AC_MSG_RESULT(no)]
289         )
290 fi
291
292 if test "x${PBX_HDLC}" != "x1"; then
293    AC_MSG_NOTICE([GENERIC_HDLC_VERSION (version 4) not found, disabling sethdlc.])
294 fi
295
296 AC_SUBST(PBX_HDLC)
297 AM_CONDITIONAL([PBX_HDLC], [test "$PBX_HDLC" = "1"])
298
299 AC_ARG_WITH(selinux,
300         [AS_HELP_STRING([--with-selinux],
301                         [enable (with) / disable (without) SELinux])],
302         [USE_SELINUX=$withval],
303         [ if test ! -x /usr/sbin/sestatus; then 
304                 USE_SELINUX=no;
305           elif /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"; then
306                 USE_SELINUX=yes
307           fi
308         ]
309 )
310
311
312 AC_SUBST(USE_SELINUX)
313
314 # for asciidoc before ver. 7, the backend must be stated explicitly:
315 ASCIIDOC='asciidoc'
316 asciidoc_ver=`asciidoc --version 2>&1 | awk '/^asciidoc /{print $2}' | cut -d. -f 1 | head -n 1`
317 if test "$asciidoc_ver" != '' && test $asciidoc_ver -lt 7; then
318         ASCIIDOC="asciidoc -b xhtml"
319 fi
320 AC_SUBST(ASCIIDOC)
321
322 AC_ARG_WITH(ppp,
323             [AS_HELP_STRING([--with-ppp=PATH],[Use PPP support from PATH])],
324             [],
325             [with_ppp=check]
326             )
327 # somebody will fix that
328 default_ppp_path=/usr
329
330 case "$with_ppp" in
331         yes|check) ppp_path="$default_ppp_path";;
332         no) ppp_path='' ;;
333         *) ppp_path="$with_ppp" ;;
334 esac
335
336 level_file="$ppp_path/include/pppd/patchlevel.h"
337 PPP_VERSION=
338 if test "$ppp_path" != '' && test -r "$level_file"; then
339         PPPD_VERSION=`awk -F '"' '/VERSION/ { print $$2; }' $level_file`
340 fi
341
342 case "$with_ppp" in 
343         check|no) :;;
344         *) 
345         # If we asked explicitly for ppp support
346         if test "$PPPD_VERSION" = ''; then
347                 # but have not detected it
348                 AC_MSG_ERROR(failed to find pppd/patchlevel.h: no ppp support.)
349         fi
350         ;;
351 esac
352
353 AC_SUBST(PPPD_VERSION)
354 AM_CONDITIONAL([PPPD], [test "$PPPD_VERSION" != ''])
355
356 if test "x${PBX_DAHDI}" != "x1"; then
357    AC_MSG_NOTICE([***])
358    AC_MSG_NOTICE([*** Building this package requires DAHDI support. *** ])
359    AC_MSG_NOTICE([*** Please install the dahdi-linux package. ***])
360    AC_MSG_NOTICE([***])
361    exit 1
362 fi
363
364 if test "x${PBX_DAHDI23}" != "x1"; then
365    AC_MSG_NOTICE([***])
366    AC_MSG_NOTICE([*** Building this package requires DAHDI support (>= 2.3) *** ])
367    AC_MSG_NOTICE([*** Please install a recent dahdi-linux package. ***])
368    AC_MSG_NOTICE([***])
369    exit 1
370 fi
371
372 AC_SUBST(PPPD_VERSION)
373
374 # Taken from octasic-helper
375 AC_SUBST([USE_OCTASIC], [yes])
376 AM_CONDITIONAL([USE_OCTASIC], [test "$USE_OCTASIC" = 'yes'])
377 octasic_dir='$(top_srcdir)/xpp/oct612x'
378 AC_SUBST([OCTASIC_CFLAGS], ["-I$octasic_dir/include -I$octasic_dir/octdeviceapi -I$octasic_dir/octdeviceapi/oct6100api"])
379
380 AC_SUBST([TOOLSVERSION], m4_esyscmd([build_tools/make_version . dahdi/tools]))
381
382 AC_CONFIG_FILES([
383         makeopts
384         version.c
385         Makefile
386         doc/Makefile
387         hotplug/Makefile
388         ppp/Makefile
389         xpp/Makefile
390         xpp/xtalk/Makefile
391         xpp/oct612x/Makefile
392         xpp/perl_modules/Makefile
393         ])
394 AC_OUTPUT
395
396 AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)