--- configure.ac.orig	2011-03-25 22:28:18 UTC
+++ configure.ac
@@ -97,6 +97,14 @@ case "${host_os}" in
     devdir_default="/usr/lirc/dev/"
     use_fifos="yes"
     ;;
+  freebsd*)
+    dnl PortAudio for UNIX OSS
+    portaudio_lib_other="-lm -lpthread ${forkpty}"
+
+    dnl default devdir
+    devdir_default="/dev"
+    use_fifos="yes"
+    ;;
   *)
     dnl Unix OSS configuration
 
@@ -310,70 +318,22 @@ AH_TEMPLATE([SYSCONFDIR],
 AH_TEMPLATE([USE_SYSLOG],
 	[define if you want to log to syslog instead of logfile])
 
-if test -n "${LIBUSB_CONFIG}"; then
+AC_CHECK_FUNCS(strchrnul strnlen)
+
+AC_CHECK_HEADER(libusb.h)
+if test "$ac_cv_header_libusb_h" = yes -o -n "${LIBUSB_CONFIG}"; then
   AC_DEFINE(HAVE_LIBUSB)
   possible_drivers="${possible_drivers} (atilibusb) (awlibusb) (dfclibusb) (commandir) (srm7500libusb)" 
 fi
 
-AC_CHECK_LIB(caraca_client, caraca_init,
-  AC_DEFINE(HAVE_LIBCARACA)
-  possible_drivers="${possible_drivers} (caraca)"
-)
 AC_CHECK_HEADER(ftdi.h,
   AC_DEFINE(HAVE_FTDI)
   possible_drivers="${possible_drivers} (ftdi)"
 )
-AC_CHECK_HEADER(iguanaIR.h,
-  AC_DEFINE(HAVE_IGUANAIR)
-  possible_drivers="${possible_drivers} (iguanaIR)"
-)
 AC_CHECK_LIB(irman, ir_strerror,
   AC_DEFINE(HAVE_LIBIRMAN)
   possible_drivers="${possible_drivers} (irman)"
 )
-AC_CHECK_LIB(irman_sw, ir_strerror,
-  AC_DEFINE(HAVE_LIBIRMAN_SW)
-  possible_drivers="${possible_drivers} (irman_sw)"
-)
-dnl audio driver requires PortAudio library installed and some linker flags
-AC_CHECK_HEADERS(portaudio.h,[
-  AC_CHECK_LIB(portaudio, Pa_Initialize,[
-    AC_DEFINE(HAVE_LIBPORTAUDIO)
-    possible_drivers="${possible_drivers} (audio)"
-    ],,${portaudio_lib_other}
-  )]
-)
-dnl audio_alsa driver requires ALSA library installed and some linker flags
-have_alsa=no
-AC_CHECK_HEADERS(alsa/asoundlib.h,[
-  AC_CHECK_LIB(asound, snd_pcm_open,[
-    AC_DEFINE(HAVE_LIBALSA)
-    have_alsa=yes
-    possible_drivers="${possible_drivers} (audio_alsa)"
-    ],,
-  )]
-)
-dnl alsa_usb driver requires an ALSA that knows about our hwdep device
-if test "$have_alsa" = "yes"; then
-  AC_MSG_CHECKING(for ALSA SB RC hwdep support)
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <alsa/asoundlib.h>
-]], [[
-  if (snd_hwdep_info_get_iface(NULL) == SND_HWDEP_IFACE_SB_RC) {}
-]])],[
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(HAVE_ALSA_SB_RC)
-    possible_drivers="${possible_drivers} (alsa_usb)"
-    ],[
-    AC_MSG_RESULT(no)
-  ])
-fi
-dnl creative_infracd driver requires linux scsi api
-AC_CHECK_HEADERS(scsi/sg.h,[
-  AC_DEFINE(HAVE_SCSI)
-  possible_drivers="${possible_drivers} (creative_infracd)"
-  ]
-)
 dnl dev_input driver requires linux input device api
 AC_CHECK_HEADERS(linux/input.h,[
   AC_DEFINE(HAVE_LINUX_DEVINPUT)
@@ -403,17 +363,18 @@ AC_CHECK_HEADERS([linux/hiddev.h],[
 #endif
 ]
 )
+dnl FreeBSD usbhid.h - patched daemons/hw_hiddev.c needs testing
+AC_CHECK_HEADERS([usbhid.h],[
+  dnl possible_drivers="${possible_drivers} (asusdh) (bw6130) (dvico) (macmini)"
+  possible_drivers="${possible_drivers} (bw6130) (dvico)"
+  ], [], []
+)
 dnl dsp driver requires linux soundcard api
 AC_CHECK_HEADERS(sys/soundcard.h,[
   AC_DEFINE(HAVE_SOUNDCARD)
   possible_drivers="${possible_drivers} (dsp)"
   ]
 )
-dnl i2cuser driver requires the Linux I2C API
-AC_CHECK_HEADERS(linux/i2c-dev.h,[
-  possible_drivers="${possible_drivers} (i2cuser)"
-  ]
-)
 
 dnl here we see what driver the user wants.
 
@@ -498,8 +459,8 @@ if test "$driver" = "userspace" -o "$driver" = "all"; 
 		;;
 	atilibusb)
 		hw_module="${hw_module} hw_atilibusb.o receive.o"
-		atilibusb_lib=`${LIBUSB_CONFIG} --libs`
-		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+		atilibusb_lib=-lusb
+		CFLAGS="$CFLAGS "
 		;;
 	atwf83)
 		hw_module="${hw_module} hw_atwf83.o"
