xpp: README: hwid attribute of the xpd sysfs node
[dahdi/tools.git] / configure.ac
index c688f66..826a7ec 100644 (file)
@@ -25,21 +25,42 @@ AM_CONDITIONAL([SILENT_RULES], [test "$AM_DEFAULT_VERBOSITY" = '0'])
 AC_COPYRIGHT("dahdi-tools")
 AC_REVISION($Revision$)
 
+# Preserve old defaults if called without --prefix or --prefix=/usr
+#  prefix=/usr
+#  sysconfdir=/etc
+
 ac_default_prefix=/usr
-if test ${sysconfdir} = '${prefix}/etc'; then
-   sysconfdir=/etc
-fi
-if test ${mandir} = '${prefix}/man'; then
-   mandir=/usr/share/man
-fi
+if test "$prefix" = 'NONE' -o "$prefix" = '/usr'; then
+       if test ${sysconfdir} = '${prefix}/etc'; then
+          sysconfdir=/etc
+       fi
+       if test ${mandir} = '${prefix}/man'; then
+          mandir=/usr/share/man
+       fi
 
-if test ${localstatedir} = '${prefix}/var'; then
-     localstatedir=/var
+       if test ${localstatedir} = '${prefix}/var'; then
+            localstatedir=/var
+       fi
 fi
 AC_SUBST([dahditoolsdir], ['${datadir}/dahdi'])
 AC_SUBST([dahdiincludedir], ['${includedir}/dahdi'])
 
-AC_SUBST([udevrulesdir], '${sysconfdir}/udev/rules.d')
+# Where to install udev rules?
+#  * Our default is $sysconfdir/udev/rules.d:
+#    - This preserve legacy location.
+#    - It doesn't write into modern vendor supplied location (/lib/udev/rules.d)
+#    - It doesn't break "make distcheck" (where everything should be relative
+#      to prefix.
+#  * Packagers are encouraged to use --udevrules=/lib/udev/rules.d
+#
+m4_define([_UDEV_RULES_DIR_DEFAULT], [${sysconfdir}/udev/rules.d])dnl
+AC_ARG_WITH(udevrules,
+       [AS_HELP_STRING([--with-udevrules=PATH],
+               [Location of UDEV rules @<:@default=]_UDEV_RULES_DIR_DEFAULT[@:>@])],
+       [udevrulesdir=$withval],
+       [udevrulesdir=]'_UDEV_RULES_DIR_DEFAULT'
+)
+AC_SUBST([udevrulesdir], "$udevrulesdir")
 
 # specify output header file
 AC_CONFIG_HEADER(autoconfig.h)
@@ -47,8 +68,6 @@ AC_CONFIG_HEADER(autoconfig.h)
 # This needs to be before any macros that use the C compiler
 AC_GNU_SOURCE
 
-AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
-
 AC_CHECK_TOOL([LD], [ld])
 
 # Checks for programs.
@@ -94,9 +113,28 @@ AC_PATH_PROG([PERL], [perl])
 if test "$PERL" = ''; then
              AC_MSG_ERROR(perl is mandatory)
 fi
+# Where to install perl modules?
+#  * Packagers are encouraged to use the result of "perl -V:vendorlib"
+#  * Our default is:
+#    - The result of "perl -V:sitelib" for our default prefix (/usr)
+#    - The "$datadir/perl5" directory otherwise (e.g: during "make distcheck")
+#
 AC_MSG_CHECKING(for perl libdir)
-eval `"$PERL" -V:sitelib`
-AC_SUBST([perllibdir], [`echo "$sitelib"`])
+m4_define([_PERL_LIBDIR_DEFAULT], [${datadir}/perl5])dnl
+AC_ARG_WITH(perllib,
+       [AS_HELP_STRING([--with-perllib=PATH],
+               [Location of perl modules @<:@default=]_PERL_LIBDIR_DEFAULT[, or perl -V:sitelib@:>@])],
+       [perllibdir=$withval],
+       [
+               if test "$prefix" = 'NONE' -o "$prefix" = '/usr'; then
+                       eval `"$PERL" -V:sitelib`
+                       perllibdir="$sitelib"
+               else
+                       perllibdir='_PERL_LIBDIR_DEFAULT'
+               fi
+       ]
+)
+AC_SUBST([perllibdir], "$perllibdir")
 AC_MSG_RESULT([$perllibdir])
 AM_CONDITIONAL([PERL], [test "$perllibdir" != ''])
 
@@ -120,6 +158,22 @@ else
 fi
 AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
 
+# Checks for header files.
+AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
+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])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T
+
+# Checks for libraries.
+AC_CHECK_LIB([m], [cos])
+AC_CHECK_LIB([pthread], [pthread_create])
+
 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
 AST_EXT_LIB_SETUP([USB], [usb], [usb])
@@ -141,6 +195,67 @@ AM_CONDITIONAL([PBX_NEWT], [test "$PBX_NEWT" = "1"])
 AM_CONDITIONAL([PBX_PCAP], [test "$PBX_PCAP" = "1" -a "$DAHDI_TXMIRROR" = "1"])
 
 AC_CHECK_FUNCS([semtimedop])
+AC_CHECK_FUNCS([alarm bzero gettimeofday memset pow regcomp select socket strcasecmp strchr strdup strerror strrchr strstr strtol strtoul])
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_MALLOC
+
+# What the user asked for? libusb/libusbx
+AC_ARG_WITH([libusbx],
+       [AS_HELP_STRING([--without-libusbx], [Disable libusbx @<:@default=check@:>@])],
+       [],
+       [with_libusbx=check])
+AC_ARG_WITH([libusb],
+       [AS_HELP_STRING([--without-libusb], [Disable libusb-0.1 @<:@default=check@:>@])],
+       [],
+       [with_libusb=check])
+
+# LIBUSBX tests
+have_libusbx=
+AS_IF([test "$with_libusbx" != "no"],
+       [PKG_CHECK_MODULES([LIBUSBX], [libusb-1.0],
+               [AC_CHECK_LIB([usb-1.0], [libusb_error_name],
+                       [
+                               have_libusbx="yes"
+                               AC_DEFINE([HAVE_LIBUSBX], [1], [Define to 1 if you have <libusb.h>.])
+                               AC_SUBST([PBX_USB], [1])
+                       ], [
+                               if test "$with_libusbx" != "yes"; then
+                                       AC_MSG_NOTICE([Ignoring old libusb-1.0, trying fallback to old libusb])
+                               fi
+                       ])
+               ], [:])
+       ], [])
+
+AS_IF([test "$with_libusbx" = "yes" -a "$have_libusbx" = ""],
+       [AC_MSG_ERROR([No libusbx found (--with-libusbx was given)])])
+
+# LIBUSB tests
+have_libusb=
+AS_IF([test "$with_libusb" != "no"],
+       [AS_IF([test "$have_libusbx" != ""],
+               [
+                       AS_IF([test "$with_libusbx" = "check"], [
+                               AC_MSG_NOTICE([Skipping LIBUSB tests (have good LIBUSBX)])
+                               ])
+               ], [
+                       PKG_CHECK_MODULES([LIBUSB], [libusb],
+                               [
+                                       have_libusb="yes"
+                                       AC_SUBST([PBX_USB], [1])
+                               ]
+                               [AC_DEFINE([HAVE_LIBUSB], [1], [Define to 1 if you have <usb.h>.])],
+                               [:]
+                               )
+               ])
+       ], [])
+
+AS_IF([test "$with_libusb" = "yes" -a "$have_libusb" = ""],
+       [AC_MSG_ERROR([No libusb found (--with-libusb was given)])])
+
+AM_CONDITIONAL([LIBUSBX], [test "$have_libusbx" != ""])
+AM_CONDITIONAL([LIBUSB], [test "$have_libusb" != ""])
+AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
+
 
 PBX_HDLC=0
 AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
@@ -256,8 +371,6 @@ fi
 
 AC_SUBST(PPPD_VERSION)
 
-AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
-
 # Taken from octasic-helper
 AC_SUBST([USE_OCTASIC], [yes])
 AM_CONDITIONAL([USE_OCTASIC], [test "$USE_OCTASIC" = 'yes'])
@@ -274,6 +387,7 @@ AC_CONFIG_FILES([
        hotplug/Makefile
        ppp/Makefile
        xpp/Makefile
+       xpp/xtalk/Makefile
        xpp/oct612x/Makefile
        xpp/perl_modules/Makefile
        ])