@@ -515,8 +476,8 @@ if test "$driver" = "userspace" -o "$driver" = "all"; 
 		;;
 	awlibusb)
 		hw_module="${hw_module} hw_awlibusb.o receive.o"
-		awlibusb_lib=`${LIBUSB_CONFIG} --libs`
-		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+		awlibusb_lib=-lusb
+		CFLAGS="$CFLAGS "
 		;;
 	bte)
 		hw_module="${hw_module} hw_bte.o serial.o"
@@ -536,16 +497,16 @@ if test "$driver" = "userspace" -o "$driver" = "all"; 
 		;;
 	commandir)
 		hw_module="${hw_module} hw_commandir.o receive.o"
-		commandir_lib=`${LIBUSB_CONFIG} --libs`
-		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+		commandir_lib=-lusb
+		CFLAGS="$CFLAGS "
 		;;
 	devinput)
 		hw_module="${hw_module} hw_devinput.o"
 		;;
 	dfclibusb)
 		hw_module="${hw_module} hw_dfclibusb.o receive.o"
-		dfclibusb_lib=`${LIBUSB_CONFIG} --libs`
-		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+		dfclibusb_lib=-lusb
+		CFLAGS="$CFLAGS "
 		;;
 	dsp)
 		hw_module="${hw_module} hw_dsp.o receive.o"
@@ -665,8 +626,8 @@ if test "$driver" = "userspace" -o "$driver" = "all"; 
 		#;;
 	srm7500libusb)
 		hw_module="${hw_module} hw_srm7500libusb.o receive.o"
-		srm7500libusb_lib=`${LIBUSB_CONFIG} --libs`
-		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+		srm7500libusb_lib=-lusb
+		CFLAGS="$CFLAGS "
 		;;
 	tira|tira_raw)
 		hw_module="${hw_module} hw_tira.o receive.o transmit.o"
@@ -758,8 +719,8 @@ if test "$driver" = "atilibusb"; then
   HW_DEFAULT="hw_atilibusb"
   lircd_conf="atiusb/lircd.conf.atilibusb"
   if test -n "${LIBUSB_CONFIG}"; then
-    atilibusb_lib=`${LIBUSB_CONFIG} --libs`
-    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+    atilibusb_lib=-lusb
+    CFLAGS="$CFLAGS "
   fi
 fi
 
@@ -777,8 +738,8 @@ if test "$driver" = "awlibusb"; then
   HW_DEFAULT="hw_awlibusb"
   lircd_conf="awlibusb/lircd.conf.awlibusb"
   if test -n "${LIBUSB_CONFIG}"; then
-    awlibusb_lib=`${LIBUSB_CONFIG} --libs`
-    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+    awlibusb_lib=-lusb
+    CFLAGS="$CFLAGS "
   fi
 fi
 
@@ -893,8 +854,8 @@ if test "$driver" = "commandir"; then
   lircd_conf="hauppauge/lircd.conf.hauppauge"
   lircmd_conf="hauppauge/lircmd.conf.hauppauge"
   if test -n "${LIBUSB_CONFIG}"; then
-    commandir_lib=`${LIBUSB_CONFIG} --libs`
-    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+    commandir_lib=-lusb
+    CFLAGS="$CFLAGS "
   fi
 fi
 
@@ -931,8 +892,8 @@ if test "$driver" = "dfclibusb"; then
   hw_module="hw_dfclibusb.o receive.o"
   HW_DEFAULT="hw_dfclibusb"
   if test -n "${LIBUSB_CONFIG}"; then
-    dfclibusb_lib=`${LIBUSB_CONFIG} --libs`
-    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+    dfclibusb_lib=-lusb
+    CFLAGS="$CFLAGS "
   fi
 fi
 
@@ -1332,8 +1293,8 @@ if test "$driver" = "srm7500libusb"; then
   HW_DEFAULT="hw_srm7500libusb"
   lircd_conf="philips/lircd.conf.srm7500libusb"
   if test -n "${LIBUSB_CONFIG}"; then
-    srm7500libusb_lib=`${LIBUSB_CONFIG} --libs`
-    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
+    srm7500libusb_lib=-lusb
+    CFLAGS="$CFLAGS "
   fi
 fi
 
